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
|
@ -53,5 +53,5 @@
|
|||
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script>
|
||||
<script src="/static/scripts/tooltip.js" type="application/javascript"></script>
|
||||
</body>
|
||||
<script src="/static/scripts/analytics.js" type="module"></script></body>
|
||||
</html>
|
|
@ -71,5 +71,6 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.min.js" integrity="sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
|
||||
<script src="/static/scripts/gallery.js" type="application/javascript"></script>
|
||||
<script src="/static/scripts/analytics.js" type="module" id="analytics"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -52,11 +52,20 @@
|
|||
</div>
|
||||
<div class="settings">
|
||||
<p class="title"><strong>Create log files</strong></p>
|
||||
<p class="desc">Every Nasa will create files in which errors will be written that will help developers when correcting errors.</p>
|
||||
<p class="desc">EveryNasa will create files in which errors will be written that will help developers when correcting errors.</p>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="settings_saveLoggSwitch">
|
||||
<label class="form-check-label" for="settings_autoSetWallpaperTogglerName" id="settings_saveLoggTogglerName">Off</label>
|
||||
</div> </div>
|
||||
<label class="form-check-label" for="settings_saveLoggTogglerName" id="settings_saveLoggTogglerName">Off</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings">
|
||||
<p class="title"><strong>Enable Analytics</strong></p>
|
||||
<p class="desc">EveryNasa will collect Anonymous Usage data.</p>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="settings_analyticsSwitch">
|
||||
<label class="form-check-label" for="settings_analyticsTogglerName" id="settings_analyticsTogglerName">Off</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings">
|
||||
<p class="title"><strong>Create an application shortcut</strong></p>
|
||||
<p class="desc">EveryNasa will create an application shortcut on your desktop.</p>
|
||||
|
|
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