QR.file
This commit is contained in:
parent
8d5c282110
commit
f096221f2f
@ -1254,6 +1254,7 @@
|
|||||||
QR.accept = "'" + accept + "'";
|
QR.accept = "'" + accept + "'";
|
||||||
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value;
|
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value;
|
||||||
QR.spoiler = $('.postarea label') ? ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' : '';
|
QR.spoiler = $('.postarea label') ? ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' : '';
|
||||||
|
QR.file = "<input type=file name=upfile accept=" + QR.accept + ">";
|
||||||
if (conf['Persistent QR']) {
|
if (conf['Persistent QR']) {
|
||||||
QR.dialog();
|
QR.dialog();
|
||||||
if (conf['Auto Hide QR']) {
|
if (conf['Auto Hide QR']) {
|
||||||
@ -1270,7 +1271,7 @@
|
|||||||
var div, file;
|
var div, file;
|
||||||
$('#auto', QR.qr).checked = true;
|
$('#auto', QR.qr).checked = true;
|
||||||
div = $.el('div', {
|
div = $.el('div', {
|
||||||
innerHTML: "<input name=upfile type=file accept=" + QR.accept + "><a class=close>X</a>"
|
innerHTML: "" + QR.file + "<a class=close>X</a>"
|
||||||
});
|
});
|
||||||
file = $('input', div);
|
file = $('input', div);
|
||||||
$.bind(file, 'change', QR.change);
|
$.bind(file, 'change', QR.change);
|
||||||
@ -1281,18 +1282,14 @@
|
|||||||
return file.click();
|
return file.click();
|
||||||
},
|
},
|
||||||
attachNext: function() {
|
attachNext: function() {
|
||||||
var file, oldFile;
|
var file, old;
|
||||||
oldFile = $('[type=file]', QR.qr);
|
old = $('[type=file]', QR.qr);
|
||||||
if (file = $('#files input', QR.qr)) {
|
if (file = $('#files input', QR.qr)) {
|
||||||
$.rm(file.parentNode);
|
$.rm(file.parentNode);
|
||||||
|
return $.replace(old, file);
|
||||||
} else {
|
} else {
|
||||||
file = $.el('input', {
|
return $.refreshFile(old);
|
||||||
type: 'file',
|
|
||||||
name: 'upfile',
|
|
||||||
accept: QR.accept
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return $.replace(oldFile, file);
|
|
||||||
},
|
},
|
||||||
captchaNode: function(e) {
|
captchaNode: function(e) {
|
||||||
var c;
|
var c;
|
||||||
@ -1329,14 +1326,25 @@
|
|||||||
$('#cl', QR.qr).textContent = captchas.length + ' captchas';
|
$('#cl', QR.qr).textContent = captchas.length + ' captchas';
|
||||||
return captcha;
|
return captcha;
|
||||||
},
|
},
|
||||||
change: function() {
|
change: function(e) {
|
||||||
if (this.files[0].size > QR.MAX_FILE_SIZE) {
|
if (!(this.files[0].size > QR.MAX_FILE_SIZE)) {
|
||||||
alert('Error: File too large.');
|
return;
|
||||||
return this.click();
|
|
||||||
} else {
|
|
||||||
$.unbind(this, 'change', QR.change);
|
|
||||||
return QR.attach();
|
|
||||||
}
|
}
|
||||||
|
alert('Error: File too large.');
|
||||||
|
return QR.refreshFile(this);
|
||||||
|
},
|
||||||
|
refreshFile: function(old) {
|
||||||
|
var div, file;
|
||||||
|
div = $.el('div', {
|
||||||
|
innerHTML: QR.file
|
||||||
|
});
|
||||||
|
file = div.firstChild;
|
||||||
|
$.bind(file, 'change', QR.change);
|
||||||
|
return $.replace(old, file);
|
||||||
|
},
|
||||||
|
change1: function() {
|
||||||
|
$.unbind(this, 'change', QR.change);
|
||||||
|
return QR.attach();
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
$.rm(QR.qr);
|
$.rm(QR.qr);
|
||||||
@ -1375,7 +1383,7 @@
|
|||||||
QR.qr = qr = ui.dialog('qr', {
|
QR.qr = qr = ui.dialog('qr', {
|
||||||
top: '0',
|
top: '0',
|
||||||
left: '0'
|
left: '0'
|
||||||
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form class=inputtext>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + tid + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email class=inputtext>" + QR.spoiler + "</div> <div><input placeholder=Subject name=sub class=inputtext><button>Submit</button><label>auto<input id=auto type=checkbox></label></div> <div><textarea placeholder=Comment name=com class=inputtext></textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field class=inputtext><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input name=upfile type=file accept=" + QR.accept + "></div> </form> <div id=files></div> <div><input placeholder=Password name=pwd type=password class=inputtext><a id=attach>attach another file</a></div> <a class=error></a> ");
|
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form class=inputtext>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + tid + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email class=inputtext>" + QR.spoiler + "</div> <div><input placeholder=Subject name=sub class=inputtext><button>Submit</button><label>auto<input id=auto type=checkbox></label></div> <div><textarea placeholder=Comment name=com class=inputtext></textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field class=inputtext><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div>" + QR.file + "</div> </form> <div id=files></div> <div><input placeholder=Password name=pwd type=password class=inputtext><a id=attach>attach another file</a></div> <a class=error></a> ");
|
||||||
c = d.cookie;
|
c = d.cookie;
|
||||||
$('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
|
$('[name=name]', qr).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
|
||||||
$('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
|
$('[name=email]', qr).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
|
||||||
|
|||||||
@ -987,6 +987,7 @@ QR =
|
|||||||
QR.accept = "'#{accept}'"
|
QR.accept = "'#{accept}'"
|
||||||
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value
|
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value
|
||||||
QR.spoiler = if $('.postarea label') then ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' else ''
|
QR.spoiler = if $('.postarea label') then ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' else ''
|
||||||
|
QR.file = "<input type=file name=upfile accept=#{QR.accept}>"
|
||||||
if conf['Persistent QR']
|
if conf['Persistent QR']
|
||||||
QR.dialog()
|
QR.dialog()
|
||||||
if conf['Auto Hide QR']
|
if conf['Auto Hide QR']
|
||||||
@ -998,22 +999,19 @@ QR =
|
|||||||
attach: ->
|
attach: ->
|
||||||
$('#auto', QR.qr).checked = true
|
$('#auto', QR.qr).checked = true
|
||||||
div = $.el 'div',
|
div = $.el 'div',
|
||||||
innerHTML: "<input name=upfile type=file accept=#{QR.accept}><a class=close>X</a>"
|
innerHTML: "#{QR.file}<a class=close>X</a>"
|
||||||
file = $ 'input', div
|
file = $ 'input', div
|
||||||
$.bind file, 'change', QR.change
|
$.bind file, 'change', QR.change
|
||||||
$.bind $('a', div), 'click', -> $.rm @parentNode
|
$.bind $('a', div), 'click', -> $.rm @parentNode
|
||||||
$.append $('#files', QR.qr), div
|
$.append $('#files', QR.qr), div
|
||||||
file.click()
|
file.click()
|
||||||
attachNext: ->
|
attachNext: ->
|
||||||
oldFile = $ '[type=file]', QR.qr
|
old = $ '[type=file]', QR.qr
|
||||||
if file = $ '#files input', QR.qr
|
if file = $ '#files input', QR.qr
|
||||||
$.rm file.parentNode
|
$.rm file.parentNode
|
||||||
|
$.replace old, file
|
||||||
else
|
else
|
||||||
file = $.el 'input',
|
$.refreshFile old
|
||||||
type: 'file'
|
|
||||||
name: 'upfile'
|
|
||||||
accept: QR.accept
|
|
||||||
$.replace oldFile, file
|
|
||||||
captchaNode: (e) ->
|
captchaNode: (e) ->
|
||||||
c = e.target.value
|
c = e.target.value
|
||||||
$('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr
|
$('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr
|
||||||
@ -1038,13 +1036,19 @@ QR =
|
|||||||
$.set 'captchas', captchas
|
$.set 'captchas', captchas
|
||||||
$('#cl', QR.qr).textContent = captchas.length + ' captchas'
|
$('#cl', QR.qr).textContent = captchas.length + ' captchas'
|
||||||
captcha
|
captcha
|
||||||
change: ->
|
change: (e) ->
|
||||||
if @files[0].size > QR.MAX_FILE_SIZE
|
return unless @files[0].size > QR.MAX_FILE_SIZE
|
||||||
alert 'Error: File too large.'
|
alert 'Error: File too large.'
|
||||||
@.click()
|
QR.refreshFile @
|
||||||
else
|
refreshFile: (old) ->
|
||||||
$.unbind @, 'change', QR.change
|
div = $.el 'div'
|
||||||
QR.attach()
|
innerHTML: QR.file
|
||||||
|
file = div.firstChild
|
||||||
|
$.bind file, 'change', QR.change
|
||||||
|
$.replace old, file
|
||||||
|
change1: ->
|
||||||
|
$.unbind @, 'change', QR.change
|
||||||
|
QR.attach()
|
||||||
close: ->
|
close: ->
|
||||||
$.rm QR.qr
|
$.rm QR.qr
|
||||||
QR.qr = null
|
QR.qr = null
|
||||||
@ -1078,7 +1082,7 @@ QR =
|
|||||||
<div><textarea placeholder=Comment name=com class=inputtext></textarea></div>
|
<div><textarea placeholder=Comment name=com class=inputtext></textarea></div>
|
||||||
<div><img src=http://www.google.com/recaptcha/api/image?c=#{QR.captcha.challenge}></div>
|
<div><img src=http://www.google.com/recaptcha/api/image?c=#{QR.captcha.challenge}></div>
|
||||||
<div><input placeholder=Verification autocomplete=off id=recaptcha_response_field class=inputtext><span id=cl>#{$.get('captchas', []).length} captchas</span></div>
|
<div><input placeholder=Verification autocomplete=off id=recaptcha_response_field class=inputtext><span id=cl>#{$.get('captchas', []).length} captchas</span></div>
|
||||||
<div><input name=upfile type=file accept=#{QR.accept}></div>
|
<div>#{QR.file}</div>
|
||||||
</form>
|
</form>
|
||||||
<div id=files></div>
|
<div id=files></div>
|
||||||
<div><input placeholder=Password name=pwd type=password class=inputtext><a id=attach>attach another file</a></div>
|
<div><input placeholder=Password name=pwd type=password class=inputtext><a id=attach>attach another file</a></div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user