summaryrefslogtreecommitdiff
path: root/modules/todo/todo.html
diff options
context:
space:
mode:
Diffstat (limited to 'modules/todo/todo.html')
-rw-r--r--modules/todo/todo.html28
1 files changed, 23 insertions, 5 deletions
diff --git a/modules/todo/todo.html b/modules/todo/todo.html
index e2f13af..19b9370 100644
--- a/modules/todo/todo.html
+++ b/modules/todo/todo.html
@@ -5,6 +5,10 @@
<title>TODO</title>
<script>
"use strict";
+var preload_todolist=/*REPLACEME*/null/*TODOLIST*/;
+</script>
+<script>
+"use strict";
function fetch(method,url,data/*?*/,creds/*?*/,cb){
if(!creds){
@@ -155,18 +159,32 @@ function refreshlist(list){
}
}
+function handleReceivedList(list){
+ var i;
+ for(i=0;i<list.length;i++)list[i].date=new Date(list[i].date);
+ refreshlist(list);
+}
+
function getlist(){
- fetch("GET","/todo/list",function(status,json){
+ if(preload_todolist!=null){
+ handleReceivedList(preload_todolist);
+ preload_todolist=null;
+ return;
+ }
+
+ fetch("GET","/todo/list",function(status,body){
+ if(status!=200){
+ alert("Error: "+body);
+ return;
+ }
var list;
try {
- list=JSON.parse(json);
+ list=JSON.parse(body);
} catch(e){
alert("An error occurred!");
return;
}
- var i;
- for(i=0;i<list.length;i++)list[i].date=new Date(list[i].date);
- refreshlist(list);
+ handleReceivedList(list);
});
}