|
23 | 23 | M.server.defaultLocation = "/lists"; //// "lists/default/items" |
24 | 24 |
|
25 | 25 | var currentList = "Default"; |
26 | | - var itemSet = {}; |
| 26 | + var itemSet = {}; // the list of items to be displayed, ordered by numerical keys |
27 | 27 | var itemNumber = 1; |
28 | 28 | var now = new Date(); |
29 | 29 | var week = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; |
|
475 | 475 | let storedItem = M[storagePlace].recall(description); |
476 | 476 | storedItem.lastFinished = lastFinished; |
477 | 477 | storedItem.done = done; |
| 478 | + storedItem.lastUpdated = now.getTime(); |
478 | 479 | M[storagePlace].store(description, storedItem); |
| 480 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
479 | 481 | var needsToRunFunctionAgain = true; |
480 | 482 | } |
481 | 483 | } |
|
570 | 572 | } |
571 | 573 | } |
572 | 574 | M[storagePlace].store(key, currentItem); |
| 575 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
573 | 576 | } |
574 | 577 | }); |
575 | 578 | // corrects the items in itemSet |
|
773 | 776 | } else { |
774 | 777 | M[storagePlace].store(description, { importance: S.getId("importance").value, time: date, recurrence: S.getId("recurrence").value, lastFinished: now.getTime(), lastUpdated: now.getTime(), done: false, labels: labels, elaboration: S.getId(advancedEditorSection, "elaboration").value, difficulty: Number(advancedEditorSection.querySelector("#difficulty").value) }); |
775 | 778 | } |
| 779 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
776 | 780 | // resets stuff |
777 | 781 | cancel(); |
778 | 782 | // refreshes the list |
|
838 | 842 | }); |
839 | 843 | // stores the information |
840 | 844 | M[storagePlace].store(encode(S.getId("description").value.trim()), { position: position, importance: S.getId("importance").value, done: false, positioned: positioned, lastFinished: now.getTime(), lastUpdated: now.getTime(), labels: labels, elaboration: S.getId(advancedEditorSection, "elaboration").value }); |
| 845 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
841 | 846 | // resets stuff |
842 | 847 | cancel(); |
843 | 848 | // refreshes the list |
|
869 | 874 | }); |
870 | 875 | // stores the information |
871 | 876 | M[storagePlace].store(encode(S.getId("description").value.trim()), { importance: S.getId("importance").value, done: false, lastUpdated: now.getTime(), labels: labels, elaboration: S.getId(advancedEditorSection, "elaboration").value }); |
| 877 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
872 | 878 | // resets stuff |
873 | 879 | cancel(); |
874 | 880 | // refreshes the list |
|
1095 | 1101 | S.getId("labelContainer").innerHTML = ""; |
1096 | 1102 | S.getId("listList").innerHTML = ""; |
1097 | 1103 | S.getId("defaultList").innerHTML = ""; |
| 1104 | + if (M[storagePlace].store("../lastUpdated") instanceof Error) { |
| 1105 | + M[storagePlace].store("../lastUpdated", now.getTime()); |
| 1106 | + } |
1098 | 1107 | // fills itemSet |
1099 | 1108 | if (M[storagePlace].recall("../settings/lastUpdated") instanceof Error) { |
1100 | 1109 | M[storagePlace].store("../settings/lastUpdated", now.getTime()); |
|
1307 | 1316 | item.lastUpdated = now.getTime(); |
1308 | 1317 | M[storagePlace].store(encode(listItem.description), item); |
1309 | 1318 | refresh(); |
| 1319 | + if (S.getId(advancedSettingsSection, "inspiringMessages").checked) { |
| 1320 | + if (item.difficulty == 4) { |
| 1321 | + S.makeDialog("You're doing great!", "Keep going"); |
| 1322 | + } else if (item.difficulty == 5) { |
| 1323 | + S.makeDialog("WOOHOO! That's how it's done!", "Keep being<br>awesome"); |
| 1324 | + } |
| 1325 | + } |
1310 | 1326 | }); |
1311 | 1327 | // listens for double-clicking on a description |
1312 | 1328 | // (pulls up the editor for that item) |
|
1810 | 1826 |
|
1811 | 1827 | S.listen("listOrdering", "change", function () { |
1812 | 1828 | M[storagePlace].store("../settings/ordering", this.value); |
| 1829 | + M[storagePlace].store("../settings/lastUpdated", now.getTime()); |
1813 | 1830 | refresh(); |
1814 | 1831 | }); |
1815 | 1832 |
|
1816 | 1833 | S.listen("dayThresholdSetter", "change", function () { |
1817 | 1834 | if (this.value == Math.round(this.value)) { // if the number is an integer |
1818 | 1835 | M[storagePlace].store("../settings/threshold", this.value); |
| 1836 | + M[storagePlace].store("../settings/lastUpdated", now.getTime()); |
1819 | 1837 | refresh(); |
1820 | 1838 | } |
1821 | 1839 | }); |
|
1835 | 1853 | // puts lower-priority items further off into the future |
1836 | 1854 | // randomly assigns exact times within certain tiers |
1837 | 1855 | item.time = Math.round(now.getTime() + ((3.7 - Number(item.importance)) * 7 + Math.random() * 7 - 3.5) * 86400000) + "~"; |
| 1856 | + item.lastUpdated = now.getTime(); |
1838 | 1857 | M[storagePlace].store(key, item); |
1839 | 1858 | } else if (item.recurrence == "continual") { |
1840 | 1859 | item.time = now.getTime() + Math.pow(6 - Number(item.importance), 2) * 100000000 + "~"; // This is half the normal time. |
| 1860 | + item.lastUpdated = now.getTime(); |
1841 | 1861 | M[storagePlace].store(key, item); |
1842 | 1862 | } |
1843 | 1863 | } |
|
1865 | 1885 | } else { |
1866 | 1886 | M[storagePlace].defaultLocation = "lists/Default/items"; |
1867 | 1887 | currentList = "Default"; |
| 1888 | + M[storagePlace].store("../settings/lastUpdated", now.getTime()); |
1868 | 1889 | M[storagePlace].store("../settings/ordering", "dynamic"); |
1869 | 1890 | M[storagePlace].store("../settings/filter", []); |
1870 | 1891 | let settings = M[storagePlace].recall("/lists/start-up settings"); |
|
0 commit comments