Dashboard/widgets, ready() triggered twice, replace with $(window).load() to prevent duplicate requests. closes https://github.com/opnsense/core/issues/2104

This commit is contained in:
Ad Schellevis 2018-01-25 22:03:24 +01:00
parent 75365a0a45
commit d2a8576375
6 changed files with 30 additions and 28 deletions

View File

@ -76,7 +76,7 @@ if (isset($config['ipsec']['phase1'])) {
if (isset($config['ipsec']['phase2'])) {
?>
<script>
$(document).ready(function() {
$(window).load(function() {
$(".ipsec-tab").click(function(){
$(".ipsec-tab").css('background-color', '#777777');
$(".ipsec-tab").css('color', 'white');

View File

@ -73,7 +73,7 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
?>
<script>
$( document ).ready(function() {
$(window).load(function() {
// needed to display the widget settings menu
$("#log-configure").removeClass("disabled");
// icons
@ -161,9 +161,9 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
}
$("#filter-log-entries > tbody > tr:gt("+(parseInt($("#filterlogentries").val())-1)+")").remove();
$("#filter-log-entries > tbody > tr").show();
// schedule next fetch
});
// schedule next fetch
setTimeout(fetch_log, 2000);
setTimeout(fetch_log, 5000);
}
fetch_log();

View File

@ -478,25 +478,27 @@ function clockUpdate()
<script>
function ntp_getstatus() {
scroll(0,0);
var url = "/widgets/widgets/ntp_status.widget.php";
var pars = 'updateme=yes';
jQuery.ajax(
url,
{
type: 'get',
data: pars,
complete: ntpstatuscallback
});
// Refresh the status every 1 minute
setTimeout('ntp_getstatus()', 1*60*1000);
}
function ntpstatuscallback(transport) {
// The server returns formatted html code
var responseStringNtp = transport.responseText
jQuery('#ntpstatus').prop('innerHTML',responseStringNtp);
}
// Do the first status check 1 second after the dashboard opens
setTimeout('ntp_getstatus()', 1000);
$(window).load(function() {
function ntp_getstatus() {
scroll(0,0);
var url = "/widgets/widgets/ntp_status.widget.php";
var pars = 'updateme=yes';
jQuery.ajax(
url,
{
type: 'get',
data: pars,
complete: ntpstatuscallback
});
// Refresh the status every 1 minute
setTimeout('ntp_getstatus()', 1*60*1000);
}
function ntpstatuscallback(transport) {
// The server returns formatted html code
var responseStringNtp = transport.responseText
jQuery('#ntpstatus').prop('innerHTML',responseStringNtp);
}
// Do the first status check 1 second after the dashboard opens
setTimeout('ntp_getstatus()', 1000);
});
</script>

View File

@ -35,7 +35,7 @@ $clients = openvpn_get_active_clients();
?>
<script>
$( document ).ready(function() {
$(window).load(function() {
// link kill buttons
$(".act_kill_client").click(function(event){
event.preventDefault();

View File

@ -135,7 +135,7 @@ require_once("system.inc");
/**
* page setup
*/
$( document ).ready(function() {
$(window).load(function() {
// draw cpu graph
nv.addGraph(function() {
system_information_widget_cpu_chart = nv.models.lineChart()

View File

@ -114,7 +114,7 @@
/**
* page setup
*/
$( document ).ready(function() {
$(window).load(function() {
// draw traffic in graph
nv.addGraph(function() {
traffic_graph_widget_chart_in = nv.models.lineChart()