Source
// TODO: remove, do not use timestamp passing to server and back to ensure newest content will be shown.
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
(function($) {
window.flickerfreeScreen = {
screens: [],
responsiveness: 10000,
/**
* Set or reset UI in progress state for element with id.
*
* @param {boolean} in_progress
* @param {string} id
*/
setElementProgressState: function(id, in_progress) {
var elm = $('#flickerfreescreen_'+id);
if (in_progress) {
elm.addClass('is-loading is-loading-fadein delayed-15s');
}
else {
elm.removeClass('is-loading is-loading-fadein delayed-15s');
}
},
add: function(screen) {
// switch off time control refreshing using full page refresh
timeControl.refreshPage = false;
// init screen item
this.screens[screen.id] = screen;
this.screens[screen.id].interval = (screen.interval > 0) ? screen.interval * 1000 : 0;
this.screens[screen.id].timestamp = 0;
this.screens[screen.id].timestampResponsiveness = 0;
this.screens[screen.id].timestampActual = 0;
this.screens[screen.id].isRefreshing = false;
this.screens[screen.id].isReRefreshRequire = false;
this.screens[screen.id].error = 0;
// SCREEN_RESOURCE_MAP
if (screen.resourcetype == 2) {
this.screens[screen.id].data = new SVGMap(this.screens[screen.id].data);
$(screen.data.container).attr({'aria-label': screen.data.options.aria_label, 'tabindex': 0})
.find('svg').attr('aria-hidden', 'true');
}
// init refresh plan
if (screen.isFlickerfree && screen.interval > 0) {
this.screens[screen.id].timeoutHandler = window.setTimeout(
function() {
window.flickerfreeScreen.refresh(screen.id);
},
this.screens[screen.id].interval
);
}
},
remove: function(screen) {
if (typeof screen.id !== 'undefined' && typeof this.screens[screen.id] !== 'undefined') {
if (typeof this.screens[screen.id].timeoutHandler !== 'undefined') {
window.clearTimeout(this.screens[screen.id].timeoutHandler);
}
delete this.screens[screen.id];
}
},
refresh: function(id) {
var screen = this.screens[id];
if (empty(screen.id)) {
return;