diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-10-29 23:21:32 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-10-29 23:21:32 +0200 |
commit | 848db6a4e3f7091dc4a2e20dcae47f6669801e99 (patch) | |
tree | 898702f2313ae5363f02205d3812e11f814cf4b8 /modules/todo/todo.html | |
parent | 730a78ba9deb5a70b56497dd61e3aa52e62d58ed (diff) |
todo: Introducing multi-user TODO!
Diffstat (limited to 'modules/todo/todo.html')
-rw-r--r-- | modules/todo/todo.html | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/modules/todo/todo.html b/modules/todo/todo.html index b196682..1f2a060 100644 --- a/modules/todo/todo.html +++ b/modules/todo/todo.html @@ -6,18 +6,26 @@ <script> "use strict"; -function fetch(method,url,data/*?*/,cb){ - if(!cb){ +function fetch(method,url,data/*?*/,creds/*?*/,cb){ + if(!creds){ cb=data; data=undefined; - if(!cb)throw new Error("No callback passed to fetch"); + creds=undefined; + } else if(!cb){ + cb=creds; + creds=undefined; } + if(!cb)throw new Error("No callback passed to fetch"); var xhr=new XMLHttpRequest(); xhr.onreadystatechange=function(ev){ if(xhr.readyState<4)return; cb(xhr.status,xhr.responseText); }; - xhr.open(method,url); + if(creds){ + xhr.open(method,url,true,creds[0],creds[1]); + } else { + xhr.open(method,url); + } xhr.send(data); } @@ -187,6 +195,12 @@ function doAddTask(ev){ }); } +function logoutReload(){ + fetch("GET","/todo/authfail",undefined,["baduser","badpass"],function(status,body){ + location.href=location.href; + }); +} + window.addEventListener("load",getlist); </script> <style> @@ -238,9 +252,15 @@ body{ #addtaskform.invisible{ display:none; } +#logoutwrapper{ + float:right; +} </style> </head> <body> +<div id="logoutwrapper"> + <input type="button" onclick="logoutReload();" value="Logout"> +</div> <h1>TODO</h1> <div id="todolist"></div> <br><br> |