mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
Remove redundant logic in client-side javascript
This commit is contained in:
parent
97fab3e109
commit
10648d66ad
@ -2,15 +2,8 @@ PetiteVue.createApp({
|
||||
$delimiters: ['${', '}'],
|
||||
get currentInterval() {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const cookies = new URLSearchParams(document.cookie.replaceAll('; ', '&'))
|
||||
|
||||
if (urlParams.has('interval'))
|
||||
return urlParams.get('interval')
|
||||
if (cookies.has('wakapi_summary_interval'))
|
||||
return cookies.get('wakapi_summary_interval')
|
||||
if (!urlParams.has('from') && !urlParams.has('to'))
|
||||
return 'today'
|
||||
|
||||
if (urlParams.has('interval')) return urlParams.get('interval')
|
||||
if (!urlParams.has('from') && !urlParams.has('to')) return 'today'
|
||||
return null
|
||||
}
|
||||
}).mount('#summary-page')
|
@ -23,16 +23,8 @@ function TimePicker({ fromDate, toDate, timeSelection }) {
|
||||
})
|
||||
|
||||
const query = new URLSearchParams(window.location.search)
|
||||
const cookies = new URLSearchParams(document.cookie.replaceAll('; ', '&'))
|
||||
|
||||
let interval = undefined;
|
||||
if (query.has('interval'))
|
||||
interval = query.get('interval')
|
||||
else if (cookies.has('wakapi_summary_interval'))
|
||||
interval = cookies.get('wakapi_summary_interval')
|
||||
|
||||
if (interval) {
|
||||
const refEl = document.getElementById(`time-option-${interval}`)
|
||||
if (query.has('interval')) {
|
||||
const refEl = document.getElementById(`time-option-${query.get('interval')}`)
|
||||
this.timeSelection = refEl ? refEl.innerText : 'Unknown'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user