Set user credentials inside callAPI()
This commit is contained in:
parent
f579a9bfeb
commit
b67ab6cddf
@ -80,6 +80,8 @@ function checkClientVersion(success, failure) {
|
||||
* @return {undefined}
|
||||
*/
|
||||
function callAPI(action, data, success, failure) {
|
||||
data.username = localStorage.getItem("username");
|
||||
data.password = localStorage.getItem("password");
|
||||
return $.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
@ -131,6 +133,8 @@ function callAPI(action, data, success, failure) {
|
||||
* @return {undefined}
|
||||
*/
|
||||
function callAPIRawResponse(action, data, success, failure) {
|
||||
data.username = localStorage.getItem("username");
|
||||
data.password = localStorage.getItem("password");
|
||||
return $.ajax({
|
||||
type: 'POST',
|
||||
url: getActionUrl(action),
|
||||
|
@ -69,10 +69,7 @@ function refreshChat(forcescroll) {
|
||||
if (typeof forcescroll == 'undefined') {
|
||||
forcescroll = false;
|
||||
}
|
||||
var vars = {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
};
|
||||
var vars = {};
|
||||
if (!(map.getCenter().lng == 0 && Math.abs(map.getCenter().lat) > 0.000001)) {
|
||||
vars["latitude"] = map.getCenter().lat;
|
||||
vars["longitude"] = map.getCenter().lng;
|
||||
@ -147,8 +144,6 @@ function sendChat() {
|
||||
return false;
|
||||
}
|
||||
callAPI("sendchat", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
latitude: map.getCenter().lat,
|
||||
longitude: map.getCenter().lng,
|
||||
message: message
|
||||
|
@ -38,8 +38,6 @@ function checkAndSave(username, password) {
|
||||
$(".type-card").click(function () {
|
||||
app.preloader.show();
|
||||
callAPI("createplayer", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
team: $(this).data("id")
|
||||
}, function (success) {
|
||||
app.preloader.hide();
|
||||
|
@ -9,10 +9,7 @@ var playerProfile = [];
|
||||
var messages = null;
|
||||
|
||||
function loadHomePage(callback) {
|
||||
callAPI("getprofile", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (data) {
|
||||
callAPI("getprofile", {}, function (data) {
|
||||
playerProfile = data.profile;
|
||||
setupProfile();
|
||||
initChat();
|
||||
@ -20,10 +17,7 @@ function loadHomePage(callback) {
|
||||
setInterval(refreshChat, 1000 * 15);
|
||||
// Refresh health bar
|
||||
setInterval(function () {
|
||||
callAPI("getprofile", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (data) {
|
||||
callAPI("getprofile", {}, function (data) {
|
||||
playerProfile = data.profile;
|
||||
setupProfile();
|
||||
});
|
||||
@ -49,8 +43,6 @@ function setupProfile() {
|
||||
function scanCode() {
|
||||
scanBarcode(function (text) {
|
||||
callAPI("code", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
code: text,
|
||||
latitude: playerPosition.coords.latitude,
|
||||
longitude: playerPosition.coords.longitude,
|
||||
@ -126,8 +118,6 @@ function openPlace(id, name) {
|
||||
|
||||
function updatePlaceStats(id, successCallback, errorCallback) {
|
||||
callAPI("getplace", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
id: id
|
||||
}, function (resp) {
|
||||
var place = resp.place;
|
||||
@ -170,8 +160,6 @@ function updatePlaceStats(id, successCallback, errorCallback) {
|
||||
|
||||
$("#magic-action-button").click(function () {
|
||||
callAPI("placeact", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
id: $("#place-popup").data("placeid")
|
||||
}, function (resp) {
|
||||
updatePlaceStats($("#place-popup").data("placeid"));
|
||||
|
@ -26,10 +26,7 @@ function loadInventory(reload, target) {
|
||||
$(target + " .item-bin .item-col").remove();
|
||||
$(target + " .item-bin .bag-preloader").removeClass("display-none");
|
||||
}
|
||||
callAPI("inventory", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (resp) {
|
||||
callAPI("inventory", {}, function (resp) {
|
||||
if (resp.items.length == 0) {
|
||||
$(target + " .bag-empty").removeClass("display-none");
|
||||
} else {
|
||||
@ -91,8 +88,6 @@ function loadInventory(reload, target) {
|
||||
var qty = itemdom.data("qty");
|
||||
var uuid = uuids.split("|")[0];
|
||||
callAPI("useitem", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
uuid: uuid,
|
||||
placeid: (inventoryloadedfromplacepopup ? $("#place-popup").data("placeid") : null)
|
||||
}, function (success) {
|
||||
|
@ -61,10 +61,7 @@ router.on("pageInit", function (pagedata) {
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function isServerAlive(callback) {
|
||||
callAPIRawResponse("ping", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (data) {
|
||||
callAPIRawResponse("ping", {}, function (data) {
|
||||
callback(true);
|
||||
}, function (msg, xhr) {
|
||||
app.preloader.hide();
|
||||
@ -89,10 +86,7 @@ function checkLogin(callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
callAPI("ping", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (data) {
|
||||
callAPI("ping", {}, function (data) {
|
||||
callback(true);
|
||||
}, function (msg) {
|
||||
callback(false);
|
||||
@ -107,10 +101,7 @@ if (localStorage.getItem("configured") == null) {
|
||||
// Version OK
|
||||
checkLogin(function (valid) {
|
||||
if (valid) {
|
||||
callAPI("playerexists", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password")
|
||||
}, function (resp) {
|
||||
callAPI("playerexists", {}, function (resp) {
|
||||
if (resp.exists == true) {
|
||||
router.navigate("/home");
|
||||
} else {
|
||||
|
@ -63,8 +63,6 @@ function setMapLocation(latitude, longitude) {
|
||||
|
||||
function updatePlaceLayer(latitude, longitude) {
|
||||
callAPI("nearbyplaces", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
radius: 1
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
function loadProfile() {
|
||||
callAPI("getprofile", {
|
||||
username: localStorage.getItem("username"),
|
||||
password: localStorage.getItem("password"),
|
||||
id: $(".page[data-name=profile]").data("playerid")
|
||||
}, function (data) {
|
||||
console.log(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user