aboutsummaryrefslogtreecommitdiff
path: root/src/mixins/sub.pug
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-09-01 19:18:23 +0100
committerAkshay <[email protected]>2024-09-01 19:18:23 +0100
commit8b5db5e1954de865933fd4de003fdd21d57add4a (patch)
tree2c03ba09a51f8d472c1e815942318d5447fb16b2 /src/mixins/sub.pug
parent55ef1a63136c2ff0ec808ba44160f5503cc4416b (diff)
finish subscriptions
Diffstat (limited to 'src/mixins/sub.pug')
-rw-r--r--src/mixins/sub.pug32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mixins/sub.pug b/src/mixins/sub.pug
new file mode 100644
index 0000000..a40aa68
--- /dev/null
+++ b/src/mixins/sub.pug
@@ -0,0 +1,32 @@
1mixin subMgmt()
2 script.
3 function getSubs() {
4 var store = localStorage.getItem('subs');
5 if (store) {
6 return store.split(',').map((n)=>n.replace(/\/?r\//,''));
7 } else {
8 return [];
9 }
10 }
11
12 function subscribe(newsub) {
13 var subs = getSubs();
14 if (!subs.includes(newsub)) {
15 localStorage.setItem('subs',[...subs,newsub]);
16 updateButton(newsub);
17 }
18 }
19
20 function unsubscribe(sub) {
21 var subs = getSubs();
22 if (subs.includes(sub)) {
23 localStorage.setItem('subs',subs.filter((s)=>s!=sub));
24 updateButton(sub);
25 }
26 }
27
28 function issub(sub) {
29 return getSubs().includes(sub);
30 }
31
32