c = console. replaces $.log

This commit is contained in:
Nicolas Stepien 2013-03-12 21:54:40 +01:00
parent 0290db120e
commit b6f7514605
6 changed files with 33 additions and 32 deletions

View File

@ -43,7 +43,7 @@
*/ */
(function() { (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, __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; }, __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, __hasProp = {}.hasOwnProperty,
@ -193,6 +193,8 @@
Conf = {}; Conf = {};
c = console;
d = document; d = document;
doc = d.documentElement; doc = d.documentElement;
@ -640,7 +642,6 @@
MINUTE: 1000 * 60, MINUTE: 1000 * 60,
HOUR: 1000 * 60 * 60, HOUR: 1000 * 60 * 60,
DAY: 1000 * 60 * 60 * 24, DAY: 1000 * 60 * 60 * 24,
log: console.log.bind(console),
engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase(), engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase(),
id: function(id) { id: function(id) {
return d.getElementById(id); return d.getElementById(id);
@ -1426,7 +1427,7 @@
} }
} catch (err) { } catch (err) {
output.textContent = 'Import failed due to an error.'; output.textContent = 'Import failed due to an error.';
return $.log(err.stack); return c.log(err.stack);
} }
}; };
return reader.readAsText(file); return reader.readAsText(file);
@ -6507,7 +6508,7 @@
} }
img = $.el('img'); img = $.el('img');
img.onload = function() { 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; s = 90 * 2;
height = img.height, width = img.width; height = img.height, width = img.width;
if (height < s || width < s) { if (height < s || width < s) {
@ -6524,12 +6525,12 @@
height = s / width * height; height = s / width * height;
width = s; width = s;
} }
c = $.el('canvas'); cv = $.el('canvas');
c.height = img.height = height; cv.height = img.height = height;
c.width = img.width = width; cv.width = img.width = width;
c.getContext('2d').drawImage(img, 0, 0, width, height); cv.getContext('2d').drawImage(img, 0, 0, width, height);
if (!window.URL) { if (!window.URL) {
_this.nodes.el.style.backgroundImage = "url(" + (c.toDataURL()) + ")"; _this.nodes.el.style.backgroundImage = "url(" + (cv.toDataURL()) + ")";
delete _this.URL; delete _this.URL;
return; return;
} }
@ -6538,11 +6539,11 @@
_this.URL = URL.createObjectURL(blob); _this.URL = URL.createObjectURL(blob);
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")"; return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
}; };
if (c.toBlob) { if (cv.toBlob) {
c.toBlob(applyBlob); cv.toBlob(applyBlob);
return; return;
} }
data = atob(c.toDataURL().split(',')[1]); data = atob(cv.toDataURL().split(',')[1]);
l = data.length; l = data.length;
ui8a = new Uint8Array(l); ui8a = new Uint8Array(l);
for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) { for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) {
@ -7489,6 +7490,7 @@
return; return;
} }
initFeature = function(name, module) { initFeature = function(name, module) {
c.time("" + name + " initialization");
try { try {
return module.init(); return module.init();
} catch (err) { } catch (err) {
@ -7497,7 +7499,7 @@
error: err error: err
}); });
} finally { } finally {
c.timeEnd("" + name + " initialization");
} }
}; };
initFeature('Polyfill', Polyfill); initFeature('Polyfill', Polyfill);
@ -7715,7 +7717,7 @@
parseError: function(data) { parseError: function(data) {
var error, message; var error, message;
message = data.message, error = data.error; message = data.message, error = data.error;
$.log(message, error.stack); c.log(message, error.stack);
message = $.el('div', { message = $.el('div', {
textContent: message textContent: message
}); });

View File

@ -16,8 +16,6 @@ $.extend $,
MINUTE: 1000 * 60 MINUTE: 1000 * 60
HOUR : 1000 * 60 * 60 HOUR : 1000 * 60 * 60
DAY : 1000 * 60 * 60 * 24 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() engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase()
id: (id) -> id: (id) ->
d.getElementById id d.getElementById id

View File

@ -342,7 +342,7 @@ Settings =
window.location.reload() window.location.reload()
catch err catch err
output.textContent = 'Import failed due to an error.' output.textContent = 'Import failed due to an error.'
$.log err.stack c.log err.stack
reader.readAsText file reader.readAsText file
loadSettings: (data) -> loadSettings: (data) ->
version = data.version.split '.' version = data.version.split '.'

View File

@ -3,6 +3,7 @@
return unless /^(boards|images|sys)\.4chan\.org$/.test location.hostname return unless /^(boards|images|sys)\.4chan\.org$/.test location.hostname
Conf = {} Conf = {}
c = console
d = document d = document
doc = d.documentElement doc = d.documentElement
g = g =

View File

@ -300,7 +300,7 @@ Main =
return return
initFeature = (name, module) -> initFeature = (name, module) ->
# console.time "#{name} initialization" c.time "#{name} initialization"
try try
module.init() module.init()
catch err catch err
@ -308,9 +308,9 @@ Main =
message: "\"#{name}\" initialization crashed." message: "\"#{name}\" initialization crashed."
error: err error: err
finally finally
# console.timeEnd "#{name} initialization" c.timeEnd "#{name} initialization"
# console.time 'All initializations' # c.time 'All initializations'
initFeature 'Polyfill', Polyfill initFeature 'Polyfill', Polyfill
initFeature 'Header', Header initFeature 'Header', Header
initFeature 'Settings', Settings initFeature 'Settings', Settings
@ -357,7 +357,7 @@ Main =
initFeature 'Thread Watcher', ThreadWatcher initFeature 'Thread Watcher', ThreadWatcher
initFeature 'Index Navigation', Nav initFeature 'Index Navigation', Nav
initFeature 'Keybinds', Keybinds initFeature 'Keybinds', Keybinds
# console.timeEnd 'All initializations' # c.timeEnd 'All initializations'
$.on d, 'AddCallback', Main.addCallback $.on d, 'AddCallback', Main.addCallback
$.on d, '4chanMainInit', Main.initStyle $.on d, '4chanMainInit', Main.initStyle
@ -440,7 +440,7 @@ Main =
# get the nodes' length only once # get the nodes' length only once
len = nodes.length len = nodes.length
for callback in klass::callbacks for callback in klass::callbacks
# console.profile callback.name # c.profile callback.name
for i in [0...len] for i in [0...len]
node = nodes[i] node = nodes[i]
try try
@ -451,7 +451,7 @@ Main =
errors.push errors.push
message: "\"#{callback.name}\" crashed on #{klass.name} No.#{node} (/#{node.board}/)." message: "\"#{callback.name}\" crashed on #{klass.name} No.#{node} (/#{node.board}/)."
error: err error: err
# console.profileEnd callback.name # c.profileEnd callback.name
Main.handleErrors errors if errors Main.handleErrors errors if errors
addCallback: (e) -> addCallback: (e) ->
@ -491,7 +491,7 @@ Main =
parseError: (data) -> parseError: (data) ->
{message, error} = data {message, error} = data
$.log message, error.stack c.log message, error.stack
message = $.el 'div', message = $.el 'div',
textContent: message textContent: message
error = $.el 'div', error = $.el 'div',

View File

@ -492,22 +492,22 @@ QR =
else else
height = s / width * height height = s / width * height
width = s width = s
c = $.el 'canvas' cv = $.el 'canvas'
c.height = img.height = height cv.height = img.height = height
c.width = img.width = width cv.width = img.width = width
c.getContext('2d').drawImage img, 0, 0, width, height cv.getContext('2d').drawImage img, 0, 0, width, height
unless window.URL unless window.URL
@nodes.el.style.backgroundImage = "url(#{c.toDataURL()})" @nodes.el.style.backgroundImage = "url(#{cv.toDataURL()})"
delete @URL delete @URL
return return
URL.revokeObjectURL fileURL URL.revokeObjectURL fileURL
applyBlob = (blob) => applyBlob = (blob) =>
@URL = URL.createObjectURL blob @URL = URL.createObjectURL blob
@nodes.el.style.backgroundImage = "url(#{@URL})" @nodes.el.style.backgroundImage = "url(#{@URL})"
if c.toBlob if cv.toBlob
c.toBlob applyBlob cv.toBlob applyBlob
return return
data = atob c.toDataURL().split(',')[1] data = atob cv.toDataURL().split(',')[1]
# DataUrl to Binary code from Aeosynth's 4chan X repo # DataUrl to Binary code from Aeosynth's 4chan X repo
l = data.length l = data.length