-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathsettings.js
More file actions
47 lines (44 loc) · 1.56 KB
/
settings.js
File metadata and controls
47 lines (44 loc) · 1.56 KB
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
document.addEventListener("DOMContentLoaded", () => {
const tabBtn = document.getElementsByClassName("tab");
for (let i = 0; i < tabBtn.length; i++) {
const btn = document.getElementById("tab" + i);
btn.addEventListener("click", () => {
tabClick(btn.id, tabBtn);
});
}
var menstrualSubscriptionSwitch = document.getElementById("switch3");
menstrualSubscriptionSwitch.addEventListener("click", () => {
btnState = menstrualSubscriptionSwitch.checked;
if (btnState) {
fetch('/menstrual-predictor/')
.then(response => {
text = response;
let subscriptionContainer = document.getElementById('menstrual-prediction-container');
subscriptionContainer.innerHTML = text;
})
//.then(body => {
// console.log(body, 'body')
// subscriptionContainer.innerHTML= body;
// });
// window.location = '/menstrual-predictor/'
console.log(menstrualSubscriptionSwitch.checked);
}
});
});
async function loadSubscriptionPage(response){
data = await response.text();
return data;
}
function toggleMenstrualPredictor() {}
function tabClick(tab_id, tabBtn) {
let shownTab = document.querySelector(".tab-show");
let selectedTabContent = document.querySelector(`#${tab_id}-content`);
shownTab.classList.remove("tab-show");
shownTab.classList.add("tab-hide");
for (btn of tabBtn) {
btn.children[0].classList.remove("active");
}
document.getElementById(tab_id).classList.add("active");
selectedTabContent.classList.remove("tab-hide");
selectedTabContent.classList.add("tab-show");
}