forked from shariq/thistle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (105 loc) · 4.94 KB
/
index.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html>
<head>
<title>Thistle</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8";>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script src='https://cdn.firebase.com/js/client/1.1.1/firebase.js'></script>
<style type="text/css"></style>
<style type="text/css">
body {
font-family: monospace;
font-size: 3pt;
}
</style>
</head>
<body>
<h1>
Thistle
</h1>
<div class= "table">
<ul>
<li>
</li>
</ul>
</div>
<script>
//Make jQueury debuggable or whatever
$( document ).ready(function() {
console.log( "ready!" );
//I need redo the redirect so that the member the url
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
};
//Ensure that they navigate to the correct website I do actually have a function for this
if (window.location == "http://thistle.io")
{
console.log()
debugger;
console.log()
window.location = "http://thistle.io/"+makeid();
}
//Ask for Username
var user=prompt("Enter your name");
/* this needs to be done in conjugction with
* adding a new user to the "room" */
//consider using prepend.to//
var newuser = new Firebase('https://thistle-io.firebaseio.com/'); //(find a way to add the elemnt into the on('child_added') for whatever reason I am getting an error)
newuser.on('child_added', function(snapshot){
debugger;
console.log('NEVER GOES IN HERE');
var snapshotvalue=snapshot.val();
$("<li class='slideshit'>"+a.shit+"</li>").prependTo("#");;
});
</script>
<div class="shitlist">
<ul id="table">
<li class="" style="display: list-item;">the name of this site</li>
</ul>
<script>myRootRef.endAt().limit(16).on('child_added', function(snapshot){
debugger;
var message = snapshot.name(), a = snapshot.val();
$("<li class='slideshit'>"+a.shit+"</li>").prependTo("#table");
$('.slideshit').hide();
$('.slideshit').slideDown();
$('.slideshit').removeClass('slideshit');
});
</script>
</div>
<script>
//If this person gave use some random URL then we want to create a key value to store in the database
var roomID = document.URL.split("/")[length(document.URL.split("/"))];
var newentry = new Firebase('https://thistle-io.firebaseio.com/'+roomID) //Do I need to create a entry further in or just stop at thistle.io/?//
var defaultmessage = newentry.push()
defaultmessage.set({'username':user, '0':'Welcome to this unnecessary console'});
// add terminal console to the added li
// Record the current time immediately, and queue an event to
// record the time at which the user disconnects.
var sessionsRef = new Firebase('https://samplechat.firebaseio-demo.com/sessions/');
var mySessionRef = sessionsRef.push();
mySessionRef.onDisconnect().update({ endedAt: Firebase.ServerValue.TIMESTAMP });
mySessionRef.update({ startedAt: Firebase.ServerValue.TIMESTAMP });
//have a latest and a list of their previous commands, so when they add a new push
// this will probably need a for each statment
datasnapshot.forEach(function(childSnapshot){
debugger;
var people = childSnapshot.name();
var peopledata = childSnapshot.val();
})
var numUsers = peopledata.length
for(var x = 0; x < numUsers; x=! user){
peopledata = chidSnapshot.val();
}
//Try to get the values or children of snapshot at the roomID specified path level
//I don't want to push these values into the database, since they should alreay be there, I want to display
//them alongside the terminal that I created for the specifc user that came onto the site
//However I need to exclude members that are the same as the cureent user to keep track of their other statements
//Each of those other statements needs to have its own list I shouldn't worry about the position of the list yet
});
</script>
</body>
</html>