simple url building

This commit is contained in:
James Campos 2011-07-31 16:23:05 -07:00
parent 0c0a8c6dbd
commit b61453fde1
2 changed files with 40 additions and 38 deletions

View File

@ -1374,7 +1374,7 @@
return qr.el = null;
},
sys: function() {
var c, duration, id, noko, recaptcha, thread, _, _ref;
var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref;
if (recaptcha = $('#recaptcha_response_field')) {
$.bind(recaptcha, 'keydown', Recaptcha.listener);
return;
@ -1402,28 +1402,27 @@
c = $('b').lastChild;
if (c.nodeType === 8) {
_ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2];
noko = /noko/.test(location.search);
if (thread === '0') {
if (/watch/.test(location.search)) {
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch";
} else if (noko) {
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id;
search = location.search;
cooldown = /cooldown/.test(search);
noko = /noko/.test(search);
sage = /sage/.test(search);
watch = /watch/.test(search);
url = "http://boards.4chan.org/" + g.BOARD;
if (noko) {
url += '/res/';
url += thread === 0 ? id : thread;
if (watch) {
url += '?watch';
}
} else if (/cooldown/.test(location.search)) {
duration = Date.now() + 30000;
if (/sage/.test(location.search)) {
duration += 30000;
}
if (noko) {
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "?cooldown=" + duration + "#" + id;
} else {
return window.location = "http://boards.4chan.org/" + g.BOARD + "?cooldown=" + duration;
}
} else if (noko) {
return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id;
} else {
return window.location = "http://boards.4chan.org/" + g.BOARD;
}
if (cooldown) {
duration = Date.now() + (sage ? 60 : 30) * 1000;
url += '?cooldown=' + duration;
}
if (noko) {
url += '#' + id;
}
return window.location = url;
}
}
};

View File

@ -1127,23 +1127,26 @@ qr =
if c.nodeType is 8 #comment node
[_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/)
noko = /noko/.test location.search
if thread is '0'
if /watch/.test location.search
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch"
else if noko
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}"
else if /cooldown/.test location.search
duration = Date.now() + 30000
duration += 30000 if /sage/.test location.search
if noko
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}?cooldown=#{duration}##{id}"
else
window.location = "http://boards.4chan.org/#{g.BOARD}?cooldown=#{duration}"
else if noko
window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}"
else
window.location = "http://boards.4chan.org/#{g.BOARD}"
{search} = location
cooldown = /cooldown/.test search
noko = /noko/ .test search
sage = /sage/ .test search
watch = /watch/ .test search
url = "http://boards.4chan.org/#{g.BOARD}"
if noko
url += '/res/'
url += if thread is 0 then id else thread
if watch
url += '?watch'
if cooldown
duration = Date.now() + (if sage then 60 else 30) * 1000
url += '?cooldown=' + duration
if noko
url += '#' + id
window.location = url
threading =
init: ->