X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Fmonitoring%2Fmonitor.js;h=ec4821cc5f9a20b3b917e747dff3fa6e76cc2050;hb=24d000c2290126abf88204089d132229d63f9a05;hp=22d71824a7f231124dcdd8049c978a7abffa3112;hpb=80444c55e5debc4807df81342e537b5a4e6c4971;p=src%2Fapp-framework-binder.git diff --git a/test/monitoring/monitor.js b/test/monitoring/monitor.js index 22d71824..ec4821cc 100644 --- a/test/monitoring/monitor.js +++ b/test/monitoring/monitor.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 "IoT.bzh" + * Copyright (C) 2017, 2018 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,6 +39,8 @@ var logmsgs_node; var apis_node; var all_node; +var styles; + /* flags */ var show_perms = false; var show_monitor_events = false; @@ -81,7 +83,14 @@ function on_connect(evt) { connect(); } +function next_style(evt) { + styles.next(); +} + function init() { + styles = makecss(); + at("style").onclick = next_style; + /* prepare the DOM templates */ t_api = at("t-api").content.firstElementChild; t_verb = at("t-verb").content.firstElementChild; @@ -122,7 +131,7 @@ function init() { at("param-host").value = document.location.hostname; at("param-port").value = document.location.port; var args = new URLSearchParams(document.location.search.substring(1)); - at("param-token").value = args.get("x-afb-token") || args.get("token") || "hello"; + at("param-token").value = args.get("x-afb-token") || args.get("token") || "HELLO"; document.onbeforeunload = on_disconnect; @@ -499,6 +508,7 @@ function obj2html(json) { cls = 'key'; } else { cls = 'string'; + match = match.replace(/\\n/g, "\\n
"); } } else if (/true|false/.test(match)) { cls = 'boolean'; @@ -509,3 +519,44 @@ function obj2html(json) { }); } +function makecss() +{ + var i, l, a, links, x; + + x = { idx: 0, byidx: [], byname: {}, names: [] }; + links = document.getElementsByTagName("link"); + for (i = 0 ; i < links.length ; i++) { + l = links[i]; + if (l.title && l.rel.indexOf( "stylesheet" ) != -1) { + if (!(l.title in x.byname)) { + x.byname[l.title] = x.byidx.length; + x.names.push(l.title); + x.byidx.push([]); + } + x.byidx[x.byname[l.title]].push(l); + } + } + + x.set = function(id) { + if (id in x.byname) + id = x.byname[id]; + if (id in x.byidx) { + var i, j, a, b; + x.idx = id; + a = x.byidx; + for (i = 0 ; i < a.length ; i++) { + b = a[i]; + for (j = 0 ; j < b.length ; j++) + b[j].disabled = i != id; + } + } + }; + + x.next = function() { + x.set((x.idx + 1) % x.byidx.length); + }; + + x.set(0); + return x; +} +