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_transporter"); 9 window.location.href = transporterUrl; 10 } 11 }) 12}) 13 14const breadCrumb = document.querySelector('.breadcrumb') 15const breadCrumbItem = `<li class="breadcrumb-item"><a href="javascript: void(0);">Kago</a></li>` 16const titleTag = document.querySelector("title") 17 18const currentPath = window.location.pathname.split('.')[0] 19breadCrumb.innerHTML = '' 20const paths = currentPath.split('/') 21let lastPath = paths.pop() 22// const origin = window.location.origin 23paths.forEach(path => { 24 if (path !== '') { 25 breadCrumb.innerHTML += `<li class="breadcrumb-item text-capitalize"><a href="#">${path}</a></li>` 26 } 27}) 28 29lastPath = lastPath.replaceAll('-', ' ') 30lastPath = lastPath.replaceAll('_', ' ') 31lastPath = lastPath.replace(/[0-9]/g, '') 32 33breadCrumb.innerHTML += `<li class="breadcrumb-item active text-capitalize text-dark"><a href="${window.location.href}">${lastPath}</a></li>` 34 35titleTag.textContent = `Kago Transporter Portal - ${lastPath}` 36 37// Currency Toggle 38async function getCurrency() { 39 const res = await fetch(`${TRANSPORTER_URL_JSON}?appType=getCurrency`, { 40 headers: {'Authorization': `Bearer ${token}`} 41 }) 42 // 43 const data = await res.json() 44 45 return data 46} 47 48async function toggleCurrency(currencyId) { 49 const res = await fetch(`${TRANSPORTER_URL_JSON}`, { 50 headers: {'Authorization': `Bearer ${token}`}, 51 method: 'POST', 52 body: JSON.stringify({currencyId: currencyId, appType: 'toggleCurrency'}) 53 }) 54 const data = await res.json() 55 56 return data 57} 58 59const toggleCurrencyBtns = document.querySelectorAll('[data-currency-id]') 60const displayedCurrency = document.querySelector('#selected-currency-display-img') 61const displayedCurrencyText = document.querySelector('#selected-currency-display-span') 62 63// On initial load, change the currency to default currency 64// getCurrency() 65// .then(data => { 66// 67// 68// if (data.status != 'failed') { 69// data.data.forEach(currency => { 70// if (currency.symbol == USER_DATA.currency) { 71// displayedCurrencyText.textContent = currency.symbol 72// displayedCurrency.src = `assets/images/flags/${currency.symbol}.jpg` 73// } 74// }) 75// } 76// }) 77 78const currencyData = JSON.parse(localStorage.getItem('currencyData')) 79displayedCurrencyText.textContent = currencyData.currency 80displayedCurrency.src = `assets/images/flags/${currencyData.currency}.jpg` 81 82const priceSymbols = document.querySelectorAll('[data-currency]') 83priceSymbols.forEach(symbol => { 84 symbol.textContent = currencyData.currency 85}) 86 87toggleCurrencyBtns.forEach(toggleBtn => { 88 toggleBtn.addEventListener("click", (e) => { 89 const currencyId = e.target.dataset.currencyId 90 91 if (currencyId == '1') { 92 displayedCurrencyText.textContent = 'USD' 93 displayedCurrency.src = `assets/images/flags/USD.jpg` 94 95 // Get all prices and convert to USD 96 const prices = document.querySelectorAll('[data-price]') 97 const priceSymbols = document.querySelectorAll('[data-currency]') 98 99 toggleCurrency(currencyId) 100 .then(data => { 101 if (data.status != 'failed') { 102 currencyData.currency = data.currency 103 currencyData.currencyRate = data.currencyRate 104 105 localStorage.setItem('currencyData', JSON.stringify(currencyData)) 106 107 window.location.reload() 108 109 // const newRate = data.currencyRate 110 // prices.forEach(price => { 111 // const originalAmount = price.dataset.originalAmount 112 // 113 // // const priceValue = price.textContent 114 // // 115 // // 116 // price.textContent = originalAmount * newRate 117 // }) 118
119 // priceSymbols.forEach(symbol => { 120 // symbol.textContent = data.currency 121 // }) 122 } 123 }) 124 } 125 126 else if (currencyId == '2') { 127 displayedCurrencyText.textContent = 'TZH' 128 displayedCurrency.src = `../client/assets/images/flags/TZS.jpg` 129 130 // Get all prices and convert to USD 131 const prices = document.querySelectorAll('[data-price]') 132 const priceSymbols = document.querySelectorAll('[data-currency]') 133 134 toggleCurrency(currencyId) 135 .then(data => { 136 if (data.status != 'failed') { 137 currencyData.currency = data.currency 138 currencyData.currencyRate = data.currencyRate 139 140 localStorage.setItem('currencyData', JSON.stringify(currencyData)) 141 142 window.location.reload() 143 144 // const newRate = data.currencyRate 145 // prices.forEach(price => { 146 // const priceValue = price.textContent 147 // 148 // // 149 // price.textContent = priceValue * newRate 150 // }) 151 152 // priceSymbols.forEach(symbol => { 153 // symbol.textContent = data.currency 154 // }) 155 } 156 }) 157 } 158 }) 159}) 160 161// Check for any system notifications 162getData({ 163 appType: "getSystemNotifications" 164}) 165 .then(res => { 166 const notification = res.data; 167 if (!notification) return; 168 customAlertify.confirm( 169 notification.title, 170 notification.message, 171 { 172 showCancel: notification.allow_cancel, 173 okText: notification.confirm_button_text, 174 onOk: async () => { 175 try { 176 await postData({ 177 appType: "systemNotificationAck", 178 notificationId: notification.id 179 }); 180 } catch (err) { 181 customAlertify.error('Failed to save data. Please try again.'); 182 return false; // Keeps the modal open so user can retry 183 } 184 } 185 } 186 ) 187})
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.