chg: remove more JS from hell

pull/990/head
Raphaël Vinot 2024-11-11 02:06:19 +01:00
parent 34871f3729
commit bece3c6960
6 changed files with 63 additions and 87 deletions

View File

@ -20,8 +20,8 @@
"favicon.ico": "KOmrfwRbOQqhhwSeBkNpMRAxSVMmmLg+2kRMg9iSv7OWjE9spJc7x4MKB4AE/hi0knaV7UBVctAU6XZ7AC72ZA==",
"font.png": "RwoQkj9dT9SLUL2F7cAA16Nat9t2hDb58eQlHF9ThUar829p0INUXG+5XuDaFOC8SsmCZK5vw2f+YAQ6mLC1Qw==",
"generic.css": "Sh/BcxFMLYYaLdCluVt9efGvJ9CF5d+YJ7lkL2M24PRGu8VZHI9lJiUlFObIocjQgwss3Ve2U5cUAE5WiAdpQQ==",
"generic.js": "4IMm1lUySxybv57NQgNSvGyzWzihzPl26cBvbai/5MYMcil964nNfiTBgF2ifhZAwDvLMlu7V1h+LOcc/3DDOw==",
"hostname_popup.js": "vBWeN+TLq3OnuUqfmDWiDT10C4lzwklvqZFO9bTvabARHPGZ/95WOETDEXcbvWkx7YUO8Ybp/MTYLg01CKQeyA==",
"generic.js": "B1Kd8EpQRDDLAxh7eD2QZNyDBwY8zyC8NBoGhml8zpF9TRsEtiH7XcXus+NMNvRtqKoo93Xhc+JTAW9Fn0lMdw==",
"hostname_popup.js": "kYsVppmphN/tsdLnWVHD8GAVp4CvViRWquL5xVowLsALai/Oeb2RXVYn7SsVoMOuvWaGVmzsY4ZkxetgNJhGdA==",
"html.png": "T7pZrb8MMDsA/JV/51hu+TOglTqlxySuEVY0rpDjTuAEyhzk2v+W4kYrj7vX+Tp3n2d2lvVD08PwhCG62Yfbzg==",
"ifr.png": "rI5YJypmz1QcULRf9UaOYSqV4tPUSxUdLAycoYzCwywt4Pw4eWzBg9SUr769VyIimoiIyJR+aNuoIA4p5WO2fQ==",
"img.png": "bknBlmIfSb9qv9/lSaJ2idn2a8bDyvJ2pATj4oOpehRlCdXlWYOyb2jN3wV1QGHFoqyxNqOv5MfCpI0tbqkicg==",
@ -33,13 +33,13 @@
"loader.gif": "ZZKD5vLSKBWKeUpa2KI9qheUJ49iTI/UULmVU/AX28fBfH00K3lLc2v5pVJZ4qXG1BbB13LTXzRKKU35H2XfNg==",
"lookyloo.jpeg": "i6wBj8CsIM5YAQLEMQfhs3CNOSKkErF8AMqqM6ZygSwCyQgv9CU8xt94veMZhM/ufBWoz7kAXmR+yywmxsTxug==",
"redirect.png": "PAjzlPV97rEFvH55mG1ZC9wRl98be3yMeX/nENuFkJcds6/AXgSR2ig/QyPULgobSnNgiYieLVWY/oqsgeywrQ==",
"render_tables.js": "OLZO9NhH1yPc6oneYjwRyk0aVAEPGlt/O6TjGvqhFYj8FMZSP9w32kTByYzWXIY0AszJj6It33u8U2uLuGiEZQ==",
"render_tables.js": "Lpte5N1uaEGRFWyn8DlriXQUS51LEMBTj9Ux8CcdkTcg70LuuTo3RPdBrC2b63U/sdaOR9RuDFo9Z4UELK2GTw==",
"secure.svg": "H8ni7t0d60nCJDVGuZpuxC+RBy/ipAjWT627D12HlZGg6LUmjSwPTQTUekm3UJupEP7TUkhXyq6WHc5gy7QBjg==",
"stats.css": "/kY943FwWBTne4IIyf7iBROSfbGd82TeBicEXqKkRwawMVRIvM/Pk5MRa7okUyGIxaDjFQGmV/U1vy+PhN6Jbw==",
"stats_graph.js": "S/sMNQK1UMMLD0xQeEa7sq3ce8o6oPxwxGlyKVtaHOODjair86dbBDm7cu6pa/elMRDJT1j09jEFjWp+5GbhTw==",
"tree.css": "jc7+RiJaZy7utfMu7iMWicpt0y0ZFiEQlB4c7MFNdlWcZf0czi3LgSQUFlDWt828Mx463V+JP1RalXuRjbGcEg==",
"tree.js": "lj5SMtMYs2Oo++fWzHl2aQVHraCFZgpLCey99kql5wjhpYXryoacHM1zLHrP9E6A+b/1VA2zun9d445E3RLk4Q==",
"tree_modals.js": "mGWQ9o4O+x8vBe9XNuAFrEfz8veuRwqE+wpreVKFQcvBvxNcgvxI0SjH9Z3gdozTTY7Hq7yqvC7xA9PWDblN/Q==",
"tree_modals.js": "E3SbfY0PXAwAOjaTu+l8VJ1L84bM7VgMRt3xEwdsPmstipyAlFtJAUTBV1FoV6nXRp7vKqeHtKDvncgapGs1Uw==",
"up.jpg": "d1ljZJ9f5JekyM6RLFFH2Ua44j6neiQBdUIXOenRTjGppQr3JaeglpQIH6BjPCJL177+TH52U3UIRNS5YAyKIg==",
"up_right.jpg": "OMmz+n+MxR34P8/fn5t4DkqKqdJRzQbXQ7fAi2lhkZIJGhVs2vIyY1f2hpYoBxDAX1OcYsSE2lqIR2vXNDGZsA==",
"video.png": "gJtmkfr8I1Kw43pYEKjg6CAjgmhl1vIBKBQ3ZkxCu3wvxQm+6kf93iLrrFiY2WuiXzxEn2Leu52GJzmVN5id0g==",

