diff options
author | 2018-02-04 22:42:15 +0300 | |
---|---|---|
committer | 2018-02-04 22:42:15 +0300 | |
commit | fa070e8e63fb25dabddc97a6c1c6b72c2b46b66f (patch) | |
tree | f5dab39989972c8e6d15c984565c50de787bdcd5 /juick-www/src | |
parent | 3ed3802f12eba5673406d0e4c937bb9e24740a67 (diff) |
www: addTag on post form
Diffstat (limited to 'juick-www/src')
-rw-r--r-- | juick-www/src/main/static/scripts.js | 22 |
1 files changed, 22 insertions, 0 deletions
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'); |