mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 12:20:00 +02:00
polling users and displaying user count
This commit is contained in:
parent
b5b781f4a5
commit
0a3a0e817e
1 changed files with 20 additions and 3 deletions
|
@ -103,6 +103,7 @@
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var METAVERSE_API_URL = "https://metaverse.highfidelity.com/api/v1/users?status=online";
|
var METAVERSE_API_URL = "https://metaverse.highfidelity.com/api/v1/users?status=online";
|
||||||
|
var FRIENDS_FILTER = "&filter=friends";
|
||||||
var myUsername = null;
|
var myUsername = null;
|
||||||
|
|
||||||
function displayUsers(data) {
|
function displayUsers(data) {
|
||||||
|
@ -123,15 +124,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processData(data, type) {
|
||||||
|
var num = data.users.length;
|
||||||
|
if (type === "everyone") {
|
||||||
|
$(".tabs li:nth-child(1)").text("Everyone (" + num + ")");
|
||||||
|
} else if (type === "friends") {
|
||||||
|
$(".tabs li:nth-child(2)").text("Friends (" + num + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function pollUsers() {
|
function pollUsers() {
|
||||||
// TODO: better transition visual such as spin wheel or loading bar
|
|
||||||
$("#dev-div").append("<p>polling users..</p>");
|
$("#dev-div").append("<p>polling users..</p>");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: METAVERSE_API_URL,
|
url: METAVERSE_API_URL,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
$("#dev-div").append("<p>polling sucess</p>");
|
$("#dev-div").append("<p>polling everyone sucess</p>");
|
||||||
displayUsers(response.data);
|
processData(response.data, "everyone");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: METAVERSE_API_URL + FRIENDS_FILTER,
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
$("#dev-div").append("<p>polling friends sucess</p>");
|
||||||
|
processData(response.data, "friends");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue