-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirepad.html
More file actions
180 lines (168 loc) · 6.11 KB
/
firepad.html
File metadata and controls
180 lines (168 loc) · 6.11 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!doctype html>
<!-- See http://www.firepad.io/docs/ for detailed embedding docs. -->
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta charset="utf-8" />
<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>
<!--BootStrap-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- CodeMirror -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.17.0/codemirror.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.17.0/codemirror.css" />
<!-- Firepad -->
<link rel="stylesheet" href="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.css" />
<script src="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.min.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-container {
width: 100%;
height: 100%;
background-color: #DDDDDD;
}
.navbar {
padding-top: 15px;
padding-bottom: 15px;
border: 0;
border-radius: 0;
margin-bottom: 0;
font-size: 12px;
letter-spacing: 5px;
}
.navbar-nav li a:hover {
color: #1abc9c !important;
}
</style>
</head>
<body onload="init()">
<!-- Navbar -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">AGGIE|ROBOTICS</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="#what">WHAT</a></li>
<li><a href="#events">EVENTS</a></li>
<li><a href="#who">WHO</a></li>
<li><a href="#about">WHY</a></li>
<li><a href="#where">WHERE</a></li>
</ul>
</div>
</div>
</nav>
<div id="firepad-container"></div>
<script>
function init() {
//// Initialize Firebase.
//// TODO: replace with your Firebase project configuration.
////ADD DETAILS 6/18/17
var config = {
apiKey: "AIzaSyDFilEzgiwSWBA5kW0TqgBqcdQKIfar2TM",
databaseURL: 'https://aggierobotics-10746.firebaseio.com'
};
firebase.initializeApp(config);
//// Get Firebase Database reference.
var firepadRef = getExampleRef();
//// Create CodeMirror (with lineWrapping on).
var codeMirror = CodeMirror(document.getElementById('firepad-container'), { lineWrapping: true });
//// Create Firepad (with rich text toolbar and shortcuts enabled).
var firepad = Firepad.fromCodeMirror(firepadRef, codeMirror,
{ richTextToolbar: true, richTextShortcuts: true });
//// Initialize contents.
firepad.on('ready', function() {
if (firepad.isHistoryEmpty()) {
firepad.setHtml(
'<span style="font-size: 24px;">Rich-text editing with <span style="color: red">Firepad!</span></span><br/>\n' +
'<br/>' +
'<div style="font-size: 18px">' +
'Supports:<br/>' +
'<ul>' +
'<li>Different ' +
'<span style="font-family: impact">fonts,</span>' +
'<span style="font-size: 24px;"> sizes, </span>' +
'<span style="color: blue">and colors.</span>' +
'</li>' +
'<li>' +
'<b>Bold, </b>' +
'<i>italic, </i>' +
'<u>and underline.</u>' +
'</li>' +
'<li>Lists' +
'<ol>' +
'<li>One</li>' +
'<li>Two</li>' +
'</ol>' +
'</li>' +
'<li>Undo / redo</li>' +
'<li>Cursor / selection synchronization.</li>' +
'<li><checkbox></checkbox> It supports customized entities.</li>' +
'<li>And it\'s all fully collaborative!</li>' +
'</ul>' +
'</div>');
}
});
// An example of a complex custom entity.
firepad.registerEntity('checkbox', {
render: function (info, entityHandler) {
var inputElement = document.createElement('input');
inputElement.setAttribute('type', 'checkbox');
if(info.checked) {
inputElement.checked = 'checked';
}
inputElement.addEventListener('click', function () {
entityHandler.replace({checked:this.checked});
});
return inputElement;
}.bind(this),
fromElement: function (element) {
var info = {};
if(element.hasAttribute('checked')) {
info.checked = true;
}
return info;
},
update: function (info, element) {
if (info.checked) {
element.checked = 'checked';
} else {
element.checked = null;
}
},
export: function (info) {
var inputElement = document.createElement('checkbox');
if(info.checked) {
inputElement.setAttribute('checked', true);
}
return inputElement;
}
});
}
// Helper to get hash from end of URL or generate a random one.
function getExampleRef() {
var ref = firebase.database().ref().child('firepad');
var hash = window.location.hash.replace(/#/g, '');
if (hash) {
ref = ref.child(hash);
} else {
ref = ref.push(); // generate unique location.
window.location = window.location + '#' + ref.key; // add it as a hash to the URL.
}
if (typeof console !== 'undefined') {
console.log('Firebase data: ', ref.toString());
}
return ref;
}
</script>
</body>
</html>