forked from raghunandangupta1992/CollaborativeTextEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.html
59 lines (50 loc) · 1.87 KB
/
code.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
<!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 and its JavaScript mode file -->
<script src="codemirror/lib/codemirror.js"></script>
<script src="codemirror/mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="codemirror/lib/codemirror.css" />
<!-- Include Firepad -->
<script src="firepad.js"></script>
<link rel="stylesheet" href="firepad.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%; position: relative; }
/* Height / width / positioning can be customized for your use case.
For demo purposes, we make firepad fill the entire browser. */
.firepad {
position: absolute; left: 0; top: 0; bottom: 0; right: 0; height: auto;
}
</style>
</head>
<body>
<div id="firepad-container"></div>
<script>
//// Initialize Firebase.
var firepadRef = getExampleRef();
// TODO: Replace above line with:
// var ref = new Firebase('<YOUR FIREBASE URL>');
//// Create CodeMirror (with line numbers and the JavaScript mode).
var codeMirror = CodeMirror(document.getElementById('firepad-container'), {
lineNumbers: true,
mode: 'javascript'
});
//// Create Firepad.
var firepad = Firepad.fromCodeMirror(firepadRef, codeMirror);
//// Initialize contents.
firepad.on('ready', function() {
if (firepad.isHistoryEmpty()) {
firepad.setText('// JavaScript Editing with Firepad!\nfunction go() {\n var message = "Hello, world.";\n console.log(message);\n}');
}
});
</script>
</body>
</html>