-
Notifications
You must be signed in to change notification settings - Fork 0
/
Testing.html
82 lines (68 loc) · 2.11 KB
/
Testing.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<!-- This site was created in Webflow. http://www.webflow.com-->
<!-- Last Published: Wed Jun 03 2015 03:21:30 GMT+0000 (UTC) -->
<html data-wf-site="54f9268573ee3d0b05795f70" data-wf-page="556e6d321e21f90a486f6628">
<head>
<script src="https://cdn.firebase.com/js/client/2.2.6/firebase.js"></script>
</head>
<body>
<script type="text/javascript">
var ref = new Firebase("https://goconverse.firebaseio.com/users");
// Counts the total number of registered users
/*
function usersCount()
{
ref.once("value", function(snapshot)
{
var simpleIdTicker = 61;
var simpleIdTotal = 0;
// console.log(snapshot.val());
// console.log(snapshot.child("simplelogin:" + simpleIdTicker).child("country").val());
while (snapshot.child("simplelogin:" + simpleIdTicker).child("country").val() != null)
{
simpleIdTicker++;
simpleIdTotal++;
}
console.log("The last user element is simplelogin:" + simpleIdTicker);
console.log("There are " + simpleIdTotal + " users registered.");
},
function (errorObject)
{
console.log("The read failed: " + errorObject.code);
});
}
*/
</script>
<script type="text/javascript">
// Filters out same-country users and sorts by number of conversations
var usersRef = new Firebase("https://goconverse.firebaseio.com/users");
var usersList = [];
usersRef.once("value", function(snapshot)
{
var simpleIdTicker = 61;
while (simpleIdTicker < 100)
{
if (snapshot.child("simplelogin:" + simpleIdTicker).child("country").val() == "USA" && snapshot.child("simplelogin:" + simpleIdTicker).child("country").val() != null)
{
// console.log(snapshot.child("simplelogin:" + simpleIdTicker).val());
usersList.push(snapshot.child("simplelogin:" + simpleIdTicker).val());
simpleIdTicker++;
}
else
{
simpleIdTicker++;
}
}
var sortedUserList = usersList.sort(function(a, b)
{
return a.conversationsCount - b.conversationsCount;
});
var userTwoId = sortedUserList[0].userid;
console.log(userTwoId);
},
function (errorObject)
{
console.log("The read failed: " + errorObject.code);
});
</script>
</body>