/* * 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/. */ function userpasslogin(username, password) { $.post(accounthubapi, { key: apikey, username: username, password: password, action: "auth" }, function (resp) { if (resp.status == "OK") { $.post(accounthubapi, { key: apikey, username: username, action: "userinfo" }, function (resp) { if (resp.status == "OK") { setuser(resp.data.username); setname(resp.data.name); setuid(resp.data.uid); openScreen("home"); } else { showmsg(resp.msg, "danger"); } }, "json"); } else { showmsg(resp.msg, "danger"); } }, "json"); } function codelogin(code) { $.post(accounthubapi, { key: apikey, code: code, action: "codelogin" }, function (resp) { if (resp.status == "OK") { setuser(resp.user.username); setname(resp.user.realname); setuid(resp.user.uid); openScreen("home"); } else { showmsg(resp.msg, "danger"); } }, "json"); } function loadQuickLogin() { if (!isNaN(group)) { $.post(accounthubapi, { key: apikey, gid: group, action: "getusersbygroup", get: "detail" }, function (resp) { if (resp.status == "OK") { var userhtml = ""; for (var user in resp.users) { var u = resp.users[user]; userhtml += '
\n' + '\n' + '
\n' + u["name"] + "\n" + '
\n'; } $("#userlist .row").html(userhtml); $(".quick-user").click(function () { setuser($(this).data("username")); setname($(this).data("name")); setuid($(this).data("uid")); openScreen("home"); }); } else { $("#quickaccess_tab").tab("dispose"); $("#userpass_tab").tab("show"); } }, "json"); } else { $("#quickaccess_tab").tab("dispose"); $("#quickaccess_tab").css("display", "none"); $("#userpass_tab").tab("show"); } } $("#userpassloginbtn").click(function () { var user = $("#username").val(); var pass = $("#password").val(); if (user != "" && pass != "") { userpasslogin(user, pass); } }); $("#mobilecodeloginbtn").click(function () { var code = $("#code").val(); if (code != "") { codelogin(code); } }); $(document).ready(function () { loadQuickLogin(); });