shuffle
This commit is contained in:
parent
ad24caf366
commit
32dfad4da1
@ -1250,6 +1250,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
attach: function() {
|
||||||
|
var div;
|
||||||
|
div = $.el('div', {
|
||||||
|
innerHTML: '<input name=upfile type=file><a class=close>X</a>'
|
||||||
|
});
|
||||||
|
$.bind($('input', div), 'change', QR.change);
|
||||||
|
$.bind($('a', div), 'click', function() {
|
||||||
|
return $.rm(this.parentNode);
|
||||||
|
});
|
||||||
|
return $.append($('#files', QR.el), div);
|
||||||
|
},
|
||||||
|
autoPost: function() {
|
||||||
|
if (!QR.hasContent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return QR.submit();
|
||||||
|
},
|
||||||
captchaNode: function(e) {
|
captchaNode: function(e) {
|
||||||
var c;
|
var c;
|
||||||
c = e.target.value;
|
c = e.target.value;
|
||||||
@ -1282,10 +1299,39 @@
|
|||||||
$.set('captchas', captchas);
|
$.set('captchas', captchas);
|
||||||
return captcha;
|
return captcha;
|
||||||
},
|
},
|
||||||
|
change: function() {
|
||||||
|
$.unbind(this, 'change', QR.change);
|
||||||
|
return QR.attach();
|
||||||
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
$.rm(QR.el);
|
$.rm(QR.el);
|
||||||
return QR.el = null;
|
return QR.el = null;
|
||||||
},
|
},
|
||||||
|
cooldown: function() {
|
||||||
|
var b, n, now;
|
||||||
|
if (!QR.el) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cooldown = $.get("cooldown/" + g.BOARD, 0);
|
||||||
|
now = Date.now();
|
||||||
|
n = Math.ceil((cooldown - now) / 1000);
|
||||||
|
b = $('button', QR.el);
|
||||||
|
if (n > 0) {
|
||||||
|
$.extend(b, {
|
||||||
|
textContent: n,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
return setTimeout(QR.cooldown, 1000);
|
||||||
|
} else {
|
||||||
|
$.extend(b, {
|
||||||
|
textContent: 'Submit',
|
||||||
|
disabled: false
|
||||||
|
});
|
||||||
|
if ($('#auto', QR.el).checked) {
|
||||||
|
return QR.autoPost();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
dialog: function(text) {
|
dialog: function(text) {
|
||||||
var el, l, ta;
|
var el, l, ta;
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
@ -1308,30 +1354,9 @@
|
|||||||
ta.setSelectionRange(l, l);
|
ta.setSelectionRange(l, l);
|
||||||
return ta.focus();
|
return ta.focus();
|
||||||
},
|
},
|
||||||
change: function() {
|
|
||||||
$.unbind(this, 'change', QR.change);
|
|
||||||
return QR.attach();
|
|
||||||
},
|
|
||||||
attach: function() {
|
|
||||||
var div;
|
|
||||||
div = $.el('div', {
|
|
||||||
innerHTML: '<input name=upfile type=file><a class=close>X</a>'
|
|
||||||
});
|
|
||||||
$.bind($('input', div), 'change', QR.change);
|
|
||||||
$.bind($('a', div), 'click', function() {
|
|
||||||
return $.rm(this.parentNode);
|
|
||||||
});
|
|
||||||
return $.append($('#files', QR.el), div);
|
|
||||||
},
|
|
||||||
hasContent: function() {
|
hasContent: function() {
|
||||||
return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length;
|
return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length;
|
||||||
},
|
},
|
||||||
autoPost: function() {
|
|
||||||
if (!QR.hasContent()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return QR.submit();
|
|
||||||
},
|
|
||||||
keydown: function(e) {
|
keydown: function(e) {
|
||||||
if (!(e.keyCode === 13 && this.value)) {
|
if (!(e.keyCode === 13 && this.value)) {
|
||||||
return;
|
return;
|
||||||
@ -1358,34 +1383,6 @@
|
|||||||
ta.setSelectionRange(i, i);
|
ta.setSelectionRange(i, i);
|
||||||
return ta.focus();
|
return ta.focus();
|
||||||
},
|
},
|
||||||
cooldown: function() {
|
|
||||||
var b, n, now;
|
|
||||||
if (!QR.el) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cooldown = $.get("cooldown/" + g.BOARD, 0);
|
|
||||||
now = Date.now();
|
|
||||||
n = Math.ceil((cooldown - now) / 1000);
|
|
||||||
b = $('button', QR.el);
|
|
||||||
if (n > 0) {
|
|
||||||
$.extend(b, {
|
|
||||||
textContent: n,
|
|
||||||
disabled: true
|
|
||||||
});
|
|
||||||
return setTimeout(QR.cooldown, 1000);
|
|
||||||
} else {
|
|
||||||
$.extend(b, {
|
|
||||||
textContent: 'Submit',
|
|
||||||
disabled: false
|
|
||||||
});
|
|
||||||
if ($('#auto', QR.el).checked) {
|
|
||||||
return QR.autoPost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
reset: function() {
|
|
||||||
return $('textarea', QR.el).value = '';
|
|
||||||
},
|
|
||||||
receive: function(e) {
|
receive: function(e) {
|
||||||
var data;
|
var data;
|
||||||
data = e.data;
|
data = e.data;
|
||||||
@ -1404,6 +1401,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
reset: function() {
|
||||||
|
return $('textarea', QR.el).value = '';
|
||||||
|
},
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var captcha, challenge, el, response;
|
var captcha, challenge, el, response;
|
||||||
$('.error', qr.el).textContent = '';
|
$('.error', qr.el).textContent = '';
|
||||||
|
|||||||
@ -979,6 +979,15 @@ QR =
|
|||||||
qr.dialog()
|
qr.dialog()
|
||||||
if conf['Auto Hide QR']
|
if conf['Auto Hide QR']
|
||||||
$('#autohide', QR.el).checked = true
|
$('#autohide', QR.el).checked = true
|
||||||
|
attach: ->
|
||||||
|
div = $.el 'div',
|
||||||
|
innerHTML: '<input name=upfile type=file><a class=close>X</a>'
|
||||||
|
$.bind $('input', div), 'change', QR.change
|
||||||
|
$.bind $('a', div), 'click', -> $.rm @parentNode
|
||||||
|
$.append $('#files', QR.el), div
|
||||||
|
autoPost: ->
|
||||||
|
return unless QR.hasContent()
|
||||||
|
QR.submit()
|
||||||
captchaNode: (e) ->
|
captchaNode: (e) ->
|
||||||
c = e.target.value
|
c = e.target.value
|
||||||
$('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}"
|
$('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}"
|
||||||
@ -1002,9 +1011,28 @@ QR =
|
|||||||
break
|
break
|
||||||
$.set 'captchas', captchas
|
$.set 'captchas', captchas
|
||||||
captcha
|
captcha
|
||||||
|
change: ->
|
||||||
|
$.unbind @, 'change', QR.change
|
||||||
|
QR.attach()
|
||||||
close: ->
|
close: ->
|
||||||
$.rm QR.el
|
$.rm QR.el
|
||||||
QR.el = null
|
QR.el = null
|
||||||
|
cooldown: ->
|
||||||
|
return unless QR.el
|
||||||
|
cooldown = $.get "cooldown/#{g.BOARD}", 0
|
||||||
|
now = Date.now()
|
||||||
|
n = Math.ceil (cooldown - now) / 1000
|
||||||
|
b = $ 'button', QR.el
|
||||||
|
if n > 0
|
||||||
|
$.extend b,
|
||||||
|
textContent: n
|
||||||
|
disabled: true
|
||||||
|
setTimeout QR.cooldown, 1000
|
||||||
|
else
|
||||||
|
$.extend b,
|
||||||
|
textContent: 'Submit'
|
||||||
|
disabled: false
|
||||||
|
QR.autoPost() if $('#auto', QR.el).checked
|
||||||
dialog: (text='') ->
|
dialog: (text='') ->
|
||||||
QR.el = el = ui.dialog 'qr', top: '0', left: '0', "
|
QR.el = el = ui.dialog 'qr', top: '0', left: '0', "
|
||||||
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
|
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
|
||||||
@ -1035,20 +1063,8 @@ QR =
|
|||||||
l = text.length
|
l = text.length
|
||||||
ta.setSelectionRange l, l
|
ta.setSelectionRange l, l
|
||||||
ta.focus()
|
ta.focus()
|
||||||
change: ->
|
|
||||||
$.unbind @, 'change', QR.change
|
|
||||||
QR.attach()
|
|
||||||
attach: ->
|
|
||||||
div = $.el 'div',
|
|
||||||
innerHTML: '<input name=upfile type=file><a class=close>X</a>'
|
|
||||||
$.bind $('input', div), 'change', QR.change
|
|
||||||
$.bind $('a', div), 'click', -> $.rm @parentNode
|
|
||||||
$.append $('#files', QR.el), div
|
|
||||||
hasContent: ->
|
hasContent: ->
|
||||||
$('textarea', QR.el).value or $('[type=file]', QR.el).files.length
|
$('textarea', QR.el).value or $('[type=file]', QR.el).files.length
|
||||||
autoPost: ->
|
|
||||||
return unless QR.hasContent()
|
|
||||||
QR.submit()
|
|
||||||
keydown: (e) ->
|
keydown: (e) ->
|
||||||
return unless e.keyCode is 13 and @value #enter, captcha filled
|
return unless e.keyCode is 13 and @value #enter, captcha filled
|
||||||
return if QR.hasContent()
|
return if QR.hasContent()
|
||||||
@ -1067,24 +1083,6 @@ QR =
|
|||||||
i = ss + text.length
|
i = ss + text.length
|
||||||
ta.setSelectionRange i, i
|
ta.setSelectionRange i, i
|
||||||
ta.focus()
|
ta.focus()
|
||||||
cooldown: ->
|
|
||||||
return unless QR.el
|
|
||||||
cooldown = $.get "cooldown/#{g.BOARD}", 0
|
|
||||||
now = Date.now()
|
|
||||||
n = Math.ceil (cooldown - now) / 1000
|
|
||||||
b = $ 'button', QR.el
|
|
||||||
if n > 0
|
|
||||||
$.extend b,
|
|
||||||
textContent: n
|
|
||||||
disabled: true
|
|
||||||
setTimeout QR.cooldown, 1000
|
|
||||||
else
|
|
||||||
$.extend b,
|
|
||||||
textContent: 'Submit'
|
|
||||||
disabled: false
|
|
||||||
QR.autoPost() if $('#auto', QR.el).checked
|
|
||||||
reset: ->
|
|
||||||
$('textarea', QR.el).value = ''
|
|
||||||
receive: (e) ->
|
receive: (e) ->
|
||||||
{data} = e
|
{data} = e
|
||||||
if data
|
if data
|
||||||
@ -1098,6 +1096,8 @@ QR =
|
|||||||
cooldown = Date.now() + 30*SECOND
|
cooldown = Date.now() + 30*SECOND
|
||||||
$.set "cooldown/#{g.BOARD}", cooldown
|
$.set "cooldown/#{g.BOARD}", cooldown
|
||||||
QR.cooldown()
|
QR.cooldown()
|
||||||
|
reset: ->
|
||||||
|
$('textarea', QR.el).value = ''
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
#XXX e is undefined if we're called from QR.autoPost
|
#XXX e is undefined if we're called from QR.autoPost
|
||||||
$('.error', qr.el).textContent = ''
|
$('.error', qr.el).textContent = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user