reset file

This commit is contained in:
James Campos 2011-09-02 22:20:23 -07:00
parent 3a939f81ec
commit c35f959f42
2 changed files with 20 additions and 8 deletions

View File

@ -1388,13 +1388,13 @@
return ta.focus();
},
receive: function(e) {
var data;
var data, file;
data = e.data;
if (data) {
return $.extend($('a.error', QR.el), JSON.parse(data));
} else {
if (conf['Persistent QR']) {
QR.reset();
if (((file = $('#files input', QR.el)) && file.files.length) || conf['Persistent QR']) {
QR.reset(file);
} else {
QR.close();
}
@ -1405,8 +1405,15 @@
}
}
},
reset: function() {
return $('textarea', QR.el).value = '';
reset: function(file) {
var oldFile;
$('textarea', QR.el).value = '';
oldFile = $('[type=file]', QR.el);
file || (file = $.el('input', {
type: 'file',
name: 'upfile'
}));
return $.replace(oldFile, file);
},
submit: function(e) {
var captcha, challenge, el, response;

View File

@ -1091,16 +1091,21 @@ QR =
if data
$.extend $('a.error', QR.el), JSON.parse data
else
if conf['Persistent QR']
QR.reset()
if ((file = $('#files input', QR.el)) and file.files.length) or conf['Persistent QR']
QR.reset file
else
QR.close()
if conf['Cooldown']
cooldown = Date.now() + 30*SECOND
$.set "cooldown/#{g.BOARD}", cooldown
QR.cooldown()
reset: ->
reset: (file) ->
$('textarea', QR.el).value = ''
oldFile = $ '[type=file]', QR.el
file or= $.el 'input',
type: 'file'
name: 'upfile'
$.replace oldFile, file
submit: (e) ->
#XXX e is undefined if we're called from QR.autoPost
$('.error', qr.el).textContent = ''