2013-08-02 03:16:34 -04:00
|
|
|
(function(){
|
|
|
|
|
2013-01-02 12:40:30 -05:00
|
|
|
var cache = new Array(),
|
|
|
|
thread = false,
|
|
|
|
loading = false;
|
2013-08-02 04:20:57 -04:00
|
|
|
|
|
|
|
if (localStorage.hiddenboards !== null) {
|
|
|
|
localStorage.hiddenboards = "{}";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load data from HTML5 localStorage
|
|
|
|
var hiddenboards = JSON.parse(localStorage.hiddenboards);
|
|
|
|
|
|
|
|
var storeboards = function() {
|
|
|
|
localStorage.hiddenboards = JSON.stringify(hiddenboards);
|
|
|
|
};
|
|
|
|
|
2013-01-02 12:40:30 -05:00
|
|
|
$(document).ready(function() {
|
2013-08-02 04:20:57 -04:00
|
|
|
var addukkohide = function() {
|
|
|
|
var ukkohide = $('<a href="javascript:void(0);" class="unimportant ukkohide"></a>');
|
|
|
|
var board = $(this).next().data("board");
|
|
|
|
var hr = $("<hr />");
|
|
|
|
|
|
|
|
$(this).append(ukkohide);
|
|
|
|
$(this).append(hr);
|
|
|
|
|
|
|
|
if (hiddenboards[board] !== true) {
|
|
|
|
ukkohide.html(_("(hide threads from this board)"));
|
|
|
|
hr.hide();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ukkohide.html(_("(show threads from this board)"));
|
|
|
|
$(this).next().hide();
|
|
|
|
}
|
|
|
|
ukkohide.click(function() {
|
|
|
|
hiddenboards[board] = (hiddenboards[board] !== true);
|
|
|
|
if (hiddenboards[board] !== true) {
|
2013-08-02 04:36:08 -04:00
|
|
|
$('[data-board="'+board+'"]:not([data-cached="yes"])').show().prev().
|
2013-08-02 04:20:57 -04:00
|
|
|
find('.ukkohide').html(_("(hide threads from this board)")).
|
|
|
|
parent().find('hr').hide();
|
|
|
|
}
|
|
|
|
else {
|
2013-08-02 04:36:08 -04:00
|
|
|
$('[data-board="'+board+'"]:not([data-cached="yes"])').hide().prev().
|
2013-08-02 04:20:57 -04:00
|
|
|
find('.ukkohide').html(_("(show threads from this board)"))
|
|
|
|
.parent().find('hr').show();
|
|
|
|
}
|
|
|
|
storeboards();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
$("h2").each(addukkohide);
|
|
|
|
|
2013-08-02 03:16:34 -04:00
|
|
|
$('.pages').hide();
|
2013-01-02 12:40:30 -05:00
|
|
|
$(window).on('scroll', function() {
|
2013-08-02 03:16:34 -04:00
|
|
|
if (overflow.length == 0) {
|
|
|
|
$('.pages').show().html(_("No more threads to display"));
|
|
|
|
}
|
|
|
|
while($(window).scrollTop() + $(window).height() + 500 > $(document).height() && !loading && overflow.length > 0) {
|
2013-01-02 12:40:30 -05:00
|
|
|
var page = '../' + overflow[0].board + '/' + overflow[0].page;
|
2013-08-02 03:16:34 -04:00
|
|
|
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
|
2013-08-02 04:36:08 -04:00
|
|
|
if (thread.length > 0 && thread.attr("data-cached") !== 'yes') { // already present
|
2013-08-02 03:16:34 -04:00
|
|
|
overflow.shift();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-08-02 04:20:57 -04:00
|
|
|
var boardheader = $('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a> </h2>');
|
|
|
|
|
2013-08-02 03:16:34 -04:00
|
|
|
if($.inArray(page, cache) != -1 && thread.length > 0) {
|
2013-08-02 04:36:08 -04:00
|
|
|
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).attr("data-cached", "no").css('display', 'block'));
|
2013-08-02 04:20:57 -04:00
|
|
|
boardheader.insertBefore(thread);
|
|
|
|
addukkohide.call(boardheader);
|
2013-08-02 03:16:34 -04:00
|
|
|
$(document).trigger('new_post', thread);
|
|
|
|
overflow.shift();
|
2013-01-02 12:40:30 -05:00
|
|
|
} else {
|
|
|
|
loading = true;
|
2013-08-02 03:16:34 -04:00
|
|
|
$('.pages').show().html(_("Loading..."));
|
2013-01-02 12:40:30 -05:00
|
|
|
$.get(page, function(data) {
|
|
|
|
cache.push(page);
|
|
|
|
|
|
|
|
$(data).find('div[id*="thread_"]').each(function() {
|
2013-08-02 04:36:08 -04:00
|
|
|
$('form[name="postcontrols"]').prepend($(this).css('display', 'none').attr("data-cached", "yes").attr('data-board', overflow[0].board));
|
2013-01-02 12:40:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
|
2013-08-02 04:36:08 -04:00
|
|
|
if(thread.length > 0 && thread.attr('data-cached') !== 'no') {
|
|
|
|
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).attr("data-cached", "no").css('display', 'block'));
|
2013-08-02 04:20:57 -04:00
|
|
|
boardheader.insertBefore(thread);
|
|
|
|
addukkohide.call(boardheader);
|
2013-07-27 00:57:12 -04:00
|
|
|
$(document).trigger('new_post', thread);
|
2013-01-02 12:40:30 -05:00
|
|
|
overflow.shift();
|
|
|
|
}
|
2013-08-02 03:16:34 -04:00
|
|
|
else {
|
|
|
|
overflow.shift(); // We missed it? Or already present...
|
|
|
|
}
|
2013-01-02 12:40:30 -05:00
|
|
|
|
|
|
|
loading = false;
|
2013-08-02 03:16:34 -04:00
|
|
|
$('.pages').hide().html("");
|
2013-01-02 12:40:30 -05:00
|
|
|
});
|
2013-08-02 03:16:34 -04:00
|
|
|
break;
|
2013-01-02 12:40:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-07-27 00:13:54 -04:00
|
|
|
});
|
2013-08-02 03:16:34 -04:00
|
|
|
|
|
|
|
})();
|