From 34871f37296289ecc11b4475b61e2c7f5122527c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 9 Nov 2024 22:15:53 +0100 Subject: [PATCH] fix: More cleanup in JS --- website/web/sri.txt | 4 +-- website/web/static/generic.js | 12 ++++++++- website/web/static/hostname_popup.js | 40 +++++----------------------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/website/web/sri.txt b/website/web/sri.txt index e2d7cb3b..3c7190f8 100644 --- a/website/web/sri.txt +++ b/website/web/sri.txt @@ -20,8 +20,8 @@ "favicon.ico": "KOmrfwRbOQqhhwSeBkNpMRAxSVMmmLg+2kRMg9iSv7OWjE9spJc7x4MKB4AE/hi0knaV7UBVctAU6XZ7AC72ZA==", "font.png": "RwoQkj9dT9SLUL2F7cAA16Nat9t2hDb58eQlHF9ThUar829p0INUXG+5XuDaFOC8SsmCZK5vw2f+YAQ6mLC1Qw==", "generic.css": "Sh/BcxFMLYYaLdCluVt9efGvJ9CF5d+YJ7lkL2M24PRGu8VZHI9lJiUlFObIocjQgwss3Ve2U5cUAE5WiAdpQQ==", - "generic.js": "/8a1CxlMcMAwl3UMfcGVe1smZZUB0gesxjd3Bmy7LLV16gE/ZPq6HciOnjNq0Jh+55PSSgIRLPsTbqGNv6Mcxw==", - "hostname_popup.js": "8VoaZVwk2FBFCBVjgAup534WPy8B+e5/uUJPqyERUYf3kBcUVC8/T72ha9BYPYj5a6SNOOUJPgVmD5QI6qtAWw==", + "generic.js": "4IMm1lUySxybv57NQgNSvGyzWzihzPl26cBvbai/5MYMcil964nNfiTBgF2ifhZAwDvLMlu7V1h+LOcc/3DDOw==", + "hostname_popup.js": "vBWeN+TLq3OnuUqfmDWiDT10C4lzwklvqZFO9bTvabARHPGZ/95WOETDEXcbvWkx7YUO8Ybp/MTYLg01CKQeyA==", "html.png": "T7pZrb8MMDsA/JV/51hu+TOglTqlxySuEVY0rpDjTuAEyhzk2v+W4kYrj7vX+Tp3n2d2lvVD08PwhCG62Yfbzg==", "ifr.png": "rI5YJypmz1QcULRf9UaOYSqV4tPUSxUdLAycoYzCwywt4Pw4eWzBg9SUr769VyIimoiIyJR+aNuoIA4p5WO2fQ==", "img.png": "bknBlmIfSb9qv9/lSaJ2idn2a8bDyvJ2pATj4oOpehRlCdXlWYOyb2jN3wV1QGHFoqyxNqOv5MfCpI0tbqkicg==", diff --git a/website/web/static/generic.js b/website/web/static/generic.js index 5ae8d47f..14582f74 100644 --- a/website/web/static/generic.js +++ b/website/web/static/generic.js @@ -52,10 +52,20 @@ openNewTabButtons.forEach(el => el.addEventListener('click', event => { if (window.opener === null) { return openTreeInNewTab(el.dataset.capture, el.dataset.hostnode) } else { - return window.opener.openTreeInNewTab(el.dataset.capture, el.dataset.hostnode); + let success = window.opener.openTreeInNewTab(el.dataset.capture, el.dataset.hostnode); + if (! success) { + alert("Your browser doesn't allow Lookyloo to open a new tab. There should be an icon on the right side of your URL bar *in the main window* to allow it."); + } } })); +const locateInTree = document.querySelectorAll(".locateInTree") +if (locateInTree) { + locateInTree.forEach(el => el.addEventListener('click', event => { + window.opener.LocateNode(el.dataset.hostnode); + })); +} + // Parameters: // contentType: The content type of your file. // its like application/pdf or application/msword or image/jpeg or diff --git a/website/web/static/hostname_popup.js b/website/web/static/hostname_popup.js index 9d4ca200..de655e0d 100644 --- a/website/web/static/hostname_popup.js +++ b/website/web/static/hostname_popup.js @@ -1,24 +1,3 @@ -const locateInTree = document.querySelectorAll(".locateInTree") -if (locateInTree) { - locateInTree.forEach(el => el.addEventListener('click', event => { - window.opener.LocateNode(el.dataset.hostnode); - })); -} - -let openTreeInNewTab = (capture_uuid, hostnode_uuid=Null) => { - let success = window.opener.openTreeInNewTab(capture_uuid, hostnode_uuid); - if (! success) { - alert("Your browser doesn't allow Lookyloo to open a new tab. There should be an icon on the right side of your URL bar *in the main window* to allow it."); - } -} - -var openNewTabButtons = document.querySelectorAll('.openNewTab'); -if (openNewTabButtons) { - openNewTabButtons.forEach(el => el.addEventListener('click', event => { - openTreeInNewTab(el.dataset.capture, el.dataset.hostnode); - })); -} - document.addEventListener("DOMContentLoaded", () => { // Grab any text in the attribute 'data-copy' and pass it to the copy function $('.js-copy').tooltip(); @@ -59,16 +38,9 @@ function submit_pandora(node_uuid, ressource_hash){ }); }; -var submitPandoraButtons = document.querySelectorAll('.submitPandoraButton'); -if (submitPandoraButtons) { - submitPandoraButtons.forEach(el => el.addEventListener('click', event => { - submit_pandora(el.dataset.hostnode, el.dataset.hash); - })); -} - -let openURLInNewTab = (url) => { - let success = window.opener.openURLInNewTab(url); - if (! success) { - alert("Your browser doesn't allow Lookyloo to open a new tab. There should be an icon on the right side of your URL bar *in the main window* to allow it."); - } -} +document.addEventListener("DOMContentLoaded", () => { + document.querySelectorAll('.submitPandoraButton').forEach( + el => el.addEventListener('click', event => { + submit_pandora(el.dataset.hostnode, el.dataset.hash); + })); +});