/*
 * 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/.
 */


$('.item-link[data-setting=apptheme] select').on("change", function () {
    setStorage("apptheme", $('.item-link[data-setting=apptheme] select').val());

    applyColorTheme();
});

$('.item-link[data-setting=animation] select').on("change", function () {
    setStorage("animation", $('.item-link[data-setting=animation] select').val());

    if (getStorage("animation") != "auto") {
        setAnimations();
    }
    if (getStorage("animation") == "auto") {
        toggleAnimations(auto_disable_animations == false);
    }
});

$('.item-link[data-setting=mapsource] select').on("change", function () {
    setStorage("mapsource", $('.item-link[data-setting=mapsource] select').val());

    reloadMap();
});

$('.item-content[data-setting=hideaccountnag] .toggle input').on("change", function () {
    var checked = $(this).prop('checked');
    setStorage("hideaccountnag", checked);
});

$('.item-content[data-setting=analytics] .toggle input').on("change", function () {
    var checked = $(this).prop('checked');
    setStorage("analytics", checked ? "true" : "false");
});

function resetAccountPrompt() {
    app.dialog.confirm("Are you sure you want to log out?", function () {
        removeFromStorage("accountnumber");
        removeFromStorage("accountkey");
        restartApplication();
    });
}