aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-02-04 22:42:15 +0300
committerGravatar Vitaly Takmazov2018-02-04 22:42:15 +0300
commitfa070e8e63fb25dabddc97a6c1c6b72c2b46b66f (patch)
treef5dab39989972c8e6d15c984565c50de787bdcd5
parent3ed3802f12eba5673406d0e4c937bb9e24740a67 (diff)
www: addTag on post form
-rw-r--r--juick-www/package-lock.json5
-rw-r--r--juick-www/package.json1
-rw-r--r--juick-www/src/main/static/scripts.js22
3 files changed, 28 insertions, 0 deletions
diff --git a/juick-www/package-lock.json b/juick-www/package-lock.json
index 1511195a..37f7e493 100644
--- a/juick-www/package-lock.json
+++ b/juick-www/package-lock.json
@@ -10057,6 +10057,11 @@
"schema-utils": "0.3.0"
}
},
+ "url-search-params-polyfill": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/url-search-params-polyfill/-/url-search-params-polyfill-2.0.2.tgz",
+ "integrity": "sha512-zFN1r66KeSpxM2qrbHPf4u6nbIIGLOCNdO3JXdV5mEqeoBPev7VwuCv5goL69TQmfAQdVyTHI8lmzCIRPEW4Bg=="
+ },
"util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
diff --git a/juick-www/package.json b/juick-www/package.json
index fa3ce1a3..e77e6a32 100644
--- a/juick-www/package.json
+++ b/juick-www/package.json
@@ -39,6 +39,7 @@
"element-closest": "^2.0.2",
"evil-icons": "^1.9.0",
"killy": "file:src/main/js/killy",
+ "url-search-params-polyfill": "^2.0.2",
"whatwg-fetch": "^2.0.3"
}
}
diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js
index dc7745a9..22a75fac 100644
--- a/juick-www/src/main/static/scripts.js
+++ b/juick-www/src/main/static/scripts.js
@@ -1,6 +1,7 @@
require('whatwg-fetch');
require('element-closest');
require('classlist.js');
+require('url-search-params-polyfill');
let killy = require('killy');
let Awesomplete = require('awesomplete');
@@ -15,6 +16,9 @@ if (!('remove' in Element.prototype)) { // Firefox <23
NodeList.prototype.forEach = Array.prototype.forEach;
HTMLCollection.prototype.forEach = Array.prototype.forEach;
+NodeList.prototype.filter = Array.prototype.filter;
+HTMLCollection.prototype.filter = Array.prototype.filter;
+
Element.prototype.selectText = function () {
let d = document;
if (d.body.createTextRange) {
@@ -615,6 +619,11 @@ function getTags() {
return false;
}
+function addTag(tag) {
+ document.forms['postmsg'].body.value='*'+tag+' '+document.forms['postmsg'].body.value;
+ return false;
+}
+
/******************************************************************************/
function ready(fn) {
@@ -677,6 +686,19 @@ ready(function () {
}
}
+ var postmsg = document.getElementById('postmsg');
+ if (postmsg) {
+ document.querySelectorAll('a').filter(t => t.href.indexOf('?') >=0).forEach(t => {
+ t.addEventListener('click', e => {
+ let params = new URLSearchParams(t.href.slice(t.href.indexOf('?') + 1));
+ if (params.has('tag')) {
+ addTag(params.get('tag'));
+ e.preventDefault();
+ }
+ });
+ });
+ }
+
document.querySelectorAll('.msg-menu').forEach(function (el) {
el.addEventListener('click', function (e) {
var reply = e.target.closest('li');