Merge Zixaphir X
This commit is contained in:
commit
2fcbe0bf30
@ -1370,10 +1370,7 @@
|
||||
})();
|
||||
|
||||
Polyfill = {
|
||||
init: function() {
|
||||
Polyfill.toBlob();
|
||||
return Polyfill.visibility();
|
||||
},
|
||||
init: function() {},
|
||||
toBlob: function() {
|
||||
var _base;
|
||||
return (_base = HTMLCanvasElement.prototype).toBlob || (_base.toBlob = function(cb) {
|
||||
@ -1413,10 +1410,10 @@
|
||||
|
||||
Header = {
|
||||
init: function() {
|
||||
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler,
|
||||
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler, menuButton,
|
||||
_this = this;
|
||||
this.menu = new UI.Menu('header');
|
||||
this.menuButton = $.el('span', {
|
||||
menuButton = $.el('span', {
|
||||
className: 'menu-button',
|
||||
innerHTML: '<i></i>'
|
||||
});
|
||||
@ -1448,7 +1445,7 @@
|
||||
this.headerToggler = headerToggler.firstElementChild;
|
||||
this.footerToggler = footerToggler.firstElementChild;
|
||||
this.customNavToggler = customNavToggler.firstElementChild;
|
||||
$.on(this.menuButton, 'click', this.menuToggle);
|
||||
$.on(menuButton, 'click', this.menuToggle);
|
||||
$.on(this.barFixedToggler, 'change', this.toggleBarFixed);
|
||||
$.on(this.barPositionToggler, 'change', this.toggleBarPosition);
|
||||
$.on(this.linkJustifyToggler, 'change', this.toggleLinkJustify);
|
||||
@ -1463,7 +1460,7 @@
|
||||
$.sync('Bottom Header', Header.setBarPosition);
|
||||
$.sync('Header auto-hide', Header.setBarVisibility);
|
||||
$.sync('Centered links', Header.setLinkJustify);
|
||||
this.addShortcut(Header.menuButton);
|
||||
this.addShortcut(menuButton);
|
||||
$.event('AddMenuEntry', {
|
||||
type: 'header',
|
||||
el: $.el('span', {
|
||||
@ -1963,6 +1960,9 @@
|
||||
threadFromRoot: function(root) {
|
||||
return g.threads["" + g.BOARD + "." + root.id.slice(1)];
|
||||
},
|
||||
threadFromNode: function(node) {
|
||||
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
||||
},
|
||||
postFromRoot: function(root) {
|
||||
var boardID, index, link, post, postID;
|
||||
link = $('a[title="Highlight this post"]', root);
|
||||
@ -1979,8 +1979,8 @@
|
||||
postFromNode: function(root) {
|
||||
return Get.postFromRoot($.x('(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root));
|
||||
},
|
||||
contextFromNode: function(quotelink) {
|
||||
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink));
|
||||
contextFromNode: function(node) {
|
||||
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', node));
|
||||
},
|
||||
postDataFromLink: function(link) {
|
||||
var boardID, path, postID, threadID, _ref;
|
||||
@ -2413,7 +2413,7 @@
|
||||
};
|
||||
|
||||
Menu.prototype.focus = function(entry) {
|
||||
var bottom, cHeight, cWidth, eRect, focused, left, right, sRect, style, submenu, top, _i, _len, _ref, _ref1, _ref2;
|
||||
var cHeight, cWidth, eRect, focused, sRect, submenu, _i, _len, _ref;
|
||||
while (focused = $.x('parent::*/child::*[contains(@class,"focused")]', entry)) {
|
||||
$.rmClass(focused, 'focused');
|
||||
}
|
||||
@ -2430,13 +2430,20 @@
|
||||
eRect = entry.getBoundingClientRect();
|
||||
cHeight = doc.clientHeight;
|
||||
cWidth = doc.clientWidth;
|
||||
_ref1 = eRect.top + sRect.height < cHeight ? ['0px', 'auto'] : ['auto', '0px'], top = _ref1[0], bottom = _ref1[1];
|
||||
_ref2 = eRect.right + sRect.width < cWidth ? ['100%', 'auto'] : ['auto', '100%'], left = _ref2[0], right = _ref2[1];
|
||||
style = submenu.style;
|
||||
style.top = top;
|
||||
style.bottom = bottom;
|
||||
style.left = left;
|
||||
return style.right = right;
|
||||
if (eRect.top + sRect.height < cHeight) {
|
||||
$.addClass(submenu, 'top');
|
||||
$.rmClass(submenu, 'bottom');
|
||||
} else {
|
||||
$.addClass(submenu, 'bottom');
|
||||
$.rmClass(submenu, 'top');
|
||||
}
|
||||
if (eRect.right + sRect.width < cWidth) {
|
||||
$.addClass(submenu, 'left');
|
||||
return $.rmClass(submenu, 'right');
|
||||
} else {
|
||||
$.addClass(submenu, 'right');
|
||||
return $.rmClass(submenu, 'left');
|
||||
}
|
||||
};
|
||||
|
||||
Menu.prototype.addEntry = function(e) {
|
||||
@ -3202,7 +3209,7 @@
|
||||
post.nodes.stub = $.el('div', {
|
||||
className: 'stub'
|
||||
});
|
||||
$.add(post.nodes.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(post)]);
|
||||
$.add(post.nodes.stub, Conf['Menu'] ? [a, $.tn(' '), button = Menu.makeButton(post)] : a);
|
||||
return $.prepend(post.nodes.root, post.nodes.stub);
|
||||
},
|
||||
show: function(post, showRecursively) {
|
||||
@ -3516,7 +3523,7 @@
|
||||
return ThreadHiding.saveHiddenState(thread);
|
||||
},
|
||||
hide: function(thread, makeStub) {
|
||||
var OP, a, button, numReplies, opInfo, span, threadRoot;
|
||||
var OP, a, numReplies, opInfo, span, threadRoot;
|
||||
if (makeStub == null) {
|
||||
makeStub = Conf['Stubs'];
|
||||
}
|
||||
@ -3535,7 +3542,7 @@
|
||||
thread.stub = $.el('div', {
|
||||
className: 'stub'
|
||||
});
|
||||
$.add(thread.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(OP)]);
|
||||
$.add(thread.stub, Conf['Menu'] ? [a, $.tn(' '), Menu.makeButton()] : a);
|
||||
return $.prepend(threadRoot, thread.stub);
|
||||
},
|
||||
show: function(thread) {
|
||||
@ -3640,25 +3647,22 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var board, boardID, quotelink, quotelinks, quotes, thread, threadID, _i, _len, _ref, _ref1;
|
||||
var board, boardID, quotelink, thread, threadID, _i, _len, _ref, _ref1, _ref2;
|
||||
if (this.isClone && this.thread === this.context.thread) {
|
||||
return;
|
||||
}
|
||||
if (!(quotes = this.quotes).length) {
|
||||
return;
|
||||
}
|
||||
quotelinks = this.nodes.quotelinks;
|
||||
_ref = this.isClone ? this.context : this, board = _ref.board, thread = _ref.thread;
|
||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||
quotelink = quotelinks[_i];
|
||||
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, threadID = _ref1.threadID;
|
||||
_ref1 = this.nodes.quotelinks;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
quotelink = _ref1[_i];
|
||||
_ref2 = Get.postDataFromLink(quotelink), boardID = _ref2.boardID, threadID = _ref2.threadID;
|
||||
if (!threadID) {
|
||||
continue;
|
||||
}
|
||||
if (this.isClone) {
|
||||
quotelink.textContent = quotelink.textContent.replace(QuoteCT.text, '');
|
||||
}
|
||||
if (boardID === this.board.ID && threadID !== thread.ID) {
|
||||
if (boardID === board.ID && threadID !== thread.ID) {
|
||||
$.add(quotelink, $.tn(QuoteCT.text));
|
||||
}
|
||||
}
|
||||
@ -3800,7 +3804,7 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var boardID, op, postID, quotelink, quotelinks, quotes, _i, _j, _len, _len1, _ref;
|
||||
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
|
||||
if (this.isClone && this.thread === this.context.thread) {
|
||||
return;
|
||||
}
|
||||
@ -3809,19 +3813,19 @@
|
||||
}
|
||||
quotelinks = this.nodes.quotelinks;
|
||||
if (this.isClone && quotes.contains(this.thread.fullID)) {
|
||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||
quotelink = quotelinks[_i];
|
||||
i = 0;
|
||||
while (quotelink = quotelinks[i++]) {
|
||||
quotelink.textContent = quotelink.textContent.replace(QuoteOP.text, '');
|
||||
}
|
||||
}
|
||||
op = (this.isClone ? this.context : this).thread.fullID;
|
||||
if (!quotes.contains(op)) {
|
||||
fullID = (this.isClone ? this.context : this).thread.fullID;
|
||||
if (!quotes.contains(fullID)) {
|
||||
return;
|
||||
}
|
||||
for (_j = 0, _len1 = quotelinks.length; _j < _len1; _j++) {
|
||||
quotelink = quotelinks[_j];
|
||||
i = 0;
|
||||
while (quotelink = quotelinks[i++]) {
|
||||
_ref = Get.postDataFromLink(quotelink), boardID = _ref.boardID, postID = _ref.postID;
|
||||
if (("" + boardID + "." + postID) === op) {
|
||||
if (("" + boardID + "." + postID) === fullID) {
|
||||
$.add(quotelink, $.tn(QuoteOP.text));
|
||||
}
|
||||
}
|
||||
@ -5170,7 +5174,7 @@
|
||||
}
|
||||
_ref = QR.nodes, com = _ref.com, thread = _ref.thread;
|
||||
if (!com.value) {
|
||||
thread.value = Get.contextFromNode(this).thread;
|
||||
thread.value = Get.threadFromNode(this);
|
||||
}
|
||||
caretPos = com.selectionStart;
|
||||
com.value = com.value.slice(0, caretPos) + text + com.value.slice(com.selectionEnd);
|
||||
@ -6121,7 +6125,7 @@
|
||||
href: 'javascript:;'
|
||||
});
|
||||
$.on(this.EAI, 'click', ImageExpand.cb.toggleAll);
|
||||
Header.addShortcut(this.EAI);
|
||||
Header.addShortcut(this.EAI, 2);
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Image Expansion',
|
||||
cb: this.node
|
||||
@ -6834,45 +6838,44 @@
|
||||
}
|
||||
};
|
||||
|
||||
Menu = (function() {
|
||||
var a;
|
||||
a = $.el('a', {
|
||||
className: 'menu-button brackets-wrap',
|
||||
innerHTML: '<i></i>',
|
||||
href: 'javascript:;'
|
||||
});
|
||||
return {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Menu']) {
|
||||
return;
|
||||
}
|
||||
this.menu = new UI.Menu('post');
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Menu',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var button;
|
||||
if (this.isClone) {
|
||||
button = $('.menu-button', this.nodes.info);
|
||||
} else {
|
||||
button = a.cloneNode(true);
|
||||
$.add(this.nodes.info, [$.tn('\u00A0'), button]);
|
||||
}
|
||||
return $.on(button, 'click', Menu.toggle);
|
||||
},
|
||||
makeButton: function() {
|
||||
var el;
|
||||
el = a.cloneNode(true);
|
||||
$.on(el, 'click', Menu.toggle);
|
||||
return el;
|
||||
},
|
||||
toggle: function(e) {
|
||||
return Menu.menu.toggle(e, this, Get.postFromNode(this));
|
||||
Menu = {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Menu']) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
})();
|
||||
this.menu = new UI.Menu('post');
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Menu',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
if (this.isClone) {
|
||||
return $.on($('.menu-button', this.nodes.info), 'click', Menu.toggle);
|
||||
} else {
|
||||
return $.add(this.nodes.info, [$.tn('\u00A0'), Menu.makeButton()]);
|
||||
}
|
||||
},
|
||||
makeButton: (function() {
|
||||
var a;
|
||||
a = $.el('a', {
|
||||
className: 'menu-button brackets-wrap',
|
||||
innerHTML: '<i></i>',
|
||||
href: 'javascript:;'
|
||||
});
|
||||
return function() {
|
||||
var button;
|
||||
button = a.cloneNode(true);
|
||||
$.on(button, 'click', Menu.toggle);
|
||||
return button;
|
||||
};
|
||||
})(),
|
||||
toggle: function(e) {
|
||||
var post;
|
||||
post = Get.postFromNode(this);
|
||||
return Menu.menu.toggle(e, this, post);
|
||||
}
|
||||
};
|
||||
|
||||
ReportLink = {
|
||||
init: function() {
|
||||
@ -7629,11 +7632,13 @@
|
||||
fetching: 0
|
||||
},
|
||||
fetchAllStatus: function() {
|
||||
var thread, _i, _len, _ref;
|
||||
var thread, threads, _i, _len;
|
||||
if (!(threads = ThreadWatcher.getAll()).length) {
|
||||
return;
|
||||
}
|
||||
ThreadWatcher.status.textContent = '...';
|
||||
_ref = ThreadWatcher.getAll();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
thread = _ref[_i];
|
||||
for (_i = 0, _len = threads.length; _i < _len; _i++) {
|
||||
thread = threads[_i];
|
||||
ThreadWatcher.fetchStatus(thread);
|
||||
}
|
||||
},
|
||||
@ -8778,7 +8783,7 @@
|
||||
return ("" + status + " " + posts + " post" + (posts > 1 ? 's' : '')) + (+files ? " and " + files + " image repl" + (files > 1 ? 'ies' : 'y') : "") + (" " + (status === '-' ? 'shown' : 'omitted') + ".");
|
||||
},
|
||||
cbToggle: function() {
|
||||
return ExpandThread.toggle(Get.threadFromRoot(this.parentNode));
|
||||
return ExpandThread.toggle(Get.threadFromNode(this));
|
||||
},
|
||||
toggle: function(thread) {
|
||||
var a, files, filesCount, inlined, num, post, posts, postsCount, reply, threadRoot, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
||||
@ -10378,7 +10383,6 @@
|
||||
}
|
||||
Conf['selectedArchives'] = {};
|
||||
Conf['CachedTitles'] = [];
|
||||
Conf['archives'] = Redirect.archives;
|
||||
$.get(Conf, function(items) {
|
||||
$.extend(Conf, items);
|
||||
return Main.initFeatures();
|
||||
@ -10551,7 +10555,7 @@
|
||||
},
|
||||
initReady: function() {
|
||||
var board, err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
||||
if (d.title === '4chan - 404 Not Found') {
|
||||
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
|
||||
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
|
||||
href = Redirect.to('thread', {
|
||||
boardID: g.BOARD.ID,
|
||||
|
||||
@ -1426,10 +1426,10 @@
|
||||
|
||||
Header = {
|
||||
init: function() {
|
||||
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler,
|
||||
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler, menuButton,
|
||||
_this = this;
|
||||
this.menu = new UI.Menu('header');
|
||||
this.menuButton = $.el('span', {
|
||||
menuButton = $.el('span', {
|
||||
className: 'menu-button',
|
||||
innerHTML: '<i></i>'
|
||||
});
|
||||
@ -1461,7 +1461,7 @@
|
||||
this.headerToggler = headerToggler.firstElementChild;
|
||||
this.footerToggler = footerToggler.firstElementChild;
|
||||
this.customNavToggler = customNavToggler.firstElementChild;
|
||||
$.on(this.menuButton, 'click', this.menuToggle);
|
||||
$.on(menuButton, 'click', this.menuToggle);
|
||||
$.on(this.barFixedToggler, 'change', this.toggleBarFixed);
|
||||
$.on(this.barPositionToggler, 'change', this.toggleBarPosition);
|
||||
$.on(this.linkJustifyToggler, 'change', this.toggleLinkJustify);
|
||||
@ -1476,7 +1476,7 @@
|
||||
$.sync('Bottom Header', Header.setBarPosition);
|
||||
$.sync('Header auto-hide', Header.setBarVisibility);
|
||||
$.sync('Centered links', Header.setLinkJustify);
|
||||
this.addShortcut(Header.menuButton);
|
||||
this.addShortcut(menuButton);
|
||||
$.event('AddMenuEntry', {
|
||||
type: 'header',
|
||||
el: $.el('span', {
|
||||
@ -1976,6 +1976,9 @@
|
||||
threadFromRoot: function(root) {
|
||||
return g.threads["" + g.BOARD + "." + root.id.slice(1)];
|
||||
},
|
||||
threadFromNode: function(node) {
|
||||
return Get.threadFromRoot($.x('ancestor::div[@class="thread"]', node));
|
||||
},
|
||||
postFromRoot: function(root) {
|
||||
var boardID, index, link, post, postID;
|
||||
link = $('a[title="Highlight this post"]', root);
|
||||
@ -1992,8 +1995,8 @@
|
||||
postFromNode: function(root) {
|
||||
return Get.postFromRoot($.x('(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root));
|
||||
},
|
||||
contextFromNode: function(quotelink) {
|
||||
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink));
|
||||
contextFromNode: function(node) {
|
||||
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', node));
|
||||
},
|
||||
postDataFromLink: function(link) {
|
||||
var boardID, path, postID, threadID, _ref;
|
||||
@ -2426,7 +2429,7 @@
|
||||
};
|
||||
|
||||
Menu.prototype.focus = function(entry) {
|
||||
var bottom, cHeight, cWidth, eRect, focused, left, right, sRect, style, submenu, top, _i, _len, _ref, _ref1, _ref2;
|
||||
var cHeight, cWidth, eRect, focused, sRect, submenu, _i, _len, _ref;
|
||||
while (focused = $.x('parent::*/child::*[contains(@class,"focused")]', entry)) {
|
||||
$.rmClass(focused, 'focused');
|
||||
}
|
||||
@ -2443,13 +2446,20 @@
|
||||
eRect = entry.getBoundingClientRect();
|
||||
cHeight = doc.clientHeight;
|
||||
cWidth = doc.clientWidth;
|
||||
_ref1 = eRect.top + sRect.height < cHeight ? ['0px', 'auto'] : ['auto', '0px'], top = _ref1[0], bottom = _ref1[1];
|
||||
_ref2 = eRect.right + sRect.width < cWidth ? ['100%', 'auto'] : ['auto', '100%'], left = _ref2[0], right = _ref2[1];
|
||||
style = submenu.style;
|
||||
style.top = top;
|
||||
style.bottom = bottom;
|
||||
style.left = left;
|
||||
return style.right = right;
|
||||
if (eRect.top + sRect.height < cHeight) {
|
||||
$.addClass(submenu, 'top');
|
||||
$.rmClass(submenu, 'bottom');
|
||||
} else {
|
||||
$.addClass(submenu, 'bottom');
|
||||
$.rmClass(submenu, 'top');
|
||||
}
|
||||
if (eRect.right + sRect.width < cWidth) {
|
||||
$.addClass(submenu, 'left');
|
||||
return $.rmClass(submenu, 'right');
|
||||
} else {
|
||||
$.addClass(submenu, 'right');
|
||||
return $.rmClass(submenu, 'left');
|
||||
}
|
||||
};
|
||||
|
||||
Menu.prototype.addEntry = function(e) {
|
||||
@ -3208,7 +3218,7 @@
|
||||
post.nodes.stub = $.el('div', {
|
||||
className: 'stub'
|
||||
});
|
||||
$.add(post.nodes.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(post)]);
|
||||
$.add(post.nodes.stub, Conf['Menu'] ? [a, $.tn(' '), button = Menu.makeButton(post)] : a);
|
||||
return $.prepend(post.nodes.root, post.nodes.stub);
|
||||
},
|
||||
show: function(post, showRecursively) {
|
||||
@ -3522,7 +3532,7 @@
|
||||
return ThreadHiding.saveHiddenState(thread);
|
||||
},
|
||||
hide: function(thread, makeStub) {
|
||||
var OP, a, button, numReplies, opInfo, span, threadRoot;
|
||||
var OP, a, numReplies, opInfo, span, threadRoot;
|
||||
if (makeStub == null) {
|
||||
makeStub = Conf['Stubs'];
|
||||
}
|
||||
@ -3541,7 +3551,7 @@
|
||||
thread.stub = $.el('div', {
|
||||
className: 'stub'
|
||||
});
|
||||
$.add(thread.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(OP)]);
|
||||
$.add(thread.stub, Conf['Menu'] ? [a, $.tn(' '), Menu.makeButton()] : a);
|
||||
return $.prepend(threadRoot, thread.stub);
|
||||
},
|
||||
show: function(thread) {
|
||||
@ -3646,25 +3656,22 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var board, boardID, quotelink, quotelinks, quotes, thread, threadID, _i, _len, _ref, _ref1;
|
||||
var board, boardID, quotelink, thread, threadID, _i, _len, _ref, _ref1, _ref2;
|
||||
if (this.isClone && this.thread === this.context.thread) {
|
||||
return;
|
||||
}
|
||||
if (!(quotes = this.quotes).length) {
|
||||
return;
|
||||
}
|
||||
quotelinks = this.nodes.quotelinks;
|
||||
_ref = this.isClone ? this.context : this, board = _ref.board, thread = _ref.thread;
|
||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||
quotelink = quotelinks[_i];
|
||||
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, threadID = _ref1.threadID;
|
||||
_ref1 = this.nodes.quotelinks;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
quotelink = _ref1[_i];
|
||||
_ref2 = Get.postDataFromLink(quotelink), boardID = _ref2.boardID, threadID = _ref2.threadID;
|
||||
if (!threadID) {
|
||||
continue;
|
||||
}
|
||||
if (this.isClone) {
|
||||
quotelink.textContent = quotelink.textContent.replace(QuoteCT.text, '');
|
||||
}
|
||||
if (boardID === this.board.ID && threadID !== thread.ID) {
|
||||
if (boardID === board.ID && threadID !== thread.ID) {
|
||||
$.add(quotelink, $.tn(QuoteCT.text));
|
||||
}
|
||||
}
|
||||
@ -3806,7 +3813,7 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var boardID, op, postID, quotelink, quotelinks, quotes, _i, _j, _len, _len1, _ref;
|
||||
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
|
||||
if (this.isClone && this.thread === this.context.thread) {
|
||||
return;
|
||||
}
|
||||
@ -3815,19 +3822,19 @@
|
||||
}
|
||||
quotelinks = this.nodes.quotelinks;
|
||||
if (this.isClone && quotes.contains(this.thread.fullID)) {
|
||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||
quotelink = quotelinks[_i];
|
||||
i = 0;
|
||||
while (quotelink = quotelinks[i++]) {
|
||||
quotelink.textContent = quotelink.textContent.replace(QuoteOP.text, '');
|
||||
}
|
||||
}
|
||||
op = (this.isClone ? this.context : this).thread.fullID;
|
||||
if (!quotes.contains(op)) {
|
||||
fullID = (this.isClone ? this.context : this).thread.fullID;
|
||||
if (!quotes.contains(fullID)) {
|
||||
return;
|
||||
}
|
||||
for (_j = 0, _len1 = quotelinks.length; _j < _len1; _j++) {
|
||||
quotelink = quotelinks[_j];
|
||||
i = 0;
|
||||
while (quotelink = quotelinks[i++]) {
|
||||
_ref = Get.postDataFromLink(quotelink), boardID = _ref.boardID, postID = _ref.postID;
|
||||
if (("" + boardID + "." + postID) === op) {
|
||||
if (("" + boardID + "." + postID) === fullID) {
|
||||
$.add(quotelink, $.tn(QuoteOP.text));
|
||||
}
|
||||
}
|
||||
@ -5177,7 +5184,7 @@
|
||||
}
|
||||
_ref = QR.nodes, com = _ref.com, thread = _ref.thread;
|
||||
if (!com.value) {
|
||||
thread.value = Get.contextFromNode(this).thread;
|
||||
thread.value = Get.threadFromNode(this);
|
||||
}
|
||||
caretPos = com.selectionStart;
|
||||
com.value = com.value.slice(0, caretPos) + text + com.value.slice(com.selectionEnd);
|
||||
@ -6103,7 +6110,7 @@
|
||||
href: 'javascript:;'
|
||||
});
|
||||
$.on(this.EAI, 'click', ImageExpand.cb.toggleAll);
|
||||
Header.addShortcut(this.EAI);
|
||||
Header.addShortcut(this.EAI, 2);
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Image Expansion',
|
||||
cb: this.node
|
||||
@ -6816,45 +6823,44 @@
|
||||
}
|
||||
};
|
||||
|
||||
Menu = (function() {
|
||||
var a;
|
||||
a = $.el('a', {
|
||||
className: 'menu-button brackets-wrap',
|
||||
innerHTML: '<i></i>',
|
||||
href: 'javascript:;'
|
||||
});
|
||||
return {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Menu']) {
|
||||
return;
|
||||
}
|
||||
this.menu = new UI.Menu('post');
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Menu',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var button;
|
||||
if (this.isClone) {
|
||||
button = $('.menu-button', this.nodes.info);
|
||||
} else {
|
||||
button = a.cloneNode(true);
|
||||
$.add(this.nodes.info, [$.tn('\u00A0'), button]);
|
||||
}
|
||||
return $.on(button, 'click', Menu.toggle);
|
||||
},
|
||||
makeButton: function() {
|
||||
var el;
|
||||
el = a.cloneNode(true);
|
||||
$.on(el, 'click', Menu.toggle);
|
||||
return el;
|
||||
},
|
||||
toggle: function(e) {
|
||||
return Menu.menu.toggle(e, this, Get.postFromNode(this));
|
||||
Menu = {
|
||||
init: function() {
|
||||
if (g.VIEW === 'catalog' || !Conf['Menu']) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
})();
|
||||
this.menu = new UI.Menu('post');
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Menu',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
if (this.isClone) {
|
||||
return $.on($('.menu-button', this.nodes.info), 'click', Menu.toggle);
|
||||
} else {
|
||||
return $.add(this.nodes.info, [$.tn('\u00A0'), Menu.makeButton()]);
|
||||
}
|
||||
},
|
||||
makeButton: (function() {
|
||||
var a;
|
||||
a = $.el('a', {
|
||||
className: 'menu-button brackets-wrap',
|
||||
innerHTML: '<i></i>',
|
||||
href: 'javascript:;'
|
||||
});
|
||||
return function() {
|
||||
var button;
|
||||
button = a.cloneNode(true);
|
||||
$.on(button, 'click', Menu.toggle);
|
||||
return button;
|
||||
};
|
||||
})(),
|
||||
toggle: function(e) {
|
||||
var post;
|
||||
post = Get.postFromNode(this);
|
||||
return Menu.menu.toggle(e, this, post);
|
||||
}
|
||||
};
|
||||
|
||||
ReportLink = {
|
||||
init: function() {
|
||||
@ -7611,11 +7617,13 @@
|
||||
fetching: 0
|
||||
},
|
||||
fetchAllStatus: function() {
|
||||
var thread, _i, _len, _ref;
|
||||
var thread, threads, _i, _len;
|
||||
if (!(threads = ThreadWatcher.getAll()).length) {
|
||||
return;
|
||||
}
|
||||
ThreadWatcher.status.textContent = '...';
|
||||
_ref = ThreadWatcher.getAll();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
thread = _ref[_i];
|
||||
for (_i = 0, _len = threads.length; _i < _len; _i++) {
|
||||
thread = threads[_i];
|
||||
ThreadWatcher.fetchStatus(thread);
|
||||
}
|
||||
},
|
||||
@ -8765,7 +8773,7 @@
|
||||
return ("" + status + " " + posts + " post" + (posts > 1 ? 's' : '')) + (+files ? " and " + files + " image repl" + (files > 1 ? 'ies' : 'y') : "") + (" " + (status === '-' ? 'shown' : 'omitted') + ".");
|
||||
},
|
||||
cbToggle: function() {
|
||||
return ExpandThread.toggle(Get.threadFromRoot(this.parentNode));
|
||||
return ExpandThread.toggle(Get.threadFromNode(this));
|
||||
},
|
||||
toggle: function(thread) {
|
||||
var a, files, filesCount, inlined, num, post, posts, postsCount, reply, threadRoot, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
||||
@ -10363,7 +10371,6 @@
|
||||
}
|
||||
Conf['selectedArchives'] = {};
|
||||
Conf['CachedTitles'] = [];
|
||||
Conf['archives'] = Redirect.archives;
|
||||
$.get(Conf, function(items) {
|
||||
$.extend(Conf, items);
|
||||
if (!items) {
|
||||
@ -10545,7 +10552,7 @@
|
||||
},
|
||||
initReady: function() {
|
||||
var board, err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
||||
if (d.title === '4chan - 404 Not Found') {
|
||||
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
|
||||
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
|
||||
href = Redirect.to('thread', {
|
||||
boardID: g.BOARD.ID,
|
||||
|
||||
9
html/General/Header.html
Normal file
9
html/General/Header.html
Normal file
@ -0,0 +1,9 @@
|
||||
<div id="header-bar" class="dialog">
|
||||
<span id="shortcuts" class="brackets-wrap"></span>
|
||||
<span id="board-list">
|
||||
<span id="custom-board-list"></span>
|
||||
<span id="full-board-list" hidden></span>
|
||||
</span>
|
||||
<div id="toggle-header-bar" title="Toggle the header auto-hiding."></div>
|
||||
</div>
|
||||
<div id="notifications"></div>
|
||||
@ -2,6 +2,7 @@
|
||||
"name": "4chan-X",
|
||||
"version": "1.2.27",
|
||||
"description": "Cross-browser userscript for maximum lurking on 4chan.",
|
||||
|
||||
"meta": {
|
||||
"name": "4chan X",
|
||||
"repo": "https://github.com/seaweedchan/4chan-x/",
|
||||
|
||||
@ -186,10 +186,10 @@ PostHiding =
|
||||
$.add a, $.tn " #{postInfo}"
|
||||
post.nodes.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
$.add post.nodes.stub, unless Conf['Menu']
|
||||
a
|
||||
$.add post.nodes.stub, if Conf['Menu']
|
||||
[a, $.tn(' '), button = Menu.makeButton post]
|
||||
else
|
||||
[a, $.tn(' '), button = Menu.makeButton post]
|
||||
a
|
||||
$.prepend post.nodes.root, post.nodes.stub
|
||||
|
||||
show: (post, showRecursively=Conf['Recursive Hiding']) ->
|
||||
@ -204,4 +204,4 @@ PostHiding =
|
||||
Recursive.rm PostHiding.hide, post
|
||||
for quotelink in Get.allQuotelinksLinkingTo post
|
||||
$.rmClass quotelink, 'filtered'
|
||||
return
|
||||
return
|
||||
|
||||
@ -191,10 +191,10 @@ ThreadHiding =
|
||||
$.add a, $.tn " #{opInfo} (#{numReplies})"
|
||||
thread.stub = $.el 'div',
|
||||
className: 'stub'
|
||||
$.add thread.stub, unless Conf['Menu']
|
||||
a
|
||||
$.add thread.stub, if Conf['Menu']
|
||||
[a, $.tn(' '), Menu.makeButton()]
|
||||
else
|
||||
[a, $.tn(' '), button = Menu.makeButton OP]
|
||||
a
|
||||
$.prepend threadRoot, thread.stub
|
||||
|
||||
show: (thread) ->
|
||||
|
||||
@ -10,6 +10,8 @@ Get =
|
||||
"/#{thread.board}/ - #{excerpt}"
|
||||
threadFromRoot: (root) ->
|
||||
g.threads["#{g.BOARD}.#{root.id[1..]}"]
|
||||
threadFromNode: (node) ->
|
||||
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
||||
postFromRoot: (root) ->
|
||||
link = $ 'a[title="Highlight this post"]', root
|
||||
boardID = link.pathname.split('/')[1]
|
||||
@ -19,8 +21,8 @@ Get =
|
||||
if index then post.clones[index] else post
|
||||
postFromNode: (root) ->
|
||||
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root
|
||||
contextFromNode: (quotelink) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
|
||||
contextFromNode: (node) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', node
|
||||
postDataFromLink: (link) ->
|
||||
if link.hostname is 'boards.4chan.org'
|
||||
path = link.pathname.split '/'
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
Header =
|
||||
init: ->
|
||||
@menu = new UI.Menu 'header'
|
||||
@menuButton = $.el 'span',
|
||||
|
||||
menuButton = $.el 'span',
|
||||
className: 'menu-button'
|
||||
innerHTML: '<i></i>'
|
||||
|
||||
@ -28,7 +29,7 @@ Header =
|
||||
@footerToggler = footerToggler.firstElementChild
|
||||
@customNavToggler = customNavToggler.firstElementChild
|
||||
|
||||
$.on @menuButton, 'click', @menuToggle
|
||||
$.on menuButton, 'click', @menuToggle
|
||||
$.on @barFixedToggler, 'change', @toggleBarFixed
|
||||
$.on @barPositionToggler, 'change', @toggleBarPosition
|
||||
$.on @linkJustifyToggler, 'change', @toggleLinkJustify
|
||||
@ -46,7 +47,7 @@ Header =
|
||||
$.sync 'Header auto-hide', Header.setBarVisibility
|
||||
$.sync 'Centered links', Header.setLinkJustify
|
||||
|
||||
@addShortcut Header.menuButton
|
||||
@addShortcut menuButton
|
||||
|
||||
$.event 'AddMenuEntry',
|
||||
type: 'header'
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
Main =
|
||||
init: ->
|
||||
|
||||
# flatten Config into Conf
|
||||
# and get saved or default values
|
||||
flatten = (parent, obj) ->
|
||||
@ -16,7 +17,6 @@ Main =
|
||||
Conf[db] = boards: {}
|
||||
Conf['selectedArchives'] = {}
|
||||
Conf['CachedTitles'] = []
|
||||
Conf['archives'] = Redirect.archives
|
||||
$.get Conf, (items) ->
|
||||
$.extend Conf, items
|
||||
<% if (type === 'crx') { %>
|
||||
@ -52,6 +52,7 @@ Main =
|
||||
'index'
|
||||
if g.VIEW is 'thread'
|
||||
g.THREADID = +pathname[3]
|
||||
|
||||
switch location.hostname
|
||||
when 'api.4chan.org'
|
||||
return
|
||||
@ -183,7 +184,7 @@ Main =
|
||||
attributeFilter: ['href']
|
||||
|
||||
initReady: ->
|
||||
if d.title is '4chan - 404 Not Found'
|
||||
if ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
|
||||
if Conf['404 Redirect'] and g.VIEW is 'thread'
|
||||
href = Redirect.to 'thread',
|
||||
boardID: g.BOARD.ID
|
||||
|
||||
@ -91,7 +91,7 @@ UI = do ->
|
||||
$.addClass menu, 'left'
|
||||
|
||||
entry = $ '.entry', menu
|
||||
# We've removed flexbox, so we don't user order anymore.
|
||||
# We've removed flexbox, so we don't use order anymore.
|
||||
# while prevEntry = @findNextEntry entry, -1
|
||||
# entry = prevEntry
|
||||
@focus entry
|
||||
@ -171,19 +171,18 @@ UI = do ->
|
||||
eRect = entry.getBoundingClientRect()
|
||||
cHeight = doc.clientHeight
|
||||
cWidth = doc.clientWidth
|
||||
[top, bottom] = if eRect.top + sRect.height < cHeight
|
||||
['0px', 'auto']
|
||||
if eRect.top + sRect.height < cHeight
|
||||
$.addClass submenu, 'top'
|
||||
$.rmClass submenu, 'bottom'
|
||||
else
|
||||
['auto', '0px']
|
||||
[left, right] = if eRect.right + sRect.width < cWidth
|
||||
['100%', 'auto']
|
||||
$.addClass submenu, 'bottom'
|
||||
$.rmClass submenu, 'top'
|
||||
if eRect.right + sRect.width < cWidth
|
||||
$.addClass submenu, 'left'
|
||||
$.rmClass submenu, 'right'
|
||||
else
|
||||
['auto', '100%']
|
||||
{style} = submenu
|
||||
style.top = top
|
||||
style.bottom = bottom
|
||||
style.left = left
|
||||
style.right = right
|
||||
$.addClass submenu, 'right'
|
||||
$.rmClass submenu, 'left'
|
||||
|
||||
addEntry: (e) ->
|
||||
entry = e.detail
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
Polyfill =
|
||||
init: ->
|
||||
<% if (type === 'crx') { %>
|
||||
Polyfill.toBlob()
|
||||
Polyfill.visibility()
|
||||
<% } %>
|
||||
toBlob: ->
|
||||
HTMLCanvasElement::toBlob or= (cb) ->
|
||||
data = atob @toDataURL()[22..]
|
||||
|
||||
@ -8,7 +8,7 @@ ImageExpand =
|
||||
title: 'Expand All Images'
|
||||
href: 'javascript:;'
|
||||
$.on @EAI, 'click', ImageExpand.cb.toggleAll
|
||||
Header.addShortcut @EAI
|
||||
Header.addShortcut @EAI, 2
|
||||
|
||||
Post::callbacks.push
|
||||
name: 'Image Expansion'
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
Menu = do ->
|
||||
a = $.el 'a',
|
||||
className: 'menu-button brackets-wrap'
|
||||
innerHTML: '<i></i>'
|
||||
href: 'javascript:;'
|
||||
|
||||
Menu =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or !Conf['Menu']
|
||||
|
||||
@ -14,16 +9,20 @@ Menu = do ->
|
||||
|
||||
node: ->
|
||||
if @isClone
|
||||
button = $ '.menu-button', @nodes.info
|
||||
$.on $('.menu-button', @nodes.info), 'click', Menu.toggle
|
||||
else
|
||||
button = a.cloneNode true
|
||||
$.add @nodes.info, [$.tn('\u00A0'), button]
|
||||
$.on button, 'click', Menu.toggle
|
||||
$.add @nodes.info, [$.tn('\u00A0'), Menu.makeButton()]
|
||||
|
||||
makeButton: ->
|
||||
el = a.cloneNode true
|
||||
$.on el, 'click', Menu.toggle
|
||||
el
|
||||
makeButton: do ->
|
||||
a = $.el 'a',
|
||||
className: 'menu-button brackets-wrap'
|
||||
innerHTML: '<i></i>'
|
||||
href: 'javascript:;'
|
||||
->
|
||||
button = a.cloneNode true
|
||||
$.on button, 'click', Menu.toggle
|
||||
button
|
||||
|
||||
toggle: (e) ->
|
||||
Menu.menu.toggle e, @, Get.postFromNode @
|
||||
post = Get.postFromNode @
|
||||
Menu.menu.toggle e, @, post
|
||||
|
||||
@ -22,7 +22,7 @@ ExpandThread =
|
||||
" #{if status is '-' then 'shown' else 'omitted'}."
|
||||
|
||||
cbToggle: ->
|
||||
ExpandThread.toggle Get.threadFromRoot @parentNode
|
||||
ExpandThread.toggle Get.threadFromNode @
|
||||
|
||||
toggle: (thread) ->
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
|
||||
@ -107,8 +107,9 @@ ThreadWatcher =
|
||||
fetched: 0
|
||||
fetching: 0
|
||||
fetchAllStatus: ->
|
||||
return unless (threads = ThreadWatcher.getAll()).length
|
||||
ThreadWatcher.status.textContent = '...'
|
||||
for thread in ThreadWatcher.getAll()
|
||||
for thread in threads
|
||||
ThreadWatcher.fetchStatus thread
|
||||
return
|
||||
fetchStatus: ({boardID, threadID, data}) ->
|
||||
|
||||
@ -385,7 +385,7 @@ QR =
|
||||
$.addClass QR.nodes.el, 'dump'
|
||||
QR.cooldown.auto = true
|
||||
{com, thread} = QR.nodes
|
||||
thread.value = Get.contextFromNode(@).thread unless com.value
|
||||
thread.value = Get.threadFromNode @ unless com.value
|
||||
|
||||
caretPos = com.selectionStart
|
||||
# Replace selection for text.
|
||||
|
||||
@ -13,16 +13,13 @@ QuoteCT =
|
||||
node: ->
|
||||
# Stop there if it's a clone of a post in the same thread.
|
||||
return if @isClone and @thread is @context.thread
|
||||
# Stop there if there's no quotes in that post.
|
||||
return unless (quotes = @quotes).length
|
||||
{quotelinks} = @nodes
|
||||
|
||||
{board, thread} = if @isClone then @context else @
|
||||
for quotelink in quotelinks
|
||||
for quotelink in @nodes.quotelinks
|
||||
{boardID, threadID} = Get.postDataFromLink quotelink
|
||||
continue unless threadID # deadlink
|
||||
if @isClone
|
||||
quotelink.textContent = quotelink.textContent.replace QuoteCT.text, ''
|
||||
if boardID is @board.ID and threadID isnt thread.ID
|
||||
if boardID is board.ID and threadID isnt thread.ID
|
||||
$.add quotelink, $.tn QuoteCT.text
|
||||
return
|
||||
return
|
||||
|
||||
@ -10,6 +10,7 @@ QuoteOP =
|
||||
Post::callbacks.push
|
||||
name: 'Mark OP Quotes'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
# Stop there if it's a clone of a post in the same thread.
|
||||
return if @isClone and @thread is @context.thread
|
||||
@ -19,14 +20,16 @@ QuoteOP =
|
||||
|
||||
# rm (OP) from cross-thread quotes.
|
||||
if @isClone and quotes.contains @thread.fullID
|
||||
for quotelink in quotelinks
|
||||
i = 0
|
||||
while quotelink = quotelinks[i++]
|
||||
quotelink.textContent = quotelink.textContent.replace QuoteOP.text, ''
|
||||
|
||||
op = (if @isClone then @context else @).thread.fullID
|
||||
{fullID} = (if @isClone then @context else @).thread
|
||||
# add (OP) to quotes quoting this context's OP.
|
||||
return unless quotes.contains op
|
||||
for quotelink in quotelinks
|
||||
return unless quotes.contains fullID
|
||||
i = 0
|
||||
while quotelink = quotelinks[i++]
|
||||
{boardID, postID} = Get.postDataFromLink quotelink
|
||||
if "#{boardID}.#{postID}" is op
|
||||
if "#{boardID}.#{postID}" is fullID
|
||||
$.add quotelink, $.tn QuoteOP.text
|
||||
return
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user