diff --git a/assets/js/calendar.js b/assets/js/calendar.js index ff6c3ff..b31652e 100644 --- a/assets/js/calendar.js +++ b/assets/js/calendar.js @@ -1,86 +1,77 @@ -today = new Date(); -currentMonth = today.getMonth(); -currentYear = today.getFullYear(); -selectYear = document.getElementById("year"); -selectMonth = document.getElementById("month"); +today = new Date() +currentMonth = today.getMonth() +currentYear = today.getFullYear() +selectYear = document.getElementById('year') +selectMonth = document.getElementById('month') -months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; +months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] -monthAndYear = document.getElementById("monthAndYear"); -showCalendar(currentMonth, currentYear); +monthAndYear = document.getElementById('monthAndYear') +showCalendar(currentMonth, currentYear) - -function next() { - currentYear = (currentMonth === 11) ? currentYear + 1 : currentYear; - currentMonth = (currentMonth + 1) % 12; - showCalendar(currentMonth, currentYear); +function next () { + currentYear = (currentMonth === 11) ? currentYear + 1 : currentYear + currentMonth = (currentMonth + 1) % 12 + showCalendar(currentMonth, currentYear) } -function previous() { - currentYear = (currentMonth === 0) ? currentYear - 1 : currentYear; - currentMonth = (currentMonth === 0) ? 11 : currentMonth - 1; - showCalendar(currentMonth, currentYear); +function previous () { + currentYear = (currentMonth === 0) ? currentYear - 1 : currentYear + currentMonth = (currentMonth === 0) ? 11 : currentMonth - 1 + showCalendar(currentMonth, currentYear) } -function jump() { - currentYear = parseInt(selectYear.value); - currentMonth = parseInt(selectMonth.value); - showCalendar(currentMonth, currentYear); +function jump () { + currentYear = parseInt(selectYear.value) + currentMonth = parseInt(selectMonth.value) + showCalendar(currentMonth, currentYear) } -function showCalendar(month, year) { - - let firstDay = (new Date(year, month)).getDay(); - - tbl = document.getElementById("calendar-body"); // body of the calendar - - // clearing all previous cells - tbl.innerHTML = ""; - - // filing data about month and in the page via DOM. - monthAndYear.innerHTML = months[month] + " " + year; - selectYear.value = year; - selectMonth.value = month; - - // creating all cells - let date = 1; - for (let i = 0; i < 6; i++) { - // creates a table row - let row = document.createElement("tr"); - - //creating individual cells, filing them up with data. - for (let j = 0; j < 7; j++) { - if (i === 0 && j < firstDay) { - cell = document.createElement("td"); - cellText = document.createTextNode(""); - cell.appendChild(cellText); - row.appendChild(cell); - } - else if (date > daysInMonth(month, year)) { - break; - } - - else { - cell = document.createElement("td"); - cellText = document.createTextNode(date); - if (date === today.getDate() && year === today.getFullYear() && month === today.getMonth()) { - cell.classList.add("bg-primary", "text-white", "shadow-lg"); - } // color today's date - cell.appendChild(cellText); - row.appendChild(cell); - date++; - } - - - } - - tbl.appendChild(row); // appending each row into calendar body. +function showCalendar (month, year) { + const firstDay = (new Date(year, month)).getDay() + + tbl = document.getElementById('calendar-body') // body of the calendar + + // clearing all previous cells + tbl.innerHTML = '' + + // filing data about month and in the page via DOM. + monthAndYear.innerHTML = months[month] + ' ' + year + selectYear.value = year + selectMonth.value = month + + // creating all cells + let date = 1 + for (let i = 0; i < 6; i++) { + // creates a table row + const row = document.createElement('tr') + + // creating individual cells, filing them up with data. + for (let j = 0; j < 7; j++) { + if (i === 0 && j < firstDay) { + cell = document.createElement('td') + cellText = document.createTextNode('') + cell.appendChild(cellText) + row.appendChild(cell) + } else if (date > daysInMonth(month, year)) { + break + } else { + cell = document.createElement('td') + cellText = document.createTextNode(date) + if (date === today.getDate() && year === today.getFullYear() && month === today.getMonth()) { + cell.classList.add('bg-primary', 'text-white', 'shadow-lg') + } // color today's date + cell.appendChild(cellText) + row.appendChild(cell) + date++ + } } + tbl.appendChild(row) // appending each row into calendar body. + } } - // check how many days in a month code from https://dzone.com/articles/determining-number-days-month -function daysInMonth(iMonth, iYear) { - return 32 - new Date(iYear, iMonth, 32).getDate(); +function daysInMonth (iMonth, iYear) { + return 32 - new Date(iYear, iMonth, 32).getDate() } diff --git a/assets/js/zxce3.js b/assets/js/zxce3.js index c40a137..ebffe60 100644 --- a/assets/js/zxce3.js +++ b/assets/js/zxce3.js @@ -1 +1 @@ -Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),"document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||function(e){"use strict";if("Element"in e){var t="classList",o="prototype",a=e.Element[o],s=Object,n=String[o].trim||function(){return this.replace(/^\s+|\s+$/g,"")},i=Array[o].indexOf||function(e){for(var t=0,o=this.length;t"+o+""+t),r.classList.add("alert"),a&&r.classList.add(a),s&&r.classList.add(s),n&&(t=""+t),r.innerHTML=t,this.stickyAlerts.insertBefore(r,this.stickyAlerts.childNodes[0]),this.toastAlert(r.getAttribute("id"),i)},clickHandler:function(e){},keydownHandler:function(e){}};function zxce3OnDOMContentLoaded(){zxce3.pageWrapper||(zxce3.pageWrapper=document.getElementsByClassName("page-wrapper")[0]),zxce3.stickyAlerts||(zxce3.stickyAlerts=document.getElementsByClassName("sticky-alerts")[0]),zxce3.readCookie("zxce3_preferredMode")?"dark-mode"==zxce3.readCookie("zxce3_preferredMode")?zxce3.darkModeOn=!0:zxce3.darkModeOn=!1:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches||document.body.classList.contains("dark-mode")?zxce3.darkModeOn=!0:zxce3.darkModeOn=!1,(document.body.getAttribute("data-set-preferred-mode-onload")||document.body.getAttribute("data-set-preferred-theme-onload"))&&(zxce3.darkModeOn?document.body.classList.contains("dark-mode")||document.body.classList.add("dark-mode"):document.body.classList.contains("dark-mode")&&document.body.classList.remove("dark-mode")),document.documentElement.clientWidth<=768?zxce3.pageWrapper&&(zxce3.pageWrapper.getAttribute("data-show-sidebar-onload-sm-and-down")||zxce3.pageWrapper.setAttribute("data-sidebar-hidden","hidden")):zxce3.pageWrapper&&"overlayed-all"===zxce3.pageWrapper.getAttribute("data-sidebar-type")&&zxce3.pageWrapper.setAttribute("data-sidebar-hidden","hidden"),document.addEventListener("click",function(e){var t,o,a=e,s=e.target;s.matches("[data-toggle='dropdown']")||s.matches("[data-toggle='dropdown'] *")?(s.matches("[data-toggle='dropdown'] *")&&(s=s.closest("[data-toggle='dropdown']")),s.classList.contains("active")?(s.classList.remove("active"),s.closest(".dropdown").classList.remove("show")):(zxce3.deactivateAllDropdownToggles(),s.classList.add("active"),s.closest(".dropdown").classList.add("show"))):s.matches(".dropdown-menu *")||zxce3.deactivateAllDropdownToggles(),(s.matches(".alert [data-dismiss='alert']")||s.matches(".alert [data-dismiss='alert'] *"))&&(s.matches(".alert [data-dismiss='alert'] *")&&(s=s.closest(".alert [data-dismiss='alert']")),s.parentNode.classList.add("dispose")),(s.matches("[data-toggle='modal']")||s.matches("[data-toggle='modal'] *"))&&(s.matches("[data-toggle='modal'] *")&&(s=s.closest("[data-toggle='modal']")),(t=document.getElementById(s.getAttribute("data-target")))&&t.classList.contains("modal")&&zxce3.toggleModal(s.getAttribute("data-target"))),(s.matches(".modal [data-dismiss='modal']")||s.matches(".modal [data-dismiss='modal'] *"))&&(s.matches(".modal [data-dismiss='modal'] *")&&(s=s.closest(".modal [data-dismiss='modal']")),s.closest(".modal").classList.remove("show")),s.matches(".modal-dialog")&&((o=s.closest(".modal")).getAttribute("data-overlay-dismissal-disabled")||(o.classList.contains("show")?o.classList.remove("show"):window.location.hash="#")),zxce3.clickHandler(a)},!1),document.addEventListener("keydown",function(e){var t,o,a,s=e;document.querySelector("input:focus")||document.querySelector("textarea:focus")||document.querySelector("select:focus")||(e=e||window.event).ctrlKey||e.metaKey||(document.body.getAttribute("data-sidebar-shortcut-enabled")&&e.shiftKey&&83==e.which&&(t=!1,window.location.hash&&(o=window.location.hash.substring(1),(a=document.getElementById(o))&&a.classList.contains("modal")&&(t=!0)),document.querySelector(".modal.show")&&(t=!0),t||(zxce3.toggleSidebar(),e.preventDefault())),document.body.getAttribute("data-dm-shortcut-enabled")&&e.shiftKey&&68==e.which&&(zxce3.toggleDarkMode(),e.preventDefault())),27===e.which&&(document.querySelector("[data-toggle='dropdown'].active")?((a=document.querySelector("[data-toggle='dropdown'].active")).classList.remove("active"),a.closest(".dropdown").classList.remove("show"),e.preventDefault()):(window.location.hash&&(o=window.location.hash.substring(1),(a=document.getElementById(o))&&a.classList.contains("modal")&&(a.getAttribute("data-esc-dismissal-disabled")||(window.location.hash="#",e.preventDefault()))),document.querySelector(".modal.show")&&((a=document.querySelector(".modal.show")).getAttribute("data-esc-dismissal-disabled")||(a.classList.remove("show"),e.preventDefault())))),zxce3.keydownHandler(s)});for(var e=document.querySelectorAll(".custom-file input"),t=0;t' + t), r.classList.add('alert'), a && r.classList.add(a), s && r.classList.add(s), n && (t = "" + t), r.innerHTML = t, this.stickyAlerts.insertBefore(r, this.stickyAlerts.childNodes[0]), this.toastAlert(r.getAttribute('id'), i) }, clickHandler: function (e) {}, keydownHandler: function (e) {} }; function zxce3OnDOMContentLoaded () { zxce3.pageWrapper || (zxce3.pageWrapper = document.getElementsByClassName('page-wrapper')[0]), zxce3.stickyAlerts || (zxce3.stickyAlerts = document.getElementsByClassName('sticky-alerts')[0]), zxce3.readCookie('zxce3_preferredMode') ? zxce3.readCookie('zxce3_preferredMode') == 'dark-mode' ? zxce3.darkModeOn = !0 : zxce3.darkModeOn = !1 : window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches || document.body.classList.contains('dark-mode') ? zxce3.darkModeOn = !0 : zxce3.darkModeOn = !1, (document.body.getAttribute('data-set-preferred-mode-onload') || document.body.getAttribute('data-set-preferred-theme-onload')) && (zxce3.darkModeOn ? document.body.classList.contains('dark-mode') || document.body.classList.add('dark-mode') : document.body.classList.contains('dark-mode') && document.body.classList.remove('dark-mode')), document.documentElement.clientWidth <= 768 ? zxce3.pageWrapper && (zxce3.pageWrapper.getAttribute('data-show-sidebar-onload-sm-and-down') || zxce3.pageWrapper.setAttribute('data-sidebar-hidden', 'hidden')) : zxce3.pageWrapper && zxce3.pageWrapper.getAttribute('data-sidebar-type') === 'overlayed-all' && zxce3.pageWrapper.setAttribute('data-sidebar-hidden', 'hidden'), document.addEventListener('click', function (e) { let t; let o; const a = e; let s = e.target; s.matches("[data-toggle='dropdown']") || s.matches("[data-toggle='dropdown'] *") ? (s.matches("[data-toggle='dropdown'] *") && (s = s.closest("[data-toggle='dropdown']")), s.classList.contains('active') ? (s.classList.remove('active'), s.closest('.dropdown').classList.remove('show')) : (zxce3.deactivateAllDropdownToggles(), s.classList.add('active'), s.closest('.dropdown').classList.add('show'))) : s.matches('.dropdown-menu *') || zxce3.deactivateAllDropdownToggles(), (s.matches(".alert [data-dismiss='alert']") || s.matches(".alert [data-dismiss='alert'] *")) && (s.matches(".alert [data-dismiss='alert'] *") && (s = s.closest(".alert [data-dismiss='alert']")), s.parentNode.classList.add('dispose')), (s.matches("[data-toggle='modal']") || s.matches("[data-toggle='modal'] *")) && (s.matches("[data-toggle='modal'] *") && (s = s.closest("[data-toggle='modal']")), (t = document.getElementById(s.getAttribute('data-target'))) && t.classList.contains('modal') && zxce3.toggleModal(s.getAttribute('data-target'))), (s.matches(".modal [data-dismiss='modal']") || s.matches(".modal [data-dismiss='modal'] *")) && (s.matches(".modal [data-dismiss='modal'] *") && (s = s.closest(".modal [data-dismiss='modal']")), s.closest('.modal').classList.remove('show')), s.matches('.modal-dialog') && ((o = s.closest('.modal')).getAttribute('data-overlay-dismissal-disabled') || (o.classList.contains('show') ? o.classList.remove('show') : window.location.hash = '#')), zxce3.clickHandler(a) }, !1), document.addEventListener('keydown', function (e) { let t; let o; let a; const s = e; document.querySelector('input:focus') || document.querySelector('textarea:focus') || document.querySelector('select:focus') || (e = e || window.event).ctrlKey || e.metaKey || (document.body.getAttribute('data-sidebar-shortcut-enabled') && e.shiftKey && e.which == 83 && (t = !1, window.location.hash && (o = window.location.hash.substring(1), (a = document.getElementById(o)) && a.classList.contains('modal') && (t = !0)), document.querySelector('.modal.show') && (t = !0), t || (zxce3.toggleSidebar(), e.preventDefault())), document.body.getAttribute('data-dm-shortcut-enabled') && e.shiftKey && e.which == 68 && (zxce3.toggleDarkMode(), e.preventDefault())), e.which === 27 && (document.querySelector("[data-toggle='dropdown'].active") ? ((a = document.querySelector("[data-toggle='dropdown'].active")).classList.remove('active'), a.closest('.dropdown').classList.remove('show'), e.preventDefault()) : (window.location.hash && (o = window.location.hash.substring(1), (a = document.getElementById(o)) && a.classList.contains('modal') && (a.getAttribute('data-esc-dismissal-disabled') || (window.location.hash = '#', e.preventDefault()))), document.querySelector('.modal.show') && ((a = document.querySelector('.modal.show')).getAttribute('data-esc-dismissal-disabled') || (a.classList.remove('show'), e.preventDefault())))), zxce3.keydownHandler(s) }); for (let e = document.querySelectorAll('.custom-file input'), t = 0; t < e.length; t++) { const o = e[t]; var a = document.createElement('div'); a.classList.add('file-names'); const s = o.getAttribute('data-default-value'); a.innerHTML = s || 'No file chosen', o.parentNode.appendChild(a), o.addEventListener('change', function (e) { a = e.target.parentNode.querySelector('.file-names'), e.target.files.length === 1 ? a.innerHTML = e.target.files[0].name : e.target.files.length > 1 ? a.innerHTML = e.target.files.length + ' files' : a.innerHTML = 'No file chosen' }) }zxce3.pageWrapper && zxce3.pageWrapper.classList.add('with-transitions') }document.addEventListener('DOMContentLoaded', zxce3OnDOMContentLoaded)