1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-02 12:57:35 +01:00

auto-reload.js: format

This commit is contained in:
Zankaria 2025-01-04 21:42:01 +01:00
parent 8d56da9108
commit 209c334667

View File

@ -17,31 +17,33 @@
*
* You must have boardlinks or else this script will not load.
* Search for "$config['boards'] = array(" within your inc/config.php and add something similar to your instance-config.php.
*
*/
auto_reload_enabled = true; // for watch.js to interop
auto_reload_enabled = true; // For watch.js to interop.
$(document).ready(function(){
if($('div.banner').length == 0)
return; // not index
if($('div.banner').length == 0) {
// Not index.
return;
}
if($(".post.op").size() != 1)
return; //not thread page
if($(".post.op").size() != 1) {
// Not thread page.
return;
}
var countdown_interval;
// Add an update link
// Add an update link.
$('.boardlist.bottom').prev().after("<span id='updater'><a href='#' id='update_thread' style='padding-left:10px'>["+_("Update")+"]</a> (<input type='checkbox' id='auto_update_status' checked> "+_("Auto")+") <span id='update_secs'></span></span>");
// Grab the settings
// Grab the settings.
var settings = new script_settings('auto-reload');
var poll_interval_mindelay = settings.get('min_delay_bottom', 5000);
var poll_interval_maxdelay = settings.get('max_delay', 600000);
var poll_interval_errordelay = settings.get('error_delay', 30000);
// number of ms to wait before reloading
// number of ms to wait before reloading.
var poll_interval_delay = poll_interval_mindelay;
var poll_current_time = poll_interval_delay;
@ -62,17 +64,18 @@ $(document).ready(function(){
};
}
if (typeof add_title_collector != "undefined")
if (typeof add_title_collector != "undefined") {
add_title_collector(function() {
return new_posts;
});
}
var window_active = true;
$(window).focus(function() {
window_active = true;
recheck_activated();
// Reset the delay if needed
// Reset the delay if needed.
if(settings.get('reset_focus', true)) {
poll_interval_delay = poll_interval_mindelay;
}
@ -89,7 +92,6 @@ $(document).ready(function(){
stop_auto_update();
$('#update_secs').text("");
}
});
@ -225,7 +227,7 @@ $(document).ready(function(){
$(window).scroll(function() {
recheck_activated();
// if the newest post is not visible
// If the newest post is not visible.
if($(this).scrollTop() + $(this).height() <
$('div.post:last').position().top + $('div.post:last').height()) {
end_of_page = false;