View File

@ -1,23 +1,5 @@
"use strict";
// Copy to clipboard
// Source: https://codepen.io/nathanlong/pen/ZpAmjv
let copyToClipboard = (text, el) => {
const elOriginalText = el.attr('data-original-title');
const copyTextArea = document.createElement("textarea");
copyTextArea.value = text;
document.body.appendChild(copyTextArea);
copyTextArea.select();
const successful = document.execCommand('copy');
const msg = successful ? 'Copied!' : 'Whoops, not copied!';
el.attr('data-original-title', msg).tooltip('show');
document.body.removeChild(copyTextArea);
el.attr('data-original-title', elOriginalText);
}
function checkAllBoxes(name) {
let checkboxs = document.getElementsByName(name);
for(let i = 0; i < checkboxs.length ; i++) {
@ -42,30 +24,6 @@ function openTreeInNewTab(capture_uuid, hostnode_uuid=null) {
return openURLInNewTab(url);
}
const goBackButtons = document.querySelectorAll('.goBack');
goBackButtons.forEach(el => el.addEventListener('click', event => {
window.history.back();
}));
const openNewTabButtons = document.querySelectorAll('.openNewTab');
openNewTabButtons.forEach(el => el.addEventListener('click', event => {
if (window.opener === null) {
return openTreeInNewTab(el.dataset.capture, el.dataset.hostnode)
} else {
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
@ -80,3 +38,25 @@ function downloadBase64File(contentType, base64Data, fileName) {
downloadLink.download = fileName;
downloadLink.click();
}
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll('.goBack').forEach(el => el.addEventListener('click', event => {
window.history.back();
}));
document.querySelectorAll('.openNewTab').forEach(el => el.addEventListener('click', event => {
if (window.opener === null) {
return openTreeInNewTab(el.dataset.capture, el.dataset.hostnode)
} else {
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.");
}
}
}));
document.querySelectorAll(".locateInTree").forEach(el => el.addEventListener('click', event => {
window.opener.LocateNode(el.dataset.hostnode);
}));
});

View File

@ -1,19 +1,3 @@
document.addEventListener("DOMContentLoaded", () => {
// Grab any text in the attribute 'data-copy' and pass it to the copy function
$('.js-copy').tooltip();
$('.js-copy').click(function() {
const text = $(this).attr('data-copy');
const el = $(this);
copyToClipboard(text, el);
});
});
document.addEventListener("DOMContentLoaded", () => {
$(function () {
$('[data-bs-toggle="tooltip"]').tooltip()
})
});
function submit_pandora(node_uuid, ressource_hash){
let data = {};
if (node_uuid) {
@ -39,8 +23,20 @@ function submit_pandora(node_uuid, ressource_hash){
};
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll('.submitPandoraButton').forEach(
el => el.addEventListener('click', event => {
submit_pandora(el.dataset.hostnode, el.dataset.hash);
}));
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
document.querySelectorAll('.submitPandoraButton').forEach(
el => el.addEventListener('click', event => {
submit_pandora(el.dataset.hostnode, el.dataset.hash);
}));
document.querySelectorAll('.js-copy').forEach(
el => el.addEventListener('click', event => {
navigator.clipboard.writeText(el.dataset.copy).then(function() {
el.setAttribute('data-bs-original-title', 'Copying to clipboard was successful!');
}, function(err) {
el.setAttribute('data-bs-original-title', 'Could not copy text: ' + err);
});
})
);
});

View File

@ -1,4 +1,4 @@
["load", "shown.bs.modal"].forEach(e => window.addEventListener(e, function() {
["DOMContentLoaded", "shown.bs.modal", "jquery.modal.rendered"].forEach(e => window.addEventListener(e, function() {
if (document.getElementById('bodyHashDetailsTable')) {
new DataTable('#bodyHashDetailsTable', {

View File

@ -3,108 +3,108 @@
$('#hashlookupModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#modulesModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#historyModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#categoriesModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#statsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#identifiersModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#identifierDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#faviconsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#faviconDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#captureHashesTypesModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#captureHashesTypesDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#faviconDetailsProbabilisticHashModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#bodyHashesModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#bodyHashDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#hostnamesModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#hostnameDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#urlsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#urlDetailsModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
$('#mispPushModal').on('show.bs.modal', function(e) {
@ -134,7 +134,7 @@ $('#mispLookupModal').on('show.bs.modal', function(e) {
$('#urlsInPageModal').on('show.bs.modal', function(e) {
var button = $(e.relatedTarget);
var modal = $(this);
modal.find('.modal-body').load(button.data("remote"));
modal.find('.modal-body').load(button.data("remote")).trigger('jquery.modal.rendered');
});
// Categories

View File

@ -143,7 +143,7 @@
... /{{ shorten_string(url['url_path'], 50)}}
{# Copy full URL to clipbard #}
<button type="button" class="btn btn-default btn-copy js-copy"
data-bs-toggle="tooltip" data-bs-placement="bottom" data-copy="{{ url['url_object'].name }}" data-original-title="Copy to clipboard">
data-bs-toggle="tooltip" data-bs-placement="bottom" data-copy="{{ url['url_object'].name }}" data-bs-original-title="Copy to clipboard">
<svg class="bi bi-clipboard" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
<path fill-rule="evenodd" d="M9.5 1h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>