28.08.2024, 12:53
Here's a working example that should be added to Custom JavaScript. Change tag, plan_id and img variables as needed.
Code:
$(function() {
if (typeof grp != 'object') {
return;
}
var tag = 'light';
var plan_id = 1;
function check() {
var objs = grp.tag(tag);
var res = false;
$.each(objs, function(id, obj) {
res = res || obj.value;
});
if (currentPlanId == plan_id) {
var img;
if (res) {
img = '/scada/resources/img/light.png';
}
else {
img = '/scada/resources/img/dark.png';
}
img = 'url(' + img + ')';
$E.planBg
.css('background-image', img)
.data('background-image', img);
}
}
grp.taglisten(tag, check);
$E.body.on('showplan', check);
});