diff --git a/LICENSE b/LICENSE index b29bc0147..62139460f 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.4.0 - 2014-02-27 +* 4chan X - Version 1.4.0 - 2014-02-28 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f845c5ac4..8d725b802 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.4.0 - 2014-02-27 +* 4chan X - Version 1.4.0 - 2014-02-28 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -6001,28 +6001,11 @@ img.onload = function() { var height, width; height = img.height, width = img.width; - if (g.BOARD.ID === 'hr') { - if (height > 10000 || width > 10000) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 10000x10000px"); - } + if (height > QR.max_heigth || width > QR.max_heigth) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); } - if (g.BOARD.ID === 'hr') { - if (height < 1000 || width < 1000) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 1000x1000px"); - } - } - if (g.BOARD.ID === 'wg') { - if (height < 480 || width < 600) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); - } - } - if (g.BOARD.ID === 'w') { - if (height < 480 || width < 600) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); - } - } - if (height > 5000 || width > 5000) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 5000x5000px"); + if (height < QR.min_heigth || width < QR.min_heigth) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, max: " + QR.min_heigth + "x" + QR.min_width + "px)"); } return QR.handleFile(file, isSingle, max); }; @@ -6097,7 +6080,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, name, node, nodes, save, value, _ref; + var dialog, elm, event, i, items, key, name, node, nodes, rules, save, value, _ref; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
×
+
No selected file
") }; @@ -6131,6 +6114,27 @@ value = _ref[key]; nodes[key] = $(value, dialog); } + rules = $('ul.rules').textContent.trim(); + try { + QR.min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1]; + } catch (_error) { + QR.min_width = 1; + } + try { + QR.min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2]; + } catch (_error) { + QR.min_heigth = 1; + } + try { + QR.max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1]; + } catch (_error) { + QR.max_width = 5000; + } + try { + QR.max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2]; + } catch (_error) { + QR.max_heigth = 5000; + } nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = !!$('input[name=spoiler]'); if (QR.spoiler) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 207a6b88f..f6180ee86 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.4.0 - 2014-02-27 +* 4chan X - Version 1.4.0 - 2014-02-28 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -6037,28 +6037,11 @@ img.onload = function() { var height, width; height = img.height, width = img.width; - if (g.BOARD.ID === 'hr') { - if (height > 10000 || width > 10000) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 10000x10000px"); - } + if (height > QR.max_heigth || width > QR.max_heigth) { + return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + QR.max_heigth + "x" + QR.max_width + "px)"); } - if (g.BOARD.ID === 'hr') { - if (height < 1000 || width < 1000) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 1000x1000px"); - } - } - if (g.BOARD.ID === 'wg') { - if (height < 480 || width < 600) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); - } - } - if (g.BOARD.ID === 'w') { - if (height < 480 || width < 600) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: 480x600px"); - } - } - if (height > 5000 || width > 5000) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: 5000x5000px"); + if (height < QR.min_heigth || width < QR.min_heigth) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, max: " + QR.min_heigth + "x" + QR.min_width + "px)"); } return QR.handleFile(file, isSingle, max); }; @@ -6133,7 +6116,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, name, node, nodes, save, value, _ref; + var dialog, elm, event, i, items, key, name, node, nodes, rules, save, value, _ref; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
×
+
No selected file
") }; @@ -6167,6 +6150,27 @@ value = _ref[key]; nodes[key] = $(value, dialog); } + rules = $('ul.rules').textContent.trim(); + try { + QR.min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1]; + } catch (_error) { + QR.min_width = 1; + } + try { + QR.min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2]; + } catch (_error) { + QR.min_heigth = 1; + } + try { + QR.max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1]; + } catch (_error) { + QR.max_width = 5000; + } + try { + QR.max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2]; + } catch (_error) { + QR.max_heigth = 5000; + } nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = !!$('input[name=spoiler]'); if (QR.spoiler) { diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index a05f72c2c..2750446fa 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -362,15 +362,8 @@ QR = img = new Image() img.onload = => {height, width} = img - if g.BOARD.ID is 'hr' - return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: 10000x10000px" if height > 10000 or width > 10000 - if g.BOARD.ID is 'hr' - return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 1000x1000px" if height < 1000 or width < 1000 - if g.BOARD.ID is 'wg' - return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 480x600px" if height < 480 or width < 600 - if g.BOARD.ID is 'w' - return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: 480x600px" if height < 480 or width < 600 - return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: 5000x5000px" if height > 5000 or width > 5000 + return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: #{QR.max_heigth}x#{QR.max_width}px)" if height > QR.max_heigth or width > QR.max_heigth + return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, max: #{QR.min_heigth}x#{QR.min_width}px)" if height < QR.min_heigth or width < QR.min_heigth QR.handleFile file, isSingle, max img.src = URL.createObjectURL file @@ -455,6 +448,24 @@ QR = status: '[type=submit]' fileInput: '[type=file]' } + + rules = $('ul.rules').textContent.trim() + try + QR.min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1] + catch + QR.min_width = 1 + try + QR.min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2] + catch + QR.min_heigth = 1 + try + QR.max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1] + catch + QR.max_width = 5000 + try + QR.max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2] + catch + QR.max_heigth = 5000 nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value