diff --git a/src/ajax.js b/src/ajax.js index 751568f..4a92b26 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -31,9 +31,9 @@ function loadTasks() { tz = -1 * (new Date()).getTimezoneOffset(); setAjaxErrorTrigger(); - if(filter.search) search = '&s='+encodeURIComponent(filter.search); else search = ''; - if(filter.tag) tag = '&t='+encodeURIComponent(filter.tag); else tag = ''; - nocache = '&rnd='+Math.random(); + var search = filter.search ? '&s='+encodeURIComponent(filter.search) : ''; + var tag = filter.tag ? '&t='+encodeURIComponent(filter.tag) : ''; + var nocache = '&rnd='+Math.random(); $.getJSON('ajax.php?loadTasks&list='+curList.id+'&compl='+filter.compl+'&sort='+sortBy+search+tag+'&tz='+tz+nocache, function(json){ resetAjaxErrorTrigger(); taskList = new Array(); @@ -61,9 +61,9 @@ function loadTasks() function prepareTaskStr(item) { - id = parseInt(item.id); - prio = parseInt(item.prio); - readOnly = (flag.needAuth && flag.canAllRead && !flag.isLogged) ? true : false; + var id = parseInt(item.id); + var prio = parseInt(item.prio); + var readOnly = (flag.needAuth && flag.canAllRead && !flag.isLogged) ? true : false; return '
  • '+ ''+ ''+ @@ -85,13 +85,13 @@ function prepareTaskStr(item) function prepareHtml(s) { // make URLs clickable - s = s.replace(/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/gi, '$1$2$4'); + var s = s.replace(/(^|\s|>)(www\.([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/gi, '$1$2$4'); return s.replace(/(^|\s|>)((?:http|https|ftp):\/\/([\w\#$%&~\/.\-\+;:=,\?\[\]@]+?))(,|\.|:|)?(?=\s|"|<|>|\"|<|>|$)/ig, '$1$2$4'); } function preparePrio(prio,id) { - cl = v = ''; + var cl =''; var v = ''; if(prio < 0) { cl = 'prio-neg'; v = '−'+Math.abs(prio); } else if(prio > 0) { cl = 'prio-pos'; v = '+'+prio; } else { cl = 'prio-o'; v = '±0'; } @@ -101,9 +101,9 @@ function preparePrio(prio,id) function prepareTagsStr(tags) { if(!tags || tags == '') return ''; - a = tags.split(','); + var a = tags.split(','); if(!a.length) return ''; - for(i in a) { + for(var i in a) { a[i] = ''+a[i]+''; } return ''+a.join(', ')+''; @@ -120,7 +120,7 @@ function submitNewTask(form) if(form.task.value == '') return false; var tz = -1 * (new Date()).getTimezoneOffset(); setAjaxErrorTrigger() - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.post('ajax.php?newTask'+nocache, { list:curList.id, title: form.task.value, tz:tz, tag:filter.tag }, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return; @@ -159,7 +159,7 @@ function flashError(str, details) function toggleMsgDetails() { - el = $("#msgdetails"); + var el = $("#msgdetails"); if(!el) return; if(el.css('display') == 'none') el.show(); else el.hide() @@ -177,7 +177,7 @@ function deleteTask(id) return false; } setAjaxErrorTrigger() - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.getJSON('ajax.php?deleteTask='+id+nocache, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return; @@ -194,7 +194,7 @@ function deleteTask(id) function completeTask(id,ch) { - compl = 0; + var compl = 0; if(ch.checked) compl = 1; setAjaxErrorTrigger(); $.getJSON('ajax.php?completeTask='+id+'&compl='+compl+nocache, function(json){ @@ -222,7 +222,7 @@ function completeTask(id,ch) function toggleTaskNote(id) { - aArea = '#tasknotearea'+id; + var aArea = '#tasknotearea'+id; if($(aArea).css('display') == 'none') { $('#notetext'+id).val(taskList[id].noteText); @@ -250,7 +250,7 @@ function cancelTaskNote(id) function saveTaskNote(id) { setAjaxErrorTrigger() - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.post('ajax.php?editNote='+id+nocache, {note: $('#notetext'+id).val()}, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return; @@ -274,12 +274,12 @@ function editTask(id) document.edittask.id.value = item.id; document.edittask.tags.value = item.tags.split(',').join(', '); document.edittask.duedate.value = item.duedate; - sel = document.edittask.prio; - for(i=0; i
    ').appendTo('body').css('opacity', 0.5).show(); - w = $('#page_taskedit'); + var w = $('#page_taskedit'); if(!flag.windowTaskEditMoved) { var x,y; @@ -319,7 +319,7 @@ function saveTask(form) { if(flag.needAuth && !flag.isLogged && flag.canAllRead) return false; setAjaxErrorTrigger(); - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.post('ajax.php?editTask='+form.id.value+nocache, { list:curList.id, title: form.task.value, note:form.note.value, prio:form.prio.value, tags:form.tags.value, duedate:form.duedate.value }, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return; @@ -358,19 +358,19 @@ function orderChanged(event,ui) { if(!ui.item[0]) return; var itemId = ui.item[0].id; - n = $(this).sortable('toArray'); + var n = $(this).sortable('toArray'); // remove possible empty id's - for(i=0; i 0) dir = 1; - else if(dir < 0) die = -1; + else if(dir < 0) dir = -1; if(cl == 'soon') { taskCnt.soon += dir; return true; } else if(cl == 'today') { taskCnt.today += dir; return true; } else if(cl == 'past') { taskCnt.past+= dir; return true; } @@ -754,10 +754,10 @@ function refreshTaskCnt() function showTaskview(el) { - w = $('#taskview'); + var w = $('#taskview'); if(w.css('display') == 'none') { - offset = $(el).offset(); + var offset = $(el).offset(); w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: offset.left , 'min-width': $(el).width() }).show(); $(document).bind("click", taskviewClose); } @@ -823,7 +823,7 @@ function setTaskview(v, dontLoadTasks) function editFormResize(startstop, event) { - f = $('#page_taskedit'); + var f = $('#page_taskedit'); if(startstop == 1) { tmp.editformdiff = f.height() - $('#page_taskedit textarea').height(); } @@ -862,7 +862,7 @@ function btnMenu(el) if(!el.id) return; oBtnMenu.container = el.id+'container'; oBtnMenu.targets = [el.id, oBtnMenu.container]; - w = $('#'+oBtnMenu.container); + var w = $('#'+oBtnMenu.container); if(w.css('display') == 'none') { oBtnMenu.h = []; @@ -875,7 +875,7 @@ function btnMenu(el) oBtnMenu.h[i] = null; } } ); - offset = $(el).offset(); + var offset = $(el).offset(); w.css({ position: 'absolute', top: offset.top+el.offsetHeight-1, left: offset.left , 'min-width': $(el).width() }).show(); $(document).bind("click", btnMenuClose); } @@ -910,7 +910,7 @@ function toggleNote(id) function toggleAllNotes(show) { - for(id in taskList) + for(var id in taskList) { if(taskList[id].note == '') continue; if(show) { @@ -933,7 +933,7 @@ function loadLists(onInit) $('#searchbar').hide(); } setAjaxErrorTrigger(); - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.getJSON('ajax.php?loadLists'+nocache, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) { @@ -959,7 +959,7 @@ function addList() var r = prompt(lang.addList, lang.addListDefault); if(r == null) return; setAjaxErrorTrigger() - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.post('ajax.php?'+nocache, { addList:1, name:r }, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return; @@ -977,7 +977,7 @@ function renameCurList() var r = prompt(lang.renameList, dehtml(curList.name)); if(r == null || r == '') return; setAjaxErrorTrigger() - nocache = '&rnd='+Math.random(); + var nocache = '&rnd='+Math.random(); $.post('ajax.php?'+nocache, { renameList:1, id:curList.id, name:r }, function(json){ resetAjaxErrorTrigger(); if(!parseInt(json.total)) return;