From 823d072ad49e30832d167e4c04bdf1b64b5a5336 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 25 Feb 2017 09:55:13 +0100 Subject: todo: Shift ahead repeating items --- modules/todo/todo.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'modules/todo/todo.js') diff --git a/modules/todo/todo.js b/modules/todo/todo.js index 66433d9..8fabc63 100644 --- a/modules/todo/todo.js +++ b/modules/todo/todo.js @@ -52,6 +52,18 @@ var naccounts=0; })(); +function shiftDate(date,repweeks){ + var Y=date.getFullYear(), + M=date.getMonth(), + D=date.getDate(), + h=date.getHours(), + m=date.getMinutes(), + s=date.getSeconds(), + ms=date.getMilliseconds(); + return new Date(Y,M,D+7*repweeks,h,m,s,ms); +} + + function sendUnauth(res){ res.set("WWW-Authenticate","Basic realm=Authorization required"); return res.sendStatus(401); @@ -161,6 +173,33 @@ module.exports=function(app,io,_moddir){ if(fail)res.status(404).send("Unknown id"); else res.status(200).end(); }); + app.post("/todo/task/shiftahead",function(req,res){ + var id=+req.body; + var i; + var fail=false; + var usertasks=tasks[req.authuser]; + var now; + if(id<0||~~id!=id||isNaN(id)||!usertasks){ + fail=true; + } else { + for(i=0;i