Filesize -> FileFormat. Added PDF to the regex for /po/. Changed width and height to just resolution.

This commit is contained in:
ahodesuka 2012-02-21 15:38:05 -06:00
parent 29af83337b
commit 56877c39c2
3 changed files with 169 additions and 165 deletions

View File

@ -72,7 +72,7 @@
*/ */
(function() { (function() {
var $, $$, DAY, Favicon, Filesize, HOUR, MINUTE, Main, NAMESPACE, SECOND, Time, VERSION, anonymize, conf, config, d, engine, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteIndicators, quoteInline, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, unxify, updater, val, watcher, _base; var $, $$, DAY, Favicon, FileFormat, HOUR, MINUTE, Main, NAMESPACE, SECOND, Time, VERSION, anonymize, conf, config, d, engine, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteIndicators, quoteInline, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, unxify, updater, val, watcher, _base;
config = { config = {
main: { main: {
@ -81,7 +81,7 @@
'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number'], 'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number'],
'Keybinds': [true, 'Binds actions to keys'], 'Keybinds': [true, 'Binds actions to keys'],
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
'Filesize Formatting': [true, 'Reformats the image information'], 'File Info Formatting': [true, 'Reformats the file information'],
'Report Button': [true, 'Add report buttons'], 'Report Button': [true, 'Add report buttons'],
'Comment Expansion': [true, 'Expand too long comments'], 'Comment Expansion': [true, 'Expand too long comments'],
'Thread Expansion': [true, 'View all replies'], 'Thread Expansion': [true, 'View all replies'],
@ -149,8 +149,8 @@
sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2', '#http://omploader.org/upload?url1=$2', '# "View Same" in archives:', '#http://archive.foolz.us/a/image/$3/', '#http://archive.installgentoo.net/g/image/$3'].join('\n'), sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2', '#http://omploader.org/upload?url1=$2', '# "View Same" in archives:', '#http://archive.foolz.us/a/image/$3/', '#http://archive.installgentoo.net/g/image/$3'].join('\n'),
time: '%m/%d/%y(%a)%H:%M', time: '%m/%d/%y(%a)%H:%M',
backlink: '>>%id', backlink: '>>%id',
filesizeR: '%l (%s, %wx%h, %n)', fileFormatR: '%l (%s, %r, %n)',
filesizeT: '%l (%s, %wx%h)', fileFormatT: '%l (%s, %r)',
favicon: 'ferongr', favicon: 'ferongr',
hotkeys: { hotkeys: {
openOptions: ['ctrl+o', 'Open Options'], openOptions: ['ctrl+o', 'Open Options'],
@ -2079,7 +2079,7 @@
} }
}, },
dialog: function() { dialog: function() {
var arr, back, checked, description, dialog, favicon, filesizeR, filesizeT, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, tr, ul, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4; var arr, back, checked, description, dialog, favicon, fileFormatR, fileFormatT, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, tr, ul, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4;
dialog = $.el('div', { dialog = $.el('div', {
id: 'options', id: 'options',
className: 'reply dialog', className: 'reply dialog',
@ -2123,7 +2123,7 @@
<p>Comment:<br><textarea name=comment></textarea></p>\ <p>Comment:<br><textarea name=comment></textarea></p>\
<p>Filename:<br><textarea name=filename></textarea></p>\ <p>Filename:<br><textarea name=filename></textarea></p>\
<p>Image dimensions:<br><textarea name=dimensions></textarea></p>\ <p>Image dimensions:<br><textarea name=dimensions></textarea></p>\
<p>Filesize:<br><textarea name=filesize></textarea></p>\ <p>FileFormat:<br><textarea name=filesize></textarea></p>\
<p>Image MD5:<br><textarea name=md5></textarea></p>\ <p>Image MD5:<br><textarea name=md5></textarea></p>\
</div>\ </div>\
<input type=radio name=tab hidden id=rice_tab>\ <input type=radio name=tab hidden id=rice_tab>\
@ -2144,16 +2144,15 @@
<li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\ <li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\
<li>Minutes: %M</li>\ <li>Minutes: %M</li>\
</ul>\ </ul>\
<div class=warning><code>Filesize Formatting</code> is disabled.</div>\ <div class=warning><code>File Info Formatting</code> is disabled.</div>\
<ul>\ <ul>\
Reply Filesize formatting\ Reply File Info Formatting\
<li><input type=text name=filesizeR> : <span id=filesizeRPreview></span></li>\ <li><input type=text name=fileFormatR> : <span id=fileFormatRPreview></span></li>\
Thread Filesize formatting\ Thread File Info Formatting\
<li><input type=text name=filesizeT> : <span id=filesizeTPreview></span></li>\ <li><input type=text name=fileFormatT> : <span id=fileFormatTPreview></span></li>\
<li>Link: %l (lowercase L)</li>\ <li>Link: %l (lowercase L)</li>\
<li>Size: %B (Bytes), %K (KB), %M (MB), %s (simplified unit)</li>\ <li>Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)</li>\
<li>Width: %w</li>\ <li>Resolution: %r (Displays PDF on /po/, for PDF\'s)</li>\
<li>Height: %h</li>\
<li>Original filename: %n (Reply only)</li>\ <li>Original filename: %n (Reply only)</li>\
</ul>\ </ul>\
<div class=warning><code>Unread Favicon</code> is disabled.</div>\ <div class=warning><code>Unread Favicon</code> is disabled.</div>\
@ -2209,16 +2208,16 @@
} }
(back = $('[name=backlink]', dialog)).value = conf['backlink']; (back = $('[name=backlink]', dialog)).value = conf['backlink'];
(time = $('[name=time]', dialog)).value = conf['time']; (time = $('[name=time]', dialog)).value = conf['time'];
(filesizeR = $('[name=filesizeR]', dialog)).value = conf['filesizeR']; (fileFormatR = $('[name=fileFormatR]', dialog)).value = conf['fileFormatR'];
(filesizeT = $('[name=filesizeT]', dialog)).value = conf['filesizeT']; (fileFormatT = $('[name=fileFormatT]', dialog)).value = conf['fileFormatT'];
$.on(back, 'keyup', $.cb.value); $.on(back, 'keyup', $.cb.value);
$.on(back, 'keyup', options.backlink); $.on(back, 'keyup', options.backlink);
$.on(time, 'keyup', $.cb.value); $.on(time, 'keyup', $.cb.value);
$.on(time, 'keyup', options.time); $.on(time, 'keyup', options.time);
$.on(filesizeR, 'keyup', $.cb.value); $.on(fileFormatR, 'keyup', $.cb.value);
$.on(filesizeR, 'keyup', options.filesize); $.on(fileFormatR, 'keyup', options.fileFormat);
$.on(filesizeT, 'keyup', $.cb.value); $.on(fileFormatT, 'keyup', $.cb.value);
$.on(filesizeT, 'keyup', options.filesize); $.on(fileFormatT, 'keyup', options.fileFormat);
favicon = $('select', dialog); favicon = $('select', dialog);
favicon.value = conf['favicon']; favicon.value = conf['favicon'];
$.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', $.cb.value);
@ -2257,8 +2256,8 @@
d.body.style.setProperty('overflow', 'hidden', null); d.body.style.setProperty('overflow', 'hidden', null);
options.backlink.call(back); options.backlink.call(back);
options.time.call(time); options.time.call(time);
options.filesize.call(filesizeR); options.fileFormat.call(fileFormatR);
options.filesize.call(filesizeT); options.fileFormat.call(fileFormatT);
return options.favicon.call(favicon); return options.favicon.call(favicon);
}, },
close: function() { close: function() {
@ -2287,18 +2286,15 @@
backlink: function() { backlink: function() {
return $.id('backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789'); return $.id('backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
}, },
filesize: function() { fileFormat: function() {
Filesize.fstype = this.name === 'filesizeR' ? 0 : 1; FileFormat.data = {
Filesize.getFormat();
Filesize.data = {
link: '<a href="javascript:;">1329791824.png</a>', link: '<a href="javascript:;">1329791824.png</a>',
size: 996, size: 996,
unit: 'KB', unit: 'KB',
width: 1366, resolution: '1366x768',
height: 768 filename: 'Untitled.png'
}; };
if (Filesize.fstype === 0) Filesize.data.filename = 'Untitled.png'; return $.id("" + this.name + "Preview").innerHTML = FileFormat.funks[this.name === 'fileFormatR' ? 0 : 1](FileFormat);
return $.id("" + this.name + "Preview").innerHTML = Filesize.funk(Filesize);
}, },
favicon: function() { favicon: function() {
Favicon["switch"](); Favicon["switch"]();
@ -2893,51 +2889,52 @@
} }
}; };
Filesize = { FileFormat = {
init: function() { init: function() {
Filesize.fstype = g.REPLY ? 0 : 1; if (g.BOARD === 'f') return;
Filesize.fsconf = ['filesizeR', 'filesizeT']; FileFormat.ffConf = ['fileFormatR', 'fileFormatT'];
Filesize.regEx = [/File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+)x(\d+),\s<span\stitle=\"([^\"]+)\">/, /File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+)x(\d+)\)/]; FileFormat.ffMtrs = [/%([BKlMnrs])/g, /%([BKlMrs])/g];
FileFormat.ffRgex = [/File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF),\s<span\stitle=\"([^\"]+)\">/, /File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF)\)/];
this.parse = function(node) { this.parse = function(node) {
var filename, height, link, size, unit, width, _, _ref; var filename, link, resolution, size, unit, _, _ref;
_ref = node.innerHTML.match(Filesize.regEx[Filesize.fstype]), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], width = _ref[4], height = _ref[5], filename = _ref[6]; FileFormat.ffType = node.childNodes.length > 3 ? 0 : 1;
_ref = node.innerHTML.match(FileFormat.ffRgex[FileFormat.ffType]), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], resolution = _ref[4], filename = _ref[5];
return { return {
'link': link, link: link,
'size': size, size: size,
'unit': unit, unit: unit,
'width': width, resolution: resolution,
'height': height, filename: filename
'filename': filename
}; };
}; };
Filesize.getFormat(); FileFormat.funks = FileFormat.setFormats();
return g.callbacks.push(this.node); return g.callbacks.push(this.node);
}, },
node: function(root) { node: function(root) {
var filesize, node; var node;
if (root.className === 'inline' || !(node = $('.filesize', root))) return; if (root.className === 'inline' || !(node = $('.filesize', root))) return;
Filesize.data = Filesize.parse(node); FileFormat.data = FileFormat.parse(node);
filesize = $.el('span', { return node.innerHTML = FileFormat.funks[FileFormat.ffType](FileFormat) + ' ';
className: 'filesize',
innerHTML: Filesize.funk(Filesize) + ' '
});
return $.replace(node, filesize);
}, },
getFormat: function() { setFormats: function() {
var code; var code, i, _results;
code = conf[Filesize.fsconf[Filesize.fstype]].replace(/%([BhKlMnsw])/g, function(s, c) { _results = [];
if (c in Filesize.formatters) { for (i = 0; i <= 1; i++) {
return "' + Filesize.formatters." + c + "() + '"; code = conf[FileFormat.ffConf[i]].replace(FileFormat.ffMtrs[i], function(s, c) {
} else { if (c in FileFormat.formatters) {
return s; return "' + FileFormat.formatters." + c + "() + '";
} } else {
}); return s;
return Filesize.funk = Function('Filesize', "return '" + code + "'"); }
});
_results.push(Function('FileFormat', "return '" + code + "'"));
}
return _results;
}, },
convertUnit: function(unitT) { convertUnit: function(unitT) {
var i, size, unitF, units; var i, size, unitF, units;
size = Filesize.data.size; size = FileFormat.data.size;
unitF = Filesize.data.unit; unitF = FileFormat.data.unit;
if (unitF !== unitT) { if (unitF !== unitT) {
units = ['B', 'KB', 'MB']; units = ['B', 'KB', 'MB'];
i = units.indexOf(unitF) - units.indexOf(unitT); i = units.indexOf(unitF) - units.indexOf(unitT);
@ -2959,32 +2956,30 @@
}, },
formatters: { formatters: {
B: function() { B: function() {
return Filesize.convertUnit('B'); return FileFormat.convertUnit('B');
},
h: function() {
return Filesize.data.height;
}, },
K: function() { K: function() {
return Filesize.convertUnit('KB'); return FileFormat.convertUnit('KB');
}, },
l: function() { l: function() {
return Filesize.data.link; return FileFormat.data.link;
}, },
M: function() { M: function() {
return Filesize.convertUnit('MB'); return FileFormat.convertUnit('MB');
}, },
n: function() { n: function() {
if (Filesize.fstype === 0) { var ext;
return Filesize.data.filename; if ((ext = FileFormat.data.filename.lastIndexOf('.')) > 38) {
return '<span class=fnfull>' + FileFormat.data.filename + '</span><span class=fntrunc>' + FileFormat.data.filename.substr(0, 32) + ' (...)' + FileFormat.data.filename.substr(ext) + '</span>';
} else { } else {
return '%n'; return FileFormat.data.filename;
} }
}, },
s: function() { r: function() {
return "" + Filesize.data.size + " " + Filesize.data.unit; return FileFormat.data.resolution;
}, },
w: function() { s: function() {
return Filesize.data.width; return "" + FileFormat.data.size + " " + FileFormat.data.unit;
} }
} }
}; };
@ -3253,8 +3248,8 @@
qp.innerHTML = html; qp.innerHTML = html;
if (conf['Image Auto-Gif']) imgGif.node(qp); if (conf['Image Auto-Gif']) imgGif.node(qp);
if (conf['Time Formatting']) Time.node(qp); if (conf['Time Formatting']) Time.node(qp);
if (conf['Filesize Formatting']) { if (conf['File Info Formatting']) {
if (id !== threadID) return Filesize.node(qp); if (id !== threadID) return FileFormat.node(qp);
} }
} }
}; };
@ -3748,7 +3743,7 @@
if (conf['Filter'] || conf['Reply Hiding']) strikethroughQuotes.init(); if (conf['Filter'] || conf['Reply Hiding']) strikethroughQuotes.init();
if (conf['Anonymize']) anonymize.init(); if (conf['Anonymize']) anonymize.init();
if (conf['Time Formatting']) Time.init(); if (conf['Time Formatting']) Time.init();
if (conf['Filesize Formatting']) Filesize.init(); if (conf['File Info Formatting']) FileFormat.init();
if (conf['Sauce']) sauce.init(); if (conf['Sauce']) sauce.init();
if (conf['Reveal Spoilers']) revealSpoilers.init(); if (conf['Reveal Spoilers']) revealSpoilers.init();
if (conf['Image Auto-Gif']) imgGif.init(); if (conf['Image Auto-Gif']) imgGif.init();
@ -3793,10 +3788,6 @@
} }
nodes = $$('.op, a + table', form); nodes = $$('.op, a + table', form);
Main.node(nodes, true); Main.node(nodes, true);
if (!g.REPLY && conf['Filesize Formatting']) {
Filesize.fstype = 0;
Filesize.getFormat();
}
if (MutationObserver = window.WebKitMutationObserver || window.MozMutationObserver || window.OMutationObserver || window.MutationObserver) { if (MutationObserver = window.WebKitMutationObserver || window.MozMutationObserver || window.OMutationObserver || window.MutationObserver) {
observer = new MutationObserver(Main.observer); observer = new MutationObserver(Main.observer);
return observer.observe(form, { return observer.observe(form, {
@ -4084,6 +4075,12 @@ td.replyhider {\
float: left;\ float: left;\
pointer-events: none;\ pointer-events: none;\
}\ }\
.filesize .fnfull, .filesize:hover .fntrunc {\
display: none;\
}\
.filesize:hover .fnfull {\
display: inline;\
}\
img[md5], img[md5] + img {\ img[md5], img[md5] + img {\
pointer-events: all;\ pointer-events: all;\
}\ }\

View File

@ -1,9 +1,20 @@
master master
- aeosynth / ahodesuka
new option: expand images from current position
- ahodesuka
Add Open Reply in New Tab option for replies made from the main board (not dumping).
Scroll back up (top of anchor - 42px) when unexpanding images.
Reply/Thread File Info Formatting:
- Link: %l.
- Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default).
- Resolution/PDF: %r
- Original filename: %n (truncated if longer than 40~ character, on hover the entire string is shown.
- Mayhem - Mayhem
The Filter now has per filter settings: The Filter now has per filter settings:
- Filter the OP along its thread, replies only, or both. - Filter the OP only along its thread, replies only, or both.
- Per boards, or global. - Per boards, or global.
- Highlight, or hide. - Highlight, or hide.
- Highlighted OPs will have their threads put on top of the board page by default.
New filter group: Image dimensions. New filter group: Image dimensions.
Fix posting on Safari. Fix posting on Safari.
Fix rare case where the QR would not accept certain image types. Fix rare case where the QR would not accept certain image types.
@ -101,7 +112,7 @@ master
see https://github.com/MayhemYDG/4chan-x/issues/136 see https://github.com/MayhemYDG/4chan-x/issues/136
2.24.4 2.24.4
- ahokadesuka - ahodesuka
Scroll back up when unexpanding images. Scroll back up when unexpanding images.
- e000 - e000
Prevent absurd cooldown durations. Prevent absurd cooldown durations.

View File

@ -5,7 +5,7 @@ config =
'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number'] 'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number']
'Keybinds': [true, 'Binds actions to keys'] 'Keybinds': [true, 'Binds actions to keys']
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
'Filesize Formatting': [true, 'Reformats the image information'] 'File Info Formatting': [true, 'Reformats the file information']
'Report Button': [true, 'Add report buttons'] 'Report Button': [true, 'Add report buttons']
'Comment Expansion': [true, 'Expand too long comments'] 'Comment Expansion': [true, 'Expand too long comments']
'Thread Expansion': [true, 'View all replies'] 'Thread Expansion': [true, 'View all replies']
@ -78,8 +78,8 @@ config =
].join '\n' ].join '\n'
time: '%m/%d/%y(%a)%H:%M' time: '%m/%d/%y(%a)%H:%M'
backlink: '>>%id' backlink: '>>%id'
filesizeR: '%l (%s, %wx%h, %n)' fileFormatR: '%l (%s, %r, %n)'
filesizeT: '%l (%s, %wx%h)' fileFormatT: '%l (%s, %r)'
favicon: 'ferongr' favicon: 'ferongr'
hotkeys: hotkeys:
openOptions: ['ctrl+o', 'Open Options'] openOptions: ['ctrl+o', 'Open Options']
@ -1695,7 +1695,7 @@ options =
<p>Comment:<br><textarea name=comment></textarea></p> <p>Comment:<br><textarea name=comment></textarea></p>
<p>Filename:<br><textarea name=filename></textarea></p> <p>Filename:<br><textarea name=filename></textarea></p>
<p>Image dimensions:<br><textarea name=dimensions></textarea></p> <p>Image dimensions:<br><textarea name=dimensions></textarea></p>
<p>Filesize:<br><textarea name=filesize></textarea></p> <p>FileFormat:<br><textarea name=filesize></textarea></p>
<p>Image MD5:<br><textarea name=md5></textarea></p> <p>Image MD5:<br><textarea name=md5></textarea></p>
</div> </div>
<input type=radio name=tab hidden id=rice_tab> <input type=radio name=tab hidden id=rice_tab>
@ -1716,16 +1716,15 @@ options =
<li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li> <li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>
<li>Minutes: %M</li> <li>Minutes: %M</li>
</ul> </ul>
<div class=warning><code>Filesize Formatting</code> is disabled.</div> <div class=warning><code>File Info Formatting</code> is disabled.</div>
<ul> <ul>
Reply Filesize formatting Reply File Info Formatting
<li><input type=text name=filesizeR> : <span id=filesizeRPreview></span></li> <li><input type=text name=fileFormatR> : <span id=fileFormatRPreview></span></li>
Thread Filesize formatting Thread File Info Formatting
<li><input type=text name=filesizeT> : <span id=filesizeTPreview></span></li> <li><input type=text name=fileFormatT> : <span id=fileFormatTPreview></span></li>
<li>Link: %l (lowercase L)</li> <li>Link: %l (lowercase L)</li>
<li>Size: %B (Bytes), %K (KB), %M (MB), %s (simplified unit)</li> <li>Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)</li>
<li>Width: %w</li> <li>Resolution: %r (Displays PDF on /po/, for PDF\'s)</li>
<li>Height: %h</li>
<li>Original filename: %n (Reply only)</li> <li>Original filename: %n (Reply only)</li>
</ul> </ul>
<div class=warning><code>Unread Favicon</code> is disabled.</div> <div class=warning><code>Unread Favicon</code> is disabled.</div>
@ -1774,18 +1773,18 @@ options =
$.on ta, 'change', $.cb.value $.on ta, 'change', $.cb.value
#rice #rice
(back = $ '[name=backlink]', dialog).value = conf['backlink'] (back = $ '[name=backlink]', dialog).value = conf['backlink']
(time = $ '[name=time]', dialog).value = conf['time'] (time = $ '[name=time]', dialog).value = conf['time']
(filesizeR = $ '[name=filesizeR]', dialog).value = conf['filesizeR'] (fileFormatR = $ '[name=fileFormatR]', dialog).value = conf['fileFormatR']
(filesizeT = $ '[name=filesizeT]', dialog).value = conf['filesizeT'] (fileFormatT = $ '[name=fileFormatT]', dialog).value = conf['fileFormatT']
$.on back, 'keyup', $.cb.value $.on back, 'keyup', $.cb.value
$.on back, 'keyup', options.backlink $.on back, 'keyup', options.backlink
$.on time, 'keyup', $.cb.value $.on time, 'keyup', $.cb.value
$.on time, 'keyup', options.time $.on time, 'keyup', options.time
$.on filesizeR, 'keyup', $.cb.value $.on fileFormatR, 'keyup', $.cb.value
$.on filesizeR, 'keyup', options.filesize $.on fileFormatR, 'keyup', options.fileFormat
$.on filesizeT, 'keyup', $.cb.value $.on fileFormatT, 'keyup', $.cb.value
$.on filesizeT, 'keyup', options.filesize $.on fileFormatT, 'keyup', options.fileFormat
favicon = $ 'select', dialog favicon = $ 'select', dialog
favicon.value = conf['favicon'] favicon.value = conf['favicon']
$.on favicon, 'change', $.cb.value $.on favicon, 'change', $.cb.value
@ -1818,8 +1817,8 @@ options =
options.backlink.call back options.backlink.call back
options.time.call time options.time.call time
options.filesize.call filesizeR options.fileFormat.call fileFormatR
options.filesize.call filesizeT options.fileFormat.call fileFormatT
options.favicon.call favicon options.favicon.call favicon
close: -> close: ->
@ -1846,18 +1845,14 @@ options =
$.id('timePreview').textContent = Time.funk Time $.id('timePreview').textContent = Time.funk Time
backlink: -> backlink: ->
$.id('backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789' $.id('backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
filesize: () -> fileFormat: ->
Filesize.fstype = if @name is 'filesizeR' then 0 else 1 FileFormat.data =
Filesize.getFormat() link : '<a href="javascript:;">1329791824.png</a>'
Filesize.data = { size : 996
link : '<a href="javascript:;">1329791824.png</a>', unit : 'KB'
size : 996, resolution: '1366x768'
unit : 'KB', filename : 'Untitled.png'
width : 1366, $.id("#{@name}Preview").innerHTML = FileFormat.funks[if @name is 'fileFormatR' then 0 else 1] FileFormat
height : 768
}
Filesize.data.filename = 'Untitled.png' if Filesize.fstype is 0
$.id("#{@name}Preview").innerHTML = Filesize.funk Filesize
favicon: -> favicon: ->
Favicon.switch() Favicon.switch()
unread.update true unread.update true
@ -2334,43 +2329,40 @@ Time =
P: -> if Time.date.getHours() < 12 then 'am' else 'pm' P: -> if Time.date.getHours() < 12 then 'am' else 'pm'
y: -> Time.date.getFullYear() - 2000 y: -> Time.date.getFullYear() - 2000
Filesize = FileFormat =
init: -> init: ->
Filesize.fstype = if g.REPLY then 0 else 1 return if g.BOARD is 'f'
Filesize.fsconf = [ 'filesizeR', 'filesizeT' ] FileFormat.ffConf = [ 'fileFormatR', 'fileFormatT' ]
Filesize.regEx = [ /File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+)x(\d+),\s<span\stitle=\"([^\"]+)\">/, FileFormat.ffMtrs = [ /%([BKlMnrs])/g, /%([BKlMrs])/g ]
/File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+)x(\d+)\)/ ] FileFormat.ffRgex = [ /File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF),\s<span\stitle=\"([^\"]+)\">/,
/File:\s(<a.+<\/a>)-\((?:Spoiler Image,\s)?([\d\.]+)\s([BKM]{1,2}),\s(\d+x\d+|PDF)\)/ ]
@parse = (node) -> @parse = (node) ->
[_, link, size, unit, width, height, filename] = FileFormat.ffType = if node.childNodes.length > 3 then 0 else 1
node.innerHTML.match Filesize.regEx[Filesize.fstype] [_, link, size, unit, resolution, filename] =
{ node.innerHTML.match FileFormat.ffRgex[FileFormat.ffType]
'link' : link, link : link
'size' : size, size : size
'unit' : unit, unit : unit
'width' : width, resolution: resolution
'height' : height, filename : filename
'filename': filename
}
Filesize.getFormat() FileFormat.funks = FileFormat.setFormats()
g.callbacks.push @node g.callbacks.push @node
node: (root) -> node: (root) ->
return if root.className is 'inline' or not node = $ '.filesize', root return if root.className is 'inline' or not node = $ '.filesize', root
Filesize.data = Filesize.parse node FileFormat.data = FileFormat.parse node
filesize = $.el 'span', node.innerHTML = FileFormat.funks[FileFormat.ffType](FileFormat) + ' '
className: 'filesize', setFormats: ->
innerHTML: Filesize.funk(Filesize) + ' ' for i in [0..1]
$.replace node, filesize code = conf[FileFormat.ffConf[i]].replace FileFormat.ffMtrs[i], (s, c) ->
getFormat: -> if c of FileFormat.formatters
code = conf[Filesize.fsconf[Filesize.fstype]].replace /%([BhKlMnsw])/g, (s, c) -> "' + FileFormat.formatters.#{c}() + '"
if c of Filesize.formatters else
"' + Filesize.formatters.#{c}() + '" s
else Function 'FileFormat', "return '#{code}'"
s
Filesize.funk = Function 'Filesize', "return '#{code}'"
convertUnit: (unitT) -> convertUnit: (unitT) ->
size = Filesize.data.size size = FileFormat.data.size
unitF = Filesize.data.unit unitF = FileFormat.data.unit
if unitF isnt unitT if unitF isnt unitT
units = [ 'B', 'KB', 'MB' ] units = [ 'B', 'KB', 'MB' ]
i = units.indexOf(unitF) - units.indexOf(unitT) i = units.indexOf(unitF) - units.indexOf(unitT)
@ -2383,14 +2375,16 @@ Filesize =
size = size.toFixed 2 size = size.toFixed 2
"#{size} #{unitT}" "#{size} #{unitT}"
formatters: formatters:
B: -> Filesize.convertUnit 'B' B: -> FileFormat.convertUnit 'B'
h: -> Filesize.data.height K: -> FileFormat.convertUnit 'KB'
K: -> Filesize.convertUnit 'KB' l: -> FileFormat.data.link
l: -> Filesize.data.link M: -> FileFormat.convertUnit 'MB'
M: -> Filesize.convertUnit 'MB' n: -> if (ext = FileFormat.data.filename.lastIndexOf '.') > 38
n: -> if Filesize.fstype is 0 then Filesize.data.filename else '%n' '<span class=fnfull>' + FileFormat.data.filename + '</span><span class=fntrunc>' + FileFormat.data.filename.substr(0, 32) + ' (...)' + FileFormat.data.filename.substr(ext) + '</span>'
s: -> "#{Filesize.data.size} #{Filesize.data.unit}" else
w: -> Filesize.data.width FileFormat.data.filename
r: -> FileFormat.data.resolution
s: -> "#{FileFormat.data.size} #{FileFormat.data.unit}"
getTitle = (thread) -> getTitle = (thread) ->
el = $ '.filetitle', thread el = $ '.filetitle', thread
@ -2591,8 +2585,8 @@ quotePreview =
imgGif.node qp imgGif.node qp
if conf['Time Formatting'] if conf['Time Formatting']
Time.node qp Time.node qp
if conf['Filesize Formatting'] if conf['File Info Formatting']
Filesize.node qp if id isnt threadID FileFormat.node qp if id isnt threadID
quoteIndicators = quoteIndicators =
init: -> init: ->
@ -2991,8 +2985,8 @@ Main =
if conf['Time Formatting'] if conf['Time Formatting']
Time.init() Time.init()
if conf['Filesize Formatting'] if conf['File Info Formatting']
Filesize.init() FileFormat.init()
if conf['Sauce'] if conf['Sauce']
sauce.init() sauce.init()
@ -3084,10 +3078,6 @@ Main =
nodes = $$ '.op, a + table', form nodes = $$ '.op, a + table', form
Main.node nodes, true Main.node nodes, true
if not g.REPLY and conf['Filesize Formatting']
Filesize.fstype = 0
Filesize.getFormat()
if MutationObserver = window.WebKitMutationObserver or window.MozMutationObserver or window.OMutationObserver or window.MutationObserver if MutationObserver = window.WebKitMutationObserver or window.MozMutationObserver or window.OMutationObserver or window.MutationObserver
observer = new MutationObserver Main.observer observer = new MutationObserver Main.observer
observer.observe form, observer.observe form,
@ -3353,6 +3343,12 @@ td.replyhider {
float: left; float: left;
pointer-events: none; pointer-events: none;
} }
.filesize .fnfull, .filesize:hover .fntrunc {
display: none;
}
.filesize:hover .fnfull {
display: inline;
}
img[md5], img[md5] + img { img[md5], img[md5] + img {
pointer-events: all; pointer-events: all;
} }