decentralized-video-chat/public/js/pricing-switcher.js

27 lines
747 B
JavaScript
Raw Normal View History

2020-03-31 02:16:08 +08:00
(function () {
"use strict";
const pricingToggle = document.getElementById("pricing-toggle");
2020-03-24 11:20:28 +08:00
if (pricingToggle) {
2020-03-31 02:16:08 +08:00
window.addEventListener("load", pricingSwitch);
pricingToggle.addEventListener("change", pricingSwitch);
2020-03-24 11:20:28 +08:00
}
2020-03-31 02:16:08 +08:00
function pricingSwitch() {
const switchables = document.getElementsByClassName("pricing-switchable");
2020-03-24 11:20:28 +08:00
if (pricingToggle.checked) {
for (let i = 0; i < switchables.length; i++) {
2020-03-31 02:16:08 +08:00
switchables[i].innerHTML = switchables[i].getAttribute(
"data-pricing-yearly"
);
2020-03-24 11:20:28 +08:00
}
} else {
for (let i = 0; i < switchables.length; i++) {
2020-03-31 02:16:08 +08:00
switchables[i].innerHTML = switchables[i].getAttribute(
"data-pricing-monthly"
);
2020-03-24 11:20:28 +08:00
}
}
}
2020-03-31 02:16:08 +08:00
})();