1// Handle Logout 2$("#logout-btn").on("click", () => { 3 getData({ 4 appType: appTypes.LOGOUT 5 }) 6 .then(res => { 7 if (res.status == "success") { 8 localStorage.removeItem("kago_client"); 9 window.location.href = clientUrl; 10 } 11 }) 12}) 13 14// Set Breadcrumbs Path 15try { 16 const breadCrumb = document.querySelector('.breadcrumb') 17 const breadCrumbItem = `<li class="breadcrumb-item"><a href="javascript: void(0);">Kago</a></li>` 18 const titleTag = document.querySelector("title") 19 20 const currentPath = window.location.pathname.split('.')[0] 21 breadCrumb.innerHTML = '' 22 const paths = currentPath.split('/') 23 let lastPath = paths.pop() 24 // const origin = window.location.origin 25 paths.forEach(path => { 26 if (path !== '') { 27 breadCrumb.innerHTML += `<li class="breadcrumb-item"><a class='text-capitalize' href="#">${path}</a></li>` 28 } 29 }) 30 31 lastPath = lastPath.replaceAll('-', ' ') 32 lastPath = lastPath.replaceAll('_', ' ') 33 lastPath = lastPath.replace(/[0-9]/g, '') 34 35 breadCrumb.innerHTML += `<li class="breadcrumb-item active"><a class='text-capitalize' href="${window.location.href}">${lastPath}</a></li>` 36 titleTag.textContent = `Kago Client Portal - ${lastPath}` 37 38} 39 40catch(error) { 41 console.log("Failed to set breadcrumbs: ", error); 42} 43 44// Handle currency toggle 45const toggleCurrencyBtns = document.querySelectorAll('[data-currency-id]') 46const displayedCurrency = document.querySelector('#selected-currency-display-img') 47const displayedCurrencyText = document.querySelector('#selected-currency-display-span') 48 49const currencyData = JSON.parse(localStorage.getItem('currencyData')) 50displayedCurrencyText.textContent = currencyData.currency 51displayedCurrency.src = `assets/images/flags/${currencyData.currency}.jpg` 52 53const priceSymbols = document.querySelectorAll('[data-currency]') 54priceSymbols.forEach(symbol => { 55 symbol.textContent = currencyData.currency 56}) 57 58toggleCurrencyBtns.forEach(toggleBtn => { 59 toggleBtn.addEventListener("click", (e) => { 60 const currencyId = e.target.dataset.currencyId 61 62 if (currencyId == '1') { 63 displayedCurrencyText.textContent = 'USD' 64 displayedCurrency.src = `assets/images/flags/USD.jpg` 65 66 postData({ 67 appType: appTypes.TOGGLE_CURRENCY, 68 currencyId: currencyId 69 }) 70 .then(res => { 71 if (res.status == "success") { 72 currencyData.currency = res.currency 73 currencyData.currencyRate = res.currencyRate 74 75 localStorage.setItem('currencyData', JSON.stringify(currencyData)) 76 77 window.location.reload(); 78 } 79 80 else { 81 console.log("Failed to toggle currency: ", res.message); 82 } 83 }) 84 } 85 86 else if (currencyId == '2') { 87 displayedCurrencyText.textContent = 'TZH' 88 displayedCurrency.src = `../client/assets/images/flags/TZS.jpg` 89 90 postData({ 91 appType: appTypes.TOGGLE_CURRENCY, 92 currencyId: currencyId 93 }) 94 .then(res => { 95 if (res.status == 'success') { 96 currencyData.currency = res.currency 97 currencyData.currencyRate = res.currencyRate 98 99 localStorage.setItem('currencyData', JSON.stringify(currencyData)) 100 101 window.location.reload() 102 } 103 104 else { 105 console.log("Failed to toggle currency: ", res.message); 106 } 107 }) 108 } 109 }) 110}) 111 112// Handle Dismiss Alerts 113$("body").on("click", ".close.alert-dismiss.btn", (e) => { 114 e.target.parentElement.remove(); 115}); 116 117// Check for any system notifications 118getData({ 119 appType: "getSystemNotifications" 120}) 121 .then(res => { 122 const notification = res.data; 123 if (!notification) return; 124 customAlertify.confirm( 125 notification.title, 126 notification.message, 127 { 128 showCancel: notification.allow_cancel, 129 okText: notification.confirm_button_text, 130 onOk: async () => { 131 try { 132 await postData({ 133 appType: "systemNotificationAck", 134 notificationId: notification.id 135 }); 136 } catch (err) { 137 customAlertify.error('Failed to save data. Please try again.'); 138 return false; // Keeps the modal open so user can retry 139 } 140 } 141 } 142 ) 143})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.