up: notes.js
* Convert duration to hours/units * Move calcTime method here
This commit is contained in:
		| @@ -28,10 +28,11 @@ export function filterNotes() | |||||||
|             noteList.innerHTML = ''; |             noteList.innerHTML = ''; | ||||||
|  |  | ||||||
|             data.forEach(i => { |             data.forEach(i => { | ||||||
|  |                 let duration = (parseInt(i.duration) / 60).toFixed(2); | ||||||
|                 noteList.innerHTML += ` |                 noteList.innerHTML += ` | ||||||
|                 <tr> |                 <tr> | ||||||
|                     <td>${i.date}<br/> |                     <td>${i.date}<br/> | ||||||
|                         ${i.startTime}-${i.endTime} (${i.duration})</td> |                         ${i.startTime}-${i.endTime} (${duration})</td> | ||||||
|                     <td class='text-center'>${i.location}</td> |                     <td class='text-center'>${i.location}</td> | ||||||
|                     <td class='text-center'>${i.method}</td> |                     <td class='text-center'>${i.method}</td> | ||||||
|                     <td'>${i.members}</td> |                     <td'>${i.members}</td> | ||||||
| @@ -43,4 +44,48 @@ export function filterNotes() | |||||||
|                 </tr>`; |                 </tr>`; | ||||||
|             }) |             }) | ||||||
|         }); |         }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | 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() { | ||||||
|  |      | ||||||
|  | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user