Klipfolio Inc. Copyright © 2002-2009 Klipfolio Inc. info@klipfolio.com http://www.klipfolio.com To Do List to_do_8385 3.2 2008.12.17 Keep track of what you need to do. to do list urgent priority organize http://www.klipfolio.com http://www.serence.com/serence_klips/pics/todo/todo_icon.png http://www.serence.com/serence_klips/pics/todo/todo_banner.png http://www.serence.com/serence_klips/todo.klip manual utf-8 -- true 5899 Add items by right-clicking on the Klip title bar. " + gAddText.value + "" + gWizPriority.value + ""; if(gCheckbox.checked) { gFood += "http://www.serence.com/serence_klips/pics/todo/stars-" + gWizPriority.selected + ".png"; } else { gFood += "http://www.serence.com/serence_klips/pics/todo/complete-" + gWizPriority.selected + ".png"; } gFood += "" + gWizPriority.selected + ""; // Request the refresh to add the item, and clear the text field gAddText.value = ""; gItemQueued = true; if(!another) { Actions.Window.hide (); } onRefresh(); } function addItem() { if(gItem.value.length == 0) { return; } gFood = "" + gItem.value + "" + gPriority.value + ""; if(gCheckbox.checked) { gFood += "http://www.serence.com/serence_klips/pics/todo/stars-" + gPriority.selected + ".png"; } else { gFood += "http://www.serence.com/serence_klips/pics/todo/complete-" + gPriority.selected + ".png"; } gFood += "" + gPriority.selected + ""; // Request the refresh to add the item, and clear the text field gItem.value = ""; gItemQueued = true; onRefresh(); } function onRefresh() { if(gItemQueued) { Engines.KlipFood.process(gFood); gItemQueued = false; } else { // If the text currently in the text field is not in the to do list yet, add it var found = false; var i; for(i = 0; i < Items.length; i++) { if(Items[i].getData("title") == gItem.value) { found = true; } } if(!found) { addItem(); } } removeDoneItems(); if(Items.length != 0) { // Sort items by priority Items.sort(compareItems); } setItemActions(); savePrefs(); return true; } function myTick() { removeDoneItems(); savePrefs(); } function setItemActions() { Items.globalactions = ["Add a Task", addTask]; if(gCheckbox.checked) { // The priorities are using 4 stars var actionList = ["Urgent", setPriority4, "High", setPriority3, "Normal", setPriority2, "Low", setPriority1, "Done", setPriority0]; } else { // The priorities are using complete/incomplete var actionList = ["Incomplete", setPriorityIncomplete, "Complete", setPriorityComplete]; } Items.actions = ["Add a Task", addTask, "Change Task Description", editItem, "Set Priority", actionList]; } function addTask() { Actions.Window.show ("new", "main"); } function editItem(item) { gEditText.value = item.getData("title"); // The UI item the user will edit gEditing = item.getData("title"); // Stored for later use Actions.Window.show ("edit", "main"); } function saveItem(page) { var i = 0; for(i = 0; i < Items.length; i++) { if(Items[i].getData("title") == gEditing) { Items[i].setData("title", gEditText.value); savePrefs(); onRefresh(); Actions.Window.hide (); return; } } } function setPriority4(item) { item.setData("priority", "Urgent"); item.setData("level", "0"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/stars-0.png"); savePrefs(); onRefresh(); } function setPriority3(item) { item.setData("priority", "High"); item.setData("level", "1"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/stars-1.png"); savePrefs(); onRefresh(); } function setPriority2(item) { item.setData("priority", "Normal"); item.setData("level", "2"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/stars-2.png"); savePrefs(); onRefresh(); } function setPriority1(item) { item.setData("priority", "Low"); item.setData("level", "3"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/stars-3.png"); savePrefs(); onRefresh(); } function setPriority0(item) { item.setData("priority", "Done"); item.setData("level", "4"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/stars-4.png"); savePrefs(); onRefresh(); } function setPriorityIncomplete(item) { item.setData("priority", "Incomplete"); item.setData("level", "0"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/complete-0.png"); savePrefs(); onRefresh(); } function setPriorityComplete(item) { item.setData("priority", "Complete"); item.setData("level", "1"); item.setData("icon", "http://www.serence.com/serence_klips/pics/todo/complete-1.png"); savePrefs(); onRefresh(); } function removeDoneItems() { var i; var end = Items.length; var d = new Date() var t = d.getTime() var start, total; for(i = 0; i < end; i++) { var priority = Items[i].getData("priority"); if((priority == "Complete") || (priority == "Done")) { start = Items[i].getData("removeTime"); if((start.length > 0) && (start != "false")) { // Compare the item's remove "start time" with the current time, // and delete the item if necessary total = t - start; // Compare the total time the item has been in the to do list with // the removal time set by the user if((total >= gRemovalTime) && (gRemovalTime != -1)) { Items.remove(i); i -= 1; end -= 1; } } else { // The item doesn't have a removal start time, so set it Items[i].setData("removeTime", t + ""); } } else { // If the item is not marked Done, make sure it doesn't get deleted Items[i].setData("removeTime", ""); } } } function compareItems(item1, item2) { // Note: a lower priority level (number) means a higher priority if (item1.getData("level") < item2.getData("level") ) { // item1 is more urgent than item2 return -1; } else if (item1.getData("level") == item2.getData("level")) { // item1 is the same priority as item 2, so sort them alphabetically by title if(item1.getData("title").toLowerCase() < item2.getData("title").toLowerCase()) { return -1; } else { return 1; } } else { // item 1 is less urgent than item2 return 1; } } function savePrefs() { var i; var food = ""; for(i = 0; i < Items.length; i++) { food += "" + Items[i].getData("title") + "" + Items[i].getData("priority") + ""; if(gCheckbox.checked) { food += "http://www.serence.com/serence_klips/pics/todo/stars-" + Items[i].getData("level") + ".png"; } else { food += "http://www.serence.com/serence_klips/pics/todo/complete-" + Items[i].getData("level") + ".png"; } food += "" + Items[i].getData("level") + "" + Items[i].getData("removeTime") + ""; } // Convert the to do list into "KlipFood" and store it as a pref. Prefs.setPref("food", food); Prefs.setPref("remove", gRemoveTime.selected); Prefs.setPref("usePriorities", "" + gCheckbox.checked); } ]]>