aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/static
diff options
context:
space:
mode:
authorGravatar you2017-05-27 13:52:55 +0300
committerGravatar you2017-05-27 13:52:55 +0300
commitdc430dec23586fd8a6ed3a0cc272f7cb1d8a8d88 (patch)
treef811cab95de96dd94f7dc6bf9f031944901883b8 /juick-www/src/main/static
parent97e743385c94ac8a6084726d499c33373e255177 (diff)
readonly mode is now provided by Cloudflare
Diffstat (limited to 'juick-www/src/main/static')
-rw-r--r--juick-www/src/main/static/scripts.js167
1 files changed, 77 insertions, 90 deletions
diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js
index 57661caa..3951bfae 100644
--- a/juick-www/src/main/static/scripts.js
+++ b/juick-www/src/main/static/scripts.js
@@ -14,15 +14,10 @@ if (!('remove' in Element.prototype)) { // Firefox <23
NodeList.prototype.forEach = Array.prototype.forEach;
HTMLCollection.prototype.forEach = Array.prototype.forEach;
-function isReadonly() {
- return document.getElementById('body').getAttribute('data-readonly') === 'true';
-}
-
var ws,
pageTitle;
function initWS() {
- if (isReadonly()) { return }
var content = document.getElementById('content');
if (!content) { return }
var pageMID = content.getAttribute('data-mid');
@@ -557,42 +552,40 @@ function ready(fn) {
}
ready(function () {
- if (!isReadonly()) {
- autosize(document.querySelectorAll('textarea'));
-
- var insertButtons = function (e) {
- var textarea = e.target;
- textarea.classList.add('narrow');
- var att = document.createElement('div');
- att.classList.add('attach-photo');
- att.addEventListener('click', function (e) {
- attachCommentPhoto(e.target);
- });
- textarea.parentNode.insertBefore(att, textarea.nextSibling);
- textarea.parentNode.insertAdjacentHTML('afterend', '<input type="submit" value="OK"/>');
- textarea.removeEventListener('click', insertButtons);
- e.preventDefault();
- };
- document.querySelectorAll('textarea.reply').forEach(function (e) {
- e.addEventListener('click', insertButtons);
- e.addEventListener('keypress', function (e) {
- postformListener(e.target, e);
- });
+ autosize(document.querySelectorAll('textarea'));
+
+ var insertButtons = function (e) {
+ var textarea = e.target;
+ textarea.classList.add('narrow');
+ var att = document.createElement('div');
+ att.classList.add('attach-photo');
+ att.addEventListener('click', function (e) {
+ attachCommentPhoto(e.target);
});
+ textarea.parentNode.insertBefore(att, textarea.nextSibling);
+ textarea.parentNode.insertAdjacentHTML('afterend', '<input type="submit" value="OK"/>');
+ textarea.removeEventListener('click', insertButtons);
+ e.preventDefault();
+ };
+ document.querySelectorAll('textarea.reply').forEach(function (e) {
+ e.addEventListener('click', insertButtons);
+ e.addEventListener('keypress', function (e) {
+ postformListener(e.target, e);
+ });
+ });
- var insertPMButtons = function (e) {
- e.target.classList.add('narrowpm');
- e.target.parentNode.insertAdjacentHTML('afterend', '<input type="submit" value="OK"/>');
- e.target.removeEventListener('click', insertPMButtons);
- e.preventDefault();
- };
- document.querySelectorAll('textarea.replypm').forEach(function (e) {
- e.addEventListener('click', insertPMButtons);
- e.addEventListener('keypress', function(e) {
- postformListener(e.target, e);
- });
+ var insertPMButtons = function (e) {
+ e.target.classList.add('narrowpm');
+ e.target.parentNode.insertAdjacentHTML('afterend', '<input type="submit" value="OK"/>');
+ e.target.removeEventListener('click', insertPMButtons);
+ e.preventDefault();
+ };
+ document.querySelectorAll('textarea.replypm').forEach(function (e) {
+ e.addEventListener('click', insertPMButtons);
+ e.addEventListener('keypress', function (e) {
+ postformListener(e.target, e);
});
- }
+ });
var content = document.getElementById('content');
if (content) {
@@ -625,16 +618,14 @@ ready(function () {
e.preventDefault();
});
});
- if (!isReadonly()) {
- document.querySelectorAll('.l .a-comment').forEach(function (e) {
- e.addEventListener('click', function (e) {
- showCommentFooter(
- e.target,
- e.target.closest('article').getAttribute('data-mid'));
- e.preventDefault();
- });
+ document.querySelectorAll('.l .a-comment').forEach(function (e) {
+ e.addEventListener('click', function (e) {
+ showCommentFooter(
+ e.target,
+ e.target.closest('article').getAttribute('data-mid'));
+ e.preventDefault();
});
- }
+ });
document.querySelectorAll('.l .a-privacy').forEach(function (e) {
e.addEventListener('click', function (e) {
setPrivacy(
@@ -643,35 +634,33 @@ ready(function () {
e.preventDefault();
});
});
- if (!isReadonly()) {
- document.querySelectorAll('.l .a-popular-plus').forEach(function (e) {
- e.addEventListener('click', function (e) {
- setPopular(
- e.target,
- e.target.closest('article').getAttribute('data-mid'),
- 2);
- e.preventDefault();
- });
+ document.querySelectorAll('.l .a-popular-plus').forEach(function (e) {
+ e.addEventListener('click', function (e) {
+ setPopular(
+ e.target,
+ e.target.closest('article').getAttribute('data-mid'),
+ 2);
+ e.preventDefault();
});
- document.querySelectorAll('.l .a-popular-minus').forEach(function (e) {
- e.addEventListener('click', function (e) {
- setPopular(
- e.target,
- e.target.closest('article').getAttribute('data-mid'),
- -1);
- e.preventDefault();
- });
+ });
+ document.querySelectorAll('.l .a-popular-minus').forEach(function (e) {
+ e.addEventListener('click', function (e) {
+ setPopular(
+ e.target,
+ e.target.closest('article').getAttribute('data-mid'),
+ -1);
+ e.preventDefault();
});
- document.querySelectorAll('.l .a-popular-delete').forEach(function (e) {
- e.addEventListener('click', function (e) {
- setPopular(
- e.target,
- e.target.closest('article').getAttribute('data-mid'),
- -2);
- e.preventDefault();
- });
+ });
+ document.querySelectorAll('.l .a-popular-delete').forEach(function (e) {
+ e.addEventListener('click', function (e) {
+ setPopular(
+ e.target,
+ e.target.closest('article').getAttribute('data-mid'),
+ -2);
+ e.preventDefault();
});
- }
+ });
document.querySelectorAll('.ir a').forEach(function (e) {
e.addEventListener('click', function (e) {
var fname = e.target.closest('[data-fname]').getAttribute('data-fname');
@@ -724,24 +713,22 @@ ready(function () {
e.preventDefault();
});
}
- if (!isReadonly()) {
- var newMessageBlock = document.getElementById('newmessage');
- if (newMessageBlock) {
- var form = newMessageBlock.parentNode;
- form.addEventListener('submit', newMessage);
- newMessageBlock.querySelector('textarea').addEventListener('click', function (e) {
- var parent = e.target.parentNode;
- parent.querySelector('div').style.display = 'block';
- e.target.style.minHeight = '70px';
- e.target.addEventListener('keypress', function (e) {
- postformListener(e.target, e);
- });
- });
- newMessageBlock.querySelector('a').addEventListener('click', function (e) {
- attachMessagePhoto(e.target);
+ var newMessageBlock = document.getElementById('newmessage');
+ if (newMessageBlock) {
+ var form = newMessageBlock.parentNode;
+ form.addEventListener('submit', newMessage);
+ newMessageBlock.querySelector('textarea').addEventListener('click', function (e) {
+ var parent = e.target.parentNode;
+ parent.querySelector('div').style.display = 'block';
+ e.target.style.minHeight = '70px';
+ e.target.addEventListener('keypress', function (e) {
+ postformListener(e.target, e);
});
- }
- }
+ });
+ newMessageBlock.querySelector('a').addEventListener('click', function (e) {
+ attachMessagePhoto(e.target);
+ });
+ }
document.querySelectorAll('article').forEach(function (article) {
if (Array.prototype.some.call(
article.querySelectorAll('.msg-tags a'),