diff --git a/assets/js/app/notes.js b/assets/js/app/notes.js index 0e67f66..b6c0fd4 100644 --- a/assets/js/app/notes.js +++ b/assets/js/app/notes.js @@ -28,10 +28,11 @@ export function filterNotes() noteList.innerHTML = ''; data.forEach(i => { + let duration = (parseInt(i.duration) / 60).toFixed(2); noteList.innerHTML += ` ${i.date}
- ${i.startTime}-${i.endTime} (${i.duration}) + ${i.startTime}-${i.endTime} (${duration}) ${i.location} ${i.method} ${i.members} @@ -43,4 +44,48 @@ export function filterNotes() `; }) }); -} \ No newline at end of file +} + +export function calcTime(precision = 15) { + if (!document.getElementById('note_form_startTime').value || !document.getElementById('note_form_endTime').value) { + console.log('ending'); + return; + } + + let st = document.getElementById('note_form_startTime').value.split(':'); + let et = document.getElementById('note_form_endTime').value.split(':'); + + let sd = new Date(); + let ed = new Date(); + + sd.setHours(st[0]); + sd.setMinutes(st[1]); + sd.setSeconds(0); + ed.setHours(et[0]); + ed.setMinutes(et[1]); + ed.setSeconds(0); + + let timediff = (ed.getTime() - sd.getTime()) / 1000; + let increments = (timediff / 60) / precision; + + if (isFloat(increments)) { + let mod = (timediff / 60) % precision; + if (mod >= (precision / 2)) { + increments++; + } + increments = parseInt(increments); + } + + document.getElementById('case-mins').value = (increments * precision)+' minutes'; + document.getElementById('case-hours').value = ((increments * precision) / 60)+' hours'; +} + +export function autosaveNote() +{ + +} + +export function checkNotes() { + +} +