summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorCzterooki <czterooki1337@gmail.com>2013-07-20 00:19:08 -0400
committerCzterooki <czterooki1337@gmail.com>2013-07-20 00:19:08 -0400
commitaef44255920c18f443af28d100fb06d9699d4895 (patch)
treeb1d72ffc9a0e4f6a009ca16e9e3af2260806c193 /js
parent81892ebcdcd2929128c2c320f7de975cab8ed368 (diff)
parentf04566f6d30553560d5a69e25e38de72a60f297c (diff)
merge with vichan-gold
Diffstat (limited to 'js')
-rw-r--r--js/auto-reload.js3
-rw-r--r--js/expand.js7
-rw-r--r--js/forced-anon.js6
-rw-r--r--js/inline-expanding.js60
-rw-r--r--js/local-time.js36
-rw-r--r--js/post-hider.js62
-rw-r--r--js/post-hover.js2
-rw-r--r--js/quick-post-controls.js12
-rw-r--r--js/quick-reply.js11
-rw-r--r--js/show-backlinks.js4
-rw-r--r--js/smartphone-spoiler.js21
-rw-r--r--js/toggle-locked-threads.js4
12 files changed, 137 insertions, 91 deletions
diff --git a/js/auto-reload.js b/js/auto-reload.js
index c0c63056..5d96146a 100644
--- a/js/auto-reload.js
+++ b/js/auto-reload.js
@@ -16,6 +16,9 @@
$(document).ready(function(){
if($('div.banner').length == 0)
return; // not index
+
+ if($(".post.op").size() != 1)
+ return; //not thread page
var poll_interval;
diff --git a/js/expand.js b/js/expand.js
index 15408813..6371f92c 100644
--- a/js/expand.js
+++ b/js/expand.js
@@ -1,5 +1,5 @@
/*
- *expand.js
+ * expand.js
* https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js
*
* Released under the MIT license
@@ -17,7 +17,7 @@ $(document).ready(function(){
$('div.post.op span.omitted').each(function() {
$(this)
- .html($(this).text().replace(/Click reply to view\.|Kliknij Odpowiedź aby zobaczyć\./, '<a href="javascript:void(0)">Click to expand</a>.'))
+ .html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.'))
.find('a').click(function() {
var thread = $(this).parent().parent().parent();
var id = thread.attr('id').replace(/^thread_/, '');
@@ -35,9 +35,10 @@ $(document).ready(function(){
}
last_expanded = $(this);
+ $(document).trigger('new_post', this);
}
});
- $('<span class="omitted"><a href="javascript:void(0)">Hide expanded replies</a>.</span>')
+ $('<span class="omitted"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>')
.insertAfter(thread.find('span.omitted').css('display', 'none'))
.click(function() {
thread.find('.expanded').remove();
diff --git a/js/forced-anon.js b/js/forced-anon.js
index 3dbf0dfc..6ae43882 100644
--- a/js/forced-anon.js
+++ b/js/forced-anon.js
@@ -56,17 +56,17 @@ $(document).ready(function() {
forced_anon = localStorage['forcedanon'] ? true : false;
$('hr:first').before('<div id="forced-anon" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>');
- $('div#forced-anon a').text('Forced anonymity (' + (forced_anon ? 'enabled' : 'disabled') + ')');
+ $('div#forced-anon a').text(_('Forced anonymity')+' (' + (forced_anon ? _('enabled') : _('disabled')) + ')');
$('div#forced-anon a').click(function() {
forced_anon = !forced_anon;
if(forced_anon) {
- $('div#forced-anon a').text('Forced anonymity (enabled)');
+ $('div#forced-anon a').text(_('Forced anonymity')+' ('+_('enabled')+')');
localStorage.forcedanon = true;
enable_fa();
} else {
- $('div#forced-anon a').text('Forced anonymity (disabled)');
+ $('div#forced-anon a').text(_('Forced anonymity')+' ('+_('disabled')+')');
delete localStorage.forcedanon;
disable_fa();
}
diff --git a/js/inline-expanding.js b/js/inline-expanding.js
index f6714d7f..7c9923fa 100644
--- a/js/inline-expanding.js
+++ b/js/inline-expanding.js
@@ -6,42 +6,50 @@
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
*
* Usage:
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/inline-expanding.js';
*
*/
onready(function(){
- var link = document.getElementsByTagName('a');
+ var inline_expand_post = function() {
+ var link = this.getElementsByTagName('a');
- for(var i = 0; i < link.length; i++) {
- if(typeof link[i] == "object" && link[i].childNodes[0].src && link[i].className != 'file') {
- link[i].childNodes[0].style.maxWidth = '95%';
- link[i].childNodes[0].style.maxHeight = '95%';
- link[i].onclick = function(e) {
- if(e.which == 2) {
- return true;
- }
- if(!this.tag) {
- this.tag = this.childNodes[0].src;
- this.childNodes[0].src = this.href;
- this.childNodes[0].style.width = 'auto';
- this.childNodes[0].style.height = 'auto';
- this.childNodes[0].style.opacity = '0.4';
- this.childNodes[0].style.filter = 'alpha(opacity=40)';
- this.childNodes[0].onload = function() {
- this.style.opacity = '1';
- this.style.filter = '';
+ for(var i = 0; i < link.length; i++) {
+ if(typeof link[i] == "object" && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') {
+ link[i].childNodes[0].style.maxWidth = '95%';
+ link[i].onclick = function(e) {
+ if(e.which == 2) {
+ return true;
+ }
+ if(!this.tag) {
+ this.tag = this.childNodes[0].src;
+ this.childNodes[0].src = this.href;
+ this.childNodes[0].style.width = 'auto';
+ this.childNodes[0].style.height = 'auto';
+ this.childNodes[0].style.opacity = '0.4';
+ this.childNodes[0].style.filter = 'alpha(opacity=40)';
+ this.childNodes[0].onload = function() {
+ this.style.opacity = '1';
+ this.style.filter = '';
+ }
+ } else {
+ this.childNodes[0].src = this.tag;
+ this.childNodes[0].style.width = 'auto';
+ this.childNodes[0].style.height = 'auto';
+ this.tag = '';
}
- } else {
- this.childNodes[0].src = this.tag;
- this.childNodes[0].style.width = 'auto';
- this.childNodes[0].style.height = 'auto';
- this.tag = '';
+ return false;
}
- return false;
}
-
}
}
+
+ $('div[id^="thread_"]').each(inline_expand_post);
+
+ // allow to work with auto-reload.js, etc.
+ $(document).bind('new_post', function(e, post) {
+ inline_expand_post.call(post);
+ });
});
diff --git a/js/local-time.js b/js/local-time.js
index b92cc5be..a4e2fb51 100644
--- a/js/local-time.js
+++ b/js/local-time.js
@@ -6,6 +6,7 @@
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
*
* Usage:
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/local-time.js';
*
*/
@@ -21,23 +22,32 @@ onready(function(){
var zeropad = function(num, count) {
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
};
+
+ var do_localtime = function(elem) {
+ var times = elem.getElementsByTagName('time');
- var times = document.getElementsByTagName('time');
-
- for(var i = 0; i < times.length; i++) {
- if(!times[i].innerHTML.match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/))
- continue;
-
- var t = iso8601(times[i].getAttribute('datetime'));
+ for(var i = 0; i < times.length; i++) {
+ if(typeof times[i].getAttribute('data-local') == 'undefined')
+ continue;
+ var t = iso8601(times[i].getAttribute('datetime'));
- times[i].innerHTML =
- // date
- zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
- " (" + ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][t.getDay()] + ") " +
- // time
- zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
+ times[i].setAttribute('data-local', 'true');
+ times[i].innerHTML =
+ // date
+ zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
+ " (" + [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")][t.getDay()] + ") " +
+ // time
+ zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
+ };
};
+
+ do_localtime(document);
+
+ // allow to work with auto-reload.js, etc.
+ $(document).bind('new_post', function(e, post) {
+ do_localtime(post);
+ });
});
diff --git a/js/post-hider.js b/js/post-hider.js
index 5cb740a5..742c21bc 100644
--- a/js/post-hider.js
+++ b/js/post-hider.js
@@ -1,45 +1,53 @@
-function phGetCookieName(id) {
- return "ph_hide_" + id;
+function phGetCookieName(board, id) {
+ return "ph_hide_" + board + "_" + id;
}
-function phPostHidden(id) {
- return (localStorage.getItem(phGetCookieName(id)) != null);
+function phPostHidden(board, id) {
+ return (localStorage.getItem(phGetCookieName(board, id)) != null);
}
-function phPostToggle(id) {
- if(phPostHidden(id)) { localStorage.removeItem(phGetCookieName(id)); }
- else { localStorage.setItem(phGetCookieName(id),"yes"); }
+function phPostToggle(board, id) {
+ if(phPostHidden(board, id)) { localStorage.removeItem(phGetCookieName(board, id)); }
+ else { localStorage.setItem(phGetCookieName(board, id),"yes"); }
}
-function phGetInnerText(id) {
- if(phPostHidden(id)) { return "[+]"; }
- else { return "[-]"; }
+function phGetInnerText(board, id) {
+ if(phPostHidden(board, id)) { return "[+]"; }
+ else { return "[–]"; }
}
function phGetOpID(element) {
return Number(element.children("div.post.op").children("p.intro").children("a.post_no.p2").text());
}
+function phGetOpBoard(element) {
+ return element.data("board");
+}
function phPostHandle(element) {
var id = phGetOpID(element);
+ var board = phGetOpBoard(element);
var preplies = element.children("div.post.reply");
var pbody = element.children("div.post.op").children("div.body");
var pimage = element.children("a:first").children("img");
var pbutton = element.children("div.post.op").children("p.intro").children("a.posthider");
var pomitted = element.children("div.post.op").children("span.omitted");
- if(phPostHidden(id)) { element.addClass("thread-hidden"); pomitted.hide(); preplies.hide(); pbody.hide(); pimage.hide(); pbutton.text("[+]"); }
- else { element.removeClass("thread-hidden"); pomitted.show(); preplies.show(); pbody.show(); pimage.show(); pbutton.text("[-]"); }
+ if(phPostHidden(board, id)) { element.addClass("thread-hidden"); pomitted.hide(); preplies.hide(); pbody.hide(); pimage.hide(); pbutton.text("[+]"); }
+ else { element.removeClass("thread-hidden"); pomitted.show(); preplies.show(); pbody.show(); pimage.show(); pbutton.text("[–]"); }
+}
+
+function phHandleThread(index, element) {
+ // Get thread ID.
+ var pin = $(this).children("div.post.op").children("p.intro");
+ var tid = phGetOpID($(this));
+ if(tid != NaN) {
+ $("<a href='javascript:;' class='posthider'>[?]</a>").insertAfter(pin.children('a:last')).click(function(e) {
+ var eO = $(e.target);
+ var par = eO.parent().parent().parent();
+ phPostToggle(phGetOpBoard(par), phGetOpID(par));
+ phPostHandle(par);
+ return false;
+ });
+ phPostHandle($(this));
+ }
}
$(document).ready(function(){
- $('div[id^="thread"]').each(function(index, element){
- // Get thread ID.
- var pin = $(this).children("div.post.op").children("p.intro");
- var tid = phGetOpID($(this));
- if(tid != NaN) {
- $("<a href='javascript:;' class='posthider'>[?]</a>").insertAfter(pin.children('a:last')).click(function(e) {
- var eO = $(e.target);
- var par = eO.parent().parent().parent();
- phPostToggle(phGetOpID(par));
- phPostHandle(par);
- return false;
- });
- phPostHandle($(this));
- }
- });
+ if (active_page != "thread") {
+ $('form[name="postcontrols"] > div[id^="thread"]').each(phHandleThread);
+ }
});
diff --git a/js/post-hover.js b/js/post-hover.js
index 2f25540b..48f0ed96 100644
--- a/js/post-hover.js
+++ b/js/post-hover.js
@@ -20,6 +20,8 @@ onready(function(){
if(id = $link.text().match(/^>>(\d+)$/)) {
id = id[1];
+ } else {
+ return;
}
var $post = false;
diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js
index 0c164bbb..c28f874f 100644
--- a/js/quick-post-controls.js
+++ b/js/quick-post-controls.js
@@ -24,17 +24,17 @@ $(document).ready(function(){
'<input type="hidden" name="delete_' + id + '">' +
- '<label for="password_' + id + '">Password</label>: ' +
+ '<label for="password_' + id + '">'+_("Password")+'</label>: ' +
'<input id="password_' + id + '" type="password" name="password" size="11" maxlength="18">' +
- '<input title="Delete file only" type="checkbox" name="file" id="delete_file_' + id + '">' +
- '<label for="delete_file_' + id + '">File</label>' +
- ' <input type="submit" name="delete" value="Delete">' +
+ '<input title="'+_('Delete file only')+'" type="checkbox" name="file" id="delete_file_' + id + '">' +
+ '<label for="delete_file_' + id + '">'+_('File')+'</label>' +
+ ' <input type="submit" name="delete" value="'+_('Delete')+'">' +
'<br>' +
- '<label for="reason_' + id + '">Reason</label>: ' +
+ '<label for="reason_' + id + '">'+_('Reason')+'</label>: ' +
'<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' +
- ' <input type="submit" name="report" value="Report">' +
+ ' <input type="submit" name="report" value="'+_('Report')+'">' +
'</div>' +
'</form>');
post_form
diff --git a/js/quick-reply.js b/js/quick-reply.js
index ee59e805..bee204b7 100644
--- a/js/quick-reply.js
+++ b/js/quick-reply.js
@@ -12,12 +12,13 @@
*
*/
+if (active_page == 'index') {
$(document).ready(function(){
if($('div.banner').length != 0)
return; // not index
txt_new_topic = $('form[name=post] input[type=submit]').val();
- txt_new_reply = txt_new_topic == 'Submit' ? txt_new_topic : 'Reply';
+ txt_new_reply = txt_new_topic == _('Submit') ? txt_new_topic : new_reply_string;
undo_quick_reply = function() {
$('div.banner').remove();
@@ -26,10 +27,10 @@ $(document).ready(function(){
}
$('div.post.op').each(function() {
- var id = $(this).children('p.intro').children('a.post_no:eq(2)').text();
- $('<a href="#">[Quick Reply]</a>').insertAfter($(this).children('p.intro').children('a:last')).click(function() {
+ var id = $(this).children('p.intro').children('a.post_no:eq(1)').text();
+ $('<a href="#">['+_("Quick reply")+']</a>').insertAfter($(this).children('p.intro').children('a:last')).click(function() {
$('div.banner').remove();
- $('<div class="banner">Post Mode: Quick Reply to <small>&gt;&gt;' + id + '</small> <a class="unimportant" onclick="undo_quick_reply()" href="javascript:void(0)">[Return]</a></div>')
+ $('<div class="banner">'+fmt(_("Posting mode: Replying to <small>&gt;&gt;{0}</small>"), [id])+' <a class="unimportant" onclick="undo_quick_reply()" href="javascript:void(0)">['+_("Return")+']</a></div>')
.insertBefore('form[name=post]');
$('form[name=post] input[type=submit]').val(txt_new_reply);
@@ -43,4 +44,4 @@ $(document).ready(function(){
});
});
});
-
+}
diff --git a/js/show-backlinks.js b/js/show-backlinks.js
index e6e17e4f..4ead494b 100644
--- a/js/show-backlinks.js
+++ b/js/show-backlinks.js
@@ -46,5 +46,9 @@ onready(function(){
};
$('div.post.reply').each(showBackLinks);
+
+ $(document).bind('new_post', function(e, post) {
+ showBackLinks.call(post);
+ });
});
diff --git a/js/smartphone-spoiler.js b/js/smartphone-spoiler.js
index 67b9c789..ee904b54 100644
--- a/js/smartphone-spoiler.js
+++ b/js/smartphone-spoiler.js
@@ -13,12 +13,21 @@
onready(function(){
if(device_type == 'mobile') {
- var spoilers = document.getElementsByClassName('spoiler');
- for(var i = 0; i < spoilers.length; i++) {
- spoilers[i].onmousedown = function() {
- this.style.color = 'white';
- };
- }
+ var fix_spoilers = function(where) {
+ var spoilers = where.getElementsByClassName('spoiler');
+ for(var i = 0; i < spoilers.length; i++) {
+ spoilers[i].onmousedown = function() {
+ this.style.color = 'white';
+ };
+ }
+ };
+ fix_spoilers(document);
+
+ // allow to work with auto-reload.js, etc.
+ $(document).bind('new_post', function(e, post) {
+ fix_spoilers(post);
+ });
+
}
});
diff --git a/js/toggle-locked-threads.js b/js/toggle-locked-threads.js
index 50c44eda..1d517a4d 100644
--- a/js/toggle-locked-threads.js
+++ b/js/toggle-locked-threads.js
@@ -36,7 +36,7 @@ $(document).ready(function(){
$('hr:first').before('<div id="toggle-locked-threads" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>');
$('div#toggle-locked-threads a')
- .text((hide_locked_threads ? 'Show' : 'Hide') + ' locked threads')
+ .text(hide_locked_threads ? _('Show locked threads') : _('Hide locked threads'))
.click(function() {
hide_locked_threads = !hide_locked_threads;
if (hide_locked_threads) {
@@ -51,7 +51,7 @@ $(document).ready(function(){
delete localStorage.hidelockedthreads;
}
- $(this).text((hide_locked_threads ? 'Show' : 'Hide') + ' locked threads')
+ $(this).text(hide_locked_threads ? _('Show locked threads') : _('Hide locked threads'))
});
if (hide_locked_threads) {