You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Game/www/js/settings.js

134 lines
4.9 KiB
JavaScript

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var settings = [
{
setting: "litemode",
title: "Use alternate map",
text: "Replace the 3D map with a lightweight power-saving 2D version.",
icon: "game-icon game-icon-treasure-map",
color: "yellow",
type: "toggle",
restart: true
},
{
setting: "nickname",
title: "Nickname",
text: "Change your player name.",
icon: "fas fa-user-edit",
color: "blue",
onclick: "changeNickname()",
type: "link"
},
{
setting: "munzee",
title: "Link Munzee account",
text: "Scan Munzee codes from inside TerranQuest.",
icon: "fas fa-qrcode",
color: "green",
onclick: "openBrowser('" + SETTINGS["munzee_url"] + "?username=" + localStorage.getItem("username") + "&password=" + localStorage.getItem("password") + "')",
type: "link"
},
{
setting: "opensource",
title: "Credits",
text: "See information on third-party code and artwork used in TerranQuest.",
icon: "game-icon game-icon-spell-book",
color: "lightblue",
onclick: "router.navigate('/credits')",
type: "link"
},
{
setting: "privacy",
title: "Privacy Policy",
text: "Know what data we collect and what your rights are.",
icon: "game-icon game-icon-spy",
color: "purple",
onclick: "openBrowser('" + SETTINGS["terms_of_service_url"] + "')",
type: "link"
},
{
setting: "account",
title: "Sign out",
text: "Disconnect this device and open the sign in screen.",
icon: "game-icon game-icon-exit-door",
color: "red",
onclick: "logout()",
type: "link"
},
{
setting: "versions",
title: "TerranQuest v" + app_version,
text: "Copyright &copy; 2014-2019 Netsyms Technologies. License: <span style=\"text-decoration: underline;\" onclick=\"openBrowser('https://source.netsyms.com/TerranQuest/Game?pk_campaign=TerranQuestApp');\">Mozilla Public License 2.0</span>.",
icon: "far fa-copyright margin-vertical",
color: "gray",
onclick: ""
}
];
function changeNickname() {
app.dialog.prompt('New Name', function (name) {
callAPI("changenick", {
nick: name
}, function (success) {
app.dialog.alert('You are now known as ' + success.name);
}, function (error) {
app.dialog.alert(error);
});
});
}
function loadSettings() {
$("#settings-bin").html("");
settings.forEach(function (item) {
$("#settings-bin").append('<li data-setting="' + item.setting + '">'
+ (item.type == "link" ? '<a href="#" onclick="' + item.onclick + '">' : '')
+ ' <div class="item-content">'
+ ' <div class="item-media" style="justify-content: center;">'
+ ' <i class="' + item.icon + ' fa-2x text-color-' + item.color + '"></i>'
+ ' </div>'
+ ' <div class="item-inner">'
+ ' <div class="item-title">'
+ ' ' + item.title
+ ' <div class="item-footer">'
+ ' ' + item.text
+ ' </div>'
+ ' </div>'
+ ' <div class="item-after">'
+ (item.type == "toggle" ? '<label class="toggle">'
+ ' <input type="checkbox"/>'
+ ' <span class="toggle-icon"></span>'
+ '</label>' : '')
+ ' </div>'
+ ' </div>'
+ ' </div>'
+ (item.type == "link" ? '</a>' : '')
+ '</li>'
);
if (item.type == "toggle") {
var toggle = app.toggle.create({
el: "#settings-bin li[data-setting=" + item.setting + "] .toggle",
on: {
change: function () {
// Don't do anything if the setting isn't actually changed
if ((localStorage.getItem(item.setting) == "true") == this.checked) {
return;
}
localStorage.setItem(item.setting, this.checked);
if (item.restart == true) {
app.dialog.preloader('Applying changes...');
setTimeout(restartApplication, 1000);
}
}
}
});
if ((localStorage.getItem(item.setting) == "true") != toggle.checked) {
toggle.toggle();
}
}
});
}