Display owner name in place info

master
Skylar Ittner 8 years ago
parent dec08dbef4
commit 68caf33c45

@ -15,175 +15,184 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<div class="scrollable-box"> <div class="scrollable-box">
<div class="h4" id="place-name"></div> <div class="h4" id="place-name"></div>
<div id="place-info-div"> <div id="place-info-div">
Type: <span id="team-label"></span><br /> Type: <span id="team-label"></span><br />
<!-- Life: <span id="life-label"></span><br /> --> Owner: <span id="owner-label"></span><br />
Place life: <div class="progress" id="place-health-place"><div id="place-health-place-bar" class="progress-bar" role="progressbar" ></div></div> <!-- Life: <span id="life-label"></span><br /> -->
<div class="btn btn-success btn-wide" id="capturebtn" onclick="attempttake()"></div> Place life: <div class="progress" id="place-health-place"><div id="place-health-place-bar" class="progress-bar" role="progressbar" ></div></div>
My life: <div class="progress" id="user-health-place"><div id="user-health-place-bar" class="progress-bar" role="progressbar" ></div></div> <div class="btn btn-success btn-wide" id="capturebtn" onclick="attempttake()"></div>
</div> My life: <div class="progress" id="user-health-place"><div id="user-health-place-bar" class="progress-bar" role="progressbar" ></div></div>
<div class="well well-sm place-log" id="place-log"> </div>
<div class="well well-sm place-log" id="place-log">
</div>
</div> </div>
</div>
<script>
var thisplace = null; <script>
var placeteam = 0; var thisplace = null;
var capturebtndisabled = false; var placeteam = 0;
var capturebtndisabled = false;
function resetcapturebtn() {
capturebtndisabled = false; function resetcapturebtn() {
$('#capturebtn').removeClass('btn-warning'); capturebtndisabled = false;
$('#capturebtn').addClass('btn-primary'); $('#capturebtn').removeClass('btn-warning');
$('#capturebtn').removeClass('disabled'); $('#capturebtn').addClass('btn-primary');
if (placeteam == 0) { $('#capturebtn').removeClass('disabled');
$('#capturebtn').text("Claim"); if (placeteam == 0) {
} else if (placeteam == userteamid) { $('#capturebtn').text("Claim");
$('#capturebtn').css('visibility', 'hidden'); } else if (placeteam == userteamid) {
} else { $('#capturebtn').css('visibility', 'hidden');
$('#capturebtn').text("Challenge"); } else {
} $('#capturebtn').text("Challenge");
$('#capturebtn').prop('disabled', false); }
} $('#capturebtn').prop('disabled', false);
}
function resyncstats() {
$.getJSON(mkApiUrl('getstats', 'gs'), { function resyncstats() {
user: username $.getJSON(mkApiUrl('getstats', 'gs'), {
}, function (data) { user: username
if (data.status === 'OK') { }, function (data) {
maxenergy = data.stats.maxenergy; if (data.status === 'OK') {
energy = data.stats.energy; maxenergy = data.stats.maxenergy;
level = data.stats.level; energy = data.stats.energy;
energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0; level = data.stats.level;
$('#user-health-place-bar').css('width', String(energypercent) + '%'); energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
refreshStats(); $('#user-health-place-bar').css('width', String(energypercent) + '%');
} refreshStats();
}); }
$.getJSON(mkApiUrl('placestats', 'gs'), { });
locationid: thisplace.properties.gameinfo.locationid $.getJSON(mkApiUrl('placestats', 'gs'), {
}, function (data) { locationid: thisplace.properties.gameinfo.locationid
if (data.status === 'OK') { }, function (data) {
placeteam = data.stats.teamid; if (data.status === 'OK') {
var placepercent; placeteam = data.stats.teamid;
if (data.stats.currentlife > 0) { var placepercent;
placepercent = (Math.round(data.stats.currentlife) * 1.0 / Math.round(data.stats.maxlife) * 1.0) * 100.0; if (data.stats.currentlife > 0) {
} else { placepercent = (Math.round(data.stats.currentlife) * 1.0 / Math.round(data.stats.maxlife) * 1.0) * 100.0;
placepercent = 0; } else {
} placepercent = 0;
$('#place-health-place-bar').css('width', String(placepercent) + '%'); }
loadTeamSwag(); if (data.stats.nickname == null) {
} else { $('#owner-label').text("Nobody");
// } else {
} $('#owner-label').on('click', function() {
}).fail(function () { openProfile(data.stats.nickname);
}); });
} $('#owner-label').text(data.stats.nickname);
}
function resetafteraction() { $('#place-health-place-bar').css('width', String(placepercent) + '%');
resyncstats(); loadTeamSwag();
setTimeout(resetcapturebtn, 2 * 1000); } else {
} //
}
function loadTeamSwag() { }).fail(function () {
$("#place-name").css("border-color", "#" + getTeamColorFromId(placeteam)); });
$("#place-info-div").css("border-color", "#" + getTeamColorFromId(placeteam)); }
$("#place-log").css("border-color", "#" + getTeamColorFromId(placeteam));
if (placeteam == 0) { function resetafteraction() {
$("#capturebtn").css("background-color", "#" + getTeamColorFromId(userteamid)); resyncstats();
} else { setTimeout(resetcapturebtn, 2 * 1000);
$("#capturebtn").css("background-color", "#" + getTeamColorFromId(placeteam)); }
}
$("#place-health-place-bar").css("background-color", "#" + getTeamColorFromId(placeteam)); function loadTeamSwag() {
$("#team-label").css("color", "#" + getTeamColorFromId(placeteam)); $("#place-name").css("border-color", "#" + getTeamColorFromId(placeteam));
$("#team-label").text(getTeamNameFromId(placeteam)); $("#place-info-div").css("border-color", "#" + getTeamColorFromId(placeteam));
} $("#place-log").css("border-color", "#" + getTeamColorFromId(placeteam));
if (placeteam == 0) {
function loadPlace(feature) { $("#capturebtn").css("background-color", "#" + getTeamColorFromId(userteamid));
thisplace = feature; } else {
placeteam = feature.properties.gameinfo.teamid; $("#capturebtn").css("background-color", "#" + getTeamColorFromId(placeteam));
loadTeamSwag(); }
$("#place-name").text(feature.properties.name); $("#place-health-place-bar").css("background-color", "#" + getTeamColorFromId(placeteam));
$("#life-label").text(Math.round(feature.properties.gameinfo.currentlife) + " / " + Math.round(feature.properties.gameinfo.maxlife)); $("#team-label").css("color", "#" + getTeamColorFromId(placeteam));
resetcapturebtn(); $("#team-label").text(getTeamNameFromId(placeteam));
resyncstats(); }
}
function loadPlace(feature) {
function attemptcapture() { thisplace = feature;
capturebtndisabled = true; placeteam = feature.properties.gameinfo.teamid;
$('#capturebtn').prop('disabled', true); loadTeamSwag();
$('#capturebtn').addClass('disabled'); $("#place-name").text(feature.properties.name);
$.getJSON(mkApiUrl('attackplace', 'gs'), { $("#life-label").text(Math.round(feature.properties.gameinfo.currentlife) + " / " + Math.round(feature.properties.gameinfo.maxlife));
locationid: thisplace.properties.gameinfo.locationid resetcapturebtn();
}, function (data) { resyncstats();
if (data.status === 'OK') { }
$('#capturebtn').text(data.message);
switch (Math.round(Math.random() * (3 - 1) + 1)) { function attemptcapture() {
case 1: capturebtndisabled = true;
$('#place-log').prepend("Attacking...<br />"); $('#capturebtn').prop('disabled', true);
break; $('#capturebtn').addClass('disabled');
case 2: $.getJSON(mkApiUrl('attackplace', 'gs'), {
$('#place-log').prepend("Attacking..<br />"); locationid: thisplace.properties.gameinfo.locationid
break; }, function (data) {
case 3: if (data.status === 'OK') {
$('#place-log').prepend("Attacking....<br />"); $('#capturebtn').text(data.message);
} switch (Math.round(Math.random() * (3 - 1) + 1)) {
resetafteraction(); case 1:
} else { $('#place-log').prepend("Attacking...<br />");
$('#capturebtn').text(data.message); break;
$('#capturebtn').removeClass('btn-primary'); case 2:
$('#capturebtn').addClass('btn-warning'); $('#place-log').prepend("Attacking..<br />");
$('#place-log').prepend(data.message + "<br />"); break;
resetafteraction(); case 3:
} $('#place-log').prepend("Attacking....<br />");
//alert(data.message); }
}).fail(function () { resetafteraction();
$('#capturebtn').text("Try that again."); } else {
$('#capturebtn').removeClass('btn-primary'); $('#capturebtn').text(data.message);
$('#capturebtn').addClass('btn-warning'); $('#capturebtn').removeClass('btn-primary');
resetafteraction(); $('#capturebtn').addClass('btn-warning');
}); $('#place-log').prepend(data.message + "<br />");
} resetafteraction();
}
function attemptclaim() { //alert(data.message);
capturebtndisabled = true; }).fail(function () {
$('#capturebtn').prop('disabled', true); $('#capturebtn').text("Try that again.");
$('#capturebtn').addClass('disabled'); $('#capturebtn').removeClass('btn-primary');
$.getJSON(mkApiUrl('claimplace', 'gs'), { $('#capturebtn').addClass('btn-warning');
locationid: thisplace.properties.gameinfo.locationid resetafteraction();
}, function (data) { });
if (data.status === 'OK') { }
$('#capturebtn').text(data.message);
$('#place-log').prepend("Claimed!<br />"); function attemptclaim() {
resetafteraction(); capturebtndisabled = true;
} else { $('#capturebtn').prop('disabled', true);
$('#capturebtn').text(data.message); $('#capturebtn').addClass('disabled');
$('#capturebtn').removeClass('btn-primary'); $.getJSON(mkApiUrl('claimplace', 'gs'), {
$('#capturebtn').addClass('btn-warning'); locationid: thisplace.properties.gameinfo.locationid
$('#place-log').prepend(data.message + "<br />"); }, function (data) {
resetafteraction(); if (data.status === 'OK') {
} $('#capturebtn').text(data.message);
//alert(data.message); $('#place-log').prepend("Claimed!<br />");
}).fail(function () { resetafteraction();
$('#capturebtn').text("Try that again."); } else {
$('#capturebtn').removeClass('btn-primary'); $('#capturebtn').text(data.message);
$('#capturebtn').addClass('btn-warning'); $('#capturebtn').removeClass('btn-primary');
}); $('#capturebtn').addClass('btn-warning');
} $('#place-log').prepend(data.message + "<br />");
resetafteraction();
function attempttake() { }
if (capturebtndisabled) { //alert(data.message);
return; }).fail(function () {
} $('#capturebtn').text("Try that again.");
if (placeteam == 0) { $('#capturebtn').removeClass('btn-primary');
attemptclaim(); $('#capturebtn').addClass('btn-warning');
} else if (placeteam == userteamid) { });
}
} else {
attemptcapture(); function attempttake() {
} if (capturebtndisabled) {
} return;
}
if (placeteam == 0) {
attemptclaim();
} else if (placeteam == userteamid) {
} else {
attemptcapture();
}
}
</script> </script>