1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00
vichan/templates/themes/ukko/ukko.js

56 lines
1.9 KiB
JavaScript
Raw Normal View History

2013-08-02 09:16:34 +02:00
(function(){
2013-01-02 18:40:30 +01:00
var cache = new Array(),
thread = false,
loading = false;
$(document).ready(function() {
2013-08-02 09:16:34 +02:00
$('.pages').hide();
2013-01-02 18:40:30 +01:00
$(window).on('scroll', function() {
2013-08-02 09:16:34 +02: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 18:40:30 +01:00
var page = '../' + overflow[0].board + '/' + overflow[0].page;
2013-08-02 09:16:34 +02:00
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
if (thread.length > 0 && thread.css('display') != 'none') { // already present
overflow.shift();
continue;
}
if($.inArray(page, cache) != -1 && thread.length > 0) {
thread.prepend('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a></h2>');
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block'));
$(document).trigger('new_post', thread);
overflow.shift();
2013-01-02 18:40:30 +01:00
} else {
loading = true;
2013-08-02 09:16:34 +02:00
$('.pages').show().html(_("Loading..."));
2013-01-02 18:40:30 +01:00
$.get(page, function(data) {
cache.push(page);
$(data).find('div[id*="thread_"]').each(function() {
$('form[name="postcontrols"]').prepend($(this).css('display', 'none').attr('data-board', overflow[0].board));
2013-01-02 18:40:30 +01:00
});
thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]');
2013-08-02 09:16:34 +02:00
if(thread.length > 0 && thread.css('display') != 'none') {
2013-01-02 18:40:30 +01:00
thread.prepend('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a></h2>');
$('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block'));
2013-07-27 06:57:12 +02:00
$(document).trigger('new_post', thread);
2013-01-02 18:40:30 +01:00
overflow.shift();
}
2013-08-02 09:16:34 +02:00
else {
overflow.shift(); // We missed it? Or already present...
}
2013-01-02 18:40:30 +01:00
loading = false;
2013-08-02 09:16:34 +02:00
$('.pages').hide().html("");
2013-01-02 18:40:30 +01:00
});
2013-08-02 09:16:34 +02:00
break;
2013-01-02 18:40:30 +01:00
}
}
});
});
2013-08-02 09:16:34 +02:00
})();