Merge branch 'v3'

Conflicts:
	CHANGELOG.md
	LICENSE
	builds/appchan-x.user.js
	builds/crx/manifest.json
	builds/crx/script.js
	package.json
	src/General/Navigate.coffee
	src/Miscellaneous/Keybinds.coffee
	src/Posting/QR.coffee
This commit is contained in:
Zixaphir 2014-04-19 15:48:11 -07:00
commit 41ec3933cd
30 changed files with 1445 additions and 324 deletions

View File

@ -1,5 +1,6 @@
**ccd0**
- Some keybind bugfixes.
- Begin work toward compatibility with new URLs.
- `Loop in New Tab` (enabled by default) causes videos opened in a separate tab to loop, and applies your settings for inline expanded videos to them.
- Add WebM support to gallery (currently no controls).
- Add PDF support to gallery, disabled by default. Enable with `PDF in Gallery`.
@ -13,6 +14,11 @@
**fgts**
- Update archive list.
**MayhemYDG**
- Update 4chan namespaces support.
- Better handling of webm playback errors.
**Nebukazar**
- `Quote Threading` disabled by default
- Added missing titles to Header icons

View File

@ -1,5 +1,5 @@
/*
* appchan x - Version 2.9.15 - 2014-04-11
* appchan x - Version 2.9.15 - 2014-04-19
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X
// @version 1.7.7
// @version 1.7.8
// @minGMVer 1.14
// @minFFVer 26
// @namespace 4chan-X

View File

@ -25,7 +25,7 @@
// ==/UserScript==
/*
* appchan x - Version 2.9.15 - 2014-04-11
* appchan x - Version 2.9.15 - 2014-04-19
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -428,8 +428,8 @@
'Open Gallery': ['g', 'Opens the gallery.'],
'fappeTyme': ['f', 'Fappe Tyme.'],
'werkTyme': ['Shift+w', 'Werk Tyme'],
'Front page': ['0', 'Jump to page 0.'],
'Open front page': ['Shift+0', 'Open page 0 in a new tab.'],
'Front page': ['0', 'Jump to front page.'],
'Open front page': ['Shift+0', 'Open front page in a new tab.'],
'Next page': ['Shift+Right', 'Jump to the next page.'],
'Previous page': ['Shift+Left', 'Jump to the previous page.'],
'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'],
@ -3364,7 +3364,7 @@
Post.prototype.parseQuote = function(quotelink) {
var fullID, match;
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/res\/\d+#p(\d+)$/))) {
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/thread\/\d+#p(\d+)$/))) {
return;
}
this.nodes.quotelinks.push(quotelink);
@ -3398,7 +3398,7 @@
size *= 1024;
}
this.file.sizeInBytes = size;
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//t.4cdn.org/" + this.board + "/thumb/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//t.4cdn.org/" + this.board + "/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
this.file.name = (nameNode = $('span', fileText)) ? nameNode.title || nameNode.textContent : fileText.title;
this.file.isImage = /(jpg|png|gif)$/i.test(this.file.name);
this.file.isVideo = /webm$/i.test(this.file.name);
@ -4130,23 +4130,6 @@
Polyfill = {
init: function() {},
notificationPermission: function() {
if (!window.Notification || 'permission' in Notification || !window.webkitNotifications) {
return;
}
return Object.defineProperty(Notification, 'permission', {
get: function() {
switch (webkitNotifications.checkPermission()) {
case 0:
return 'granted';
case 1:
return 'default';
case 2:
return 'denied';
}
}
});
},
toBlob: function() {
var _base;
return (_base = HTMLCanvasElement.prototype).toBlob || (_base.toBlob = function(cb) {
@ -4161,26 +4144,6 @@
type: 'image/png'
}));
});
},
visibility: function() {
if ('visibilityState' in d) {
return;
}
Object.defineProperties(HTMLDocument.prototype, {
visibilityState: {
get: function() {
return this.webkitVisibilityState;
}
},
hidden: {
get: function() {
return this.webkitHidden;
}
}
});
return $.on(d, 'webkitvisibilitychange', function() {
return $.event('visibilitychange');
});
}
};
@ -5234,6 +5197,7 @@
return +window.location.pathname.split('/')[2];
},
userPageNav: function(pageNum) {
Navigate.pushState(pageNum === 0 ? './' : pageNum);
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') {
return Index.update(pageNum);
} else {
@ -5244,7 +5208,7 @@
if (Index.currentPage === pageNum && !Index.root.parentElement) {
return;
}
history.pushState(null, '', pageNum === 0 ? './' : pageNum);
Navigate.pushState(pageNum === 0 ? './' : pageNum);
return Index.pageLoad(pageNum);
},
pageLoad: function(pageNum) {
@ -5829,12 +5793,12 @@
o.file = {
name: data.filename + data.ext,
timestamp: "" + data.tim + data.ext,
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/src/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/src/" + data.tim + data.ext,
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
height: data.h,
width: data.w,
MD5: data.md5,
size: data.fsize,
turl: "//" + (Build.thumbRotate()) + ".t.4cdn.org/" + boardID + "/thumb/" + data.tim + "s.jpg",
turl: "//" + (Build.thumbRotate()) + ".t.4cdn.org/" + boardID + "/" + data.tim + "s.jpg",
theight: data.tn_h,
twidth: data.tn_w,
isSpoiler: !!data.spoiler,
@ -5921,14 +5885,14 @@
if (isOP && g.VIEW === 'index') {
pageNum = Math.floor(Index.liveThreadData.keys.indexOf("" + postID) / Index.threadsNumPerPage);
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
replyLink = " &nbsp; <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
replyLink = " &nbsp; <span>[<a href='/" + boardID + "/thread/" + threadID + "' class=replylink>Reply</a>]</span>";
} else {
pageIcon = replyLink = '';
}
container = $.el('div', {
id: "pc" + postID,
className: "postContainer " + (isOP ? 'op' : 'reply') + "Container",
innerHTML: "" + (isOP ? '' : "<div class=sideArrows>&gt;&gt;</div>") + "<div id=p" + postID + " class='post " + (isOP ? 'op' : 'reply') + (capcodeIcon === 'admin_highlight' ? ' highlightPost' : '') + "'>" + (isOP ? fileHTML : '') + "<div class='postInfo'><input type=checkbox name=" + postID + " value=delete>" + ' ' + "<span class=subject>" + (subject || '') + "</span>" + ' ' + "<span class='nameBlock" + capcodeClass + "'>" + emailStart + "<span class=name>" + (name || '') + "</span>" + (tripcode + capcodeStart + emailEnd + capcodeIcon + userID + flag) + "</span>" + " " + "<span class=dateTime data-utc=" + dateUTC + ">" + date + "</span>" + ' ' + "<span class='postNum'><a href=" + ("/" + boardID + "/res/" + threadID + "#p" + postID) + " title='Highlight this post'>No.</a><a href='" + (g.VIEW === 'thread' && g.THREADID === +threadID ? "javascript:quote(" + postID + ")" : "/" + boardID + "/res/" + threadID + "#q" + postID) + "' title='Quote this post'>" + postID + "</a>" + (pageIcon + sticky + closed + replyLink) + "</span></div>" + (isOP ? '' : fileHTML) + "<blockquote class=postMessage>" + (comment || '') + "</blockquote>" + ' ' + "</div>"
innerHTML: (isOP ? '' : "<div class=sideArrows>&gt;&gt;</div>") + ("<div id=p" + postID + " class='post " + (isOP ? 'op' : 'reply') + (capcode === 'admin_highlight' ? ' highlightPost' : '') + "'>") + (isOP ? fileHTML : '') + "<div class=postInfo>" + ("<input type=checkbox name=" + postID + " value=delete> ") + ("<span class=subject>" + (subject || '') + "</span> ") + ("<span class='nameBlock" + capcodeClass + "'>") + emailStart + ("<span class=name>" + (name || '') + "</span>") + tripcode + capcodeStart + emailEnd + capcodeIcon + userID + flag + ' </span> ' + ("<span class=dateTime data-utc=" + dateUTC + ">" + date + "</span> ") + "<span class='postNum'>" + ("<a href=" + ("/" + boardID + "/thread/" + threadID + "#p" + postID) + " title='Highlight this post'>No.</a>") + ("<a href='" + (g.VIEW === 'thread' && g.THREADID === threadID ? "javascript:quote(" + postID + ")" : "/" + boardID + "/thread/" + threadID + "#q" + postID) + "' title='Quote this post'>" + postID + "</a>") + pageIcon + sticky + closed + replyLink + '</span>' + '</div>' + (isOP ? '' : fileHTML) + ("<blockquote class=postMessage>" + (comment || '') + "</blockquote> ") + '</div>'
});
_ref = $$('.quotelink', container);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -5937,7 +5901,7 @@
if (href[0] === '/') {
continue;
}
quote.href = "/" + boardID + "/res/" + href;
quote.href = "/" + boardID + "/thread/" + href;
}
return container;
},
@ -5952,7 +5916,7 @@
return $.el('a', {
className: 'summary',
textContent: text.join(' '),
href: "/" + boardID + "/res/" + threadID
href: "/" + boardID + "/thread/" + threadID
});
},
thread: function(board, data, full) {
@ -5993,7 +5957,7 @@
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
root = $.el('div', {
className: 'catalog-thread',
innerHTML: "<a href=\"/" + thread.board + "/res/" + thread.ID + "\" class=\"thumb\"></a><div class=\"thread-stats\" title=\"Post count / File count / Page count\"><span class=\"post-count\">" + postCount + "</span> / <span class=\"file-count\">" + fileCount + "</span> / <span class=\"page-count\">" + pageCount + "</span><span class=\"thread-icons\"></span></div>" + subject + "<div class=\"comment\">" + comment + "</div>"
innerHTML: "<a href=\"/" + thread.board + "/thread/" + thread.ID + "\" class=\"thumb\"></a><div class=\"thread-stats\" title=\"Post count / File count / Page count\"><span class=\"post-count\">" + postCount + "</span> / <span class=\"file-count\">" + fileCount + "</span> / <span class=\"page-count\">" + pageCount + "</span><span class=\"thread-icons\"></span></div>" + subject + "<div class=\"comment\">" + comment + "</div>"
});
root.dataset.fullID = thread.fullID;
if (thread.isPinned) {
@ -6151,7 +6115,7 @@
}
root.textContent = "Loading post No." + postID + "...";
if (threadID) {
return $.cache("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", function() {
return $.cache("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", function() {
return Get.fetchedPost(this, boardID, threadID, postID, root, context);
});
} else if (url = Redirect.to('post', {
@ -6285,7 +6249,7 @@
width: data.media.media_w,
MD5: data.media.media_hash,
size: data.media.media_size,
turl: data.media.thumb_link || ("//t.4cdn.org/" + boardID + "/thumb/" + data.media.preview_orig),
turl: data.media.thumb_link || ("//t.4cdn.org/" + boardID + "/" + data.media.preview_orig),
theight: data.media.preview_h,
twidth: data.media.preview_w,
isSpoiler: data.media.spoiler === '1'
@ -7060,27 +7024,10 @@
href: 'javascript:;',
textContent: '\uf196'
});
Post.callbacks.push({
return Post.callbacks.push({
name: 'Post Hiding',
cb: this.node
});
return $.get('hiddenThreads', null, function(_arg) {
var board, boardID, hiddenThreads, threadID, val, _base, _base1, _ref;
hiddenThreads = _arg.hiddenThreads;
if (!hiddenThreads) {
return;
}
_ref = hiddenThreads.boards;
for (boardID in _ref) {
board = _ref[boardID];
for (threadID in board) {
val = board[threadID];
((_base = ((_base1 = PostHiding.db.data.boards)[boardID] || (_base1[boardID] = {})))[threadID] || (_base[threadID] = {}))[threadID] = val;
}
}
PostHiding.db.save();
return $["delete"]('hiddenThreads');
});
},
node: function() {
var a, data, label;
@ -7481,7 +7428,7 @@
var a, frag, hash, text;
frag = QuoteBacklink.frag.cloneNode(true);
a = frag.lastElementChild;
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
a.href = "/" + quoter.board + "/thread/" + quoter.thread + "#p" + quoter;
a.textContent = text = QuoteBacklink.funk(quoter.ID);
if (quoter.isDead) {
$.addClass(a, 'deadlink');
@ -8053,7 +8000,7 @@
quoteID = "" + boardID + "." + postID;
if (post = g.posts[quoteID]) {
a = $.el('a', {
href: "/" + boardID + "/res/" + post.thread + "#p" + postID,
href: "/" + boardID + "/thread/" + post.thread + "#p" + postID,
className: post.isDead ? 'quotelink deadlink' : 'quotelink',
textContent: quote
});
@ -8912,7 +8859,9 @@
_ref = $$('br', frag);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
node = _ref[_i];
$.replace(node, $.tn('\n>'));
if (node !== frag.lastElementChild) {
$.replace(node, $.tn('\n>'));
}
}
_ref1 = $$('s', frag);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
@ -10801,8 +10750,12 @@
delete post.file.videoControls;
}
$.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(thumb, 'expanding');
return post.file.isExpanded = false;
$.rmClass(post.file.thumb, 'expanding');
delete post.file.isExpanding;
delete post.file.isExpanded;
if (post.file.isVideo && post.file.fullImage) {
return post.file.fullImage.pause();
}
},
expand: function(post, src, disableAutoplay) {
var el, isVideo, thumb, _ref;
@ -10918,19 +10871,40 @@
return $.add(file.text, file.videoControls);
},
error: function() {
var URL, post, src, timeoutID;
var URL, error, post, src, timeoutID;
post = Get.postFromNode(this);
$.rm(this);
delete post.file.isReady;
delete post.file.fullImage;
if (!($.hasClass(post.file.thumb, 'expanding') || $.hasClass(post.nodes.root, 'expanded-image'))) {
return;
}
ImageExpand.contract(post);
if (this.error && this.error.code !== this.error.MEDIA_ERR_NETWORK) {
error = (function() {
switch (this.error.code) {
case 1:
return 'MEDIA_ERR_ABORTED';
case 3:
return 'MEDIA_ERR_DECODE';
case 4:
return 'MEDIA_ERR_SRC_NOT_SUPPORTED';
case 5:
return 'MEDIA_ERR_ENCRYPTED';
}
}).call(this);
post.file.error = $.el('div', {
textContent: "Playback error: " + error,
className: 'warning'
});
$.after(post.file.thumb, post.file.error);
return;
}
src = this.src.split('/');
if (src[2] === 'i.4cdn.org') {
URL = Redirect.to('file', {
boardID: src[3],
filename: src[5]
filename: src[4].replace(/\?.+$/, '')
});
if (URL) {
setTimeout(ImageExpand.expand, 10000, post, URL);
@ -10941,7 +10915,7 @@
}
}
timeoutID = setTimeout(ImageExpand.expand, 10000, post);
return $.ajax("//a.4cdn.org/" + post.board + "/res/" + post.thread + ".json", {
return $.ajax("//a.4cdn.org/" + post.board + "/thread/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
if (this.status !== 200) {
@ -11046,7 +11020,6 @@
TrashQueue.remove(el);
} else {
el = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: post.file.URL
});
post.file.fullImage = el;
@ -11076,10 +11049,11 @@
el: el,
latestEvent: e,
endEvents: 'mouseout click',
asapTest: function() {
return el.videoHeight || el.naturalHeight;
asapTest: post.file.isImage ? function() {
return el.naturalHeight;
} : function() {
return el.readyState >= el.HAVE_CURRENT_DATA;
},
noRemove: true,
cb: function() {
if (isVideo) {
el.pause();
@ -11100,7 +11074,7 @@
if (src[2] === 'i.4cdn.org') {
URL = Redirect.to('file', {
boardID: src[3],
filename: src[5].replace(/\?.+$/, '')
filename: src[4].replace(/\?.+$/, '')
});
if (URL) {
this.src = URL;
@ -11115,7 +11089,7 @@
return _this.src = post.file.URL + '?' + Date.now();
};
})(this)), 3000);
return $.ajax("//a.4cdn.org/" + post.board + "/res/" + post.thread + ".json", {
return $.ajax("//a.4cdn.org/" + post.board + "/thread/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
if (this.status !== 200) {
@ -12167,9 +12141,12 @@
if ((_ref = ThreadUpdater.req) != null) {
_ref.abort();
}
url = "//a.4cdn.org/" + ThreadUpdater.thread.board + "/res/" + ThreadUpdater.thread + ".json";
url = "//a.4cdn.org/" + ThreadUpdater.thread.board + "/thread/" + ThreadUpdater.thread + ".json";
return ThreadUpdater.req = $.ajax(url, {
onloadend: ThreadUpdater.cb.load
onabort: ThreadUpdater.cb.load,
onloadend: ThreadUpdater.cb.load,
ontimeout: ThreadUpdater.cb.load,
timeout: $.MINUTE
}, {
whenModified: true
});
@ -12467,7 +12444,7 @@
}
fetchCount = ThreadWatcher.fetchCount;
fetchCount.fetching++;
return $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
onloadend: function() {
var status;
fetchCount.fetched++;
@ -12536,7 +12513,7 @@
});
}
link = $.el('a', {
href: href || ("/" + boardID + "/res/" + threadID),
href: href || ("/" + boardID + "/thread/" + threadID),
textContent: data.excerpt,
title: data.excerpt
});
@ -15233,7 +15210,7 @@
var status;
ExpandThread.statuses[thread] = status = {};
a.textContent = ExpandThread.text.apply(ExpandThread, ['...'].concat(__slice.call(a.textContent.match(/\d+/g))));
return status.req = $.cache("//a.4cdn.org/" + thread.board + "/res/" + thread + ".json", function() {
return status.req = $.cache("//a.4cdn.org/" + thread.board + "/thread/" + thread + ".json", function() {
delete status.req;
return ExpandThread.parse(this, thread, a);
});
@ -15733,7 +15710,7 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
if (!(key = Keybinds.keyCode(e))) {
return;
}
@ -15827,7 +15804,9 @@
ThreadUpdater.update();
break;
case 'index':
Index.update();
if (Conf['JSON Navigation']) {
Index.update();
}
}
break;
case Conf['Watch']:
@ -15853,7 +15832,7 @@
});
break;
case Conf['Front page']:
if (g.VIEW === 'index') {
if (Conf['JSON Navigation'] && g.VIEW === 'index') {
Index.userPageNav(0);
} else {
window.location = "/" + g.BOARD + "/";
@ -15863,19 +15842,39 @@
$.open("/" + g.BOARD + "/");
break;
case Conf['Next page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) {
if (g.VIEW !== 'index') {
return;
}
$('.next button, .next a', Index.pagelist).click();
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.next button', Index.pagelist).click();
}
} else {
if (form = $('.next form')) {
window.location = form.action;
}
}
break;
case Conf['Previous page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) {
if (g.VIEW !== 'index') {
return;
}
$('.prev button, .prev a', Index.pagelist).click();
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.prev button', Index.pagelist).click();
}
} else {
if (form = $('.prev form')) {
window.location = form.action;
}
}
break;
case Conf['Search form']:
Index.searchInput.focus();
if (Conf['JSON Navigation']) {
Index.searchInput.focus();
} else {
$.id('search-btn').click();
}
break;
case Conf['Paged mode']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) {
@ -15901,6 +15900,19 @@
}
Index.cycleSortType();
break;
case Conf['Open catalog']:
if (Conf['External Catalog']) {
window.location = CatalogLinks.external(g.BOARD.ID);
} else {
if (!Conf['JSON Navigation']) {
return window.location = "/" + g.BOARD + "/catalog";
}
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'catalog')) {
return;
}
Index.setIndexMode('catalog');
}
break;
case Conf['Next thread']:
if (g.VIEW !== 'index') {
return;
@ -16033,7 +16045,7 @@
if (g.VIEW !== 'index') {
return;
}
url = "/" + thread.board + "/res/" + thread;
url = "/" + thread.board + "/thread/" + thread;
if (tab) {
return $.open(url);
} else {
@ -16651,7 +16663,7 @@
if (threadID) {
view = 'thread';
} else {
pageNum = view;
pageNum = +view;
view = 'index';
}
path = this.pathname;
@ -16660,9 +16672,8 @@
}
Navigate.makeBreadCrumb(this.href, view, boardID, threadID);
if (this.id !== 'popState') {
history.pushState('internal', '', path);
Navigate.pushState(path);
}
Navigate.path = this.pathname;
Navigate.setMode(this);
if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) {
Navigate.disconnect();
@ -16786,6 +16797,10 @@
return Main.handleErrors(errors);
}
},
pushState: function(path) {
history.pushState(null, '', path);
return Navigate.path = window.location.pathname;
},
popstate: function() {
var a;
a = $.el('a', {
@ -17251,7 +17266,7 @@
data = {
isReply: true,
file: {
URL: '//i.4cdn.org/g/src/1334437723720.jpg',
URL: '//i.4cdn.org/g/1334437723720.jpg',
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg',
size: '276 KB',
sizeInBytes: 276 * 1024,
@ -17874,6 +17889,7 @@
g.VIEW = (function() {
switch (pathname[2]) {
case 'res':
case 'thread':
return 'thread';
case 'catalog':
return 'catalog';

View File

@ -15,7 +15,7 @@
"run_at": "document_start"
}],
"homepage_url": "http://zixaphir.github.com/appchan-x/",
"minimum_chrome_version": "32",
"minimum_chrome_version": "33",
"permissions": [
"storage",
"http://*/",

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* appchan x - Version 2.9.15 - 2014-04-11
* appchan x - Version 2.9.15 - 2014-04-19
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -403,8 +403,8 @@
'Open Gallery': ['g', 'Opens the gallery.'],
'fappeTyme': ['f', 'Fappe Tyme.'],
'werkTyme': ['Shift+w', 'Werk Tyme'],
'Front page': ['0', 'Jump to page 0.'],
'Open front page': ['Shift+0', 'Open page 0 in a new tab.'],
'Front page': ['0', 'Jump to front page.'],
'Open front page': ['Shift+0', 'Open front page in a new tab.'],
'Next page': ['Shift+Right', 'Jump to the next page.'],
'Previous page': ['Shift+Left', 'Jump to the previous page.'],
'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'],
@ -3419,7 +3419,7 @@
Post.prototype.parseQuote = function(quotelink) {
var fullID, match;
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/res\/\d+#p(\d+)$/))) {
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/thread\/\d+#p(\d+)$/))) {
return;
}
this.nodes.quotelinks.push(quotelink);
@ -3453,7 +3453,7 @@
size *= 1024;
}
this.file.sizeInBytes = size;
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//t.4cdn.org/" + this.board + "/thumb/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//t.4cdn.org/" + this.board + "/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
this.file.name = (nameNode = $('span', fileText)) ? nameNode.title || nameNode.textContent : fileText.title;
this.file.name = this.file.name.replace(/%22/g, '"');
this.file.isImage = /(jpg|png|gif)$/i.test(this.file.name);
@ -4186,26 +4186,7 @@
Polyfill = {
init: function() {
this.notificationPermission();
this.toBlob();
return this.visibility();
},
notificationPermission: function() {
if (!window.Notification || 'permission' in Notification || !window.webkitNotifications) {
return;
}
return Object.defineProperty(Notification, 'permission', {
get: function() {
switch (webkitNotifications.checkPermission()) {
case 0:
return 'granted';
case 1:
return 'default';
case 2:
return 'denied';
}
}
});
return this.toBlob();
},
toBlob: function() {
var _base;
@ -4221,26 +4202,6 @@
type: 'image/png'
}));
});
},
visibility: function() {
if ('visibilityState' in d) {
return;
}
Object.defineProperties(HTMLDocument.prototype, {
visibilityState: {
get: function() {
return this.webkitVisibilityState;
}
},
hidden: {
get: function() {
return this.webkitHidden;
}
}
});
return $.on(d, 'webkitvisibilitychange', function() {
return $.event('visibilitychange');
});
}
};
@ -5294,6 +5255,7 @@
return +window.location.pathname.split('/')[2];
},
userPageNav: function(pageNum) {
Navigate.pushState(pageNum === 0 ? './' : pageNum);
if (Conf['Refreshed Navigation'] && Conf['Index Mode'] !== 'all pages') {
return Index.update(pageNum);
} else {
@ -5304,7 +5266,7 @@
if (Index.currentPage === pageNum && !Index.root.parentElement) {
return;
}
history.pushState(null, '', pageNum === 0 ? './' : pageNum);
Navigate.pushState(pageNum === 0 ? './' : pageNum);
return Index.pageLoad(pageNum);
},
pageLoad: function(pageNum) {
@ -5889,12 +5851,12 @@
o.file = {
name: data.filename + data.ext,
timestamp: "" + data.tim + data.ext,
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/src/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/src/" + data.tim + data.ext,
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
height: data.h,
width: data.w,
MD5: data.md5,
size: data.fsize,
turl: "//" + (Build.thumbRotate()) + ".t.4cdn.org/" + boardID + "/thumb/" + data.tim + "s.jpg",
turl: "//" + (Build.thumbRotate()) + ".t.4cdn.org/" + boardID + "/" + data.tim + "s.jpg",
theight: data.tn_h,
twidth: data.tn_w,
isSpoiler: !!data.spoiler,
@ -5981,14 +5943,14 @@
if (isOP && g.VIEW === 'index') {
pageNum = Math.floor(Index.liveThreadData.keys.indexOf("" + postID) / Index.threadsNumPerPage);
pageIcon = " <span class=page-num title='This thread is on page " + pageNum + " in the original index.'>Page " + pageNum + "</span>";
replyLink = " &nbsp; <span>[<a href='/" + boardID + "/res/" + threadID + "' class=replylink>Reply</a>]</span>";
replyLink = " &nbsp; <span>[<a href='/" + boardID + "/thread/" + threadID + "' class=replylink>Reply</a>]</span>";
} else {
pageIcon = replyLink = '';
}
container = $.el('div', {
id: "pc" + postID,
className: "postContainer " + (isOP ? 'op' : 'reply') + "Container",
innerHTML: "" + (isOP ? '' : "<div class=sideArrows>&gt;&gt;</div>") + "<div id=p" + postID + " class='post " + (isOP ? 'op' : 'reply') + (capcodeIcon === 'admin_highlight' ? ' highlightPost' : '') + "'>" + (isOP ? fileHTML : '') + "<div class='postInfo'><input type=checkbox name=" + postID + " value=delete>" + ' ' + "<span class=subject>" + (subject || '') + "</span>" + ' ' + "<span class='nameBlock" + capcodeClass + "'>" + emailStart + "<span class=name>" + (name || '') + "</span>" + (tripcode + capcodeStart + emailEnd + capcodeIcon + userID + flag) + "</span>" + " " + "<span class=dateTime data-utc=" + dateUTC + ">" + date + "</span>" + ' ' + "<span class='postNum'><a href=" + ("/" + boardID + "/res/" + threadID + "#p" + postID) + " title='Highlight this post'>No.</a><a href='" + (g.VIEW === 'thread' && g.THREADID === +threadID ? "javascript:quote(" + postID + ")" : "/" + boardID + "/res/" + threadID + "#q" + postID) + "' title='Quote this post'>" + postID + "</a>" + (pageIcon + sticky + closed + replyLink) + "</span></div>" + (isOP ? '' : fileHTML) + "<blockquote class=postMessage>" + (comment || '') + "</blockquote>" + ' ' + "</div>"
innerHTML: (isOP ? '' : "<div class=sideArrows>&gt;&gt;</div>") + ("<div id=p" + postID + " class='post " + (isOP ? 'op' : 'reply') + (capcode === 'admin_highlight' ? ' highlightPost' : '') + "'>") + (isOP ? fileHTML : '') + "<div class=postInfo>" + ("<input type=checkbox name=" + postID + " value=delete> ") + ("<span class=subject>" + (subject || '') + "</span> ") + ("<span class='nameBlock" + capcodeClass + "'>") + emailStart + ("<span class=name>" + (name || '') + "</span>") + tripcode + capcodeStart + emailEnd + capcodeIcon + userID + flag + ' </span> ' + ("<span class=dateTime data-utc=" + dateUTC + ">" + date + "</span> ") + "<span class='postNum'>" + ("<a href=" + ("/" + boardID + "/thread/" + threadID + "#p" + postID) + " title='Highlight this post'>No.</a>") + ("<a href='" + (g.VIEW === 'thread' && g.THREADID === threadID ? "javascript:quote(" + postID + ")" : "/" + boardID + "/thread/" + threadID + "#q" + postID) + "' title='Quote this post'>" + postID + "</a>") + pageIcon + sticky + closed + replyLink + '</span>' + '</div>' + (isOP ? '' : fileHTML) + ("<blockquote class=postMessage>" + (comment || '') + "</blockquote> ") + '</div>'
});
_ref = $$('.quotelink', container);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -5997,7 +5959,7 @@
if (href[0] === '/') {
continue;
}
quote.href = "/" + boardID + "/res/" + href;
quote.href = "/" + boardID + "/thread/" + href;
}
return container;
},
@ -6012,7 +5974,7 @@
return $.el('a', {
className: 'summary',
textContent: text.join(' '),
href: "/" + boardID + "/res/" + threadID
href: "/" + boardID + "/thread/" + threadID
});
},
thread: function(board, data, full) {
@ -6053,7 +6015,7 @@
comment = thread.OP.nodes.comment.innerHTML.replace(/(<br>\s*){2,}/g, '<br>');
root = $.el('div', {
className: 'catalog-thread',
innerHTML: "<a href=\"/" + thread.board + "/res/" + thread.ID + "\" class=\"thumb\"></a><div class=\"thread-stats\" title=\"Post count / File count / Page count\"><span class=\"post-count\">" + postCount + "</span> / <span class=\"file-count\">" + fileCount + "</span> / <span class=\"page-count\">" + pageCount + "</span><span class=\"thread-icons\"></span></div>" + subject + "<div class=\"comment\">" + comment + "</div>"
innerHTML: "<a href=\"/" + thread.board + "/thread/" + thread.ID + "\" class=\"thumb\"></a><div class=\"thread-stats\" title=\"Post count / File count / Page count\"><span class=\"post-count\">" + postCount + "</span> / <span class=\"file-count\">" + fileCount + "</span> / <span class=\"page-count\">" + pageCount + "</span><span class=\"thread-icons\"></span></div>" + subject + "<div class=\"comment\">" + comment + "</div>"
});
root.dataset.fullID = thread.fullID;
if (thread.isPinned) {
@ -6211,7 +6173,7 @@
}
root.textContent = "Loading post No." + postID + "...";
if (threadID) {
return $.cache("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", function() {
return $.cache("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", function() {
return Get.fetchedPost(this, boardID, threadID, postID, root, context);
});
} else if (url = Redirect.to('post', {
@ -6345,7 +6307,7 @@
width: data.media.media_w,
MD5: data.media.media_hash,
size: data.media.media_size,
turl: data.media.thumb_link || ("//t.4cdn.org/" + boardID + "/thumb/" + data.media.preview_orig),
turl: data.media.thumb_link || ("//t.4cdn.org/" + boardID + "/" + data.media.preview_orig),
theight: data.media.preview_h,
twidth: data.media.preview_w,
isSpoiler: data.media.spoiler === '1'
@ -7113,27 +7075,10 @@
href: 'javascript:;',
textContent: '\uf196'
});
Post.callbacks.push({
return Post.callbacks.push({
name: 'Post Hiding',
cb: this.node
});
return $.get('hiddenThreads', null, function(_arg) {
var board, boardID, hiddenThreads, threadID, val, _base, _base1, _ref;
hiddenThreads = _arg.hiddenThreads;
if (!hiddenThreads) {
return;
}
_ref = hiddenThreads.boards;
for (boardID in _ref) {
board = _ref[boardID];
for (threadID in board) {
val = board[threadID];
((_base = ((_base1 = PostHiding.db.data.boards)[boardID] || (_base1[boardID] = {})))[threadID] || (_base[threadID] = {}))[threadID] = val;
}
}
PostHiding.db.save();
return $["delete"]('hiddenThreads');
});
},
node: function() {
var a, data, label;
@ -7534,7 +7479,7 @@
var a, frag, hash, text;
frag = QuoteBacklink.frag.cloneNode(true);
a = frag.lastElementChild;
a.href = "/" + quoter.board + "/res/" + quoter.thread + "#p" + quoter;
a.href = "/" + quoter.board + "/thread/" + quoter.thread + "#p" + quoter;
a.textContent = text = QuoteBacklink.funk(quoter.ID);
if (quoter.isDead) {
$.addClass(a, 'deadlink');
@ -8106,7 +8051,7 @@
quoteID = "" + boardID + "." + postID;
if (post = g.posts[quoteID]) {
a = $.el('a', {
href: "/" + boardID + "/res/" + post.thread + "#p" + postID,
href: "/" + boardID + "/thread/" + post.thread + "#p" + postID,
className: post.isDead ? 'quotelink deadlink' : 'quotelink',
textContent: quote
});
@ -8975,7 +8920,9 @@
_ref = $$('br', frag);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
node = _ref[_i];
$.replace(node, $.tn('\n>'));
if (node !== frag.lastElementChild) {
$.replace(node, $.tn('\n>'));
}
}
_ref1 = $$('s', frag);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
@ -10839,8 +10786,12 @@
delete post.file.videoControls;
}
$.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(thumb, 'expanding');
return post.file.isExpanded = false;
$.rmClass(post.file.thumb, 'expanding');
delete post.file.isExpanding;
delete post.file.isExpanded;
if (post.file.isVideo && post.file.fullImage) {
return post.file.fullImage.pause();
}
},
expand: function(post, src, disableAutoplay) {
var el, isVideo, thumb, _ref;
@ -10956,19 +10907,40 @@
return $.add(file.text, file.videoControls);
},
error: function() {
var URL, post, src, timeoutID;
var URL, error, post, src, timeoutID;
post = Get.postFromNode(this);
$.rm(this);
delete post.file.isReady;
delete post.file.fullImage;
if (!($.hasClass(post.file.thumb, 'expanding') || $.hasClass(post.nodes.root, 'expanded-image'))) {
return;
}
ImageExpand.contract(post);
if (this.error && this.error.code !== this.error.MEDIA_ERR_NETWORK) {
error = (function() {
switch (this.error.code) {
case 1:
return 'MEDIA_ERR_ABORTED';
case 3:
return 'MEDIA_ERR_DECODE';
case 4:
return 'MEDIA_ERR_SRC_NOT_SUPPORTED';
case 5:
return 'MEDIA_ERR_ENCRYPTED';
}
}).call(this);
post.file.error = $.el('div', {
textContent: "Playback error: " + error,
className: 'warning'
});
$.after(post.file.thumb, post.file.error);
return;
}
src = this.src.split('/');
if (src[2] === 'i.4cdn.org') {
URL = Redirect.to('file', {
boardID: src[3],
filename: src[5]
filename: src[4].replace(/\?.+$/, '')
});
if (URL) {
setTimeout(ImageExpand.expand, 10000, post, URL);
@ -11073,7 +11045,6 @@
TrashQueue.remove(el);
} else {
el = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: post.file.URL
});
post.file.fullImage = el;
@ -11103,10 +11074,11 @@
el: el,
latestEvent: e,
endEvents: 'mouseout click',
asapTest: function() {
return el.videoHeight || el.naturalHeight;
asapTest: post.file.isImage ? function() {
return el.naturalHeight;
} : function() {
return el.readyState >= el.HAVE_CURRENT_DATA;
},
noRemove: true,
cb: function() {
if (isVideo) {
el.pause();
@ -11127,7 +11099,7 @@
if (src[2] === 'i.4cdn.org') {
URL = Redirect.to('file', {
boardID: src[3],
filename: src[5].replace(/\?.+$/, '')
filename: src[4].replace(/\?.+$/, '')
});
if (URL) {
this.src = URL;
@ -12183,9 +12155,12 @@
if ((_ref = ThreadUpdater.req) != null) {
_ref.abort();
}
url = "//a.4cdn.org/" + ThreadUpdater.thread.board + "/res/" + ThreadUpdater.thread + ".json";
url = "//a.4cdn.org/" + ThreadUpdater.thread.board + "/thread/" + ThreadUpdater.thread + ".json";
return ThreadUpdater.req = $.ajax(url, {
onloadend: ThreadUpdater.cb.load
onabort: ThreadUpdater.cb.load,
onloadend: ThreadUpdater.cb.load,
ontimeout: ThreadUpdater.cb.load,
timeout: $.MINUTE
}, {
whenModified: true
});
@ -12483,7 +12458,7 @@
}
fetchCount = ThreadWatcher.fetchCount;
fetchCount.fetching++;
return $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
onloadend: function() {
var status;
fetchCount.fetched++;
@ -12552,7 +12527,7 @@
});
}
link = $.el('a', {
href: href || ("/" + boardID + "/res/" + threadID),
href: href || ("/" + boardID + "/thread/" + threadID),
textContent: data.excerpt,
title: data.excerpt
});
@ -15254,7 +15229,7 @@
var status;
ExpandThread.statuses[thread] = status = {};
a.textContent = ExpandThread.text.apply(ExpandThread, ['...'].concat(__slice.call(a.textContent.match(/\d+/g))));
return status.req = $.cache("//a.4cdn.org/" + thread.board + "/res/" + thread + ".json", function() {
return status.req = $.cache("//a.4cdn.org/" + thread.board + "/thread/" + thread + ".json", function() {
delete status.req;
return ExpandThread.parse(this, thread, a);
});
@ -15754,7 +15729,7 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
if (!(key = Keybinds.keyCode(e))) {
return;
}
@ -15848,7 +15823,9 @@
ThreadUpdater.update();
break;
case 'index':
Index.update();
if (Conf['JSON Navigation']) {
Index.update();
}
}
break;
case Conf['Watch']:
@ -15874,7 +15851,7 @@
});
break;
case Conf['Front page']:
if (g.VIEW === 'index') {
if (Conf['JSON Navigation'] && g.VIEW === 'index') {
Index.userPageNav(0);
} else {
window.location = "/" + g.BOARD + "/";
@ -15884,19 +15861,39 @@
$.open("/" + g.BOARD + "/");
break;
case Conf['Next page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) {
if (g.VIEW !== 'index') {
return;
}
$('.next button, .next a', Index.pagelist).click();
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.next button', Index.pagelist).click();
}
} else {
if (form = $('.next form')) {
window.location = form.action;
}
}
break;
case Conf['Previous page']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'all pages')) {
if (g.VIEW !== 'index') {
return;
}
$('.prev button, .prev a', Index.pagelist).click();
if (Conf['JSON Navigation']) {
if (Conf['Index Mode'] !== 'all pages') {
$('.prev button', Index.pagelist).click();
}
} else {
if (form = $('.prev form')) {
window.location = form.action;
}
}
break;
case Conf['Search form']:
Index.searchInput.focus();
if (Conf['JSON Navigation']) {
Index.searchInput.focus();
} else {
$.id('search-btn').click();
}
break;
case Conf['Paged mode']:
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'paged')) {
@ -15922,6 +15919,19 @@
}
Index.cycleSortType();
break;
case Conf['Open catalog']:
if (Conf['External Catalog']) {
window.location = CatalogLinks.external(g.BOARD.ID);
} else {
if (!Conf['JSON Navigation']) {
return window.location = "/" + g.BOARD + "/catalog";
}
if (!(g.VIEW === 'index' && Conf['Index Mode'] !== 'catalog')) {
return;
}
Index.setIndexMode('catalog');
}
break;
case Conf['Next thread']:
if (g.VIEW !== 'index') {
return;
@ -16054,7 +16064,7 @@
if (g.VIEW !== 'index') {
return;
}
url = "/" + thread.board + "/res/" + thread;
url = "/" + thread.board + "/thread/" + thread;
if (tab) {
return $.open(url);
} else {
@ -16677,7 +16687,7 @@
if (threadID) {
view = 'thread';
} else {
pageNum = view;
pageNum = +view;
view = 'index';
}
path = this.pathname;
@ -16686,9 +16696,8 @@
}
Navigate.makeBreadCrumb(this.href, view, boardID, threadID);
if (this.id !== 'popState') {
history.pushState('internal', '', path);
Navigate.pushState(path);
}
Navigate.path = this.pathname;
Navigate.setMode(this);
if (!(view === 'index' && 'index' === g.VIEW && boardID === g.BOARD.ID)) {
Navigate.disconnect();
@ -16812,6 +16821,10 @@
return Main.handleErrors(errors);
}
},
pushState: function(path) {
history.pushState(null, '', path);
return Navigate.path = window.location.pathname;
},
popstate: function() {
var a;
a = $.el('a', {
@ -17275,7 +17288,7 @@
data = {
isReply: true,
file: {
URL: '//i.4cdn.org/g/src/1334437723720.jpg',
URL: '//i.4cdn.org/g/1334437723720.jpg',
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg',
size: '276 KB',
sizeInBytes: 276 * 1024,
@ -17892,6 +17905,7 @@
g.VIEW = (function() {
switch (pathname[2]) {
case 'res':
case 'thread':
return 'thread';
case 'catalog':
return 'catalog';

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.7' />
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.8' />
</app>
</gupdate>

1071
css/style.css Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
"userjs": "appchan-x.user.js"
},
"min": {
"chrome": "32",
"chrome": "33",
"firefox": "26",
"greasemonkey": "1.14"
}
@ -33,7 +33,7 @@
"grunt-concurrent": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-compress": "~0.7.0",
"grunt-contrib-compress": "~0.8.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-watch": "~0.6.1",

View File

@ -14,15 +14,6 @@ PostHiding =
name: 'Post Hiding'
cb: @node
# XXX tmp conversion
$.get 'hiddenThreads', null, ({hiddenThreads}) ->
return unless hiddenThreads
for boardID, board of hiddenThreads.boards
for threadID, val of board
((PostHiding.db.data.boards[boardID] or= {})[threadID] or= {})[threadID] = val
PostHiding.db.save()
$.delete 'hiddenThreads'
node: ->
return if !@isReply and g.VIEW isnt 'index' or @isClone

View File

@ -42,14 +42,14 @@ Build =
name: data.filename + data.ext
timestamp: "#{data.tim}#{data.ext}"
url: if boardID is 'f'
"//i.4cdn.org/#{boardID}/src/#{data.filename}#{data.ext}"
"//i.4cdn.org/#{boardID}/#{data.filename}#{data.ext}"
else
"//i.4cdn.org/#{boardID}/src/#{data.tim}#{data.ext}"
"//i.4cdn.org/#{boardID}/#{data.tim}#{data.ext}"
height: data.h
width: data.w
MD5: data.md5
size: data.fsize
turl: "//#{Build.thumbRotate()}.t.4cdn.org/#{boardID}/thumb/#{data.tim}s.jpg"
turl: "//#{Build.thumbRotate()}.t.4cdn.org/#{boardID}/#{data.tim}s.jpg"
theight: data.tn_h
twidth: data.tn_w
isSpoiler: !!data.spoiler
@ -184,19 +184,55 @@ Build =
if isOP and g.VIEW is 'index'
pageNum = Index.liveThreadData.keys.indexOf("#{postID}") // Index.threadsNumPerPage
pageIcon = " <span class=page-num title='This thread is on page #{pageNum} in the original index.'>Page #{pageNum}</span>"
replyLink = " &nbsp; <span>[<a href='/#{boardID}/res/#{threadID}' class=replylink>Reply</a>]</span>"
replyLink = " &nbsp; <span>[<a href='/#{boardID}/thread/#{threadID}' class=replylink>Reply</a>]</span>"
else
pageIcon = replyLink = ''
container = $.el 'div',
id: "pc#{postID}"
className: "postContainer #{if isOP then 'op' else 'reply'}Container"
innerHTML: <%= grunt.file.read('src/General/html/Build/post.html').replace(/>\s+/g, '>').replace(/\s+</g, '<').replace(/\s+/g, ' ').trim() %>
innerHTML: \
(if isOP then '' else "<div class=sideArrows>&gt;&gt;</div>") +
"<div id=p#{postID} class='post #{if isOP then 'op' else 'reply'}#{
if capcode is 'admin_highlight'
' highlightPost'
else
''
}'>" +
(if isOP then fileHTML else '') +
"<div class=postInfo>" +
"<input type=checkbox name=#{postID} value=delete> " +
"<span class=subject>#{subject or ''}</span> " +
"<span class='nameBlock#{capcodeClass}'>" +
emailStart +
"<span class=name>#{name or ''}</span>" + tripcode +
capcodeStart + emailEnd + capcodeIcon + userID + flag +
' </span> ' +
"<span class=dateTime data-utc=#{dateUTC}>#{date}</span> " +
"<span class='postNum'>" +
"<a href=#{"/#{boardID}/thread/#{threadID}#p#{postID}"} title='Highlight this post'>No.</a>" +
"<a href='#{
if g.VIEW is 'thread' and g.THREADID is threadID
"javascript:quote(#{postID})"
else
"/#{boardID}/thread/#{threadID}#q#{postID}"
}' title='Quote this post'>#{postID}</a>" +
pageIcon + sticky + closed + replyLink +
'</span>' +
'</div>' +
(if isOP then '' else fileHTML) +
"<blockquote class=postMessage>#{comment or ''}</blockquote> " +
'</div>'
for quote in $$ '.quotelink', container
href = quote.getAttribute 'href'
continue if href[0] is '/' # Cross-board quote, or board link
quote.href = "/#{boardID}/res/#{href}" # Fix pathnames
quote.href = "/#{boardID}/thread/#{href}" # Fix pathnames
container
@ -208,7 +244,7 @@ Build =
$.el 'a',
className: 'summary'
textContent: text.join ' '
href: "/#{boardID}/res/#{threadID}"
href: "/#{boardID}/thread/#{threadID}"
thread: (board, data, full) ->
Build.spoilerRange[board] = data.custom_spoiler

View File

@ -1029,11 +1029,11 @@ box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
# Board Navigation
'Front page': [
'0'
'Jump to page 0.'
'Jump to front page.'
]
'Open front page': [
'Shift+0'
'Open page 0 in a new tab.'
'Open front page in a new tab.'
]
'Next page': [
'Shift+Right'

View File

@ -70,7 +70,7 @@ Get =
root.textContent = "Loading post No.#{postID}..."
if threadID
$.cache "//a.4cdn.org/#{boardID}/res/#{threadID}.json", ->
$.cache "//a.4cdn.org/#{boardID}/thread/#{threadID}.json", ->
Get.fetchedPost @, boardID, threadID, postID, root, context
else if url = Redirect.to 'post', {boardID, postID}
$.cache url,
@ -200,7 +200,7 @@ Get =
width: data.media.media_w
MD5: data.media.media_hash
size: data.media.media_size
turl: data.media.thumb_link or "//t.4cdn.org/#{boardID}/thumb/#{data.media.preview_orig}"
turl: data.media.thumb_link or "//t.4cdn.org/#{boardID}/#{data.media.preview_orig}"
theight: data.media.preview_h
twidth: data.media.preview_w
isSpoiler: data.media.spoiler is '1'

View File

@ -424,6 +424,7 @@ Index =
+window.location.pathname.split('/')[2]
userPageNav: (pageNum) ->
Navigate.pushState if pageNum is 0 then './' else pageNum
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
Index.update pageNum
else
@ -431,7 +432,7 @@ Index =
pageNav: (pageNum) ->
return if Index.currentPage is pageNum and not Index.root.parentElement
history.pushState null, '', if pageNum is 0 then './' else pageNum
Navigate.pushState if pageNum is 0 then './' else pageNum
Index.pageLoad pageNum
pageLoad: (pageNum) ->

View File

@ -8,7 +8,7 @@ Main =
return if g.BOARD.ID in ['z', 'fk']
g.VIEW =
switch pathname[2]
when 'res'
when 'res', 'thread'
'thread'
when 'catalog'
'catalog'

View File

@ -226,7 +226,7 @@ Navigate =
if threadID
view = 'thread'
else
pageNum = view
pageNum = +view
view = 'index' # path is "/boardID/". See the problem?
path = @pathname
@ -234,8 +234,7 @@ Navigate =
Navigate.makeBreadCrumb @href, view, boardID, threadID
history.pushState 'internal', '', path unless @id is 'popState'
Navigate.path = @pathname
Navigate.pushState path unless @id is 'popState'
Navigate.setMode @
@ -347,6 +346,10 @@ Navigate =
Main.handleErrors errors if errors
pushState: (path) ->
history.pushState null, '', path
Navigate.path = window.location.pathname
popstate: ->
a = $.el 'a',
href: window.location

View File

@ -356,7 +356,7 @@ Settings =
data =
isReply: true
file:
URL: '//i.4cdn.org/g/src/1334437723720.jpg'
URL: '//i.4cdn.org/g/1334437723720.jpg'
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg'
size: '276 KB'
sizeInBytes: 276 * 1024

View File

@ -1,36 +0,0 @@
"""#{if isOP then '' else "<div class=sideArrows>&gt;&gt;</div>"}
<div id=p#{postID} class='post #{if isOP then 'op' else 'reply'}#{
if capcodeIcon is 'admin_highlight' then
' highlightPost'
else
''
}'>
#{if isOP then fileHTML else ''}
<div class='postInfo'>
<input type=checkbox name=#{postID} value=delete>
#{' '}<span class=subject>#{subject or ''}</span>#{' '}
<span class='nameBlock#{capcodeClass}'>
#{emailStart}
<span class=name>#{name or ''}</span>
#{tripcode + capcodeStart + emailEnd + capcodeIcon + userID + flag}
</span>#{" "}
<span class=dateTime data-utc=#{dateUTC}>#{date}</span>#{' '}
<span class='postNum'>
<a href=#{"/#{boardID}/res/#{threadID}#p#{postID}"} title='Highlight this post'>No.</a>
<a href='#{
if g.VIEW is 'thread' and g.THREADID is +threadID then
"javascript:quote(#{postID})"
else
"/#{boardID}/res/#{threadID}#q#{postID}"
}' title='Quote this post'>#{postID}</a>
#{pageIcon + sticky + closed + replyLink}
</span>
</div>
#{if isOP then '' else fileHTML}
<blockquote class=postMessage>#{comment or ''}</blockquote>#{' '}
</div>"""

View File

@ -1,4 +1,4 @@
<a href="/#{thread.board}/res/#{thread.ID}" class="thumb"></a>
<a href="/#{thread.board}/thread/#{thread.ID}" class="thumb"></a>
<div class="thread-stats" title="Post count / File count / Page count">
<span class="post-count">#{postCount}</span> / <span class="file-count">#{fileCount}</span> / <span class="page-count">#{pageCount}</span>
<span class="thread-icons"></span>

View File

@ -1,21 +1,8 @@
Polyfill =
init: ->
<% if (type === 'crx') { %>
@notificationPermission()
@toBlob()
@visibility()
<% } %>
notificationPermission: ->
return if !window.Notification or 'permission' of Notification or !window.webkitNotifications
Object.defineProperty Notification, 'permission',
get: ->
switch webkitNotifications.checkPermission()
when 0
'granted'
when 1
'default'
when 2
'denied'
toBlob: ->
HTMLCanvasElement::toBlob or= (cb) ->
data = atob @toDataURL()[22..]
@ -25,12 +12,3 @@ Polyfill =
for i in [0...l] by 1
ui8a[i] = data.charCodeAt i
cb new Blob [ui8a], type: 'image/png'
visibility: ->
# page visibility API
return if 'visibilityState' of d
Object.defineProperties HTMLDocument.prototype,
visibilityState:
get: -> @webkitVisibilityState
hidden:
get: -> @webkitHidden
$.on d, 'webkitvisibilitychange', -> $.event 'visibilitychange'

View File

@ -101,7 +101,7 @@ class Post
return unless match = quotelink.href.match ///
boards\.4chan\.org/
([^/]+) # boardID
/res/\d+#p
/thread/\d+#p
(\d+) # postID
$
///
@ -134,7 +134,7 @@ class Post
@file.thumbURL = if that.isArchived
thumb.src
else
"#{location.protocol}//t.4cdn.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
"#{location.protocol}//t.4cdn.org/#{@board}/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
@file.name = if nameNode = $ 'span', fileText
nameNode.title or nameNode.textContent
else

View File

@ -116,8 +116,10 @@ ImageExpand =
$.rm post.file.videoControls
delete post.file.videoControls
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass thumb, 'expanding'
post.file.isExpanded = false
$.rmClass post.file.thumb, 'expanding'
delete post.file.isExpanding
delete post.file.isExpanded
post.file.fullImage.pause() if post.file.isVideo and post.file.fullImage
expand: (post, src, disableAutoplay) ->
# Do not expand images of hidden/filtered replies, or already expanded pictures.
@ -198,6 +200,7 @@ ImageExpand =
error: ->
post = Get.postFromNode @
$.rm @
delete post.file.isReady
delete post.file.fullImage
# Images can error:
# - before the image started loading.
@ -207,11 +210,23 @@ ImageExpand =
return
ImageExpand.contract post
if @error and @error.code isnt @error.MEDIA_ERR_NETWORK # video
error = switch @error.code
when 1 then 'MEDIA_ERR_ABORTED'
when 3 then 'MEDIA_ERR_DECODE'
when 4 then 'MEDIA_ERR_SRC_NOT_SUPPORTED'
when 5 then 'MEDIA_ERR_ENCRYPTED'
post.file.error = $.el 'div',
textContent: "Playback error: #{error}"
className: 'warning'
$.after post.file.thumb, post.file.error
return
src = @src.split '/'
if src[2] is 'i.4cdn.org'
URL = Redirect.to 'file',
boardID: src[3]
filename: src[5]
filename: src[4].replace /\?.+$/, ''
if URL
setTimeout ImageExpand.expand, 10000, post, URL
return
@ -229,7 +244,7 @@ ImageExpand =
type: 'head'
<% } else { %>
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
return if @status isnt 200
for postObj in @response.posts
break if postObj.no is post.ID

View File

@ -25,7 +25,6 @@ ImageHover =
TrashQueue.remove el
else
el = $.el (if isVideo then 'video' else 'img'),
className: 'full-image'
src: post.file.URL
post.file.fullImage = el
{thumb} = post.file
@ -46,8 +45,10 @@ ImageHover =
el: el
latestEvent: e
endEvents: 'mouseout click'
asapTest: -> (el.videoHeight or el.naturalHeight)
noRemove: true
asapTest: if post.file.isImage
-> el.naturalHeight
else
-> el.readyState >= el.HAVE_CURRENT_DATA
cb: ->
if isVideo
el.pause()
@ -62,7 +63,7 @@ ImageHover =
if src[2] is 'i.4cdn.org'
URL = Redirect.to 'file',
boardID: src[3]
filename: src[5].replace /\?.+$/, ''
filename: src[4].replace /\?.+$/, ''
if URL
@src = URL
return
@ -80,7 +81,7 @@ ImageHover =
type: 'head'
<% } else { %>
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
return if @status isnt 200
for postObj in @response.posts
break if postObj.no is post.ID

View File

@ -49,7 +49,7 @@ ExpandThread =
expand: (thread, a, threadRoot) ->
ExpandThread.statuses[thread] = status = {}
a.textContent = ExpandThread.text '...', a.textContent.match(/\d+/g)...
status.req = $.cache "//a.4cdn.org/#{thread.board}/res/#{thread}.json", ->
status.req = $.cache "//a.4cdn.org/#{thread.board}/thread/#{thread}.json", ->
delete status.req
ExpandThread.parse @, thread, a
contract: (thread, a, threadRoot) ->

View File

@ -74,7 +74,7 @@ Keybinds =
when 'thread'
ThreadUpdater.update()
when 'index'
Index.update()
if Conf['JSON Navigation'] then Index.update()
when Conf['Watch']
ThreadWatcher.toggle thread
# Images
@ -90,20 +90,33 @@ Keybinds =
FappeTyme.cb.toggle.call {name: 'werk'}
# Board Navigation
when Conf['Front page']
if g.VIEW is 'index'
if Conf['JSON Navigation'] and g.VIEW is 'index'
Index.userPageNav 0
else
window.location = "/#{g.BOARD}/"
when Conf['Open front page']
$.open "/#{g.BOARD}/"
when Conf['Next page']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages'
$('.next button, .next a', Index.pagelist).click()
return unless g.VIEW is 'index'
if Conf['JSON Navigation']
if Conf['Index Mode'] isnt 'all pages'
$('.next button', Index.pagelist).click()
else
if form = $ '.next form'
window.location = form.action
when Conf['Previous page']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages'
$('.prev button, .prev a', Index.pagelist).click()
return unless g.VIEW is 'index'
if Conf['JSON Navigation']
if Conf['Index Mode'] isnt 'all pages'
$('.prev button', Index.pagelist).click()
else
if form = $ '.prev form'
window.location = form.action
when Conf['Search form']
Index.searchInput.focus()
if Conf['JSON Navigation']
Index.searchInput.focus()
else
$.id('search-btn').click()
when Conf['Paged mode']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'paged'
Index.setIndexMode 'paged'
@ -116,6 +129,13 @@ Keybinds =
when Conf['Cycle sort type']
return unless g.VIEW is 'index'
Index.cycleSortType()
when Conf['Open catalog']
if Conf['External Catalog']
window.location = CatalogLinks.external(g.BOARD.ID)
else
return window.location = "/#{g.BOARD}/catalog" unless Conf['JSON Navigation']
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'catalog'
Index.setIndexMode 'catalog'
# Thread Navigation
when Conf['Next thread']
return if g.VIEW isnt 'index'
@ -219,7 +239,7 @@ Keybinds =
open: (thread, tab) ->
return if g.VIEW isnt 'index'
url = "/#{thread.board}/res/#{thread}"
url = "/#{thread.board}/thread/#{thread}"
if tab
$.open url
else

View File

@ -245,8 +245,13 @@ ThreadUpdater =
else
ThreadUpdater.set 'timer', 'Update'
ThreadUpdater.req?.abort()
url = "//a.4cdn.org/#{ThreadUpdater.thread.board}/res/#{ThreadUpdater.thread}.json"
ThreadUpdater.req = $.ajax url, onloadend: ThreadUpdater.cb.load,
url = "//a.4cdn.org/#{ThreadUpdater.thread.board}/thread/#{ThreadUpdater.thread}.json"
ThreadUpdater.req = $.ajax url,
onabort: ThreadUpdater.cb.load
onloadend: ThreadUpdater.cb.load
ontimeout: ThreadUpdater.cb.load
timeout: $.MINUTE
,
whenModified: true
updateThreadStatus: (type, status) ->

View File

@ -114,7 +114,7 @@ ThreadWatcher =
return if data.isDead
{fetchCount} = ThreadWatcher
fetchCount.fetching++
$.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json",
$.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json",
onloadend: ->
fetchCount.fetched++
if fetchCount.fetched is fetchCount.fetching
@ -153,7 +153,7 @@ ThreadWatcher =
if data.isDead
href = Redirect.to 'thread', {boardID, threadID}
link = $.el 'a',
href: href or "/#{boardID}/res/#{threadID}"
href: href or "/#{boardID}/thread/#{threadID}"
textContent: data.excerpt
title: data.excerpt

View File

@ -219,7 +219,7 @@ QR =
$.prepend frag, $.tn '[code]'
$.add frag, $.tn '[/code]'
for node in $$ 'br', frag
$.replace node, $.tn '\n>'
$.replace node, $.tn '\n>' unless node is frag.lastElementChild
for node in $$ 's', frag
$.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]']
for node in $$ '.prettyprint', frag

View File

@ -56,7 +56,7 @@ QuoteBacklink =
buildBacklink: (quoted, quoter) ->
frag = QuoteBacklink.frag.cloneNode true
a = frag.lastElementChild
a.href = "/#{quoter.board}/res/#{quoter.thread}#p#{quoter}"
a.href = "/#{quoter.board}/thread/#{quoter.thread}#p#{quoter}"
a.textContent = text = QuoteBacklink.funk quoter.ID
if quoter.isDead
$.addClass a, 'deadlink'

View File

@ -44,7 +44,7 @@ Quotify =
# Don't add 'deadlink' when quotifying in an archived post,
# and we don't know if the post died yet.
a = $.el 'a',
href: "/#{boardID}/res/#{post.thread}#p#{postID}"
href: "/#{boardID}/thread/#{post.thread}#p#{postID}"
className: if post.isDead then 'quotelink deadlink' else 'quotelink'
textContent: quote
$.extend a.dataset, {boardID, threadID: post.thread.ID, postID}