diff --git a/4chan_x.user.js b/4chan_x.user.js
index 81b42fc7a..78b7e2441 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -1227,7 +1227,7 @@
};
QR = {
init: function() {
- var holder;
+ var accept, holder;
g.callbacks.push(function(root) {
var quote;
quote = $('a.quotejs + a', root);
@@ -1244,6 +1244,17 @@
QR.captchaNode({
target: holder.firstChild
});
+ accept = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) {
+ switch (type) {
+ case 'JPG':
+ return 'image/JPEG';
+ case 'PDF':
+ return 'application/' + type;
+ default:
+ return 'image/' + type;
+ }
+ });
+ QR.accept = "'" + accept + "'";
if (conf['Persistent QR']) {
QR.dialog();
if (conf['Auto Hide QR']) {
@@ -1255,7 +1266,7 @@
var div, file;
$('#auto', QR.el).checked = true;
div = $.el('div', {
- innerHTML: 'X'
+ innerHTML: "X"
});
file = $('input', div);
$.bind(file, 'change', QR.change);
@@ -1273,7 +1284,8 @@
} else {
file = $.el('input', {
type: 'file',
- name: 'upfile'
+ name: 'upfile',
+ accept: QR.accept
});
}
return $.replace(oldFile, file);
@@ -1358,7 +1370,7 @@
QR.el = el = ui.dialog('qr', {
top: '0',
left: '0'
- }, " X
Quick Reply
");
+ }, " X Quick Reply
");
if (conf['Cooldown']) {
QR.cooldown;
}
diff --git a/script.coffee b/script.coffee
index 59e3de7af..cf942d472 100644
--- a/script.coffee
+++ b/script.coffee
@@ -975,6 +975,15 @@ QR =
holder = $ '#recaptcha_challenge_field_holder'
$.bind holder, 'DOMNodeInserted', QR.captchaNode
QR.captchaNode target: holder.firstChild
+ accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) ->
+ switch type
+ when 'JPG'
+ 'image/JPEG'
+ when 'PDF'
+ 'application/' + type
+ else
+ 'image/' + type
+ QR.accept = "'#{accept}'"
if conf['Persistent QR']
QR.dialog()
if conf['Auto Hide QR']
@@ -982,7 +991,7 @@ QR =
attach: ->
$('#auto', QR.el).checked = true
div = $.el 'div',
- innerHTML: 'X'
+ innerHTML: "X"
file = $ 'input', div
$.bind file, 'change', QR.change
$.bind $('a', div), 'click', -> $.rm @parentNode
@@ -996,6 +1005,7 @@ QR =
file = $.el 'input',
type: 'file'
name: 'upfile'
+ accept: QR.accept
$.replace oldFile, file
autoPost: ->
return unless QR.hasContent()
@@ -1060,7 +1070,7 @@ QR =
#{$.get('captchas', []).length} captchas
-
+