Skip to content

Commit a767be7

Browse files
committed
Add toast to notify people about updates
1 parent 5e2858b commit a767be7

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

Calculator-v2.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="stylesheet" href="main.css">
99
<script src="https://unpkg.com/mathjs@13.0.0/lib/browser/math.js"></script>
1010
<script type="module" src="date.js"></script>
11+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
1112
<style>
1213
html, body, .content {
1314
height: 100%;
@@ -447,5 +448,8 @@
447448
update();
448449
});
449450
</script>
451+
452+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
453+
<script src="changelog.js"></script>
450454
</body>
451455
</html>

Calculator.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script src="jquery-3.6.0.min.js"></script>
1010
<script src="https://unpkg.com/mathjs@13.0.0/lib/browser/math.js"></script>
1111
<script type="module" src="date.js"></script>
12+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
1213
<script>
1314
function getType(o) {
1415
return Object.prototype.toString.call(o).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
@@ -146,5 +147,8 @@
146147
<a href="/documentation">Documentation</a>
147148
<a href="https://github.com/samfundev/TextFieldCalculator">Source</a>
148149
</footer>
150+
151+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
152+
<script src="changelog.js"></script>
149153
</body>
150154
</html>

changelog.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const lastVisit = JSON.parse(localStorage.getItem("lastVisit") ?? "null");
2+
const update = 1760245980778; // Timestamp of last update
3+
4+
localStorage.setItem("lastVisit", Date.now().toString());
5+
6+
if (lastVisit && lastVisit < update) {
7+
Toastify({
8+
text: "TCF now supports doing calculations with dates and durations. Click here to learn more.",
9+
destination: "/documentation",
10+
duration: 5000,
11+
close: true,
12+
gravity: "bottom",
13+
position: "right",
14+
stopOnFocus: true,
15+
style: {
16+
fontSize: "16px",
17+
}
18+
}).showToast();
19+
}

0 commit comments

Comments
 (0)