Less indexOf.

This commit is contained in:
Nicolas Stepien 2013-02-22 03:47:10 +01:00
parent 5851a1cb29
commit 558c5a68dc
2 changed files with 10 additions and 10 deletions

View File

@ -5823,14 +5823,14 @@
return $.addClass(QR.el, 'dump'); return $.addClass(QR.el, 'dump');
}, },
fileInput: function() { fileInput: function() {
var file, _i, _len, _ref; var file, _i, _len, _ref, _ref1, _ref2;
QR.cleanNotifications(); QR.cleanNotifications();
if (this.files.length === 1) { if (this.files.length === 1) {
file = this.files[0]; file = this.files[0];
if (file.size > this.max) { if (file.size > this.max) {
QR.error("File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ")."); QR.error("File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ").");
QR.resetFileInput(); QR.resetFileInput();
} else if (-1 === QR.mimeTypes.indexOf(file.type)) { } else if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
QR.error('Unsupported file type.'); QR.error('Unsupported file type.');
QR.resetFileInput(); QR.resetFileInput();
} else { } else {
@ -5838,12 +5838,12 @@
} }
return; return;
} }
_ref = this.files; _ref1 = this.files;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
file = _ref[_i]; file = _ref1[_i];
if (file.size > this.max) { if (file.size > this.max) {
QR.error("File " + file.name + " is too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ")."); QR.error("File " + file.name + " is too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ").");
} else if (-1 === QR.mimeTypes.indexOf(file.type)) { } else if (_ref2 = file.type, __indexOf.call(QR.mimeTypes, _ref2) < 0) {
QR.error("" + file.name + ": Unsupported file type."); QR.error("" + file.name + ": Unsupported file type.");
} }
if (!QR.replies[QR.replies.length - 1].file) { if (!QR.replies[QR.replies.length - 1].file) {
@ -6054,7 +6054,7 @@
captcha: { captcha: {
init: function() { init: function() {
var _this = this; var _this = this;
if (-1 !== d.cookie.indexOf('pass_enabled=')) { if (__indexOf.call(d.cookie, 'pass_enabled=') < 0) {
return; return;
} }
if (!(this.isEnabled = !!$.id('captchaFormPart'))) { if (!(this.isEnabled = !!$.id('captchaFormPart'))) {

View File

@ -291,7 +291,7 @@ QR =
if file.size > @max if file.size > @max
QR.error "File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})." QR.error "File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})."
QR.resetFileInput() QR.resetFileInput()
else if -1 is QR.mimeTypes.indexOf file.type else unless file.type in QR.mimeTypes
QR.error 'Unsupported file type.' QR.error 'Unsupported file type.'
QR.resetFileInput() QR.resetFileInput()
else else
@ -301,7 +301,7 @@ QR =
for file in @files for file in @files
if file.size > @max if file.size > @max
QR.error "File #{file.name} is too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})." QR.error "File #{file.name} is too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})."
else if -1 is QR.mimeTypes.indexOf file.type else unless file.type in QR.mimeTypes
QR.error "#{file.name}: Unsupported file type." QR.error "#{file.name}: Unsupported file type."
unless QR.replies[QR.replies.length - 1].file unless QR.replies[QR.replies.length - 1].file
# set last reply's file # set last reply's file
@ -456,7 +456,7 @@ QR =
captcha: captcha:
init: -> init: ->
return if -1 isnt d.cookie.indexOf 'pass_enabled=' return unless 'pass_enabled=' in d.cookie
return unless @isEnabled = !!$.id 'captchaFormPart' return unless @isEnabled = !!$.id 'captchaFormPart'
if $.id 'recaptcha_challenge_field_holder' if $.id 'recaptcha_challenge_field_holder'
@ready() @ready()