mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Cleaned up redundant js from views
This commit is contained in:
@@ -122,32 +122,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const deleteModal = document.getElementById('deleteModal');
|
const deleteModal = document.getElementById('deleteModal');
|
||||||
let currentButton = null; // The delete button that opened the modal
|
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 src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.6/dist/JsBarcode.all.min.js" defer></script>
|
||||||
|
|
||||||
<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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const rows = document.querySelectorAll('.asset-row');
|
const rows = document.querySelectorAll('.asset-row');
|
||||||
const viewModal = document.getElementById('viewAssetModal');
|
const viewModal = document.getElementById('viewAssetModal');
|
||||||
|
|||||||
@@ -90,33 +90,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const deleteModal = document.getElementById('deleteModal');
|
const deleteModal = document.getElementById('deleteModal');
|
||||||
let currentButton = null; // The delete button that opened the modal
|
let currentButton = null; // The delete button that opened the modal
|
||||||
|
|||||||
@@ -64,99 +64,6 @@
|
|||||||
|
|
||||||
<script defer>
|
<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) {
|
async function onScanSuccess(decodedText, decodedResult) {
|
||||||
const rawDecoded = decodedText;
|
const rawDecoded = decodedText;
|
||||||
decodedText = decodedText.substr(0,11).replace(/^0+/, '');
|
decodedText = decodedText.substr(0,11).replace(/^0+/, '');
|
||||||
|
|||||||
@@ -104,35 +104,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const deleteModal = document.getElementById('deleteModal');
|
const deleteModal = document.getElementById('deleteModal');
|
||||||
|
|||||||
Reference in New Issue
Block a user