diff options
author | Tom Smeding <tom@tomsmeding.com> | 2022-03-04 09:35:07 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2022-03-04 09:36:17 +0100 |
commit | 1e082de1d574ab0cf3404e63d65798210590e5f3 (patch) | |
tree | 05987b91bd2791b0527da8c78f4bc307ede4c010 | |
parent | 173bbeb321e9bf5ca9b6f6102de429e0062bfd8c (diff) |
timetrack: UI
-rw-r--r-- | modules/timetrack/timetrack.html | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/timetrack/timetrack.html b/modules/timetrack/timetrack.html index 513684e..f5ee32e 100644 --- a/modules/timetrack/timetrack.html +++ b/modules/timetrack/timetrack.html @@ -97,7 +97,7 @@ function tablerowfor(ev){ e2.addEventListener("click",function(){ if(!confirm("Really delete check-"+ev.type+" event \""+ev.sheet+"\" (\""+ev.text+"\") at "+formatdate(ev.date)+"?"))return; fetch("DELETE","/timetrack/event",ev.id,function(status,body){ - if(status==200)getlist(); + if(status==200)getlist(false); else alert("Delete failed: "+body); }); }); @@ -265,7 +265,7 @@ function handleReceivedList(list){ refreshcalendar(list); } -function getlist(){ +function getlist(isinitial){ fetch("GET","/timetrack/list",function(status,body){ if(status!=200){ alert("Error: "+body); @@ -281,6 +281,7 @@ function getlist(){ for(var i=0;i<list.length;i++)list[i].date=new Date(list[i].date); list.sort(function(a,b){return a.date-b.date;}); handleReceivedList(list); + if (isinitial) document.getElementById("addeventform").scrollIntoView(); }); } @@ -310,11 +311,10 @@ function getsheets() { }); } -function doAddEvent(ev){ +function doAddEvent(ev, type){ var sheet=document.getElementById("addeventsheet").value; var text=document.getElementById("addeventtext").value; var date=document.getElementById("addeventdate").value; - var type=document.getElementById("addeventtypein").checked?"in":"out"; if(typeof date=="string")date=new Date(date); fetch("POST","/timetrack/event",JSON.stringify({ sheet:sheet, @@ -345,7 +345,7 @@ function dateToNow() { } window.addEventListener("load",function() { - getlist(); + getlist(true); getsheets(); dateToNow(); }); @@ -448,9 +448,8 @@ body{ Text: <input type="text" id="addeventtext" placeholder="Text"> (optional) <br> Date: <input type="datetime" id="addeventdate" placeholder="YYYY-MM-DD HH:MM:SS" size="25"> <input type="button" onclick="dateToNow()" value="now"> <br> - <label for="addeventtypein"><input type="radio" id="addeventtypein" name="addeventtype" checked> In</label> - <label for="addeventtypeout" style="margin-left: 20px"><input type="radio" id="addeventtypeout" name="addeventtype"> Out</label> <br style="margin-top: 5px"> - <input type="button" onclick="doAddEvent(event)" value="Add" style="margin-top: 5px"> + <input type="button" onclick="doAddEvent(event, 'in')" value="Add IN" style="margin-top: 5px"> + <input type="button" onclick="doAddEvent(event, 'out')" value="Add OUT" style="margin-top: 5px; margin-left: 20px"> </div> <br><br> <div id="calendar"> |