better attachNext & co
This commit is contained in:
parent
4f6c79a371
commit
796e383654
@ -1265,13 +1265,17 @@
|
|||||||
$.append($('#files', QR.el), div);
|
$.append($('#files', QR.el), div);
|
||||||
return file.click();
|
return file.click();
|
||||||
},
|
},
|
||||||
attachNext: function(file) {
|
attachNext: function() {
|
||||||
var oldFile;
|
var file, oldFile;
|
||||||
oldFile = $('[type=file]', QR.el);
|
oldFile = $('[type=file]', QR.el);
|
||||||
file || (file = $.el('input', {
|
if (file = $('#files input', QR.el)) {
|
||||||
type: 'file',
|
$.rm(file.parentNode);
|
||||||
name: 'upfile'
|
} else {
|
||||||
}));
|
file = $.el('input', {
|
||||||
|
type: 'file',
|
||||||
|
name: 'upfile'
|
||||||
|
});
|
||||||
|
}
|
||||||
return $.replace(oldFile, file);
|
return $.replace(oldFile, file);
|
||||||
},
|
},
|
||||||
autoPost: function() {
|
autoPost: function() {
|
||||||
@ -1396,7 +1400,7 @@
|
|||||||
return ta.focus();
|
return ta.focus();
|
||||||
},
|
},
|
||||||
receive: function(e) {
|
receive: function(e) {
|
||||||
var data, file, tc;
|
var data, tc, _ref;
|
||||||
data = e.data;
|
data = e.data;
|
||||||
if (data) {
|
if (data) {
|
||||||
$.extend($('a.error', QR.el), JSON.parse(data));
|
$.extend($('a.error', QR.el), JSON.parse(data));
|
||||||
@ -1406,8 +1410,8 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) {
|
if (conf['Persistent QR'] || ((_ref = $('#files input', QR.el)) != null ? _ref.files.length : void 0)) {
|
||||||
QR.reset(file);
|
QR.reset();
|
||||||
} else {
|
} else {
|
||||||
QR.close();
|
QR.close();
|
||||||
}
|
}
|
||||||
@ -1417,9 +1421,9 @@
|
|||||||
return QR.cooldown();
|
return QR.cooldown();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset: function(file) {
|
reset: function() {
|
||||||
$('textarea', QR.el).value = '';
|
$('textarea', QR.el).value = '';
|
||||||
return QR.attachNext(file);
|
return QR.attachNext();
|
||||||
},
|
},
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var captcha, challenge, el, response;
|
var captcha, challenge, el, response;
|
||||||
|
|||||||
@ -988,11 +988,14 @@ QR =
|
|||||||
$.bind $('a', div), 'click', -> $.rm @parentNode
|
$.bind $('a', div), 'click', -> $.rm @parentNode
|
||||||
$.append $('#files', QR.el), div
|
$.append $('#files', QR.el), div
|
||||||
file.click()
|
file.click()
|
||||||
attachNext: (file) ->
|
attachNext: ->
|
||||||
oldFile = $ '[type=file]', QR.el
|
oldFile = $ '[type=file]', QR.el
|
||||||
file or= $.el 'input',
|
if file = $ '#files input', QR.el
|
||||||
type: 'file'
|
$.rm file.parentNode
|
||||||
name: 'upfile'
|
else
|
||||||
|
file = $.el 'input',
|
||||||
|
type: 'file'
|
||||||
|
name: 'upfile'
|
||||||
$.replace oldFile, file
|
$.replace oldFile, file
|
||||||
autoPost: ->
|
autoPost: ->
|
||||||
return unless QR.hasContent()
|
return unless QR.hasContent()
|
||||||
@ -1099,17 +1102,17 @@ QR =
|
|||||||
if tc is 'Error: Duplicate file entry detected.'
|
if tc is 'Error: Duplicate file entry detected.'
|
||||||
QR.attachNext()
|
QR.attachNext()
|
||||||
return
|
return
|
||||||
if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR']
|
if conf['Persistent QR'] or $('#files input', QR.el)?.files.length
|
||||||
QR.reset file
|
QR.reset()
|
||||||
else
|
else
|
||||||
QR.close()
|
QR.close()
|
||||||
if conf['Cooldown']
|
if conf['Cooldown']
|
||||||
cooldown = Date.now() + 30*SECOND
|
cooldown = Date.now() + 30*SECOND
|
||||||
$.set "cooldown/#{g.BOARD}", cooldown
|
$.set "cooldown/#{g.BOARD}", cooldown
|
||||||
QR.cooldown()
|
QR.cooldown()
|
||||||
reset: (file) ->
|
reset: ->
|
||||||
$('textarea', QR.el).value = ''
|
$('textarea', QR.el).value = ''
|
||||||
QR.attachNext file
|
QR.attachNext()
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
#XXX e is undefined if we're called from QR.autoPost
|
#XXX e is undefined if we're called from QR.autoPost
|
||||||
$('.error', qr.el).textContent = ''
|
$('.error', qr.el).textContent = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user