2012-03-14 23:44:15 -04:00
|
|
|
/*
|
|
|
|
* auto-reload.js
|
|
|
|
* https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/auto-reload.js
|
|
|
|
*
|
|
|
|
* Brings AJAX to Tinyboard.
|
|
|
|
*
|
|
|
|
* Released under the MIT license
|
|
|
|
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
|
|
|
*
|
|
|
|
* Usage:
|
2012-03-15 01:19:26 -04:00
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/auto-reload.js';
|
2012-03-14 23:44:15 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
if($('div.banner').length == 0)
|
|
|
|
return; // not index
|
|
|
|
|
|
|
|
setInterval(function() {
|
2012-03-15 01:42:58 -04:00
|
|
|
if($(window).scrollTop() + $(window).height() < $('div.post.reply:last').position().top + $('div.post.reply:last').height())
|
|
|
|
return; // not scrolled past last reply
|
|
|
|
|
2012-03-14 23:44:15 -04:00
|
|
|
$.ajax({
|
|
|
|
url: document.location,
|
|
|
|
success: function(data) {
|
|
|
|
$(data).find('div.post.reply').each(function() {
|
|
|
|
var id = $(this).attr('id');
|
|
|
|
if($('#' + id).length == 0) {
|
|
|
|
$(this).insertAfter($('div.reply:last').next()).after('<br class="clear">');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-03-15 01:42:58 -04:00
|
|
|
}, 5000);
|
2012-03-14 23:44:15 -04:00
|
|
|
});
|
|
|
|
|