diff --git a/4chan_x.user.js b/4chan_x.user.js index 601ddda0b..063deed91 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -43,7 +43,7 @@ */ (function() { - var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, CustomCSS, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteStrikeThrough, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, d, doc, g, + var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, CustomCSS, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteStrikeThrough, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, g, __slice = [].slice, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __hasProp = {}.hasOwnProperty, @@ -193,6 +193,8 @@ Conf = {}; + c = console; + d = document; doc = d.documentElement; @@ -640,7 +642,6 @@ MINUTE: 1000 * 60, HOUR: 1000 * 60 * 60, DAY: 1000 * 60 * 60 * 24, - log: console.log.bind(console), engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase(), id: function(id) { return d.getElementById(id); @@ -1426,7 +1427,7 @@ } } catch (err) { output.textContent = 'Import failed due to an error.'; - return $.log(err.stack); + return c.log(err.stack); } }; return reader.readAsText(file); @@ -6507,7 +6508,7 @@ } img = $.el('img'); img.onload = function() { - var applyBlob, c, data, height, i, l, s, ui8a, width, _i; + var applyBlob, cv, data, height, i, l, s, ui8a, width, _i; s = 90 * 2; height = img.height, width = img.width; if (height < s || width < s) { @@ -6524,12 +6525,12 @@ height = s / width * height; width = s; } - c = $.el('canvas'); - c.height = img.height = height; - c.width = img.width = width; - c.getContext('2d').drawImage(img, 0, 0, width, height); + cv = $.el('canvas'); + cv.height = img.height = height; + cv.width = img.width = width; + cv.getContext('2d').drawImage(img, 0, 0, width, height); if (!window.URL) { - _this.nodes.el.style.backgroundImage = "url(" + (c.toDataURL()) + ")"; + _this.nodes.el.style.backgroundImage = "url(" + (cv.toDataURL()) + ")"; delete _this.URL; return; } @@ -6538,11 +6539,11 @@ _this.URL = URL.createObjectURL(blob); return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")"; }; - if (c.toBlob) { - c.toBlob(applyBlob); + if (cv.toBlob) { + cv.toBlob(applyBlob); return; } - data = atob(c.toDataURL().split(',')[1]); + data = atob(cv.toDataURL().split(',')[1]); l = data.length; ui8a = new Uint8Array(l); for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) { @@ -7489,6 +7490,7 @@ return; } initFeature = function(name, module) { + c.time("" + name + " initialization"); try { return module.init(); } catch (err) { @@ -7497,7 +7499,7 @@ error: err }); } finally { - + c.timeEnd("" + name + " initialization"); } }; initFeature('Polyfill', Polyfill); @@ -7715,7 +7717,7 @@ parseError: function(data) { var error, message; message = data.message, error = data.error; - $.log(message, error.stack); + c.log(message, error.stack); message = $.el('div', { textContent: message }); diff --git a/lib/$.coffee b/lib/$.coffee index 384d02b24..8220b4d4e 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -16,8 +16,6 @@ $.extend $, MINUTE: 1000 * 60 HOUR : 1000 * 60 * 60 DAY : 1000 * 60 * 60 * 24 - # XXX http://code.google.com/p/phantomjs/issues/detail?id=522 - log: console.log.bind console engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase() id: (id) -> d.getElementById id diff --git a/src/features.coffee b/src/features.coffee index f0ba1d7b8..62ecac6b2 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -342,7 +342,7 @@ Settings = window.location.reload() catch err output.textContent = 'Import failed due to an error.' - $.log err.stack + c.log err.stack reader.readAsText file loadSettings: (data) -> version = data.version.split '.' diff --git a/src/globals.coffee b/src/globals.coffee index 973ab5778..827975066 100644 --- a/src/globals.coffee +++ b/src/globals.coffee @@ -3,6 +3,7 @@ return unless /^(boards|images|sys)\.4chan\.org$/.test location.hostname Conf = {} +c = console d = document doc = d.documentElement g = diff --git a/src/main.coffee b/src/main.coffee index 14ce5f4c6..128c0ac55 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -300,7 +300,7 @@ Main = return initFeature = (name, module) -> - # console.time "#{name} initialization" + c.time "#{name} initialization" try module.init() catch err @@ -308,9 +308,9 @@ Main = message: "\"#{name}\" initialization crashed." error: err finally - # console.timeEnd "#{name} initialization" + c.timeEnd "#{name} initialization" - # console.time 'All initializations' + # c.time 'All initializations' initFeature 'Polyfill', Polyfill initFeature 'Header', Header initFeature 'Settings', Settings @@ -357,7 +357,7 @@ Main = initFeature 'Thread Watcher', ThreadWatcher initFeature 'Index Navigation', Nav initFeature 'Keybinds', Keybinds - # console.timeEnd 'All initializations' + # c.timeEnd 'All initializations' $.on d, 'AddCallback', Main.addCallback $.on d, '4chanMainInit', Main.initStyle @@ -440,7 +440,7 @@ Main = # get the nodes' length only once len = nodes.length for callback in klass::callbacks - # console.profile callback.name + # c.profile callback.name for i in [0...len] node = nodes[i] try @@ -451,7 +451,7 @@ Main = errors.push message: "\"#{callback.name}\" crashed on #{klass.name} No.#{node} (/#{node.board}/)." error: err - # console.profileEnd callback.name + # c.profileEnd callback.name Main.handleErrors errors if errors addCallback: (e) -> @@ -491,7 +491,7 @@ Main = parseError: (data) -> {message, error} = data - $.log message, error.stack + c.log message, error.stack message = $.el 'div', textContent: message error = $.el 'div', diff --git a/src/qr.coffee b/src/qr.coffee index 1cc477ffb..650396c99 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -492,22 +492,22 @@ QR = else height = s / width * height width = s - c = $.el 'canvas' - c.height = img.height = height - c.width = img.width = width - c.getContext('2d').drawImage img, 0, 0, width, height + cv = $.el 'canvas' + cv.height = img.height = height + cv.width = img.width = width + cv.getContext('2d').drawImage img, 0, 0, width, height unless window.URL - @nodes.el.style.backgroundImage = "url(#{c.toDataURL()})" + @nodes.el.style.backgroundImage = "url(#{cv.toDataURL()})" delete @URL return URL.revokeObjectURL fileURL applyBlob = (blob) => @URL = URL.createObjectURL blob @nodes.el.style.backgroundImage = "url(#{@URL})" - if c.toBlob - c.toBlob applyBlob + if cv.toBlob + cv.toBlob applyBlob return - data = atob c.toDataURL().split(',')[1] + data = atob cv.toDataURL().split(',')[1] # DataUrl to Binary code from Aeosynth's 4chan X repo l = data.length