From 68163429fbff1d26082b31ec21562e354f1fb543 Mon Sep 17 00:00:00 2001 From: arnoudkooi Date: Thu, 22 Feb 2024 22:47:44 +0100 Subject: [PATCH] Improve node switching #477 --- CHANGELOG.md | 5 +++++ css/style.css | 6 +++++- manifest.json | 2 +- popup.js | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c440fee..b7a6165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG.md +## 7.3.2.2 (2024-02-22) +Fixes / changes: + - Improve cookie switching (Issue #477) + - Minor CSS adjustments for the popup window + ## 7.3.2.0 (2024-02-22) Features: - Detect links in activity (Classic UI) and convert to hyperlinks. Works on page load, and on mouse over of activity label. diff --git a/css/style.css b/css/style.css index 0544d9c..d6a6e60 100644 --- a/css/style.css +++ b/css/style.css @@ -16,6 +16,10 @@ input { accent-color: #5274FF; } +a { + text-decoration: none; +} + div.info{ border:1pt solid #ff8234; width:50%; @@ -300,7 +304,7 @@ div.snucmdurl { i.fas, i.far{ font-size:9pt; - padding-right: 3px; + margin-right: 3px; text-align: center; } diff --git a/manifest.json b/manifest.json index 3e40330..b14d6c6 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "short_name": "SN Utils", "description": "Productivity tools for ServiceNow. (Personal work, not affiliated to ServiceNow)", "author": "Arnoud Kooi / arnoudkooi.com", - "version": "7.3.2.0", + "version": "7.3.2.2", "manifest_version": 3, "permissions": [ "activeTab", diff --git a/popup.js b/popup.js index a9b7d24..2f8cded 100644 --- a/popup.js +++ b/popup.js @@ -161,6 +161,12 @@ function prepareJsonTable() { //Query ServiceNow for nodes function getNodes() { + + let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); + if (isSafari) { + document.querySelector('#nodemessage').innerText = "Node switching may not work in Safari"; + } + var myurl = url + '/api/now/table/sys_cluster_state?sysparm_query=ORDERBYsystem_id&sysparm_fields=system_id,node_id,status,node_type&sysparm_display_value=true&sysparm_exclude_reference_link=true'; snuFetch(g_ck, myurl, null, function (jsn) { setNodes(jsn.result); @@ -170,9 +176,10 @@ function getNodes() { async function setActiveNode(node) { + await fetch(url + '/example_add_two_numbers.do'); // call a random leightweight page that returns not found, to make browser aware of new node + let response = await fetch(url + '/stats.do'); let statsDo = await response.text(); - if (!statsDo.includes('Servlet statistics')) { //after a node switch, sometimes the first call fails. Try again response = await fetch(url + '/stats.do'); statsDo = await response.text(); @@ -987,9 +994,16 @@ function setDataTableNodes(nme, node) { dtNodes.search($(this).val(),true).draw(); }).focus().trigger('keyup'); - $('a.setnode').click(function () { + $('a.setnode').click(function (ev) { + + ev.currentTarget.innerHTML = " Switching..."; + ev.currentTarget.style.color = "blue"; + console.log(ev); var node = {"nodeId" : this.id, "nodeName" : $(this).attr('data-node') }; setActiveNode(node) + + + }); $('#waitingnodes').hide();