From 864b346ad031dfcff149a3a6976d20aa7d5958e2 Mon Sep 17 00:00:00 2001 From: Hannes Klinckaert Date: Tue, 8 Sep 2020 20:21:32 +0200 Subject: [PATCH] add a color identifier for modules --- debugging_tool/static/index.html | 26 +++++++++++++++++++++++-- debugging_tool/static/script.js | 33 +++++++++++++++++++------------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/debugging_tool/static/index.html b/debugging_tool/static/index.html index 8ad435b..45d69ee 100644 --- a/debugging_tool/static/index.html +++ b/debugging_tool/static/index.html @@ -33,7 +33,7 @@ } th { - background-color: gold; + background-color: #ff7f00;; border-bottom: 2px solid black; border-top: 2px solid black; height: 20px; @@ -44,13 +44,35 @@ background-color: #aaa; } - td[error] { + td.error, td.error > div { background-color: rgb(255, 71, 71); } + td.controller > div { + background-color: lightseagreen; + } + + td.puzzle > div { + background-color: gold; + } + + td.needy > div { + background-color: rgb(128, 10, 128); + } + .time, .raw_id, .sender_id { text-align: right; } + + .colorblock { + height: 20px; + width: 20px; + margin: 3.4px; + margin-right: 8.4px; + display: inline-block; + background-color:lime; + vertical-align: middle; + } diff --git a/debugging_tool/static/script.js b/debugging_tool/static/script.js index d8e8d06..1a2c0e1 100644 --- a/debugging_tool/static/script.js +++ b/debugging_tool/static/script.js @@ -1,15 +1,17 @@ - let maxseen = 0; let paused = true; let updaterID = null; +let color_classes = { + "RESERVED TYPE": "error", + "controller": "controller", + "puzzle": "puzzle", + "needy": "needy", +} + function updateShow() { for (let item of document.getElementsByClassName("raw")) { - if (document.getElementById('show_raw').checked) { - item.classList.remove("hide"); - } else { - item.classList.add("hide"); - } + item.classList.toggle("hide", !document.getElementById('show_raw').checked); } } @@ -30,23 +32,28 @@ function updateMessages() { let current = data[i]; let human_readable_type = row.insertCell(0) - human_readable_type.innerHTML = current['human_readable_type']; - human_readable_type.className = 'human_readable_type'; + let colorblock = document.createElement("div"); + colorblock.classList.add("colorblock"); + human_readable_type.append(colorblock); + + human_readable_type.innerHTML += current['human_readable_type']; + + human_readable_type.classList.add(color_classes[current['human_readable_type']]); + human_readable_type.classList.add('human_readable_type'); let sender_id = row.insertCell(-1) sender_id.innerHTML = current['sender_id']; - sender_id.className = 'sender_id'; - + sender_id.classList.add('sender_id'); let parsed = row.insertCell(-1) if (current['parsed'].startsWith("PARSE ERROR")) { - parsed.setAttribute("error", true); + parsed.classList.add("error"); } parsed.innerHTML = current['parsed']; - parsed.className += 'parsed'; + parsed.classList.add('parsed'); let time = row.insertCell(-1) time.innerHTML = current['time']; - time.className = 'time'; + time.classList.add('time'); let raw_message = row.insertCell(-1); raw_message.innerHTML = current['raw_message'];