Condense dialog code into one nice system

master
Skylar Ittner 8 years ago
parent 3e76b407e7
commit 382cf53cb2

@ -456,7 +456,7 @@ body {
.menumessage {
position: fixed;
z-index: 9999;
z-index: 99999;
background: rgba(0, 0, 0, .85);
border-radius: 10px;
left: 10%;
@ -481,6 +481,9 @@ body {
font-size: 120%;
text-align: center;
margin-bottom: 10px;
overflow-x: hidden;
overflow-y: auto;
word-wrap: break-word;
}
#shop-balance-bar {

@ -62,11 +62,26 @@
<script src="js/L.Control.Locate.min.js"></script>
<script src="js/leaflet.markercluster.js"></script>
<script src="js/music.js"></script>
<script src="js/dialogs.js"></script>
</head>
<body>
<div id="modal-load-box" class="container" style='z-index: 1000;'>
</div>
<div class="menumessage" id="alertmessagebox">
<div id="hugecheckmark" class="hugesymbol">
<i class="fa fa-5x fa-fw fa-check-circle" style="color: green;"></i>
</div>
<div id="hugetimessign" class="hugesymbol">
<i class="fa fa-5x fa-fw fa-times-circle" style="color: red;"></i>
</div>
<div class="menumessagecontent" id="alertmessagecontent">
</div>
<div class="btn btn-wide btn-default" onclick="dismissMessageBox();">
OK
</div>
</div>
<div class="container" id="content-zone" style='z-index: 1;'>
<div id="loading">

@ -21,6 +21,7 @@
*/
var authOpInProgress = false;
var logoutInProgress = false;
function askLogout() {
navigator.notification.confirm(
@ -36,6 +37,7 @@ function askLogout() {
}
function logout() {
logoutInProgress = true;
$.getJSON(mkApiUrl('deletesession'), {}, function (data) {
if (data.status === 'OK') {
localStorage.setItem("username", '');
@ -43,11 +45,14 @@ function logout() {
username = null;
password = null;
openscreen('login');
logoutInProgress = false;
} else {
logoutInProgress = false;
navigator.notification.alert("Server did not properly acknowledge logout. You might have problems for the next few hours if you switch accounts.", null, "Error", 'Dismiss');
}
}).fail(function () {
navigator.notification.alert("Cannot connect to authentication server. Check your Internet connection and try again. If that fails, clear the app data or reinstall TerranQuest.", null, "Error", 'Dismiss');
logoutInProgress = false;
navigator.notification.alert("Cannot connect to server. Check your Internet connection and try again. If that fails, clear the app data or reinstall TerranQuest.", null, "Error", 'Dismiss');
});
}

@ -0,0 +1,45 @@
/*
* TerranQuest - Augmented Reality fantasy game
*
* Copyright 2016 Netsyms Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function showSuccessMessage(text) {
$('#hugetimessign').css('display', 'none');
$('#hugecheckmark').css('display', 'block');
$('#alertmessagecontent').html(text);
$('#alertmessagebox').css('display', 'block');
}
function showErrorMessage(text) {
$('#hugetimessign').css('display', 'block');
$('#hugecheckmark').css('display', 'none');
$('#alertmessagecontent').html(text);
$('#alertmessagebox').css('display', 'block');
}
function dismissMessageBox() {
$('#alertmessagebox').css('display', 'none');
}
function serverProblemsDialog(errmsg) {
StatusBar.backgroundColorByHexString("#324150");
window.location = "servererror.html?errmsg=" + errmsg;
}
function clientProblemsDialog(errmsg) {
StatusBar.backgroundColorByHexString("#324150");
window.location = "clienterror.html?errmsg=" + errmsg;
}

@ -197,7 +197,7 @@ var updatePosition = function (position) {
function pingServer() {
if (lockGot && gpsaccuracy < requiredaccuracy) {
$.getJSON(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude, function (data) {
if (data.status == "ERROR") {
if (data.status == "ERROR" && logoutInProgress != true) {
localStorage.setItem("no_autologin", "true");
username = null;
password = null;

@ -119,17 +119,6 @@ function compareVersions(a, b) {
return segmentsA.length - segmentsB.length;
}
function serverProblemsDialog(errmsg) {
StatusBar.backgroundColorByHexString("#324150");
window.location = "servererror.html?errmsg=" + errmsg;
}
function clientProblemsDialog(errmsg) {
StatusBar.backgroundColorByHexString("#324150");
window.location = "clienterror.html?errmsg=" + errmsg;
}
function mkApiUrl(action, server) {
if (server === 'cs') {
var chatserverurl = "http://gs.terranquest.net/";
@ -512,6 +501,22 @@ var Konami = function (callback) {
return konami;
};
var konamicounter = 0;
var dev_console = new Konami(function () {
alert(eval(prompt("Enter console command: ", "$(\"#\")")));
});
konamicounter++;
if (konamicounter > 2) {
alert(eval(prompt("Enter console command: ", "$(\"#\")")));
}
});
/**
* Cancel all timeouts and intervals that may or may not exist.
*
* http://stackoverflow.com/a/8345814/2534036
*/
function forceCancelAllTimers() {
var highestTimeoutId = setTimeout(";");
for (var i = 0; i < highestTimeoutId; i++) {
clearTimeout(i);
}
}

@ -30,19 +30,19 @@ function buycoins(productId) {
if (result.status == 'OK') {
return inAppPurchase.consume(data.type, data.receipt, data.signature);
} else {
showShopMessage("Error: " + result.message, true);
showErrorMessage("Error: " + result.message);
}
}).fail(function () {
showShopMessage("Error: Lost connection to TerranQuest servers. If your purchase does not appear within a few hours, contact support@netsyms.com.", true);
showErrorMessage("Error: Lost connection to TerranQuest servers. If your purchase does not appear within a few hours, contact support@netsyms.com.");
});
})
.then(function () {
showShopMessage("Thanks for your purchase!", false);
showSuccessMessage("Thanks for your purchase!");
refreshcoins();
})
.catch(function (err) {
console.log("Error: " + err.message);
showShopMessage("Error: " + err.message, true);
showErrorMessage("Error: " + err.message);
});
} else if (getPlatform() == DEVICE_IOS) {
inAppPurchase
@ -58,37 +58,25 @@ function buycoins(productId) {
if (result.status == 'OK') {
return inAppPurchase.consume(data.type, data.receipt, data.signature);
} else {
showShopMessage("Error: " + result.message, true);
showErrorMessage("Error: " + result.message);
}
}).fail(function () {
showShopMessage("Error: Lost connection to TerranQuest servers. If your purchase does not appear within a few hours, contact support@netsyms.com.", true);
showErrorMessage("Error: Lost connection to TerranQuest servers. If your purchase does not appear within a few hours, contact support@netsyms.com.");
});
})
.then(function () {
showShopMessage("Thanks for your purchase!", false);
showSuccessMessage("Thanks for your purchase!");
refreshcoins();
})
.catch(function (err) {
console.log("Error: " + err.message);
showShopMessage("Error: " + err.message, true);
showErrorMessage("Error: " + err.message);
});
} else {
showShopMessage("Store not available on your device. Please go to terranquest.net to purchase coins.", true);
showErrorMessage("Store not available on your device. Please go to terranquest.net to purchase coins.");
}
}
function showShopMessage(msg, iserror) {
if (iserror) {
$('#hugetimessign').css('display', 'block');
$('#hugecheckmark').css('display', 'none');
} else {
$('#hugetimessign').css('display', 'none');
$('#hugecheckmark').css('display', 'block');
}
$('#shopmessagecontent').text(msg);
$('#shopmessage').css('display', 'block');
}
function buyitem(id, cost) {
$('#shopitem-' + id).prop('onclick', null).off('click');
$.getJSON(mkApiUrl('buyitem', 'gs'), {
@ -96,9 +84,9 @@ function buyitem(id, cost) {
cost: cost
}, function (data) {
if (data.status == 'OK') {
showShopMessage(data.message, false);
showSuccessMessage(data.message);
} else {
showShopMessage(data.message, true);
showErrorMessage(data.message);
}
loadstorefront();
});

@ -23,21 +23,6 @@
</div>
</div>
<div class="menumessage" id="invmessage">
<div id="hugecheckmark" class="hugesymbol">
<i class="fa fa-5x fa-fw fa-check-circle" style="color: green;"></i>
</div>
<div id="hugetimessign" class="hugesymbol">
<i class="fa fa-5x fa-fw fa-times-circle" style="color: red;"></i>
</div>
<div class="menumessagecontent" id="invmessagecontent">
</div>
<div class="btn btn-wide btn-default" onclick="$('#invmessage').css('display', 'none')">
OK
</div>
</div>
<div class="menumessage" id="giveitemmessage">
<div class="menumessagecontent" id="giveitemmessagecontent">
Give one <span id="giveitemname">item</span> to: <br />
@ -53,18 +38,6 @@
</div>
<script>
function showInvMessage(msg, iserror) {
if (iserror) {
$('#invmessage #hugetimessign').css('display', 'block');
$('#invmessage #hugecheckmark').css('display', 'none');
} else {
$('#invmessage #hugetimessign').css('display', 'none');
$('#invmessage #hugecheckmark').css('display', 'block');
}
$('#invmessagecontent').text(msg);
$('#invmessage').css('display', 'block');
}
function askgiveitem(uuid) {
$('#invitem-' + uuid).prop('onclick', null).off('click');
$('#giveitem-uuid').text(uuid);
@ -87,7 +60,7 @@
content = "";
}
if (content == '') {
showInvMessage("There is nobody nearby to give an item to.", true);
showErrorMessage("There is nobody nearby to give an item to.");
} else {
$('#nearby-players-dropdown').html(content);
$('#giveitemmessage').css('display', 'block');
@ -107,12 +80,12 @@
if (data.status === 'OK') {
loadinventory();
syncStats();
showInvMessage("Transferred!", false);
showSuccessMessage("Transferred!");
} else {
showInvMessage(data.message, true);
showErrorMessage(data.message);
}
}).fail(function () {
showInvMessage("Cannot give item. Try again.", true);
showErrorMessage("Cannot give item. Try again.");
});
}
@ -125,10 +98,10 @@
loadinventory();
syncStats();
} else {
showInvMessage(data.message, true);
showErrorMessage(data.message);
}
}).fail(function () {
showInvMessage(data.message, true);
showErrorMessage("Something went wrong. Try again.");
});
}