move files in 'correct' order

This commit is contained in:
James Campos 2011-08-10 20:58:23 -07:00
parent 1c2a38d422
commit d294b066dc
2 changed files with 15 additions and 15 deletions

View File

@ -1237,11 +1237,11 @@
$.bind(fileDiv.lastChild, 'click', (function() { $.bind(fileDiv.lastChild, 'click', (function() {
return $.rm(this.parentNode); return $.rm(this.parentNode);
})); }));
return $.prepend(qr.files, fileDiv); return $.append($('#files', qr.el), fileDiv);
}, },
attachNext: function() { attachNext: function() {
var file, fileDiv, oldFile; var file, fileDiv, oldFile;
fileDiv = $.rm(qr.files.lastChild); fileDiv = $.rm($('#files div', qr.el));
file = fileDiv.firstChild; file = fileDiv.firstChild;
oldFile = $('#qr_form input[type=file]', qr.el); oldFile = $('#qr_form input[type=file]', qr.el);
return $.replace(oldFile, file); return $.replace(oldFile, file);
@ -1315,12 +1315,11 @@
THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id;
spoiler = $('.postarea label') ? '<label> [<input type=checkbox name=spoiler>Spoiler Image?]</label>' : ''; spoiler = $('.postarea label') ? '<label> [<input type=checkbox name=spoiler>Spoiler Image?]</label>' : '';
challenge = $('#recaptcha_challenge_field').value; challenge = $('#recaptcha_challenge_field').value;
html = " <a id=close title=close>X</a> <input type=checkbox id=autohide title=autohide> <div class=move> <input class=inputtext type=text name=name placeholder=Name form=qr_form> Quick Reply </div> <form name=post action=http://sys.4chan.org/" + g.BOARD + "/post method=POST enctype=multipart/form-data target=iframe id=qr_form> <input type=hidden name=resto value=" + THREAD_ID + "> <input type=hidden name=recaptcha_challenge_field id=recaptcha_challenge_field value=" + challenge + "> <div><input class=inputtext type=text name=email placeholder=E-mail>" + spoiler + "</div> <div><input class=inputtext type=text name=sub placeholder=Subject><input type=submit value=" + submitValue + " id=com_submit " + submitDisabled + "><label><input type=checkbox id=auto>auto</label></div> <div><textarea class=inputtext name=com placeholder=Comment></textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + challenge + "></div> <div><input class=inputtext type=text name=recaptcha_response_field placeholder=Verification required autocomplete=off id=recaptcha_response_field><span class=captcha>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input type=file name=upfile></div> <div><input class=inputtext type=password name=pwd maxlength=8 placeholder=Password><input type=hidden name=mode value=regist><a name=attach>attach another file</a></div> </form> <div id=files></div> <a id=error class=error></a> "; html = " <a id=close title=close>X</a> <input type=checkbox id=autohide title=autohide> <div class=move> <input class=inputtext type=text name=name placeholder=Name form=qr_form> Quick Reply </div> <form name=post action=http://sys.4chan.org/" + g.BOARD + "/post method=POST enctype=multipart/form-data target=iframe id=qr_form> <input type=hidden name=resto value=" + THREAD_ID + "> <input type=hidden name=recaptcha_challenge_field id=recaptcha_challenge_field value=" + challenge + "> <div><input class=inputtext type=text name=email placeholder=E-mail>" + spoiler + "</div> <div><input class=inputtext type=text name=sub placeholder=Subject><input type=submit value=" + submitValue + " id=com_submit " + submitDisabled + "><label><input type=checkbox id=auto>auto</label></div> <div><textarea class=inputtext name=com placeholder=Comment></textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + challenge + "></div> <div><input class=inputtext type=text name=recaptcha_response_field placeholder=Verification required autocomplete=off id=recaptcha_response_field><span class=captcha>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input type=file name=upfile></div> </form> <div id=files></div> <div><input class=inputtext type=password name=pwd placeholder=Password form=qr_form maxlength=8 ><input type=hidden name=mode value=regist><a name=attach>attach another file</a></div> <a id=error class=error></a> ";
qr.el = ui.dialog('qr', { qr.el = ui.dialog('qr', {
top: '0px', top: '0px',
left: '0px' left: '0px'
}, html); }, html);
qr.files = $('#files', qr.el);
qr.refresh(); qr.refresh();
$('textarea', qr.el).value = $('textarea').value; $('textarea', qr.el).value = $('textarea').value;
$.bind($('input[name=name]', qr.el), 'mousedown', function(e) { $.bind($('input[name=name]', qr.el), 'mousedown', function(e) {
@ -1336,9 +1335,10 @@
return $.append(d.body, qr.el); return $.append(d.body, qr.el);
}, },
message: function(e) { message: function(e) {
var data, duration; var data, duration, fileCount;
Recaptcha.reload(); Recaptcha.reload();
$('iframe[name=iframe]').src = 'about:blank'; $('iframe[name=iframe]').src = 'about:blank';
fileCount = $('#files', qr.el).childElementCount;
data = e.data; data = e.data;
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
@ -1347,7 +1347,7 @@
$('#autohide', qr.el).checked = false; $('#autohide', qr.el).checked = false;
if (data.textContent === 'You seem to have mistyped the verification.') { if (data.textContent === 'You seem to have mistyped the verification.') {
setTimeout(qr.autoPost, 1000); setTimeout(qr.autoPost, 1000);
} else if (data.textContent === 'Error: Duplicate file entry detected.' && qr.files.childElementCount) { } else if (data.textContent === 'Error: Duplicate file entry detected.' && fileCount) {
$('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href; $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href;
qr.attachNext(); qr.attachNext();
setTimeout(qr.autoPost, 1000); setTimeout(qr.autoPost, 1000);
@ -1355,9 +1355,9 @@
return; return;
} }
if (qr.el) { if (qr.el) {
if (g.REPLY && (conf['Persistent QR'] || qr.files.childElementCount)) { if (g.REPLY && (conf['Persistent QR'] || fileCount)) {
qr.refresh(); qr.refresh();
if (qr.files.childElementCount) { if (fileCount) {
qr.attachNext(); qr.attachNext();
} }
} else { } else {

View File

@ -979,10 +979,10 @@ qr =
fileDiv = $.el 'div', innerHTML: '<input type=file name=upfile><a>X</a>' fileDiv = $.el 'div', innerHTML: '<input type=file name=upfile><a>X</a>'
$.bind fileDiv.firstChild, 'change', qr.validateFileSize $.bind fileDiv.firstChild, 'change', qr.validateFileSize
$.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode) $.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode)
$.prepend qr.files, fileDiv $.append $('#files', qr.el), fileDiv
attachNext: -> attachNext: ->
fileDiv = $.rm qr.files.lastChild fileDiv = $.rm $('#files div', qr.el)
file = fileDiv.firstChild file = fileDiv.firstChild
oldFile = $ '#qr_form input[type=file]', qr.el oldFile = $ '#qr_form input[type=file]', qr.el
$.replace oldFile, file $.replace oldFile, file
@ -1064,13 +1064,12 @@ qr =
<div><img src=http://www.google.com/recaptcha/api/image?c=#{challenge}></div> <div><img src=http://www.google.com/recaptcha/api/image?c=#{challenge}></div>
<div><input class=inputtext type=text name=recaptcha_response_field placeholder=Verification required autocomplete=off id=recaptcha_response_field><span class=captcha>#{$.get('captchas', []).length} captchas</span></div> <div><input class=inputtext type=text name=recaptcha_response_field placeholder=Verification required autocomplete=off id=recaptcha_response_field><span class=captcha>#{$.get('captchas', []).length} captchas</span></div>
<div><input type=file name=upfile></div> <div><input type=file name=upfile></div>
<div><input class=inputtext type=password name=pwd maxlength=8 placeholder=Password><input type=hidden name=mode value=regist><a name=attach>attach another file</a></div>
</form> </form>
<div id=files></div> <div id=files></div>
<div><input class=inputtext type=password name=pwd placeholder=Password form=qr_form maxlength=8 ><input type=hidden name=mode value=regist><a name=attach>attach another file</a></div>
<a id=error class=error></a> <a id=error class=error></a>
" "
qr.el = ui.dialog 'qr', top: '0px', left: '0px', html qr.el = ui.dialog 'qr', top: '0px', left: '0px', html
qr.files = $ '#files', qr.el
qr.refresh() qr.refresh()
$('textarea', qr.el).value = $('textarea').value $('textarea', qr.el).value = $('textarea').value
@ -1089,6 +1088,7 @@ qr =
message: (e) -> message: (e) ->
Recaptcha.reload() Recaptcha.reload()
$('iframe[name=iframe]').src = 'about:blank' $('iframe[name=iframe]').src = 'about:blank'
fileCount = $('#files', qr.el).childElementCount
{data} = e {data} = e
if data # error message if data # error message
@ -1098,16 +1098,16 @@ qr =
$('#autohide', qr.el).checked = false $('#autohide', qr.el).checked = false
if data.textContent is 'You seem to have mistyped the verification.' if data.textContent is 'You seem to have mistyped the verification.'
setTimeout qr.autoPost, 1000 setTimeout qr.autoPost, 1000
else if data.textContent is 'Error: Duplicate file entry detected.' and qr.files.childElementCount else if data.textContent is 'Error: Duplicate file entry detected.' and fileCount
$('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href $('textarea', qr.el).value += '\n' + data.textContent + ' ' + data.href
qr.attachNext() qr.attachNext()
setTimeout qr.autoPost, 1000 setTimeout qr.autoPost, 1000
return return
if qr.el if qr.el
if g.REPLY and (conf['Persistent QR'] or qr.files.childElementCount) if g.REPLY and (conf['Persistent QR'] or fileCount)
qr.refresh() qr.refresh()
if qr.files.childElementCount if fileCount
qr.attachNext() qr.attachNext()
else else
qr.close() qr.close()