Skip to content

Commit 3ecdc98

Browse files
updated lastUpdated times better
1 parent 01ffd06 commit 3ecdc98

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

index.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
M.server.defaultLocation = "/lists"; //// "lists/default/items"
2424

2525
var currentList = "Default";
26-
var itemSet = {};
26+
var itemSet = {}; // the list of items to be displayed, ordered by numerical keys
2727
var itemNumber = 1;
2828
var now = new Date();
2929
var week = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
@@ -475,7 +475,9 @@
475475
let storedItem = M[storagePlace].recall(description);
476476
storedItem.lastFinished = lastFinished;
477477
storedItem.done = done;
478+
storedItem.lastUpdated = now.getTime();
478479
M[storagePlace].store(description, storedItem);
480+
M[storagePlace].store("../lastUpdated", now.getTime());
479481
var needsToRunFunctionAgain = true;
480482
}
481483
}
@@ -570,6 +572,7 @@
570572
}
571573
}
572574
M[storagePlace].store(key, currentItem);
575+
M[storagePlace].store("../lastUpdated", now.getTime());
573576
}
574577
});
575578
// corrects the items in itemSet
@@ -773,6 +776,7 @@
773776
} else {
774777
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) });
775778
}
779+
M[storagePlace].store("../lastUpdated", now.getTime());
776780
// resets stuff
777781
cancel();
778782
// refreshes the list
@@ -838,6 +842,7 @@
838842
});
839843
// stores the information
840844
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());
841846
// resets stuff
842847
cancel();
843848
// refreshes the list
@@ -869,6 +874,7 @@
869874
});
870875
// stores the information
871876
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());
872878
// resets stuff
873879
cancel();
874880
// refreshes the list
@@ -1095,6 +1101,9 @@
10951101
S.getId("labelContainer").innerHTML = "";
10961102
S.getId("listList").innerHTML = "";
10971103
S.getId("defaultList").innerHTML = "";
1104+
if (M[storagePlace].store("../lastUpdated") instanceof Error) {
1105+
M[storagePlace].store("../lastUpdated", now.getTime());
1106+
}
10981107
// fills itemSet
10991108
if (M[storagePlace].recall("../settings/lastUpdated") instanceof Error) {
11001109
M[storagePlace].store("../settings/lastUpdated", now.getTime());
@@ -1307,6 +1316,13 @@
13071316
item.lastUpdated = now.getTime();
13081317
M[storagePlace].store(encode(listItem.description), item);
13091318
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+
}
13101326
});
13111327
// listens for double-clicking on a description
13121328
// (pulls up the editor for that item)
@@ -1810,12 +1826,14 @@
18101826

18111827
S.listen("listOrdering", "change", function () {
18121828
M[storagePlace].store("../settings/ordering", this.value);
1829+
M[storagePlace].store("../settings/lastUpdated", now.getTime());
18131830
refresh();
18141831
});
18151832

18161833
S.listen("dayThresholdSetter", "change", function () {
18171834
if (this.value == Math.round(this.value)) { // if the number is an integer
18181835
M[storagePlace].store("../settings/threshold", this.value);
1836+
M[storagePlace].store("../settings/lastUpdated", now.getTime());
18191837
refresh();
18201838
}
18211839
});
@@ -1835,9 +1853,11 @@
18351853
// puts lower-priority items further off into the future
18361854
// randomly assigns exact times within certain tiers
18371855
item.time = Math.round(now.getTime() + ((3.7 - Number(item.importance)) * 7 + Math.random() * 7 - 3.5) * 86400000) + "~";
1856+
item.lastUpdated = now.getTime();
18381857
M[storagePlace].store(key, item);
18391858
} else if (item.recurrence == "continual") {
18401859
item.time = now.getTime() + Math.pow(6 - Number(item.importance), 2) * 100000000 + "~"; // This is half the normal time.
1860+
item.lastUpdated = now.getTime();
18411861
M[storagePlace].store(key, item);
18421862
}
18431863
}
@@ -1865,6 +1885,7 @@
18651885
} else {
18661886
M[storagePlace].defaultLocation = "lists/Default/items";
18671887
currentList = "Default";
1888+
M[storagePlace].store("../settings/lastUpdated", now.getTime());
18681889
M[storagePlace].store("../settings/ordering", "dynamic");
18691890
M[storagePlace].store("../settings/filter", []);
18701891
let settings = M[storagePlace].recall("/lists/start-up settings");

0 commit comments

Comments
 (0)