merge with vichan-gold

This commit is contained in:
Czterooki 2013-07-20 00:19:08 -04:00
commit aef4425592
72 changed files with 3508 additions and 429 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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();
}

View file

@ -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;
}
} else {
this.childNodes[0].src = this.tag;
this.childNodes[0].style.width = 'auto';
this.childNodes[0].style.height = 'auto';
this.tag = '';
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 = '';
}
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);
});
});

View file

@ -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;
for(var i = 0; i < times.length; i++) {
if(typeof times[i].getAttribute('data-local') == 'undefined')
continue;
var t = iso8601(times[i].getAttribute('datetime'));
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);
});
});

View file

@ -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);
}
});

View file

@ -20,6 +20,8 @@ onready(function(){
if(id = $link.text().match(/^>>(\d+)$/)) {
id = id[1];
} else {
return;
}
var $post = false;

View file

@ -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

View file

@ -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(){
});
});
});
}

View file

@ -46,5 +46,9 @@ onready(function(){
};
$('div.post.reply').each(showBackLinks);
$(document).bind('new_post', function(e, post) {
showBackLinks.call(post);
});
});

View file

@ -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);
});
}
});

View file

@ -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) {