Add custom server options on login screen (Issue #3)
This commit is contained in:
parent
257bff052d
commit
c3e8553df5
@ -89,8 +89,19 @@ function clientProblemsDialog(errmsg) {
|
||||
}
|
||||
|
||||
function mkApiUrl(action, server) {
|
||||
server = "gs";
|
||||
return "http://" + server + ".terranquest.net/" + action + ".php";
|
||||
if (server === 'cs') {
|
||||
var chatserverurl = "http://gs.terranquest.net/";
|
||||
if (localStorage.getItem("chatserv") !== null && localStorage.getItem("chatserv") !== '') {
|
||||
chatserverurl = localStorage.getItem("chatserv");
|
||||
}
|
||||
return chatserverurl + action + ".php";
|
||||
} else {
|
||||
var gameserverurl = "http://gs.terranquest.net/";
|
||||
if (localStorage.getItem("gameserv") !== null && localStorage.getItem("gameserv") !== '') {
|
||||
gameserverurl = localStorage.getItem("gameserv");
|
||||
}
|
||||
return gameserverurl + action + ".php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@
|
||||
* Syncs the user's stats with the server and calls refreshStats().
|
||||
*/
|
||||
function syncStats() {
|
||||
$.getJSON(mkApiUrl('getstats', 'gs'), {
|
||||
$.getJSON(mkApiUrl('getstats'), {
|
||||
user: username
|
||||
}, function (data) {
|
||||
if (data.status === 'OK') {
|
||||
@ -51,9 +51,10 @@ function refreshStats() {
|
||||
|
||||
function getChat() {
|
||||
if (lockGot) {
|
||||
$.getJSON(mkApiUrl('chat'), {
|
||||
$.getJSON(mkApiUrl('chat', 'cs'), {
|
||||
lat: latitude,
|
||||
long: longitude
|
||||
long: longitude,
|
||||
name: username
|
||||
}, function (data) {
|
||||
data = sortResults(data, 'time', true);
|
||||
var content = "";
|
||||
@ -81,10 +82,11 @@ setInterval(function () {
|
||||
$("#chatsendform").submit(function (event) {
|
||||
var message = $('#chatbox-input').val();
|
||||
if (message !== '') {
|
||||
$.post(mkApiUrl('chat'), {
|
||||
$.post(mkApiUrl('chat', 'cs'), {
|
||||
lat: latitude,
|
||||
long: longitude,
|
||||
msg: message
|
||||
msg: message,
|
||||
name: username
|
||||
}, function (data) {
|
||||
if (data.status === 'OK') {
|
||||
$('#chatbox-input').val("");
|
||||
|
@ -27,11 +27,42 @@
|
||||
<div style="background: url(assets/mountains-simple.svg) repeat-x; background-size: auto 100%; height: 20%; position: absolute; bottom: 0; width: 100%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="server-options-modal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="server-options-box-header">Server Options</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
You can connect to third-party game servers here.
|
||||
Enter the URLs for the servers.
|
||||
Leave a box empty to connect to the official servers.
|
||||
<br /><br />
|
||||
<i class="fa fa-warning"></i> Warning: Third-party servers can
|
||||
see (and track) your location and other personal information
|
||||
sent by TerranQuest.
|
||||
<br /><br />
|
||||
<b>Custom game server:</b>
|
||||
<input type="text" class="form-control" placeholder="http://gs.terranquest.net/" id="gameserver-url-box" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
||||
<br />
|
||||
<b>Custom chat server:</b>
|
||||
<input type="text" class="form-control" placeholder="http://gs.terranquest.net/" id="chatserver-url-box" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" data-dismiss="modal" class="btn btn-default"><i class="fa fa-times"></i> Cancel</button>
|
||||
<button type="button" onclick="setCustomServers()" data-dismiss="modal" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading whitetext" id="loginheader" style="color: white;" data-localize="login-header">
|
||||
Login to TerranQuest
|
||||
<div class="panel-heading whitetext clearfix" id="loginheader" style="color: white;" data-localize="login-header">
|
||||
Login to TerranQuest <span class="pull-right" data-toggle="modal" data-target="#server-options-modal"><i class="fa fa-gear"></i></span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="errorbase" class="alert alert-danger alert-dismissable" style="display: none;">
|
||||
@ -57,6 +88,14 @@
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$('#gameserver-url-box').val(localStorage.getItem("gameserv"));
|
||||
$('#chatserver-url-box').val(localStorage.getItem("chatserv"));
|
||||
|
||||
function setCustomServers() {
|
||||
localStorage.setItem("gameserv", $('#gameserver-url-box').val());
|
||||
localStorage.setItem("chatserv", $('#chatserver-url-box').val());
|
||||
}
|
||||
|
||||
$("[data-localize]").localize("login-screen", i18n_options);
|
||||
|
||||
$('.splash-version').text("v" + window.cordova.plugins.version.getAppVersion());
|
||||
|
Reference in New Issue
Block a user