diff --git a/CHANGELOG.md b/CHANGELOG.md index d326ac2f8..068002fc1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v1.8.1 +*2014-06-19* + **MayhemYDG** - More API changes: - `ThreadUpdate`: diff --git a/LICENSE b/LICENSE index 67d7582b2..3b722e4d4 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.8.0 - 2014-06-18 +* 4chan X - Version 1.8.1 - 2014-06-19 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index 52f4a95b9..58ef9261d 100755 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.8.0 +// @version 1.8.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 8af133be9..a1c01916b 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.8.0 +// @version 1.8.1 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.8.0 - 2014-06-18 +* 4chan X - Version 1.8.1 - 2014-06-19 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -374,7 +374,7 @@ doc = d.documentElement; g = { - VERSION: '1.8.0', + VERSION: '1.8.1', NAMESPACE: '4chan X.', boards: {} }; @@ -649,7 +649,7 @@ if (root == null) { root = d; } - if (typeof cloneInto === 'function') { + if ((detail != null) && typeof cloneInto === 'function') { detail = cloneInto(detail, document.defaultView); } return root.dispatchEvent(new CustomEvent(event, { @@ -1813,8 +1813,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - UI.addMenuEntry({ - type: 'header', + this.menu.addEntry({ el: $.el('span', { textContent: 'Header' }), @@ -2363,8 +2362,7 @@ $.on(input, 'change', this.cb.sort); } } - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: $.el('span', { textContent: 'Index Navigation' }), @@ -3072,7 +3070,7 @@ This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; + var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; E = Build.h_escape; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; name || (name = ''); @@ -3090,8 +3088,9 @@ } else { h_tripcode = ''; } + email_processed = encodeURIComponent(email).replace(/%40/g, '@'); if (email) { - h_emailStart = ""; + h_emailStart = ""; h_emailEnd = ''; } else { h_emailStart = ''; @@ -3538,7 +3537,7 @@ }; UI = (function() { - var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; + var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3565,12 +3564,6 @@ return el; }; menus = {}; - addMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; - rmMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3580,7 +3573,6 @@ function Menu(type) { this.type = type; - this.rmEntry = __bind(this.rmEntry, this); this.addEntry = __bind(this.addEntry, this); this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); @@ -3793,12 +3785,6 @@ return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(entry) { - var index; - index = this.entries.indexOf(entry); - return this.entries.splice(index, 1); - }; - Menu.prototype.parseEntry = function(entry) { var el, subEntries, subEntry, _i, _len; el = entry.el, subEntries = entry.subEntries; @@ -3984,9 +3970,7 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox, - addMenuEntry: addMenuEntry, - rmMenuEntry: rmMenuEntry + checkbox: checkbox }; })(); @@ -4270,7 +4254,6 @@ textContent: 'Filter' }); entry = { - type: 'post', el: div, order: 50, open: function(post) { @@ -4284,7 +4267,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4390,8 +4373,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4429,8 +4411,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4460,8 +4441,7 @@ } ] }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(post) { @@ -4792,8 +4772,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4819,8 +4798,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4838,8 +4816,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(_arg) { @@ -5366,8 +5343,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: this.controls, order: 98 }); @@ -6571,13 +6547,12 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: { - ID: g.BOARD.ID - }, + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); $.event('QRPostSuccessful_', { + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); @@ -7472,8 +7447,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 97 }); @@ -7572,8 +7546,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - UI.addMenuEntry({ - type: 'gallery', + nodes.menu.addEntry({ el: el, order: 0 }); @@ -7807,8 +7780,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8152,8 +8124,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8325,8 +8296,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: prefetch, order: 104 }); @@ -9083,7 +9053,6 @@ textContent: 'Archive' }); entry = { - type: 'post', el: div, order: 90, open: function(_arg) { @@ -9102,7 +9071,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9179,8 +9148,7 @@ return true; } }; - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: div, order: 40, open: function(post) { @@ -9304,8 +9272,7 @@ }; })(this)); }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 100, open: function(_arg) { @@ -9373,8 +9340,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 10, open: function(post) { @@ -9621,8 +9587,7 @@ subEntries.push({ el: this.settings }); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: $.el('span', { textContent: 'Updater' }), @@ -9732,9 +9697,7 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: { - fullID: ThreadUpdater.thread.fullID - } + threadID: ThreadUpdater.thread.fullID }); break; default: @@ -9828,7 +9791,7 @@ return new Notice('info', "The thread is " + change + ".", 30); }, parse: function(postObjects) { - var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; + var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; OP = postObjects[0]; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); @@ -9853,25 +9816,15 @@ node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); } - deletedPosts = []; - deletedFiles = []; ThreadUpdater.thread.posts.forEach(function(post) { var ID; ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push({ - ID: post.ID, - fullID: post.fullID - }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push({ - ID: post.ID, - fullID: post.fullID - }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -9923,24 +9876,10 @@ } return $.event('ThreadUpdate', { 404: false, - thread: { - ID: ThreadUpdater.thread.ID, - fullID: ThreadUpdater.thread.fullID - }, - newPosts: (function() { - var _k, _len2, _results; - _results = []; - for (_k = 0, _len2 = posts.length; _k < _len2; _k++) { - post = posts[_k]; - _results.push({ - ID: post.ID, - fullID: post.fullID - }); - } - return _results; - })(), - deletedPosts: deletedPosts, - deletedFiles: deletedFiles, + threadID: ThreadUpdater.thread.fullID, + newPosts: posts.map(function(post) { + return post.fullID; + }), postCount: OP.replies + 1, fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) }); @@ -10075,14 +10014,14 @@ return ThreadWatcher.rm(boardID, +threadID); }, post: function(e) { - var board, postID, threadID, _ref; - _ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; + var boardID, postID, threadID, _ref; + _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID; if (postID === threadID) { if (Conf['Auto Watch']) { return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); + return ThreadWatcher.add(g.threads[boardID + '.' + threadID]); } }, onIndexRefresh: function() { @@ -10112,7 +10051,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = g.threads[e.detail.thread.fullID]; + thread = g.threads[e.detail.threadID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10324,7 +10263,7 @@ if (!Conf['Thread Watcher']) { return; } - menu = new UI.Menu('thread watcher'); + menu = this.menu = new UI.Menu('thread watcher'); $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { return menu.toggle(e, this, ThreadWatcher); }); @@ -10339,8 +10278,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: entryEl, order: 60 }); @@ -10361,7 +10299,6 @@ entries.push({ cb: ThreadWatcher.cb.openAll, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Open all threads' }) @@ -10373,7 +10310,6 @@ entries.push({ cb: ThreadWatcher.cb.checkThreads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Check 404\'d threads' }) @@ -10385,7 +10321,6 @@ entries.push({ cb: ThreadWatcher.cb.pruneDeads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Prune 404\'d threads' }) @@ -10402,7 +10337,6 @@ } entries.push({ entry: { - type: 'thread watcher', el: $.el('span', { textContent: 'Settings' }), @@ -10420,7 +10354,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - UI.addMenuEntry(entry); + this.menu.addEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10597,20 +10531,12 @@ }; }, onUpdate: function(e) { - var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts((function() { - var _i, _len, _ref, _results; - _ref = e.detail.newPosts; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - post = _ref[_i]; - _results.push(g.posts[post.fullID]); - } - return _results; - })()); + return Unread.addPosts(e.detail.newPosts.map(function(fullID) { + return g.posts[fullID]; + })); } else { Unread.read(); return Unread.update(); @@ -10819,7 +10745,6 @@ return; } entry = { - type: 'header', el: $.el('a', { textContent: 'Show announcement', className: 'show-announcement', @@ -10830,7 +10755,7 @@ return psa.hidden; } }; - UI.addMenuEntry(entry); + Header.menu.addEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -10983,8 +10908,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 95 }); @@ -11481,7 +11405,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); + $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11514,7 +11438,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.ID, window); + return $.event('jsmath', _this.nodes.post.id, window); }; })(this)); }, @@ -12362,7 +12286,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13206,7 +13130,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.8.0.' + innerHTML: '4chan X has been updated to version 1.8.1.' }); new Notice('info', el, 15); } else { @@ -13249,25 +13173,6 @@ }; return softTask(); }, - addCallback: function(e) { - var Klass, obj; - obj = e.detail; - if (typeof obj.callback.name !== 'string') { - throw new Error("Invalid callback name: " + obj.callback.name); - } - switch (obj.type) { - case 'Post': - Klass = Post; - break; - case 'Thread': - Klass = Thread; - break; - default: - return; - } - obj.callback.isAddon = true; - return Klass.callbacks.push(obj.callback); - }, handleErrors: function(errors) { var div, error, logs, _i, _len; if (!(errors instanceof Array)) { diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index 6bd7f9c41..0db974ca9 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/crx.crx b/builds/crx.crx index 2b979582c..89650ac61 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json index 0344b5c06..550a82f46 100755 --- a/builds/crx/manifest.json +++ b/builds/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.8.0", + "version": "1.8.1", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/crx/script.js b/builds/crx/script.js index 7212aeabd..7adf59f4b 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.8.0 - 2014-06-18 +* 4chan X - Version 1.8.1 - 2014-06-19 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -349,7 +349,7 @@ doc = d.documentElement; g = { - VERSION: '1.8.0', + VERSION: '1.8.1', NAMESPACE: '4chan X.', boards: {} }; @@ -1845,8 +1845,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - UI.addMenuEntry({ - type: 'header', + this.menu.addEntry({ el: $.el('span', { textContent: 'Header' }), @@ -2395,8 +2394,7 @@ $.on(input, 'change', this.cb.sort); } } - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: $.el('span', { textContent: 'Index Navigation' }), @@ -3104,7 +3102,7 @@ This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; + var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; E = Build.h_escape; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; name || (name = ''); @@ -3122,8 +3120,9 @@ } else { h_tripcode = ''; } + email_processed = encodeURIComponent(email).replace(/%40/g, '@'); if (email) { - h_emailStart = ""; + h_emailStart = ""; h_emailEnd = ''; } else { h_emailStart = ''; @@ -3570,7 +3569,7 @@ }; UI = (function() { - var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; + var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3597,12 +3596,6 @@ return el; }; menus = {}; - addMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; - rmMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3612,7 +3605,6 @@ function Menu(type) { this.type = type; - this.rmEntry = __bind(this.rmEntry, this); this.addEntry = __bind(this.addEntry, this); this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); @@ -3825,12 +3817,6 @@ return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(entry) { - var index; - index = this.entries.indexOf(entry); - return this.entries.splice(index, 1); - }; - Menu.prototype.parseEntry = function(entry) { var el, subEntries, subEntry, _i, _len; el = entry.el, subEntries = entry.subEntries; @@ -4009,9 +3995,7 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox, - addMenuEntry: addMenuEntry, - rmMenuEntry: rmMenuEntry + checkbox: checkbox }; })(); @@ -4292,7 +4276,6 @@ textContent: 'Filter' }); entry = { - type: 'post', el: div, order: 50, open: function(post) { @@ -4306,7 +4289,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4412,8 +4395,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4451,8 +4433,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4482,8 +4463,7 @@ } ] }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(post) { @@ -4814,8 +4794,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4841,8 +4820,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4860,8 +4838,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(_arg) { @@ -5388,8 +5365,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: this.controls, order: 98 }); @@ -6591,13 +6567,12 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: { - ID: g.BOARD.ID - }, + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); $.event('QRPostSuccessful_', { + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); @@ -7486,8 +7461,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 97 }); @@ -7586,8 +7560,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - UI.addMenuEntry({ - type: 'gallery', + nodes.menu.addEntry({ el: el, order: 0 }); @@ -7821,8 +7794,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8155,8 +8127,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8317,8 +8288,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: prefetch, order: 104 }); @@ -9075,7 +9045,6 @@ textContent: 'Archive' }); entry = { - type: 'post', el: div, order: 90, open: function(_arg) { @@ -9094,7 +9063,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9171,8 +9140,7 @@ return true; } }; - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: div, order: 40, open: function(post) { @@ -9296,8 +9264,7 @@ }; })(this)); }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 100, open: function(_arg) { @@ -9365,8 +9332,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 10, open: function(post) { @@ -9613,8 +9579,7 @@ subEntries.push({ el: this.settings }); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: $.el('span', { textContent: 'Updater' }), @@ -9724,9 +9689,7 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: { - fullID: ThreadUpdater.thread.fullID - } + threadID: ThreadUpdater.thread.fullID }); break; default: @@ -9820,7 +9783,7 @@ return new Notice('info', "The thread is " + change + ".", 30); }, parse: function(postObjects) { - var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; + var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; OP = postObjects[0]; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); @@ -9845,25 +9808,15 @@ node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); } - deletedPosts = []; - deletedFiles = []; ThreadUpdater.thread.posts.forEach(function(post) { var ID; ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push({ - ID: post.ID, - fullID: post.fullID - }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push({ - ID: post.ID, - fullID: post.fullID - }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -9915,24 +9868,10 @@ } return $.event('ThreadUpdate', { 404: false, - thread: { - ID: ThreadUpdater.thread.ID, - fullID: ThreadUpdater.thread.fullID - }, - newPosts: (function() { - var _k, _len2, _results; - _results = []; - for (_k = 0, _len2 = posts.length; _k < _len2; _k++) { - post = posts[_k]; - _results.push({ - ID: post.ID, - fullID: post.fullID - }); - } - return _results; - })(), - deletedPosts: deletedPosts, - deletedFiles: deletedFiles, + threadID: ThreadUpdater.thread.fullID, + newPosts: posts.map(function(post) { + return post.fullID; + }), postCount: OP.replies + 1, fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) }); @@ -10067,14 +10006,14 @@ return ThreadWatcher.rm(boardID, +threadID); }, post: function(e) { - var board, postID, threadID, _ref; - _ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; + var boardID, postID, threadID, _ref; + _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID; if (postID === threadID) { if (Conf['Auto Watch']) { return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); + return ThreadWatcher.add(g.threads[boardID + '.' + threadID]); } }, onIndexRefresh: function() { @@ -10104,7 +10043,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = g.threads[e.detail.thread.fullID]; + thread = g.threads[e.detail.threadID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10316,7 +10255,7 @@ if (!Conf['Thread Watcher']) { return; } - menu = new UI.Menu('thread watcher'); + menu = this.menu = new UI.Menu('thread watcher'); $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { return menu.toggle(e, this, ThreadWatcher); }); @@ -10331,8 +10270,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: entryEl, order: 60 }); @@ -10353,7 +10291,6 @@ entries.push({ cb: ThreadWatcher.cb.openAll, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Open all threads' }) @@ -10365,7 +10302,6 @@ entries.push({ cb: ThreadWatcher.cb.checkThreads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Check 404\'d threads' }) @@ -10377,7 +10313,6 @@ entries.push({ cb: ThreadWatcher.cb.pruneDeads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Prune 404\'d threads' }) @@ -10394,7 +10329,6 @@ } entries.push({ entry: { - type: 'thread watcher', el: $.el('span', { textContent: 'Settings' }), @@ -10412,7 +10346,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - UI.addMenuEntry(entry); + this.menu.addEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10589,20 +10523,12 @@ }; }, onUpdate: function(e) { - var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts((function() { - var _i, _len, _ref, _results; - _ref = e.detail.newPosts; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - post = _ref[_i]; - _results.push(g.posts[post.fullID]); - } - return _results; - })()); + return Unread.addPosts(e.detail.newPosts.map(function(fullID) { + return g.posts[fullID]; + })); } else { Unread.read(); return Unread.update(); @@ -10810,7 +10736,6 @@ return; } entry = { - type: 'header', el: $.el('a', { textContent: 'Show announcement', className: 'show-announcement', @@ -10821,7 +10746,7 @@ return psa.hidden; } }; - UI.addMenuEntry(entry); + Header.menu.addEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -10974,8 +10899,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 95 }); @@ -11472,7 +11396,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); + $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11505,7 +11429,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.ID, window); + return $.event('jsmath', _this.nodes.post.id, window); }; })(this)); }, @@ -12353,7 +12277,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13184,7 +13108,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.8.0.' + innerHTML: '4chan X has been updated to version 1.8.1.' }); new Notice('info', el, 15); } else { @@ -13227,25 +13151,6 @@ }; return softTask(); }, - addCallback: function(e) { - var Klass, obj; - obj = e.detail; - if (typeof obj.callback.name !== 'string') { - throw new Error("Invalid callback name: " + obj.callback.name); - } - switch (obj.type) { - case 'Post': - Klass = Post; - break; - case 'Thread': - Klass = Thread; - break; - default: - return; - } - obj.callback.isAddon = true; - return Klass.callbacks.push(obj.callback); - }, handleErrors: function(errors) { var div, error, logs, _i, _len; if (!(errors instanceof Array)) { diff --git a/builds/updates.xml b/builds/updates.xml index c9a5654d8..1c072d72c 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/wcrx/manifest.json b/builds/wcrx/manifest.json index e99e6244f..7f914699d 100644 --- a/builds/wcrx/manifest.json +++ b/builds/wcrx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.8.0", + "version": "1.8.1", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/wcrx/script.js b/builds/wcrx/script.js index 7212aeabd..7adf59f4b 100644 --- a/builds/wcrx/script.js +++ b/builds/wcrx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.8.0 - 2014-06-18 +* 4chan X - Version 1.8.1 - 2014-06-19 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -349,7 +349,7 @@ doc = d.documentElement; g = { - VERSION: '1.8.0', + VERSION: '1.8.1', NAMESPACE: '4chan X.', boards: {} }; @@ -1845,8 +1845,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - UI.addMenuEntry({ - type: 'header', + this.menu.addEntry({ el: $.el('span', { textContent: 'Header' }), @@ -2395,8 +2394,7 @@ $.on(input, 'change', this.cb.sort); } } - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: $.el('span', { textContent: 'Index Navigation' }), @@ -3104,7 +3102,7 @@ This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; + var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; E = Build.h_escape; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; name || (name = ''); @@ -3122,8 +3120,9 @@ } else { h_tripcode = ''; } + email_processed = encodeURIComponent(email).replace(/%40/g, '@'); if (email) { - h_emailStart = ""; + h_emailStart = ""; h_emailEnd = ''; } else { h_emailStart = ''; @@ -3570,7 +3569,7 @@ }; UI = (function() { - var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; + var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3597,12 +3596,6 @@ return el; }; menus = {}; - addMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; - rmMenuEntry = function(entry) { - return menus[entry.type].addEntry(entry); - }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3612,7 +3605,6 @@ function Menu(type) { this.type = type; - this.rmEntry = __bind(this.rmEntry, this); this.addEntry = __bind(this.addEntry, this); this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); @@ -3825,12 +3817,6 @@ return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(entry) { - var index; - index = this.entries.indexOf(entry); - return this.entries.splice(index, 1); - }; - Menu.prototype.parseEntry = function(entry) { var el, subEntries, subEntry, _i, _len; el = entry.el, subEntries = entry.subEntries; @@ -4009,9 +3995,7 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox, - addMenuEntry: addMenuEntry, - rmMenuEntry: rmMenuEntry + checkbox: checkbox }; })(); @@ -4292,7 +4276,6 @@ textContent: 'Filter' }); entry = { - type: 'post', el: div, order: 50, open: function(post) { @@ -4306,7 +4289,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4412,8 +4395,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4451,8 +4433,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(post) { @@ -4482,8 +4463,7 @@ } ] }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(post) { @@ -4814,8 +4794,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4841,8 +4820,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - UI.addMenuEntry({ - type: 'post', + Menu.menu.addEntry({ el: div, order: 20, open: function(_arg) { @@ -4860,8 +4838,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: hideStubLink, order: 15, open: function(_arg) { @@ -5388,8 +5365,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: this.controls, order: 98 }); @@ -6591,13 +6567,12 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: { - ID: g.BOARD.ID - }, + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); $.event('QRPostSuccessful_', { + boardID: g.BOARD.ID, threadID: threadID, postID: postID }); @@ -7486,8 +7461,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 97 }); @@ -7586,8 +7560,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - UI.addMenuEntry({ - type: 'gallery', + nodes.menu.addEntry({ el: el, order: 0 }); @@ -7821,8 +7794,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8155,8 +8127,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: el, order: 105, subEntries: subEntries @@ -8317,8 +8288,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return UI.addMenuEntry({ - type: 'header', + return Header.menu.addEntry({ el: prefetch, order: 104 }); @@ -9075,7 +9045,6 @@ textContent: 'Archive' }); entry = { - type: 'post', el: div, order: 90, open: function(_arg) { @@ -9094,7 +9063,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return UI.addMenuEntry(entry); + return Menu.menu.addEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9171,8 +9140,7 @@ return true; } }; - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: div, order: 40, open: function(post) { @@ -9296,8 +9264,7 @@ }; })(this)); }); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 100, open: function(_arg) { @@ -9365,8 +9332,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return UI.addMenuEntry({ - type: 'post', + return Menu.menu.addEntry({ el: a, order: 10, open: function(post) { @@ -9613,8 +9579,7 @@ subEntries.push({ el: this.settings }); - UI.addMenuEntry(this.entry = { - type: 'header', + Header.menu.addEntry(this.entry = { el: $.el('span', { textContent: 'Updater' }), @@ -9724,9 +9689,7 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: { - fullID: ThreadUpdater.thread.fullID - } + threadID: ThreadUpdater.thread.fullID }); break; default: @@ -9820,7 +9783,7 @@ return new Notice('info', "The thread is " + change + ".", 30); }, parse: function(postObjects) { - var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; + var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; OP = postObjects[0]; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); @@ -9845,25 +9808,15 @@ node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); } - deletedPosts = []; - deletedFiles = []; ThreadUpdater.thread.posts.forEach(function(post) { var ID; ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push({ - ID: post.ID, - fullID: post.fullID - }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push({ - ID: post.ID, - fullID: post.fullID - }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -9915,24 +9868,10 @@ } return $.event('ThreadUpdate', { 404: false, - thread: { - ID: ThreadUpdater.thread.ID, - fullID: ThreadUpdater.thread.fullID - }, - newPosts: (function() { - var _k, _len2, _results; - _results = []; - for (_k = 0, _len2 = posts.length; _k < _len2; _k++) { - post = posts[_k]; - _results.push({ - ID: post.ID, - fullID: post.fullID - }); - } - return _results; - })(), - deletedPosts: deletedPosts, - deletedFiles: deletedFiles, + threadID: ThreadUpdater.thread.fullID, + newPosts: posts.map(function(post) { + return post.fullID; + }), postCount: OP.replies + 1, fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) }); @@ -10067,14 +10006,14 @@ return ThreadWatcher.rm(boardID, +threadID); }, post: function(e) { - var board, postID, threadID, _ref; - _ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; + var boardID, postID, threadID, _ref; + _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID; if (postID === threadID) { if (Conf['Auto Watch']) { return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); + return ThreadWatcher.add(g.threads[boardID + '.' + threadID]); } }, onIndexRefresh: function() { @@ -10104,7 +10043,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = g.threads[e.detail.thread.fullID]; + thread = g.threads[e.detail.threadID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10316,7 +10255,7 @@ if (!Conf['Thread Watcher']) { return; } - menu = new UI.Menu('thread watcher'); + menu = this.menu = new UI.Menu('thread watcher'); $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { return menu.toggle(e, this, ThreadWatcher); }); @@ -10331,8 +10270,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: entryEl, order: 60 }); @@ -10353,7 +10291,6 @@ entries.push({ cb: ThreadWatcher.cb.openAll, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Open all threads' }) @@ -10365,7 +10302,6 @@ entries.push({ cb: ThreadWatcher.cb.checkThreads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Check 404\'d threads' }) @@ -10377,7 +10313,6 @@ entries.push({ cb: ThreadWatcher.cb.pruneDeads, entry: { - type: 'thread watcher', el: $.el('a', { textContent: 'Prune 404\'d threads' }) @@ -10394,7 +10329,6 @@ } entries.push({ entry: { - type: 'thread watcher', el: $.el('span', { textContent: 'Settings' }), @@ -10412,7 +10346,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - UI.addMenuEntry(entry); + this.menu.addEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10589,20 +10523,12 @@ }; }, onUpdate: function(e) { - var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts((function() { - var _i, _len, _ref, _results; - _ref = e.detail.newPosts; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - post = _ref[_i]; - _results.push(g.posts[post.fullID]); - } - return _results; - })()); + return Unread.addPosts(e.detail.newPosts.map(function(fullID) { + return g.posts[fullID]; + })); } else { Unread.read(); return Unread.update(); @@ -10810,7 +10736,6 @@ return; } entry = { - type: 'header', el: $.el('a', { textContent: 'Show announcement', className: 'show-announcement', @@ -10821,7 +10746,7 @@ return psa.hidden; } }; - UI.addMenuEntry(entry); + Header.menu.addEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -10974,8 +10899,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - UI.addMenuEntry({ - type: 'header', + Header.menu.addEntry({ el: el, order: 95 }); @@ -11472,7 +11396,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); + $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11505,7 +11429,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.ID, window); + return $.event('jsmath', _this.nodes.post.id, window); }; })(this)); }, @@ -12353,7 +12277,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13184,7 +13108,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.8.0.' + innerHTML: '4chan X has been updated to version 1.8.1.' }); new Notice('info', el, 15); } else { @@ -13227,25 +13151,6 @@ }; return softTask(); }, - addCallback: function(e) { - var Klass, obj; - obj = e.detail; - if (typeof obj.callback.name !== 'string') { - throw new Error("Invalid callback name: " + obj.callback.name); - } - switch (obj.type) { - case 'Post': - Klass = Post; - break; - case 'Thread': - Klass = Thread; - break; - default: - return; - } - obj.callback.isAddon = true; - return Klass.callbacks.push(obj.callback); - }, handleErrors: function(errors) { var div, error, logs, _i, _len; if (!(errors instanceof Array)) { diff --git a/package.json b/package.json index 7b3bb5296..c2c29d4ac 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "1.8.0", + "version": "1.8.1", "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X",