accepted file types
This commit is contained in:
parent
1a97a1ade8
commit
3a9160f72d
@ -1231,6 +1231,16 @@
|
||||
$.bind(window, 'message', qr.message);
|
||||
$.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode);
|
||||
qr.captchaTime = Date.now();
|
||||
qr.acceptFiles = $('.rules').textContent.match(/:(.+)/)[1].replace(/[A-Z]{3}/g, function(type) {
|
||||
switch (type) {
|
||||
case 'JPG':
|
||||
return 'image/JPEG';
|
||||
case 'PDF':
|
||||
return 'application/' + type;
|
||||
default:
|
||||
return 'image/' + type;
|
||||
}
|
||||
});
|
||||
iframe = $.el('iframe', {
|
||||
name: 'iframe',
|
||||
hidden: true
|
||||
@ -1241,7 +1251,7 @@
|
||||
attach: function() {
|
||||
var fileDiv;
|
||||
fileDiv = $.el('div', {
|
||||
innerHTML: '<input type=file name=upfile><a>X</a>'
|
||||
innerHTML: "<input type=file name=upfile accept='" + qr.acceptFiles + "'><a>X</a>"
|
||||
});
|
||||
$.bind(fileDiv.firstChild, 'change', qr.validateFileSize);
|
||||
$.bind(fileDiv.lastChild, 'click', (function() {
|
||||
@ -1304,7 +1314,7 @@
|
||||
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>' : '';
|
||||
qr.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 value='" + name + "' placeholder=Name form=qr_form> Quick Reply </div> <div class=autohide> <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> <input type=hidden name=mode value=regist> <div><input class=inputtext type=text name=email value='" + 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=" + qr.challenge + "></div> <div><input class=inputtext type=text autocomplete=off placeholder=Verification id=dummy><input type=hidden name=recaptcha_response_field id=recaptcha_response_field><span id=captchas>" + ($.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 value='" + pwd + "' placeholder=Password form=qr_form maxlength=8><a id=attach>attach another file</a></div> </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 value='" + name + "' placeholder=Name form=qr_form> Quick Reply </div> <div class=autohide> <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> <input type=hidden name=mode value=regist> <div><input class=inputtext type=text name=email value='" + 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=" + qr.challenge + "></div> <div><input class=inputtext type=text autocomplete=off placeholder=Verification id=dummy><input type=hidden name=recaptcha_response_field id=recaptcha_response_field><span id=captchas>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input type=file name=upfile accept='" + qr.acceptFiles + "'></div> </form> <div id=files></div> <div><input class=inputtext type=password name=pwd value='" + pwd + "' placeholder=Password form=qr_form maxlength=8><a id=attach>attach another file</a></div> </div> <a id=error class=error></a> ";
|
||||
qr.el = ui.dialog('qr', {
|
||||
top: '0px',
|
||||
left: '0px'
|
||||
@ -1428,7 +1438,8 @@
|
||||
oldFile = $('[type=file]', qr.el);
|
||||
newFile = $.el('input', {
|
||||
type: 'file',
|
||||
name: 'upfile'
|
||||
name: 'upfile',
|
||||
accept: qr.acceptFiles
|
||||
});
|
||||
return $.replace(oldFile, newFile);
|
||||
},
|
||||
@ -1526,7 +1537,8 @@
|
||||
}
|
||||
file = $.el('input', {
|
||||
type: 'file',
|
||||
name: 'upfile'
|
||||
name: 'upfile',
|
||||
accept: qr.acceptFiles
|
||||
});
|
||||
$.bind(file, 'change', qr.validateFileSize);
|
||||
$.replace(this, file);
|
||||
|
||||
@ -2,6 +2,7 @@ GitHub
|
||||
- mayhem:
|
||||
bring back auto posting
|
||||
don't start the cooldown on thread creation
|
||||
limit the file upload dialog to the accepted file types (qr)
|
||||
- aeosynth:
|
||||
show linebreaks as spaces in title & watcher
|
||||
auto posting fixes
|
||||
|
||||
@ -975,6 +975,15 @@ qr =
|
||||
$.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode
|
||||
qr.captchaTime = Date.now()
|
||||
|
||||
qr.acceptFiles = $('.rules').textContent.match(/:(.+)/)[1].replace /[A-Z]{3}/g, (type) ->
|
||||
switch type
|
||||
when 'JPG'
|
||||
'image/JPEG'
|
||||
when 'PDF'
|
||||
'application/' + type
|
||||
else
|
||||
'image/' + type
|
||||
|
||||
iframe = $.el 'iframe',
|
||||
name: 'iframe'
|
||||
hidden: true
|
||||
@ -984,7 +993,7 @@ qr =
|
||||
$('#recaptcha_response_field').id = ''
|
||||
|
||||
attach: ->
|
||||
fileDiv = $.el 'div', innerHTML: '<input type=file name=upfile><a>X</a>'
|
||||
fileDiv = $.el 'div', innerHTML: "<input type=file name=upfile accept='#{qr.acceptFiles}'><a>X</a>"
|
||||
$.bind fileDiv.firstChild, 'change', qr.validateFileSize
|
||||
$.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode)
|
||||
$.append $('#files', qr.el), fileDiv
|
||||
@ -1055,7 +1064,7 @@ qr =
|
||||
<div><textarea class=inputtext name=com placeholder=Comment></textarea></div>
|
||||
<div><img src=http://www.google.com/recaptcha/api/image?c=#{qr.challenge}></div>
|
||||
<div><input class=inputtext type=text autocomplete=off placeholder=Verification id=dummy><input type=hidden name=recaptcha_response_field id=recaptcha_response_field><span id=captchas>#{$.get('captchas', []).length} captchas</span></div>
|
||||
<div><input type=file name=upfile></div>
|
||||
<div><input type=file name=upfile accept='#{qr.acceptFiles}'></div>
|
||||
</form>
|
||||
<div id=files></div>
|
||||
<div><input class=inputtext type=password name=pwd value='#{pwd}' placeholder=Password form=qr_form maxlength=8><a id=attach>attach another file</a></div>
|
||||
@ -1169,7 +1178,7 @@ qr =
|
||||
$('[name=recaptcha_response_field]', qr.el).value = ''
|
||||
# XXX opera doesn't allow resetting file inputs w/ file.value = ''
|
||||
oldFile = $ '[type=file]', qr.el
|
||||
newFile = $.el 'input', type: 'file', name: 'upfile'
|
||||
newFile = $.el 'input', type: 'file', name: 'upfile', accept: qr.acceptFiles
|
||||
$.replace oldFile, newFile
|
||||
|
||||
submit: (e) ->
|
||||
@ -1247,7 +1256,7 @@ qr =
|
||||
validateFileSize: (e) ->
|
||||
return unless @files[0].size > $('input[name=MAX_FILE_SIZE]').value
|
||||
|
||||
file = $.el 'input', type: 'file', name: 'upfile'
|
||||
file = $.el 'input', type: 'file', name: 'upfile', accept: qr.acceptFiles
|
||||
$.bind file, 'change', qr.validateFileSize
|
||||
$.replace @, file
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user