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.
66 lines
1.4 KiB
JavaScript
66 lines
1.4 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/.
|
|
*/
|
|
|
|
|
|
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 {
|
|
alert(resp.msg);
|
|
}
|
|
}, "json");
|
|
} else {
|
|
alert(resp.msg);
|
|
}
|
|
}, "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 {
|
|
alert(resp.msg);
|
|
}
|
|
}, "json");
|
|
}
|
|
|
|
$("#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);
|
|
}
|
|
}); |