Cleaned up redundant js from views

This commit is contained in:
2025-10-26 08:22:24 +01:00
parent c72e863b92
commit 655ac35e35
4 changed files with 0 additions and 241 deletions

View File

@@ -122,32 +122,6 @@ document.addEventListener('DOMContentLoaded', () => {
<script>
function createToastContainer() {
const container = document.createElement('div');
container.id = 'toastContainer';
container.className = 'toast-container position-fixed bottom-0 end-0 p-3';
document.body.appendChild(container);
return container;
}
// Simple toast helper
function showToast(message, type) {
const toastContainer = document.getElementById('toastContainer') || createToastContainer();
const toast = document.createElement('div');
toast.className = `toast align-items-center text-white bg-${type} border-0`;
toast.role = 'alert';
toast.innerHTML = `
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
`;
toastContainer.appendChild(toast);
const bsToast = new bootstrap.Toast(toast, { delay: 3000 });
bsToast.show();
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
document.addEventListener('DOMContentLoaded', () => {
const deleteModal = document.getElementById('deleteModal');
let currentButton = null; // The delete button that opened the modal
@@ -680,72 +654,6 @@ document.addEventListener('DOMContentLoaded', () => {
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.6/dist/JsBarcode.all.min.js" defer></script>
<script>
function downloadBarcode(svgId, filename = "barcode.png") {
const svg = document.getElementById(svgId);
const serializer = new XMLSerializer();
const svgString = serializer.serializeToString(svg);
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
// Optionally set canvas size
const bbox = svg.getBBox();
canvas.width = bbox.width + 20; // padding
canvas.height = bbox.height + 20;
const img = new Image();
const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
const url = URL.createObjectURL(svgBlob);
img.onload = () => {
ctx.drawImage(img, 0, 0);
URL.revokeObjectURL(url);
const pngUrl = canvas.toDataURL("image/png");
const a = document.createElement("a");
a.href = pngUrl;
a.download = filename;
a.click();
};
img.src = url;
}
function printBarcode(svgId) {
const svg = document.getElementById(svgId);
if (!svg) return;
// Serialize the SVG
const serializer = new XMLSerializer();
const svgString = serializer.serializeToString(svg);
// Open a new window for printing
const printWindow = window.open('', '_blank');
printWindow.document.write(`
<html>
<head>
<title>Print Barcode</title>
<style>
body { text-align: center; margin: 0; padding: 20px; }
svg { width: 300px; height: auto; }
</style>
</head>
<body>
${svgString}
</body>
</html>
`);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
function idToEAN13(id) {
const padded = id.toString().padStart(12, "0"); // 12 digits
return padded;
}
document.addEventListener('DOMContentLoaded', () => {
const rows = document.querySelectorAll('.asset-row');
const viewModal = document.getElementById('viewAssetModal');

View File

@@ -90,33 +90,6 @@
<script>
// Simple toast helper
function showToast(message, type) {
const toastContainer = document.getElementById('toastContainer') || createToastContainer();
const toast = document.createElement('div');
toast.className = `toast align-items-center text-white bg-${type} border-0`;
toast.role = 'alert';
toast.innerHTML = `
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
`;
toastContainer.appendChild(toast);
const bsToast = new bootstrap.Toast(toast, { delay: 3000 });
bsToast.show();
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
function createToastContainer() {
const container = document.createElement('div');
container.id = 'toastContainer';
container.className = 'toast-container position-fixed bottom-0 end-0 p-3';
document.body.appendChild(container);
return container;
}
document.addEventListener('DOMContentLoaded', () => {
const deleteModal = document.getElementById('deleteModal');
let currentButton = null; // The delete button that opened the modal

View File

@@ -64,99 +64,6 @@
<script defer>
function createToastContainer() {
const container = document.createElement('div');
container.id = 'toastContainer';
container.className = 'toast-container position-fixed bottom-0 end-0 p-3';
document.body.appendChild(container);
return container;
}
// Simple toast helper
function showToast(message, type) {
const toastContainer = document.getElementById('toastContainer') || createToastContainer();
const toast = document.createElement('div');
toast.className = `toast align-items-center text-white bg-${type} border-0`;
toast.role = 'alert';
toast.innerHTML = `
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
`;
toastContainer.appendChild(toast);
const bsToast = new bootstrap.Toast(toast, { delay: 3000 });
bsToast.show();
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
function downloadBarcode(svgId, filename = "barcode.png") {
const svg = document.getElementById(svgId);
const serializer = new XMLSerializer();
const svgString = serializer.serializeToString(svg);
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
// Optionally set canvas size
const bbox = svg.getBBox();
canvas.width = bbox.width + 20; // padding
canvas.height = bbox.height + 20;
const img = new Image();
const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
const url = URL.createObjectURL(svgBlob);
img.onload = () => {
ctx.drawImage(img, 0, 0);
URL.revokeObjectURL(url);
const pngUrl = canvas.toDataURL("image/png");
const a = document.createElement("a");
a.href = pngUrl;
a.download = filename;
a.click();
};
img.src = url;
}
function printBarcode(svgId) {
const svg = document.getElementById(svgId);
if (!svg) return;
// Serialize the SVG
const serializer = new XMLSerializer();
const svgString = serializer.serializeToString(svg);
// Open a new window for printing
const printWindow = window.open('', '_blank');
printWindow.document.write(`
<html>
<head>
<title>Print Barcode</title>
<style>
body { text-align: center; margin: 0; padding: 20px; }
svg { width: 300px; height: auto; }
</style>
</head>
<body>
${svgString}
</body>
</html>
`);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
function idToEAN13(id) {
const padded = id.toString().padStart(12, "0"); // 12 digits
return padded;
}
async function onScanSuccess(decodedText, decodedResult) {
const rawDecoded = decodedText;
decodedText = decodedText.substr(0,11).replace(/^0+/, '');

View File

@@ -104,35 +104,6 @@
</div>
</div>
<script>
// Simple toast helper
function showToast(message, type) {
const toastContainer = document.getElementById('toastContainer') || createToastContainer();
const toast = document.createElement('div');
toast.className = `toast align-items-center text-white bg-${type} border-0`;
toast.role = 'alert';
toast.innerHTML = `
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
`;
toastContainer.appendChild(toast);
const bsToast = new bootstrap.Toast(toast, { delay: 3000 });
bsToast.show();
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
function createToastContainer() {
const container = document.createElement('div');
container.id = 'toastContainer';
container.className = 'toast-container position-fixed bottom-0 end-0 p-3';
document.body.appendChild(container);
return container;
}
</script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const deleteModal = document.getElementById('deleteModal');