From 9f942ded9ca4bc3794595c08e396a8cbd41a7ff4 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 30 Oct 2017 10:44:12 +0100 Subject: [PATCH] Added support of TAG albel in live dashboard --- static/js/index/index.js | 20 +++++++++++++++++++- templates/index.html | 11 +++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/static/js/index/index.js b/static/js/index/index.js index 3b7724b..ba5c257 100644 --- a/static/js/index/index.js +++ b/static/js/index/index.js @@ -267,9 +267,27 @@ function slideAndMax(orig, newData) { return [curMaxDataNumLog, slided]; } +function getTextColour(rgb) { + var r = parseInt('0x'+rgb.substring(0,2)); + var g = parseInt('0x'+rgb.substring(2,4)); + var b = parseInt('0x'+rgb.substring(4,6)); + var avg = ((2 * r) + b + (3 * g))/6; + if (avg < 128) { + return 'white'; + } else { + return 'black'; + } +} + function addObjectToLog(name, obj, td) { if(name == "Tag") { - td.appendChild(document.createTextNode('tag')); + var a = document.createElement('A'); + a.classList.add('tagElem'); + a.style.backgroundColor = obj.colour; + a.style.color = getTextColour(obj.colour.substring(1,6)); + a.innerHTML = obj.name; + td.appendChild(a); + td.appendChild(document.createElement('br')); } else if (name == "mispObject") { td.appendChild(document.createTextNode('mispObj')); } else { diff --git a/templates/index.html b/templates/index.html index 670ec8c..8e45eae 100644 --- a/templates/index.html +++ b/templates/index.html @@ -30,6 +30,17 @@