All server queries now send system language

master
Skylar Ittner 8 years ago
parent 0239ce9f89
commit 6a5fa9b4f8

@ -36,7 +36,7 @@ function askLogout() {
}
function logout() {
$.getJSON(mkApiUrl('deletesession'), {}, function (data) {
$.getJSON(mkApiUrl('deletesession') + "?lang=" + USER_LANGUAGE, {}, function (data) {
if (data.status === 'OK') {
localStorage.setItem("username", '');
localStorage.setItem("password", '');
@ -54,7 +54,8 @@ function logout() {
var teamchoosercheckretried = false;
function checkUserHasTeamOpenChooserIfNot(username) {
$.getJSON(mkApiUrl('getstats'), {
user: username
user: username,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
if (data.stats.teamid && data.stats.teamid > 0) {
@ -118,7 +119,8 @@ function dosignup() {
user: $('#usernameBox').val(),
pass: $('#passwordBox').val(),
name: $('#nameBox').val(),
email: $('#emailBox').val()
email: $('#emailBox').val(),
lang: USER_LANGUAGE
},
function (data) {
if (data === 'OK') {
@ -126,6 +128,7 @@ function dosignup() {
$.post(mkApiUrl('login'), {
user: $('#usernameBox').val(),
pass: $('#passwordBox').val(),
lang: USER_LANGUAGE
}, function (out) {
if (out.status === 'OK') {
loginOK();
@ -175,7 +178,8 @@ function dologin() {
$.post(mkApiUrl("login"),
{
user: $('#usernameBox').val(),
pass: $('#passwordBox').val()
pass: $('#passwordBox').val(),
lang: USER_LANGUAGE
},
function (data) {
if (data.status === 'OK') {

@ -139,7 +139,7 @@ function loadPlaces(lat, long) {
if (!lockGot) {
return;
}
var url = mkApiUrl('places', 'gs') + "?lat=" + lat + "&long=" + long + "&radius=.5&names=1";
var url = mkApiUrl('places', 'gs') + "?lat=" + lat + "&long=" + long + "&radius=.5&names=1&lang=" + USER_LANGUAGE;
try {
$.getJSON(
url,
@ -196,7 +196,7 @@ var updatePosition = function (position) {
function pingServer() {
if (lockGot && gpsaccuracy < requiredaccuracy) {
$.getJSON(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude, function (data) {
$.getJSON(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude + "&lang=" + USER_LANGUAGE, function (data) {
if (data.status == "ERROR" && logoutInProgress != true) {
localStorage.setItem("no_autologin", "true");
username = null;

@ -27,6 +27,8 @@ MUNZEE_CLIENT_ID = '616cecc70e17f4a3cb64146dce2d33f5';
MUNZEE_REDIRECT = 'http://gs.terranquest.net/munzee.php';
CODE_SCAN_COOLDOWN_SECONDS = 15; // Also change in CSS (.cooldown-fade-anim)
USER_LANGUAGE = "en-US";
currentscreen = "";
/*
* Runs when the app opens
@ -54,6 +56,16 @@ function onDeviceReady() {
}
}
});
setLocale();
}
function setLocale() {
navigator.globalization.getPreferredLanguage(
function (language) {
USER_LANGUAGE = language.value;
},
function () {}
);
}
// Depending on the device, a few examples are:

@ -25,7 +25,8 @@ function buycoins(productId) {
os: 'android',
data: data.receipt,
signature: data.signature,
id: productId
id: productId,
lang: USER_LANGUAGE
}, function (result) {
if (result.status == 'OK') {
return inAppPurchase.consume(data.type, data.receipt, data.signature);
@ -53,7 +54,8 @@ function buycoins(productId) {
os: 'ios',
data: data.receipt,
signature: data.signature,
id: productId
id: productId,
lang: USER_LANGUAGE
}, function (result) {
if (result.status == 'OK') {
return inAppPurchase.consume(data.type, data.receipt, data.signature);
@ -81,7 +83,8 @@ function buyitem(id, cost) {
$('#shopitem-' + id).prop('onclick', null).off('click');
$.getJSON(mkApiUrl('buyitem', 'gs'), {
merchid: id,
cost: cost
cost: cost,
lang: USER_LANGUAGE
}, function (data) {
if (data.status == 'OK') {
showSuccessMessage(data.message);
@ -142,7 +145,7 @@ function setcoinhtmlfromiap(coinsjson) {
}
function loadstorefront() {
$.getJSON(mkApiUrl('shopitems'), function (data) {
$.getJSON(mkApiUrl('shopitems') + "?lang=" + USER_LANGUAGE, function (data) {
var content = "";
if (data.status == 'OK') {
var items = data.items;
@ -163,7 +166,7 @@ function loadstorefront() {
}
function refreshcoins() {
$.getJSON(mkApiUrl('shopitems'), function (data) {
$.getJSON(mkApiUrl('shopitems') + "?lang=" + USER_LANGUAGE, function (data) {
if (data.status == 'OK') {
$('#coinbalance').text(data.balance);
}

@ -33,7 +33,8 @@ var terrainName = "Other";
*/
function syncStats() {
$.getJSON(mkApiUrl('getstats'), {
user: username
user: username,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
maxenergy = data.stats.maxenergy;
@ -57,7 +58,8 @@ function getChat() {
$.getJSON(mkApiUrl('chat', 'cs'), {
lat: latitude,
long: longitude,
name: username
name: username,
lang: USER_LANGUAGE
}, function (data) {
data = sortResults(data, 'time', true);
var content = "";
@ -79,7 +81,7 @@ function getChat() {
function privMsgSync() {
$.getJSON(
mkApiUrl('privmsgs') + "?filter=unread",
mkApiUrl('privmsgs') + "?filter=unread&lang=" + USER_LANGUAGE,
function (data) {
if (data.status === 'OK') {
if (data.msgs.length > 0) {
@ -98,7 +100,8 @@ skycons.add("weathericon", "clear-day");
function getWeather() {
$.getJSON(mkApiUrl('getweather'), {
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
var currently = data.currently;
rawWeatherData = currently;
@ -110,7 +113,8 @@ function getWeather() {
function getTerrain() {
$.getJSON(mkApiUrl('getterrain'), {
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
var terrainid = -1;
var terrainstr = "Other";
@ -159,7 +163,8 @@ $("#chatsendform").submit(function (event) {
lat: latitude,
long: longitude,
msg: message,
name: username
name: username,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
$('#chatbox-input').val("");

@ -50,7 +50,8 @@
//alert($('input[name=teamChooser]:checked').val());
var team = $('input[name=teamChooser]:checked').val();
$.getJSON(mkApiUrl('setteam', 'gs'), {
teamid: team
teamid: team,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
// We're all good.

@ -169,7 +169,8 @@
os: 'android',
data: prod.receipt,
signature: prod.signature,
id: prod.productId
id: prod.productId,
lang: USER_LANGUAGE
}, function (result) {
if (result.status == 'OK') {
inAppPurchase.consume(prod.type, prod.receipt, prod.signature);

@ -46,7 +46,8 @@
// Load the list of nearby players
$.getJSON(mkApiUrl('nearby'), {
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
var content = "";
if (data.status === 'OK') {
@ -75,7 +76,8 @@
}
$.getJSON(mkApiUrl('giveitem', 'gs'), {
giveto: playername,
itemuuid: uuid
itemuuid: uuid,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
loadinventory();
@ -92,7 +94,8 @@
function useitem(uuid) {
$('#invitem-' + uuid).prop('onclick', null).off('click');
$.getJSON(mkApiUrl('useitem', 'gs'), {
itemuuid: uuid
itemuuid: uuid,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
loadinventory();
@ -132,7 +135,8 @@
function loadinventory() {
$.getJSON(mkApiUrl('inventory'), {
user: username
user: username,
lang: USER_LANGUAGE
}, function (data) {
var content = "";
if (data.status == 'OK') {

@ -36,7 +36,8 @@
function loadnearby() {
$.getJSON(mkApiUrl('nearby'), {
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
var content = "";
if (data.status === 'OK') {

@ -87,7 +87,8 @@
function resync(firstload) {
$('#place-refresh').addClass('fa-spin');
$.getJSON(mkApiUrl('getstats', 'gs'), {
user: username
user: username,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
maxenergy = data.stats.maxenergy;
@ -99,7 +100,8 @@
}
});
$.getJSON(mkApiUrl('placestats', 'gs'), {
locationid: thisplace.properties.gameinfo.locationid
locationid: thisplace.properties.gameinfo.locationid,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
placeteam = data.stats.teamid;
@ -167,7 +169,8 @@
$.getJSON(mkApiUrl('attackplace', 'gs'), {
locationid: thisplace.properties.gameinfo.locationid,
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
$('#capturebtn').text(data.message);
@ -205,7 +208,8 @@
$.getJSON(mkApiUrl('refillplace', 'gs'), {
locationid: thisplace.properties.gameinfo.locationid,
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
$('#refillbtn').text(data.message);
@ -241,7 +245,8 @@
$.getJSON(mkApiUrl('claimplace', 'gs'), {
locationid: thisplace.properties.gameinfo.locationid,
lat: latitude,
long: longitude
long: longitude,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
$('#capturebtn').text(data.message);

@ -72,7 +72,8 @@
if (message !== '') {
$.post(mkApiUrl('privmsgs'), {
msg: message,
to: toplayer
to: toplayer,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK') {
$('#privmsgbox').val("");
@ -89,7 +90,8 @@
function loadPlayerStats(user) {
$.getJSON(mkApiUrl('getstats'), {
user: user
user: user,
lang: USER_LANGUAGE
}, function (data) {
if (data.status === 'OK' && data.stats != null) {
if (data.stats.level != null) {
@ -121,7 +123,7 @@
$('#loading-badges').html('<i class="fa fa-spinner fa-pulse"></i> Loading...');
$('#loading-badges').css('display', 'block');
$.getJSON(
mkApiUrl('getbadges') + '?user=' + user,
mkApiUrl('getbadges') + '?user=' + user + "&lang=" + USER_LANGUAGE,
function (data) {
if (data.status === 'OK') {
data.badges.forEach(function (item) {
@ -149,7 +151,7 @@
$('#privmsg-box').css('display', 'block');
$('#privmsgs').css('display', 'block');
$.getJSON(
mkApiUrl('privmsgs'),
mkApiUrl('privmsgs') + "?lang=" + USER_LANGUAGE,
function (data) {
if (data.status === 'OK') {
$('#privmsgs').html("");