This commit is contained in:
James Campos 2011-09-02 20:40:33 -07:00
parent ad24caf366
commit 32dfad4da1
2 changed files with 79 additions and 79 deletions

View File

@ -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) {
var c;
c = e.target.value;
@ -1282,10 +1299,39 @@
$.set('captchas', captchas);
return captcha;
},
change: function() {
$.unbind(this, 'change', QR.change);
return QR.attach();
},
close: function() {
$.rm(QR.el);
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) {
var el, l, ta;
if (text == null) {
@ -1308,30 +1354,9 @@
ta.setSelectionRange(l, l);
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() {
return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length;
},
autoPost: function() {
if (!QR.hasContent()) {
return;
}
return QR.submit();
},
keydown: function(e) {
if (!(e.keyCode === 13 && this.value)) {
return;
@ -1358,34 +1383,6 @@
ta.setSelectionRange(i, i);
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) {
var data;
data = e.data;
@ -1404,6 +1401,9 @@
}
}
},
reset: function() {
return $('textarea', QR.el).value = '';
},
submit: function(e) {
var captcha, challenge, el, response;
$('.error', qr.el).textContent = '';

View File

@ -979,6 +979,15 @@ QR =
qr.dialog()
if conf['Auto Hide QR']
$('#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) ->
c = e.target.value
$('img', QR.el).src = "http://www.google.com/recaptcha/api/image?c=#{c}"
@ -1002,9 +1011,28 @@ QR =
break
$.set 'captchas', captchas
captcha
change: ->
$.unbind @, 'change', QR.change
QR.attach()
close: ->
$.rm QR.el
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='') ->
QR.el = el = ui.dialog 'qr', top: '0', left: '0', "
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
@ -1035,20 +1063,8 @@ QR =
l = text.length
ta.setSelectionRange l, l
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: ->
$('textarea', QR.el).value or $('[type=file]', QR.el).files.length
autoPost: ->
return unless QR.hasContent()
QR.submit()
keydown: (e) ->
return unless e.keyCode is 13 and @value #enter, captcha filled
return if QR.hasContent()
@ -1067,24 +1083,6 @@ QR =
i = ss + text.length
ta.setSelectionRange i, i
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) ->
{data} = e
if data
@ -1098,6 +1096,8 @@ QR =
cooldown = Date.now() + 30*SECOND
$.set "cooldown/#{g.BOARD}", cooldown
QR.cooldown()
reset: ->
$('textarea', QR.el).value = ''
submit: (e) ->
#XXX e is undefined if we're called from QR.autoPost
$('.error', qr.el).textContent = ''