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