This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
news.js
56 lines (52 loc) · 1.63 KB
/
news.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function initNews() {
var news = document.getElementById("news");
var versionRead = localStorage.getItem("versionRead");
var newsData = {
"version": "perma", // for simplicity, keep this as a string
"title": "Update Log (Nov 9)",
"log": [
"Added button to copy permalink of current selection.",
[
"Desktop only."
],
"[old] Fixed autosave on mobile.",
[
"In case anyone uses the planner/fragment counters on mobile.",
"This update log is still buggy though."
]
]
};
function log2ul(list) {
var ul = document.createElement("ul");
for (var item of list) {
if (typeof item == "string") {
var li = document.createElement("li");
li.innerHTML = item;
ul.appendChild(li);
}
else {
var subul = log2ul(item);
ul.appendChild(subul);
}
}
return ul;
}
function markAsRead() {
localStorage.setItem("versionRead", newsData.version);
news.classList.add("hidden");
updateLines();
}
if (versionRead == newsData.version) {
markAsRead();
}
else {
var div = document.createElement("div");
div.innerHTML = newsData.title;
var ul = log2ul(newsData.log);
div.appendChild(ul);
div.innerHTML += "Click to close."
news.appendChild(div);
}
addTapListener(news, markAsRead);
}
window.addEventListener("DOMContentLoaded", initNews);