![]() |
|
Group adress updated at - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: OLD visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9) +--- Thread: Group adress updated at (/showthread.php?tid=2327) |
Group adress updated at - PassivPluss - 06.11.2019 Hi As subject indicated iam wondering if it is possible to get a "tooltip" when holding mouse over objects in visu that grabs the updated at from group adress? This is to indicate if the value is new or old? RE: Group adress updated at - buuuudzik - 06.11.2019 As I know only by Custom Javascript + .lp file. Custom JS could lhave such code: Code: $(function(){
const updatetimes = {};
const marked = document.querySelectorAll(".when-updated");
const gaMatcher = /wh\-([0-9]+)_([0-9]+)_([0-9]+)/i;
const isDef = n => typeof n !== "undefined";
const showDate = updatetime => new Date(updatetime * 1000).toString();
marked.forEach(element => {
let loaded = false;
const [matching, a, b, c] = element.className.match(gaMatcher);
if (!matching) return;
const ga = `${a}/${b}/${c}`;
if (typeof updatetimes[ga] === "undefined") updatetimes[ga] = 0;
grp.listen(ga, (object, state) => {
if (state === "value" && loaded) {
updatetimes[ga] = Date.now()/1000;
element.title = updatetimes[ga] ? showDate(updatetimes[ga]) : null;
}
}, true);
});
const updateUpdatetimes = data => {
if (!data) return;
const objects = JSON.parse(data);
Object.keys(updatetimes).forEach(ga => {
const found = objects.find(obj => obj.address === ga);
if (found.updatetime > updatetimes[ga]) {
updatetimes[ga] = found.updatetime;
document.querySelectorAll(`.wh-${ga.split("/").join("_")}`).forEach(element => element.title = showDate(updatetimes[ga]))
}
});
loaded = true;
}
// download current grp.all() from object.lp
$.get("/user/objects.lp", data => updateUpdatetimes(data));
});You need also /user/objects.lp file with such content: Code: <?
require("json")
require("genohm-scada")
require("apps")
objects = json.encode(grp.all())
print(objects)
?>Then all controls on the visu which will have special classes e.g. "when-updated wh-1_1_1" (for 1/1/1 address) will have title with last updated info (). This is only some scratch, for a start
|