|
|
|
@ -9,18 +9,29 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getHours = (seconds) => {
|
|
|
|
|
|
|
|
return Math.floor( seconds / 60 / 60 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getMinutes = (seconds) => {
|
|
|
|
const getMinutes = (seconds) => {
|
|
|
|
return Math.floor( seconds / 60 );
|
|
|
|
return Math.floor( seconds / 60 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createTimeObj = (seconds) => {
|
|
|
|
|
|
|
|
const hours = getHours(seconds)
|
|
|
|
|
|
|
|
let remainingSeconds = seconds - hours * 60 * 60
|
|
|
|
|
|
|
|
const minutes = getMinutes(remainingSeconds)
|
|
|
|
|
|
|
|
remainingSeconds -= minutes * 60
|
|
|
|
|
|
|
|
return { hours, minutes, seconds: remainingSeconds }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getAccumulatedSeconds = (newerTime, olderTime) => {
|
|
|
|
const getAccumulatedSeconds = (newerTime, olderTime) => {
|
|
|
|
return Math.floor((newerTime-olderTime)/1000);
|
|
|
|
return Math.floor((newerTime-olderTime)/1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const formatSeconds = (total) => {
|
|
|
|
const formatSeconds = (total) => {
|
|
|
|
const minutes = getMinutes(total);
|
|
|
|
const timeObj = createTimeObj(total)
|
|
|
|
const seconds = total - minutes*60;
|
|
|
|
return `${timeObj.hours*60 + timeObj.minutes}:${padDigits(timeObj.seconds)}`;
|
|
|
|
return `${minutes}:${padDigits(seconds)}`;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
@ -98,10 +109,16 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) - this.secondsToSubtract + this.savedPreviousSeconds;
|
|
|
|
this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) - this.secondsToSubtract + this.savedPreviousSeconds;
|
|
|
|
|
|
|
|
this.setManualTime(this.totalSeconds)
|
|
|
|
window.localStorage.setItem('lastTotalSeconds', this.totalSeconds);
|
|
|
|
window.localStorage.setItem('lastTotalSeconds', this.totalSeconds);
|
|
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
setManualTime(seconds){
|
|
|
|
|
|
|
|
const timeObj = createTimeObj(this.totalSeconds)
|
|
|
|
|
|
|
|
this.manualHours = timeObj.hours
|
|
|
|
|
|
|
|
this.manualMinutes = timeObj.minutes
|
|
|
|
|
|
|
|
this.manualSeconds = timeObj.seconds
|
|
|
|
|
|
|
|
},
|
|
|
|
updateSavedPreviousSeconds(event){
|
|
|
|
updateSavedPreviousSeconds(event){
|
|
|
|
this.savedPreviousSeconds = parseInt(event.target.value);
|
|
|
|
this.savedPreviousSeconds = parseInt(event.target.value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -163,6 +180,7 @@
|
|
|
|
this.categories = response.data
|
|
|
|
this.categories = response.data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.totalSeconds = parseInt(window.localStorage.getItem('lastTotalSeconds'))
|
|
|
|
this.totalSeconds = parseInt(window.localStorage.getItem('lastTotalSeconds'))
|
|
|
|
|
|
|
|
this.setManualTime(this.totalSeconds)
|
|
|
|
this.savedPreviousSeconds = this.totalSeconds
|
|
|
|
this.savedPreviousSeconds = this.totalSeconds
|
|
|
|
window.onbeforeunload = this.confirmClose
|
|
|
|
window.onbeforeunload = this.confirmClose
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|