diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 9a6d682a1..0e8e4ecee 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5984,30 +5984,28 @@ return; } max = QR.nodes.fileInput.max; - dim.max_heigth = QR.max_heigth; - dim.max_width = QR.max_width; isSingle = files.length === 1; QR.cleanNotifications(); for (_i = 0, _len = files.length; _i < _len; _i++) { file = files[_i]; - QR.checkDimensions(file, isSingle, max, dim); + QR.checkDimensions(file, isSingle, max); } if (!isSingle) { return $.addClass(QR.nodes.el, 'dump'); } }, - checkDimensions: function(file, isSingle, max, d) { + checkDimensions: function(file, isSingle, max) { var img, _this = this; img = new Image(); img.onload = function() { var height, width; height = img.height, width = img.width; - if (height > dim.max_heigth || width > dim.max_heigth) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + d.max_heigth + "x" + d.max_width + "px)"); + 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 (height < dim.min_heigth || width < dim.min_heigth) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: " + d.min_heigth + "x" + d.min_width + "px)"); + if (height < QR.min_heigth || width < QR.min_heigth) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: " + QR.min_heigth + "x" + QR.min_width + "px)"); } return QR.handleFile(file, isSingle, max); }; @@ -6082,7 +6080,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, value, _ref; + var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, tmp_dim, value, _ref; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
") }; @@ -6118,15 +6116,17 @@ } rules = $('ul.rules').textContent.trim(); try { - min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1]; - min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2]; + tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/); + min_width = tmp_dim[1]; + min_heigth = tmp_dim[2]; } catch (_error) { min_width = 1; min_heigth = 1; } try { - max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1]; - max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2]; + tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/); + max_width = tmp_dim[1]; + max_heigth = tmp_dim[2]; } catch (_error) { QR.max_width = 5000; QR.max_heigth = 5000; diff --git a/builds/crx/script.js b/builds/crx/script.js index d2b262138..76d63a4b3 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6020,30 +6020,28 @@ return; } max = QR.nodes.fileInput.max; - dim.max_heigth = QR.max_heigth; - dim.max_width = QR.max_width; isSingle = files.length === 1; QR.cleanNotifications(); for (_i = 0, _len = files.length; _i < _len; _i++) { file = files[_i]; - QR.checkDimensions(file, isSingle, max, dim); + QR.checkDimensions(file, isSingle, max); } if (!isSingle) { return $.addClass(QR.nodes.el, 'dump'); } }, - checkDimensions: function(file, isSingle, max, d) { + checkDimensions: function(file, isSingle, max) { var img, _this = this; img = new Image(); img.onload = function() { var height, width; height = img.height, width = img.width; - if (height > dim.max_heigth || width > dim.max_heigth) { - return QR.error("" + file.name + ": Image too large (image: " + img.height + "x" + img.width + "px, max: " + d.max_heigth + "x" + d.max_width + "px)"); + 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 (height < dim.min_heigth || width < dim.min_heigth) { - return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: " + d.min_heigth + "x" + d.min_width + "px)"); + if (height < QR.min_heigth || width < QR.min_heigth) { + return QR.error("" + file.name + ": Image too small (image: " + img.height + "x" + img.width + "px, min: " + QR.min_heigth + "x" + QR.min_width + "px)"); } return QR.handleFile(file, isSingle, max); }; @@ -6118,7 +6116,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, value, _ref; + var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, tmp_dim, value, _ref; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', " ") }; @@ -6154,15 +6152,17 @@ } rules = $('ul.rules').textContent.trim(); try { - min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1]; - min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2]; + tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/); + min_width = tmp_dim[1]; + min_heigth = tmp_dim[2]; } catch (_error) { min_width = 1; min_heigth = 1; } try { - max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1]; - max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2]; + tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/); + max_width = tmp_dim[1]; + max_heigth = tmp_dim[2]; } catch (_error) { QR.max_width = 5000; QR.max_heigth = 5000; diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 8d563ebd9..37e6d821f 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -352,20 +352,18 @@ QR = @value = null return unless files.length max = QR.nodes.fileInput.max - dim.max_heigth = QR.max_heigth - dim.max_width = QR.max_width isSingle = files.length is 1 QR.cleanNotifications() for file in files - QR.checkDimensions file, isSingle, max, dim + QR.checkDimensions file, isSingle, max $.addClass QR.nodes.el, 'dump' unless isSingle - checkDimensions: (file, isSingle, max, d) -> + checkDimensions: (file, isSingle, max) -> img = new Image() img.onload = => {height, width} = img - return QR.error "#{file.name}: Image too large (image: #{img.height}x#{img.width}px, max: #{d.max_heigth}x#{d.max_width}px)" if height > dim.max_heigth or width > dim.max_heigth - return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: #{d.min_heigth}x#{d.min_width}px)" if height < dim.min_heigth or width < dim.min_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 height > QR.max_heigth or width > QR.max_heigth + return QR.error "#{file.name}: Image too small (image: #{img.height}x#{img.width}px, min: #{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 @@ -453,14 +451,16 @@ QR = rules = $('ul.rules').textContent.trim() try - min_width = rules.match(/.+smaller than (\d+)x(\d+).+/)[1] - min_heigth = rules.match(/.+smaller than (\d+)x(\d+).+/)[2] + tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/) + min_width = tmp_dim[1] + min_heigth = tmp_dim[2] catch min_width = 1 min_heigth = 1 try - max_width = rules.match(/.+greater than (\d+)x(\d+).+/)[1] - max_heigth = rules.match(/.+greater than (\d+)x(\d+).+/)[2] + tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/) + max_width = tmp_dim[1] + max_heigth = tmp_dim[2] catch QR.max_width = 5000 QR.max_heigth = 5000