agdar/static/custom/js/custom.js
2025-11-02 14:35:35 +03:00

122 lines
4.1 KiB
JavaScript

// // Custom JavaScript for Hospital Management System v4
//
// document.addEventListener('DOMContentLoaded', function() {
// // Initialize tooltips
// var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
// var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
// return new bootstrap.Tooltip(tooltipTriggerEl);
// });
//
// // Initialize popovers
// var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
// var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
// return new bootstrap.Popover(popoverTriggerEl);
// });
//
//
// // Confirm delete actions
// var deleteButtons = document.querySelectorAll('.btn-delete');
// deleteButtons.forEach(function(button) {
// button.addEventListener('click', function(e) {
// if (!confirm('Are you sure you want to delete this item?')) {
// e.preventDefault();
// }
// });
// });
//
// // Form validation
// var forms = document.querySelectorAll('.needs-validation');
// forms.forEach(function(form) {
// form.addEventListener('submit', function(event) {
// if (!form.checkValidity()) {
// event.preventDefault();
// event.stopPropagation();
// }
// form.classList.add('was-validated');
// });
// });
//
// // Number formatting
// function formatCurrency(amount) {
// return new Intl.NumberFormat('en-SA', {
// style: 'currency',
// currency: 'SAR'
// }).format(amount);
// }
//
// // Date formatting
// function formatDate(dateString) {
// return new Date(dateString).toLocaleDateString('en-SA');
// }
//
// // Export functions for global use
// window.formatCurrency = formatCurrency;
// window.formatDate = formatDate;
// });
//
// // API helper functions
// function makeAPICall(url, method = 'GET', data = null) {
// const options = {
// method: method,
// headers: {
// 'Content-Type': 'application/json',
// 'X-CSRFToken': getCookie('csrftoken')
// }
// };
//
// if (data) {
// options.body = JSON.stringify(data);
// }
//
// return fetch(url, options)
// .then(response => {
// if (!response.ok) {
// throw new Error('Network response was not ok');
// }
// return response.json();
// });
// }
//
// // Get CSRF token from cookies
// function getCookie(name) {
// let cookieValue = null;
// if (document.cookie && document.cookie !== '') {
// const cookies = document.cookie.split(';');
// for (let i = 0; i < cookies.length; i++) {
// const cookie = cookies[i].trim();
// if (cookie.substring(0, name.length + 1) === (name + '=')) {
// cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
// break;
// }
// }
// }
// return cookieValue;
// }
//
// // Show loading spinner
// function showLoading(element) {
// element.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...';
// element.disabled = true;
// }
//
// // Hide loading spinner
// function hideLoading(element, originalText) {
// element.innerHTML = originalText;
// element.disabled = false;
// }
//
// (function() {
// 'use strict';
// window.addEventListener('load', function() {
// var forms = document.getElementsByClassName('needs-validation');
// var validation = Array.prototype.filter.call(forms, function(form) {
// form.addEventListener('submit', function(event) {
// if (form.checkValidity() === false) {
// event.preventDefault();
// event.stopPropagation();
// }
// form.classList.add('was-validated');
// }, false);
// });
// }, false);
// })();