Update src/libpoketube/init/pages-api.js
This commit is contained in:
parent
4bbe3f3161
commit
a607b5088a
@ -199,8 +199,10 @@ app.get("/api/stats/optout", (req, res) => {
|
|||||||
var v = localStorage.getItem(KEY);
|
var v = localStorage.getItem(KEY);
|
||||||
if (v === "1") {
|
if (v === "1") {
|
||||||
status.textContent = "Anonymous stats are currently DISABLED in this browser.";
|
status.textContent = "Anonymous stats are currently DISABLED in this browser.";
|
||||||
|
btn.textContent = "Re-enable anonymous stats";
|
||||||
} else {
|
} else {
|
||||||
status.textContent = "Anonymous stats are currently ENABLED in this browser.";
|
status.textContent = "Anonymous stats are currently ENABLED in this browser.";
|
||||||
|
btn.textContent = "Opt out of anonymous stats";
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
status.textContent = "Your browser blocked localStorage, so we cannot store your opt-out choice.";
|
status.textContent = "Your browser blocked localStorage, so we cannot store your opt-out choice.";
|
||||||
@ -210,7 +212,14 @@ app.get("/api/stats/optout", (req, res) => {
|
|||||||
btn.addEventListener("click", function (ev) {
|
btn.addEventListener("click", function (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(KEY, "1");
|
var v = localStorage.getItem(KEY);
|
||||||
|
if (v === "1") {
|
||||||
|
// was opted out -> turn stats back on
|
||||||
|
localStorage.removeItem(KEY);
|
||||||
|
} else {
|
||||||
|
// was enabled -> opt out
|
||||||
|
localStorage.setItem(KEY, "1");
|
||||||
|
}
|
||||||
updateStatus();
|
updateStatus();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
status.textContent = "Could not save opt-out preference (localStorage error).";
|
status.textContent = "Could not save opt-out preference (localStorage error).";
|
||||||
@ -223,6 +232,7 @@ app.get("/api/stats/optout", (req, res) => {
|
|||||||
</body>
|
</body>
|
||||||
</html>`)
|
</html>`)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/api/stats", (req, res) => {
|
app.get("/api/stats", (req, res) => {
|
||||||
const view = (req.query.view || "").toString()
|
const view = (req.query.view || "").toString()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user