1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-11 15:26:08 +01:00
vichan/templates/themes/ukko/ukko.js

39 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-01-02 18:40:30 +01:00
var cache = new Array(),
thread = false,
loading = false;
$(document).ready(function() {
$(window).on('scroll', function() {
if($(window).scrollTop() + $(window).height() + 100 > $(document).height() && !loading && overflow.length > 0) {
var page = '../' + overflow[0].board + '/' + overflow[0].page;
if($.inArray(page, cache) != -1) {
thread = $('div#thread_' + overflow[0].id);
if(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'));
2013-07-27 06:57:12 +02:00
$(document).trigger('new_post', thread);
2013-01-02 18:40:30 +01:00
overflow.shift();
}
} else {
loading = true;
$.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 + '"]');
if(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'));
2013-07-27 06:57:12 +02:00
$(document).trigger('new_post', thread);
2013-01-02 18:40:30 +01:00
overflow.shift();
}
loading = false;
});
}
}
});
});