Merge branch 'master' of github.com:aeosynth/4chan-x

This commit is contained in:
James Campos 2011-07-20 14:42:29 -07:00
commit 4bb12bf23f
3 changed files with 96 additions and 97 deletions

View File

@ -744,7 +744,7 @@
},
cb: {
keydown: function(e) {
var key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3;
var key, o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3;
if (((_ref = d.activeElement.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) {
return;
}
@ -760,8 +760,8 @@
case keybinds.close:
if (o = $('#overlay')) {
$.rm(o);
} else if (qr = $('#qr')) {
$.rm(qr);
} else if (qr.el) {
qr.close();
}
break;
case keybinds.spoiler:
@ -835,8 +835,8 @@
}
break;
case keybinds.submit:
if (qr = $('#qr_form')) {
qr.submit();
if (qr.el) {
qr.submit.call($('form', qr.el));
} else {
$('.postarea form').submit();
}
@ -882,10 +882,10 @@
if (quote) {
return qr.quote(qrLink);
} else {
if (!$('#qr')) {
if (!qr.el) {
qr.dialog(qrLink);
}
return $('#qr textarea').focus();
return $('textarea', qr.el).focus();
}
},
open: function(thread, tab) {
@ -1227,8 +1227,8 @@
submit.disabled = false;
submit.value = 'Submit';
}
if ((_ref = $('#auto')) != null ? _ref.checked : void 0) {
return qr.submit.call($('#qr_form'));
if ((_ref = $('#auto', qr.el)) != null ? _ref.checked : void 0) {
return qr.submit.call($('form', qr.el));
}
}
}
@ -1248,40 +1248,37 @@
autohide: {
set: function() {
var _ref;
return (_ref = $('#qr input[title=autohide]:not(:checked)')) != null ? _ref.click() : void 0;
return (_ref = $('input[title=autohide]:not(:checked)', qr.el)) != null ? _ref.click() : void 0;
},
unset: function() {
var _ref;
return (_ref = $('#qr input[title=autohide]:checked')) != null ? _ref.click() : void 0;
return (_ref = $('input[title=autohide]:checked', qr.el)) != null ? _ref.click() : void 0;
}
},
cb: {
autohide: function(e) {
var dialog;
dialog = $('#qr');
if (this.checked) {
return $.addClass(dialog, 'auto');
return $.addClass(qr.el, 'auto');
} else {
return $.removeClass(dialog, 'auto');
return $.removeClass(qr.el, 'auto');
}
},
message: function(e) {
var data, dialog, duration;
var data, duration;
Recaptcha.reload();
$('iframe[name=iframe]').src = 'about:blank';
data = e.data;
dialog = $('#qr');
if (data) {
$('input[name=recaptcha_response_field]', dialog).value = '';
$('#error').textContent = data;
$('input[name=recaptcha_response_field]', qr.el).value = '';
$('#error', qr.el).textContent = data;
qr.autohide.unset();
return;
}
if (dialog) {
if (qr.el) {
if (g.REPLY && $.config('Persistent QR')) {
qr.refresh(dialog);
qr.refresh();
} else {
$.rm(dialog);
qr.close();
}
}
if ($.config('Cooldown')) {
@ -1306,7 +1303,7 @@
if (g.REPLY && $('img.favicon').src === Favicon.empty) {
watcher.watch(null, g.THREAD_ID);
} else {
id = $('input[name=resto]').value;
id = $('input[name=resto]', qr.el).value;
op = d.getElementById(id);
if ($('img.favicon', op).src === Favicon.empty) {
watcher.watch(op, id);
@ -1320,7 +1317,7 @@
e.preventDefault();
}
if (isQR) {
return $('#error').textContent = 'Error: File too large.';
return $('#error', qr.el).textContent = 'Error: File too large.';
} else {
return alert('Error: File too large.');
}
@ -1328,17 +1325,17 @@
if (!e) {
this.submit();
}
$('#error').textContent = '';
$('#error', qr.el).textContent = '';
qr.autohide.set();
return qr.sage = /sage/i.test($('input[name=email]', this).value);
}
},
quote: function(link) {
var dialog, id, s, selection, selectionID, ta, text, _ref;
if (dialog = $('#qr')) {
var id, s, selection, selectionID, ta, text, _ref;
if (qr.el) {
qr.autohide.unset();
} else {
dialog = qr.dialog(link);
qr.dialog(link);
}
id = link.textContent;
text = ">>" + id + "\n";
@ -1349,48 +1346,49 @@
text += ">" + s + "\n";
}
}
ta = $('textarea', dialog);
ta = $('textarea', qr.el);
ta.focus();
return ta.value += text;
},
refresh: function(dialog) {
refresh: function() {
var c, m;
$('form', dialog).reset();
$('form', qr.el).reset();
c = d.cookie;
$('input[name=name]', dialog).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
$('input[name=email]', dialog).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
return $('input[name=pwd]', dialog).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value;
$('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
$('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : '';
return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value;
},
dialog: function(link) {
var THREAD_ID, challenge, dialog, html, spoiler, submitDisabled, submitValue;
var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue;
submitValue = $('#com_submit').value;
submitDisabled = $('#com_submit').disabled ? 'disabled' : '';
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>' : '';
challenge = $('input[name=recaptcha_challenge_field]').value;
html = " <div class=move> <input class=inputtext type=text name=name placeholder=Name form=qr_form> Quick Reply <input type=checkbox id=autohide title=autohide> <a name=close title=close>X</a> </div> <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 value=" + challenge + "> <div><input class=inputtext type=text name=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=" + challenge + "></div> <div><input class=inputtext type=text name=recaptcha_response_field placeholder=Verification required autocomplete=off></div> <div><input type=file name=upfile></div> <div><input class=inputtext type=password name=pwd maxlength=8 placeholder=Password><input type=hidden name=mode value=regist></div> </form> <div id=error class=error></div> ";
dialog = ui.dialog('qr', {
qr.el = ui.dialog('qr', {
top: '0px',
left: '0px'
}, html);
qr.refresh(dialog);
$.bind($('input[name=name]', dialog), 'mousedown', function(e) {
qr.refresh;
$.bind($('input[name=name]', qr.el), 'mousedown', function(e) {
return e.stopPropagation();
});
$.bind($('#autohide', dialog), 'click', qr.cb.autohide);
$.bind($('a[name=close]', dialog), 'click', function() {
return $.rm(dialog);
});
$.bind($('form', dialog), 'submit', qr.submit);
$.bind($('img', dialog), 'click', Recaptcha.reload);
$.bind($('input[name=recaptcha_response_field]', dialog), 'keydown', Recaptcha.listener);
$.append(d.body, dialog);
return dialog;
$.bind($('#autohide', qr.el), 'click', qr.cb.autohide);
$.bind($('a[name=close]', qr.el), 'click', qr.close);
$.bind($('form', qr.el), 'submit', qr.submit);
$.bind($('img', qr.el), 'click', Recaptcha.reload);
$.bind($('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener);
return $.append(d.body, qr.el);
},
persist: function() {
$.append(d.body, qr.dialog());
return qr.autohide.set();
},
close: function() {
$.rm(qr.el);
return qr.el = null;
},
sys: function() {
var c, duration, id, noko, recaptcha, thread, _, _ref;
if (recaptcha = $('#recaptcha_response_field')) {
@ -2410,7 +2408,7 @@
Recaptcha.reload();
}
if (e.keyCode === 13 && cooldown.duration) {
$('#auto').checked = true;
$('#auto', qr.el).checked = true;
return qr.autohide.set();
}
},
@ -2418,13 +2416,13 @@
return window.location = 'javascript:Recaptcha.reload()';
},
reloaded: function(e) {
var dialog, target;
if (!(dialog = $('#qr'))) {
var target;
if (!qr.el) {
return;
}
target = e.target;
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
return $('input[name=recaptcha_challenge_field]', dialog).value = target.value;
$('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
return $('input[name=recaptcha_challenge_field]', qr.el).value = target.value;
}
};
nodeInserted = function(e) {

View File

@ -6,6 +6,7 @@ github
- aeosynth:
- fix an upgrading problem (1.x -> 2.x)
- fix minor bugs with auto-posting
- new IRC Updating feature
2.15.1
- mayhem:

View File

@ -547,8 +547,8 @@ keybinds =
when keybinds.close
if o = $ '#overlay'
$.rm o
else if qr = $ '#qr'
$.rm qr
else if qr.el
qr.close()
when keybinds.spoiler
ta = d.activeElement
return unless ta.nodeName is 'TEXTAREA'
@ -599,8 +599,8 @@ keybinds =
when keybinds.previousPage
$('input[value=Previous]')?.click()
when keybinds.submit
if qr = $('#qr_form')
qr.submit()
if qr.el
qr.submit.call $ 'form', qr.el
else
$('.postarea form').submit()
else
@ -636,9 +636,9 @@ keybinds =
if quote
qr.quote qrLink
else
unless $ '#qr'
unless qr.el
qr.dialog qrLink
$('#qr textarea').focus()
$('textarea', qr.el).focus()
open: (thread, tab) ->
id = thread.firstChild.id
@ -961,8 +961,8 @@ cooldown =
for submit in submits
submit.disabled = false
submit.value = 'Submit'
if $('#auto')?.checked
qr.submit.call $ '#qr_form'
if $('#auto', qr.el)?.checked
qr.submit.call $ 'form', qr.el
qr =
init: ->
@ -978,35 +978,33 @@ qr =
autohide:
set: ->
$('#qr input[title=autohide]:not(:checked)')?.click()
$('input[title=autohide]:not(:checked)', qr.el)?.click()
unset: ->
$('#qr input[title=autohide]:checked')?.click()
$('input[title=autohide]:checked', qr.el)?.click()
cb:
autohide: (e) ->
dialog = $ '#qr'
if @checked
$.addClass dialog, 'auto'
$.addClass qr.el, 'auto'
else
$.removeClass dialog, 'auto'
$.removeClass qr.el, 'auto'
message: (e) ->
Recaptcha.reload()
$('iframe[name=iframe]').src = 'about:blank'
{data} = e
dialog = $ '#qr'
if data # error message
$('input[name=recaptcha_response_field]', dialog).value = ''
$('#error').textContent = data
$('input[name=recaptcha_response_field]', qr.el).value = ''
$('#error', qr.el).textContent = data
qr.autohide.unset()
return
if dialog
if qr.el
if g.REPLY and $.config 'Persistent QR'
qr.refresh dialog
qr.refresh()
else
$.rm dialog
qr.close()
if $.config 'Cooldown'
duration = if qr.sage then 60 else 30
$.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000
@ -1025,7 +1023,7 @@ qr =
if g.REPLY and $('img.favicon').src is Favicon.empty
watcher.watch null, g.THREAD_ID
else
id = $('input[name=resto]').value
id = $('input[name=resto]', qr.el).value
op = d.getElementById id
if $('img.favicon', op).src is Favicon.empty
watcher.watch op, id
@ -1036,21 +1034,21 @@ qr =
if inputfile.value and inputfile.files[0].size > $('input[name=MAX_FILE_SIZE]').value
e.preventDefault() if e
if isQR
$('#error').textContent = 'Error: File too large.'
$('#error', qr.el).textContent = 'Error: File too large.'
else
alert 'Error: File too large.'
else if isQR
if !e then @submit()
$('#error').textContent = ''
$('#error', qr.el).textContent = ''
qr.autohide.set()
qr.sage = /sage/i.test $('input[name=email]', @).value
quote: (link) ->
if dialog = $ '#qr'
if qr.el
qr.autohide.unset()
else
dialog = qr.dialog link
qr.dialog link
id = link.textContent
text = ">>#{id}\n"
@ -1061,16 +1059,16 @@ qr =
if selectionID == id
text += ">#{s}\n"
ta = $ 'textarea', dialog
ta = $ 'textarea', qr.el
ta.focus()
ta.value += text
refresh: (dialog) ->
$('form', dialog).reset()
refresh: ->
$('form', qr.el).reset()
c = d.cookie
$('input[name=name]', dialog).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else ''
$('input[name=email]', dialog).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else ''
$('input[name=pwd]', dialog).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value
$('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else ''
$('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else ''
$('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value
dialog: (link) ->
submitValue = $('#com_submit').value
@ -1099,25 +1097,27 @@ qr =
</form>
<div id=error class=error></div>
"
dialog = ui.dialog 'qr', top: '0px', left: '0px', html
qr.el = ui.dialog 'qr', top: '0px', left: '0px', html
qr.refresh dialog
qr.refresh
$.bind $('input[name=name]', dialog), 'mousedown', (e) -> e.stopPropagation()
$.bind $('#autohide', dialog), 'click', qr.cb.autohide
$.bind $('a[name=close]', dialog), 'click', -> $.rm dialog
$.bind $('form', dialog), 'submit', qr.submit
$.bind $('img', dialog), 'click', Recaptcha.reload
$.bind $('input[name=recaptcha_response_field]', dialog), 'keydown', Recaptcha.listener
$.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation()
$.bind $('#autohide', qr.el), 'click', qr.cb.autohide
$.bind $('a[name=close]', qr.el), 'click', qr.close
$.bind $('form', qr.el), 'submit', qr.submit
$.bind $('img', qr.el), 'click', Recaptcha.reload
$.bind $('input[name=recaptcha_response_field]', qr.el), 'keydown', Recaptcha.listener
$.append d.body, dialog
dialog
$.append d.body, qr.el
persist: ->
$.append d.body, qr.dialog()
qr.autohide.set()
close: ->
$.rm qr.el
qr.el = null
sys: ->
if recaptcha = $ '#recaptcha_response_field' #post reporting
$.bind recaptcha, 'keydown', Recaptcha.listener
@ -1828,15 +1828,15 @@ Recaptcha =
if e.keyCode is 8 and @value is '' # backspace to reload
Recaptcha.reload()
if e.keyCode is 13 and cooldown.duration # press enter to enable auto-post if cooldown is still running
$('#auto').checked = true
$('#auto', qr.el).checked = true
qr.autohide.set()
reload: ->
window.location = 'javascript:Recaptcha.reload()'
reloaded: (e) ->
return unless dialog = $ '#qr'
return unless qr.el
{target} = e
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
$('input[name=recaptcha_challenge_field]', dialog).value = target.value
$('img', qr.el).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
$('input[name=recaptcha_challenge_field]', qr.el).value = target.value
nodeInserted = (e) ->
{target} = e