/* * 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/. */ $('#username').on("keyup", function () { $('#username').val($('#username').val().toLowerCase()); }); function checkAndSave(username, password) { app.preloader.show(); callAPI("getkey", { username: username, password: password }, function (data) { app.preloader.hide(); callAPI("getprofile", { key: data.key }, function (profile) { if (profile.profile.type != 3) { app.preloader.hide(); app.dialog.alert("You downloaded the merchant app but you aren't a merchant. Go to helpinghelena.org to get the correct app.", "Error"); return; } localStorage.setItem("key", data.key); localStorage.setItem("username", username); localStorage.setItem("password", password); localStorage.setItem("configured", true); // Restart the app to re-read the config restartApplication(); }, function (msg) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); }, function (msg) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); } function doLogin() { var type = 3; var username = $("#username").val(); var password = $("#password").val(); checkAndSave(username, password, type); }