Add nearby players list
parent
466951bca5
commit
9ea0f050df
@ -0,0 +1,60 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<div class="scrollable-box">
|
||||
<h4>Players</h4>
|
||||
<div class="list-group" id="nearby-people-list">
|
||||
<div class="list-group-item">
|
||||
<i class="fa fa-spinner fa-pulse fa-fw"></i> Loading...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function getpeoplehtmlfromjson(person) {
|
||||
var peoplehtml = "<div class='list-group-item nearby-item' id='nearby-person-" + person.uuid + "'>"
|
||||
+ "<h4 class='nearbyname'>" + person.name + "</h4>"
|
||||
+ "<p class='nearbyteam' style='color: #" + getTeamColorFromId(person.team) + ";'>" + getTeamNameFromId(person.team) + "</p>"
|
||||
+ "</div>";
|
||||
return peoplehtml;
|
||||
}
|
||||
|
||||
function loadnearby() {
|
||||
$.getJSON(mkApiUrl('nearby'), {
|
||||
lat: latitude,
|
||||
long: longitude
|
||||
}, function (data) {
|
||||
var content = "";
|
||||
if (data.status === 'OK') {
|
||||
var people = data.people;
|
||||
people.forEach(function (person) {
|
||||
if (person.name !== username) {
|
||||
content += getpeoplehtmlfromjson(person);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
content = "<div class='list-group-item'>An error occurred.</div>";
|
||||
}
|
||||
if (content == '') {
|
||||
content = "<div class='list-group-item'>There's nobody else here...</div>";
|
||||
}
|
||||
$('#nearby-people-list').html(content);
|
||||
});
|
||||
}
|
||||
|
||||
loadnearby();
|
||||
</script>
|
Reference in New Issue