-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserlist.html
73 lines (60 loc) · 2.4 KB
/
userlist.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
<!doctype html>
<!-- See http://www.firepad.io/docs/ for detailed embedding docs. -->
<html>
<head>
<meta charset="utf-8" />
<!-- Include Firebase -->
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<!-- Include CodeMirror -->
<script src="codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="codemirror/lib/codemirror.css" />
<!-- Include Firepad -->
<script src="firepad.js"></script>
<link rel="stylesheet" href="firepad.css" />
<!-- Include example userlist. -->
<script src="firepad-userlist.js"></script>
<link rel="stylesheet" href="firepad-userlist.css" />
<!-- Helper for generating URLs / Firebase references for example purposes.
Not necessary in production apps. -->
<script src="example-helper.js"></script>
<style>
html { height: 100%; }
body { margin: 0; height: 100%; }
/* Height / width / positioning can be customized for your use case.
For demo purposes, we make the user list 175px and firepad fill the rest of the page. */
.firepad-userlist {
position: absolute; left: 0; top: 0; bottom: 0; height: auto;
width: 175px;
}
.firepad {
position: absolute; left: 175px; top: 0; bottom: 0; right: 0; height: auto;
}
</style>
</head>
<body>
<div id="userlist"></div>
<div id="firepad"></div>
<script>
//// Initialize Firebase.
var firepadRef = getExampleRef();
// TODO: Replace above line with:
// var firepadRef = new Firebase('<YOUR FIREBASE URL>');
//// Create CodeMirror (with lineWrapping on).
var codeMirror = CodeMirror(document.getElementById('firepad'), { lineWrapping: true });
// Create a random ID to use as our user ID (we must give this to firepad and FirepadUserList).
var userId = Math.floor(Math.random() * 9999999999).toString();
//// Create Firepad (with rich text features and our desired userId).
var firepad = Firepad.fromCodeMirror(firepadRef, codeMirror,
{ richTextToolbar: true, richTextShortcuts: true, userId: userId});
//// Create FirepadUserList (with our desired userId).
var firepadUserList = FirepadUserList.fromDiv(firepadRef.child('users'),
document.getElementById('userlist'), userId);
//// Initialize contents.
firepad.on('ready', function() {
if (firepad.isHistoryEmpty()) {
firepad.setText('Check out the user list to the left!');
}
});
</script>
</body>
</html>