]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
update of webqa files master
authorhadaq <jan@lxhadeb07>
Thu, 9 Oct 2025 07:49:17 +0000 (09:49 +0200)
committerhadaq <jan@lxhadeb07>
Thu, 9 Oct 2025 07:49:17 +0000 (09:49 +0200)
hadesroot/files/backupMap.json [new file with mode: 0644]
hadesroot/files/functions_base.mjs [new file with mode: 0644]
hadesroot/files/tab.css

diff --git a/hadesroot/files/backupMap.json b/hadesroot/files/backupMap.json
new file mode 100644 (file)
index 0000000..86b9a00
--- /dev/null
@@ -0,0 +1,127 @@
+{
+    "EMC": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17"
+        ]
+    },
+    "HODO": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "MDC": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "RICH": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "RPC": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "START": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "TOF": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "WALL": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    },
+    "general": {
+        "2025_05_12": [
+            "18_59_43"
+        ],
+        "2025_05_13": [
+            "09_58_33",
+            "10_28_44",
+            "10_38_33",
+            "10_50_26",
+            "13_34_01",
+            "13_48_17",
+            "13_58_37"
+        ]
+    }
+}
diff --git a/hadesroot/files/functions_base.mjs b/hadesroot/files/functions_base.mjs
new file mode 100644 (file)
index 0000000..6a0e203
--- /dev/null
@@ -0,0 +1,170 @@
+export function openTabURL() {
+  const params = new URL(document.location.href).searchParams;
+  const tab = params.get("tab");
+  const tablinks = document.getElementsByClassName("tablinks");
+  let index = 0;
+  for (let i = 0; i < tablinks.length; i++) {
+    if (tablinks[i].getAttribute("onclick").includes(tab))
+      index = i;
+  }
+  const tabcontent = document.getElementsByClassName("tabcontent");
+  for (let i = 0; i < tabcontent.length; i++) {
+    tabcontent[i].classList.remove("active");
+  }
+
+  for (let i = 0; i < tablinks.length; i++) {
+    tablinks[i].classList.remove("active");
+  }
+  tabcontent[index].classList.add("active");
+  tablinks[index].classList.add("active");
+}
+
+export function openTab(evt, name) {
+  // Get all elements with class="tabcontent" and hide them
+  const tabcontent = document.getElementsByClassName("tabcontent");
+  for (let i = 0; i < tabcontent.length; i++) {
+    tabcontent[i].classList.remove("active");
+  }
+
+  // Get all elements with class="tablinks" and remove the class "active"
+  const tablinks = document.getElementsByClassName("tablinks");
+  for (let i = 0; i < tablinks.length; i++) {
+    tablinks[i].classList.remove("active");
+  }
+
+  // Show the current tab, and add an "active" class to the button that opened the tab
+  document.getElementById(name).classList.add("active");
+  evt.currentTarget.classList.add("active");
+
+  updateURL();
+}
+
+export function updateDay(name) {
+  fetch('files/backupMap.json')
+    .then(response => response.json())
+    .then(timeMap => {
+      const daySelect = document.getElementById('daySel');
+      let currVal = daySelect.value;
+      if (!currVal) {
+        let params = new URL(document.location.href).searchParams;
+        currVal = params.get("date");
+      }
+      daySelect.innerHTML = '<option value="LIVE">LIVE</option>';
+      if (!timeMap[name]) {
+        updateTime(name);
+        return;
+      }
+      for (let day of Object.keys(timeMap[name])) {
+        const option = document.createElement('option');
+        option.value = day;
+        option.textContent = day;
+        daySelect.appendChild(option);
+      }
+      if (Array.from(daySelect.options).some(option => option.value === currVal))
+        daySelect.value = currVal;
+
+      updateTime(name);
+    });
+}
+
+export function updateTime(name) {
+  fetch('files/backupMap.json')
+    .then(response => response.json())
+    .then(timeMap => {
+      const daySelect = document.getElementById('daySel');
+      const timeSelect = document.getElementById('timeSel');
+      const selectedDay = daySelect.value;
+      let currVal = timeSelect.value;
+      if (!currVal) {
+        let params = new URL(document.location.href).searchParams;
+        currVal = params.get("time");
+      }
+
+      while (timeSelect.firstChild) {
+        timeSelect.removeChild(timeSelect.lastChild);
+      }
+      if (!timeMap[name] || !timeMap[name][selectedDay]) {
+        updateURL();
+        return;
+      }
+
+      timeMap[name][selectedDay].forEach(time => {
+        const option = document.createElement('option');
+        option.value = time;
+        option.textContent = time;
+        timeSelect.appendChild(option);
+      });
+      if (Array.from(timeSelect.options).some(option => option.value === currVal))
+        timeSelect.value = currVal;
+      if (!timeSelect.value)
+        timeSelect.value = timeSelect.firstChild.value;
+
+      updateURL();
+    });
+}
+
+export function updateURL() {
+  const url = new URL(document.location.href);
+  const params = url.searchParams;
+  const selectedDay = document.getElementById('daySel').value;
+  if (selectedDay && selectedDay != 'LIVE') {
+    params.set('date', selectedDay);
+    const selectedTime = document.getElementById('timeSel').value;
+    params.set('time', selectedTime);
+  }
+  else {
+    params.delete('date');
+    params.delete('time');
+  }
+  const tabcontent = document.getElementsByClassName("tabcontent");
+  let selectedTab = 0;
+  for (let t = 0; t < tabcontent.length; t++) {
+    if (tabcontent[t].classList.contains("active"))
+      selectedTab = tabcontent[t].id;
+  }
+  params.set('tab', selectedTab);
+  window.history.pushState({}, '', url);
+}
+
+export function createPalette(p, v, n = 100) {
+  let min = p[0];
+  let max = p[p.length - 1];
+  let range = max - min;
+  let grad = [];
+  p[0] = 0;
+  p[p.length - 1] = 1;
+  for (let i = 1; i < p.length - 1; i++) {
+    p[i] = (p[i] - min) / range;
+  }
+  let r = [], g = [], b = [];
+  for (let i = 0; i < v.length; i++) {
+    if (v[i] == 'red') { r[i] = 0xff; g[i] = 0; b[i] = 0; }
+    else if (v[i] == 'yellow') { r[i] = 0xff; g[i] = 0xff; b[i] = 0; }
+    else if (v[i] == 'violet') { r[i] = 0xff; g[i] = 0; b[i] = 0xff; }
+    else if (v[i] == 'orange') { r[i] = 0xff; g[i] = 0x80; b[i] = 0; }
+    else if (v[i] == 'black') { r[i] = 0; g[i] = 0; b[i] = 0; }
+    else if (v[i] == 'blue') { r[i] = 0; g[i] = 0; b[i] = 0xa0; }
+    else if (v[i] == 'green') { r[i] = 0; g[i] = 0xff; b[i] = 0; }
+    else {
+      r[i] = parseInt(v[i].substring(1, 3), 16);
+      g[i] = parseInt(v[i].substring(3, 5), 16);
+      b[i] = parseInt(v[i].substring(5, 7), 16);
+    }
+  }
+  let num = 0;
+  for (let i = 1; i < n; i++) {
+    let numg = Math.floor(n * p[i]) - Math.floor(n * p[i - 1]);
+    for (let c = 0; c < numg; c++) {
+      grad[num] = "rgb(";
+      grad[num] += Math.round(r[i - 1] + c * (r[i] - r[i - 1]) / numg);
+      grad[num] += ',';
+      grad[num] += Math.round(g[i - 1] + c * (g[i] - g[i - 1]) / numg);
+      grad[num] += ',';
+      grad[num] += Math.round(b[i - 1] + c * (b[i] - b[i - 1]) / numg);
+      grad[num] += ')';
+      num++;
+    }
+  }
+
+  return grad;
+}
index 42c81c1564771a49b9c7643817ea3af28fbc0cfd..ef61729e55ab97fad399ea5967c9b9444a0467b8 100644 (file)
@@ -171,7 +171,7 @@ body {
   max-height:none;
   text-align:left;
   background:#ddd;
-  overflow:scroll;
+  overflow:auto;
   width:200px;
   height:200px;
   font-size:80%;