mirror of
https://github.com/Starlio-app/StarlioX
synced 2025-02-24 23:31:26 +03:00
Analytics has been done, it is possible to turn it off
This commit is contained in:
parent
a5561d76e6
commit
d8bc09074c
9 changed files with 156 additions and 56 deletions
27
web/static/scripts/analytics.js
Normal file
27
web/static/scripts/analytics.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.14.0/firebase-app.js";
|
||||
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.14.0/firebase-analytics.js";
|
||||
|
||||
$.ajax({
|
||||
url: 'http://localhost:3000/api/get/settings',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data["analytics"] === 1) {
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyCeHtV4wmB9xJY4vfcpt7wX-WvlV-5S6v4",
|
||||
authDomain: "everynasa-181a1.firebaseapp.com",
|
||||
databaseURL: "https://everynasa-181a1-default-rtdb.firebaseio.com",
|
||||
projectId: "everynasa-181a1",
|
||||
storageBucket: "everynasa-181a1.appspot.com",
|
||||
messagingSenderId: "369869513900",
|
||||
appId: "1:369869513900:web:2ff68e57f95a36bf87ab09",
|
||||
measurementId: "G-JN83RYFK56"
|
||||
};
|
||||
|
||||
const app = initializeApp(firebaseConfig);
|
||||
getAnalytics(app);
|
||||
} else {
|
||||
$("#analytics").remove();
|
||||
}
|
||||
}
|
||||
})
|
|
@ -8,17 +8,26 @@ $(document).ready(async function() {
|
|||
const $loggingSwitch = $("#settings_saveLoggSwitch");
|
||||
const $loggingSwitchTogglerName = $("#settings_saveLoggTogglerName");
|
||||
|
||||
const $analyticsSwitch = $("#settings_analyticsSwitch");
|
||||
const $analyticsSwitchTogglerName = $("#settings_analyticsTogglerName");
|
||||
|
||||
getSettings().then((data) => {
|
||||
if (data["wallpaper"] === 1) {
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
} else if (data["startup"] === 1) {
|
||||
$startupSwitch.attr("checked", "true");
|
||||
$startupSwitchTogglerName.text("On");
|
||||
} else if (data["save_logg"] === 1) {
|
||||
$loggingSwitch.attr("checked", "true");
|
||||
$loggingSwitchTogglerName.text("On");
|
||||
}
|
||||
if (data["wallpaper"] === 1) {
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
}
|
||||
if (data["startup"] === 1) {
|
||||
$startupSwitch.attr("checked", "true");
|
||||
$startupSwitchTogglerName.text("On");
|
||||
}
|
||||
if (data["save_logg"] === 1) {
|
||||
$loggingSwitch.attr("checked", "true");
|
||||
$loggingSwitchTogglerName.text("On");
|
||||
}
|
||||
if (data["analytics"] === 1) {
|
||||
$analyticsSwitch.attr("checked", "true");
|
||||
$analyticsSwitchTogglerName.text("On");
|
||||
}
|
||||
});
|
||||
|
||||
$wallpaperSwitch.click(async function() {
|
||||
|
@ -67,7 +76,6 @@ $(document).ready(async function() {
|
|||
})
|
||||
});
|
||||
|
||||
|
||||
$startupSwitch.click(async function() {
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/api/get/settings",
|
||||
|
@ -106,7 +114,6 @@ $(document).ready(async function() {
|
|||
|
||||
$startupSwitchTogglerName.text("On");
|
||||
$startupSwitch.attr("checked", "true");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
|
@ -161,7 +168,55 @@ $(document).ready(async function() {
|
|||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
$analyticsSwitch.click(async function() {
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/api/get/settings",
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
if (data["analytics"] === 1) {
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"analytics": 0,
|
||||
},
|
||||
success: function (data) {
|
||||
if(data["status"]) {
|
||||
$analyticsSwitchTogglerName.text("Off");
|
||||
$analyticsSwitch.removeAttr("checked");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"analytics": 1,
|
||||
},
|
||||
success: function (data) {
|
||||
if(data["status"]) {
|
||||
$analyticsSwitchTogglerName.text("On");
|
||||
$analyticsSwitch.attr("checked", "true");
|
||||
|
||||
$("body").append("<script src='/static/scripts/analytics.js' type='module' id='analytics'></script>")
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue