$(() => { // Listens to click on the create employee pdf button, generates the pdf, and opens it $("#emppdfbutton").click(async (e) => { try { $("#lblstatus").text("generating report on server - please wait..."); let response = await fetch(`api/employeereport`); if (!response.ok) throw new Error(`Status - ${response.status}, Text - ${response.statusText}`); let data = await response.json(); data.msg === "Report Generated" ? window.open("/pdfs/employeelist.pdf")&$("#lblstatus").text("Report generated and opened in new tab") : $("#lblstatus").text("problem generating report"); } catch (error) { $("#lblstatus").text(error.message); } }); // Listens to click on the create call pdf button, generates the pdf, and opens it $("#callpdfbutton").click(async (e) => { try { $("#lblstatus").text("generating report on server - please wait..."); let response = await fetch(`api/callreport`); if (!response.ok) throw new Error(`Status - ${response.status}, Text - ${response.statusText}`); let data = await response.json(); data.msg === "Report Generated" ? window.open("/pdfs/calllist.pdf") & $("#lblstatus").text("Report generated and opened in new tab") : $("#lblstatus").text("problem generating report"); } catch (error) { $("#lblstatus").text(error.message); } }); // Checks if user chose to have dark mode enabled or disabled throughout the website and enables it if (sessionStorage.getItem("darkmode") == 1) { $('body').addClass('darkMode'); $('#callList').css('box-shadow', 'none'); $('button.list-group-item').css('background-color', 'dimgray'); $('#heading').css('background-color', 'black'); $('div.h4').css('background-color', 'black'); $('#status').css('background-color', 'dimgray'); $("#logo").attr("src", "img/logolight.png"); $('#lightSwitch').prop('checked', true); } //Listens to click on the darkmode button $('#lightSwitch').click(() => { if ($('#lightSwitch').is(':checked') == true) { $("#logo").attr("src", "img/logolight.png"); $('body').addClass('darkMode'); sessionStorage.setItem("darkmode", 1); } else { $("#logo").attr("src", "img/logo.png"); $('body').removeClass('darkMode'); sessionStorage.setItem("darkmode", 0); } }); });