scratch – Diff between revs 96 and 100

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 96 Rev 100
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html lang="en"> 2 <html lang="en">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> 6 <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
7 <meta http-equiv="Pragma" content="no-cache" /> 7 <meta http-equiv="Pragma" content="no-cache" />
8 <meta http-equiv="Expires" content="0" /> 8 <meta http-equiv="Expires" content="0" />
9 <meta name="viewport" content="width=device-width, initial-scale=1"> 9 <meta name="viewport" content="width=device-width, initial-scale=1">
10 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 10 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
11 <meta name="description" content="quick asset upload"> 11 <meta name="description" content="quick asset upload">
12 <meta name="author" content="Wizardry and Steamworks"> 12 <meta name="author" content="Wizardry and Steamworks">
13 <link rel="icon" href="favicon.ico"> 13 <link rel="icon" href="favicon.ico">
14   14  
15 <title>scratch</title> 15 <title>scratch</title>
16   16  
17 <!-- Bootstrap core CSS --> 17 <!-- Bootstrap core CSS -->
18 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 18 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
19 <!-- Font Awesome --> 19 <!-- Font Awesome -->
20 <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> 20 <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
21 <!-- Trumbowyg --> 21 <!-- Trumbowyg -->
22 <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet"> 22 <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet">
23   23  
24 <!-- Site-wide style CCS --> 24 <!-- Site-wide style CCS -->
25 <link href="css/style.css" rel="stylesheet"> 25 <link href="css/style.css" rel="stylesheet">
26 26
27 <!-- Local style --> 27 <!-- Local style -->
28 <link href="css/text/style.css" rel="stylesheet"> 28 <link href="css/text/style.css" rel="stylesheet">
29 </head> 29 </head>
30   30  
31 <body> 31 <body>
32   32  
33 <!-- Main component for a primary marketing message or call to action --> 33 <!-- Main component for a primary marketing message or call to action -->
34 <div class="paralax-background"></div> 34 <div class="paralax-background"></div>
35 <div class="jumbotron"> 35 <div class="jumbotron">
36 <h1>scratch copy</h1> 36 <h1>scratch copy</h1>
37 <p class="quote">the asset sharer</p> 37 <p class="quote">the asset sharer</p>
38 </div> 38 </div>
39   39  
40 <div class="container"> 40 <div class="container">
41 41
42 <ul class="nav nav-tabs"> 42 <ul class="nav nav-tabs">
43 <li><a href="index.html">Home</a></li> 43 <li><a href="index.html">Home</a></li>
44 <li><a href="file.html">File</a></li> 44 <li><a href="file.html">File</a></li>
45 <li class="active"><a href="#">Text</a></li> 45 <li class="active"><a href="#">Text</a></li>
46 <li><a href="draw.html">Draw</a></li> 46 <li><a href="draw.html">Draw</a></li>
47 <li><a href="link.html">Link</a></li> 47 <li><a href="link.html">Link</a></li>
48 </ul> 48 </ul>
49 49
50 <div id="main-panel" class="panel panel-default"> 50 <div id="main-panel" class="panel panel-default">
51 <div class="panel-heading"> 51 <div class="panel-heading">
52 <div class="form-group"> 52 <div class="form-group">
53 <div class="input-group"> 53 <div class="input-group">
54 <span class="input-group-btn"> 54 <span class="input-group-btn">
55 <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link."> 55 <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link.">
56 <i class="glyphicon glyphicon-share"></i> 56 <i class="glyphicon glyphicon-share"></i>
57 </button> 57 </button>
58 </span> 58 </span>
59 <input id="URL" type="text" class="form-control" readonly> 59 <input id="URL" type="text" class="form-control" readonly>
60 <span class="input-group-btn"> 60 <span class="input-group-btn">
61 <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> 61 <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button>
62 </span> 62 </span>
63 </div> 63 </div>
64 </div> 64 </div>
65 <form id="nick-form" role="form"> 65 <form id="nick-form" role="form">
66 <div class="form-group has-feedback"> 66 <div class="form-group has-feedback">
67 <div class="input-group"> 67 <div class="input-group">
68 <span class="input-group-btn"> 68 <span class="input-group-btn">
69 <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document."> 69 <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document.">
70 <i class="glyphicon glyphicon-play"></i> 70 <i class="glyphicon glyphicon-play"></i>
71 </button> 71 </button>
72 </span> 72 </span>
73 <span class="input-group-btn"> 73 <span class="input-group-btn">
74 <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document."> 74 <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document.">
75 <i id="home-icon" class="glyphicon glyphicon-home"></i> 75 <i id="home-icon" class="glyphicon glyphicon-home"></i>
76 </button> 76 </button>
77 </span> 77 </span>
78 <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32"> 78 <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32">
79 <span class="input-group-btn"> 79 <span class="input-group-btn">
80 <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> 80 <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button>
81 </span> 81 </span>
82 </div> 82 </div>
83 </div> 83 </div>
84 </form> 84 </form>
85 </div> 85 </div>
86 <div class="panel-body" id="editorpanel"> 86 <div class="panel-body" id="editorpanel">
87 <div id="trumbowyg"> 87 <div id="trumbowyg">
88 </div> 88 </div>
89 </div> 89 </div>
90 </div> 90 </div>
91   91  
92 </div> <!-- /container --> 92 </div> <!-- /container -->
93 93
94 <div id="footer"> 94 <div id="footer">
95 <div class="container"> 95 <div class="container">
96 <p class="text-muted credit text-center">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p> 96 <p class="text-muted credit text-center">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p>
97 </div> 97 </div>
98 </div> 98 </div>
99   99  
100 <!-- jQuery --> 100 <!-- jQuery -->
101 <script src="bower_components/jquery/dist/jquery.min.js"></script> 101 <script src="bower_components/jquery/dist/jquery.min.js"></script>
102 <!-- BootStrap --> 102 <!-- BootStrap -->
103 <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> 103 <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
104 <!-- Velocity --> 104 <!-- Velocity -->
105 <script src="bower_components/velocity/velocity.min.js"></script> 105 <script src="bower_components/velocity/velocity.min.js"></script>
106 106
107 <!-- Trumbowyg --> 107 <!-- Trumbowyg -->
108 <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> 108 <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script>
109 <!-- Clipboard --> 109 <!-- Clipboard -->
110 <script src="bower_components/clipboard/dist/clipboard.min.js"></script> 110 <script src="bower_components/clipboard/dist/clipboard.min.js"></script>
111 <!-- Fingerprint 2 --> 111 <!-- Fingerprint 2 -->
112 <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script> 112 <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script>
113 <!-- js-cookie --> 113 <!-- js-cookie -->
114 <script src="bower_components/js-cookie/src/js.cookie.js"></script> 114 <script src="bower_components/js-cookie/src/js.cookie.js"></script>
115 <!-- Bootstrap Validator --> 115 <!-- Bootstrap Validator -->
116 <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script> 116 <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script>
117 <script> 117 <script>
118 $(document).ready(() => { 118 $(document).ready(() => {
119 // Attach the form validator. 119 // Attach the form validator.
120 $('#nick-form').validator({ 120 $('#nick-form').validator({
121 focus: false 121 focus: false
122 }).on('invalid.bs.validator', () => { 122 }).on('invalid.bs.validator', () => {
123 $('#go').attr('disabled', true); 123 $('#go').attr('disabled', true);
124 }).on('valid.bs.validator', () => { 124 }).on('valid.bs.validator', () => {
125 $('#go').attr('disabled', false); 125 $('#go').attr('disabled', false);
126 }); 126 });
127 127
128 // Enable the Clipboard button. 128 // Enable the Clipboard button.
129 new Clipboard('#copy-url'); 129 new Clipboard('#copy-url');
130 130
131 // Get the fingerprint. 131 // Get the fingerprint.
132 new Fingerprint2({ 132 new Fingerprint2({
133 //excludeUserAgent: true, 133 //excludeUserAgent: true,
134 //excludeLanguage: true, 134 //excludeLanguage: true,
135 excludeColorDepth: true, 135 excludeColorDepth: true,
136 excludeScreenResolution: true, 136 excludeScreenResolution: true,
137 excludeAvailableScreenResolution: true, 137 excludeAvailableScreenResolution: true,
138 //excludeTimezoneOffset: true, 138 //excludeTimezoneOffset: true,
139 excludeSessionStorage: true, 139 excludeSessionStorage: true,
140 excludeIndexedDB: true, 140 excludeIndexedDB: true,
141 excludeAddBehavior: true, 141 excludeAddBehavior: true,
142 excludeOpenDatabase: true, 142 excludeOpenDatabase: true,
143 //excludeCpuClass: true, 143 //excludeCpuClass: true,
144 //excludePlatform: true, 144 //excludePlatform: true,
145 excludeDoNotTrack: true, 145 excludeDoNotTrack: true,
146 excludeCanvas: true, 146 excludeCanvas: true,
147 excludeWebGL: true, 147 excludeWebGL: true,
148 excludeAdBlock: true, 148 excludeAdBlock: true,
149 //excludeHasLiedLanguages: true, 149 //excludeHasLiedLanguages: true,
150 //excludeHasLiedResolution: true, 150 //excludeHasLiedResolution: true,
151 //excludeHasLiedOs: true, 151 //excludeHasLiedOs: true,
152 //excludeHasLiedBrowser: true, 152 //excludeHasLiedBrowser: true,
153 excludeJsFonts: true, 153 excludeJsFonts: true,
154 excludeFlashFonts: true, 154 excludeFlashFonts: true,
155 excludePlugins: true, 155 excludePlugins: true,
156 excludeIEPlugins: true, 156 excludeIEPlugins: true,
157 //excludeTouchSupport: true, 157 //excludeTouchSupport: true,
158 excludePixelRatio: true 158 excludePixelRatio: true
159 }).get((result, components) => { 159 }).get((result, components) => {
160 // Set the nick as a cookie. 160 // Set the nick as a cookie.
161 const fingerprint = result; 161 const fingerprint = result;
162 var nick = Cookies.get('nick'); 162 var nick = Cookies.get('nick');
163 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) { 163 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) {
164 Cookies.set('nick', result, { path: '' }); 164 Cookies.set('nick', result, { path: '' });
165 nick = result; 165 nick = result;
166 } 166 }
167 else 167 else
168 result = nick; 168 result = nick;
169 169
170 // Set the nick. 170 // Set the nick.
171 $('#nick').val(result); 171 $('#nick').val(result);
172 new Clipboard('#copy-nick'); 172 new Clipboard('#copy-nick');
173 173
174 if(fingerprint == nick) 174 if(fingerprint == nick)
175 $('#home-icon').addClass("text-success"); 175 $('#home-icon').addClass("text-success");
176 else 176 else
177 $('#home-icon').addClass("text-danger"); 177 $('#home-icon').addClass("text-danger");
178 178
179 var autoSaveTimeoutID; 179 var autoSaveTimeoutID;
180 180
181 function saveTextFile() { 181 function saveTextFile() {
182 $.get('session.php').then((token) => { 182 $.get('session.php').then((token) => {
183 $.post('text.php', { 183 $.post('text.php', {
184 data: $('#trumbowyg').trumbowyg('html'), 184 data: $('#trumbowyg').trumbowyg('html'),
185 token: token, 185 token: token,
186 fingerprint: result, 186 fingerprint: result,
187 action: 'SAVE', 187 action: 'SAVE',
188 token: token 188 token: token
189 }).done((data) => { 189 }).done((data) => {
190 190
191 // Visual feedback for a successful save. 191 // Visual feedback for a successful save.
192 $('#editorpanel') 192 $('#editorpanel')
193 .delay(250) 193 .delay(250)
194 .velocity( 194 .velocity(
195 { 195 {
196 borderColor: '#ff99ff' 196 borderColor: '#ff99ff'
197 }, 197 },
198 200) 198 200)
199 .delay(500) 199 .delay(500)
200 .velocity( 200 .velocity(
201 { 201 {
202 borderColor: '#ecf0f1' 202 borderColor: '#ecf0f1'
203 }, 203 },
204 200); 204 200);
205 205
206 }).fail(() => { 206 }).fail(() => {
207 // Reschedule saving of the file. 207 // Reschedule saving of the file.
208 if(autoSaveTimeoutID) 208 if(autoSaveTimeoutID)
209 window.clearTimeout(autoSaveTimeoutID); 209 window.clearTimeout(autoSaveTimeoutID);
210 autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); 210 autoSaveTimeoutID = window.setTimeout(saveTextFile, 250);
211 }); 211 });
212 }); 212 });
213 } 213 }
214 214
215 // Load the editor. 215 // Load the editor.
216 $('#trumbowyg').trumbowyg({ 216 $('#trumbowyg').trumbowyg({
217 semantic: true, 217 semantic: true,
218 autogrow: true, 218 autogrow: true,
219 disabled: true 219 disabled: true
220 }).on('tbwchange', () => { 220 }).on('tbwchange', () => {
221 // Clear the value of the URL box because the URL will have changed. 221 // Clear the value of the URL box because the URL will have changed.
222 $('#URL').val(''); 222 $('#URL').val('');
223 // Reschedule saving of the file. 223 // Reschedule saving of the file.
224 if(autoSaveTimeoutID) 224 if(autoSaveTimeoutID)
225 window.clearTimeout(autoSaveTimeoutID); 225 window.clearTimeout(autoSaveTimeoutID);
226 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); 226 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000);
227 }); 227 });
228 228
229 // Retrieve the contents of the shared file. 229 // Retrieve the contents of the shared file.
230 $('#trumbowyg').trumbowyg('disable'); 230 $('#trumbowyg').trumbowyg('disable');
231 $.get('session.php').then((token) => { 231 $.get('session.php').then((token) => {
232 $.post('text.php', 232 $.post('text.php',
233 { 233 {
234 timestamp: window.performance.now(), 234 timestamp: window.performance.now(),
235 fingerprint: result, 235 fingerprint: result,
236 action: 'LOAD', 236 action: 'LOAD',
237 token: token 237 token: token
238 }).done((data) => {; 238 }).done((data) => {;
239 $('#trumbowyg') 239 $('#trumbowyg')
240 .trumbowyg('html', data); 240 .trumbowyg('html', data);
241 $('#trumbowyg').trumbowyg('enable'); 241 $('#trumbowyg').trumbowyg('enable');
242 $('#trumbowyg').show(); 242 $('#trumbowyg').show();
243 }).fail(() => { 243 }).fail(() => {
244 $('#trumbowyg').trumbowyg('enable'); 244 $('#trumbowyg').trumbowyg('enable');
245 $('#trumbowyg').show(); 245 $('#trumbowyg').show();
246 }); 246 });
247 }); 247 });
248 248
249 $('#save').click(() => { 249 $('#save').click(() => {
250 $('#editor').trumbowyg('disable'); 250 $('#editor').trumbowyg('disable');
251 var formData = new FormData(); 251 var formData = new FormData();
252 formData.append('file', new Blob( 252 formData.append('file', new Blob(
253 [ 253 [
254 $('#trumbowyg').trumbowyg('html') 254 $('#trumbowyg').trumbowyg('html')
255 ] 255 ]
256 ), 256 ),
257 '.html' 257 '.html'
258 ); 258 );
259 $.get('session.php').then((token) => { 259 $.get('session.php').then((token) => {
260 formData.append('token', token); 260 formData.append('token', token);
261 $.ajax({ 261 $.ajax({
262 url: 'file.php', 262 url: 'file.php',
263 //type: 'POST', 263 type: 'POST',
264 data: formData, 264 data: formData,
265 // cache: false // FF 265 // cache: false // FF
266 processData: false, 266 processData: false,
267 contentType: false 267 contentType: false
268 }).done((data) => { 268 }).done((data) => {
269 // Serialize JSON to object. 269 // Serialize JSON to object.
270 data = JSON.parse(data); 270 data = JSON.parse(data);
271 271
272 $('#URL') 272 $('#URL')
273 .val( 273 .val(
274 location.protocol 274 location.protocol
275 .concat("//") 275 .concat("//")
276 .concat(window.location.hostname) 276 .concat(window.location.hostname)
277 .concat("/") 277 .concat("/")
278 .concat(data.hash) 278 .concat(data.hash)
279 ); 279 );
280 $('#trumbowyg').trumbowyg('enable'); 280 $('#trumbowyg').trumbowyg('enable');
281 }).fail(() => { 281 }).fail(() => {
282 $('#trumbowyg').trumbowyg('enable'); 282 $('#trumbowyg').trumbowyg('enable');
283 }); 283 });
284 }); 284 });
285 }); 285 });
286 286
287 // When the button is clicked, navigate to the fingerprint. 287 // When the button is clicked, navigate to the fingerprint.
288 $('#go').click(() => { 288 $('#go').click(() => {
289 nick = $('#nick').val(); 289 nick = $('#nick').val();
290 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 290 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
291 return; 291 return;
292 Cookies.set('nick', nick, { path: '' }); 292 Cookies.set('nick', nick, { path: '' });
293 result = nick; 293 result = nick;
294 294
295 // Retrieve the contents of the shared file. 295 // Retrieve the contents of the shared file.
296 $('#editor').trumbowyg('disable'); 296 $('#editor').trumbowyg('disable');
297 $.get('session.php').then((token) => { 297 $.get('session.php').then((token) => {
298 $.post('text.php', 298 $.post('text.php',
299 { 299 {
300 timestamp: window.performance.now(), 300 timestamp: window.performance.now(),
301 fingerprint: nick, 301 fingerprint: nick,
302 action: 'LOAD', 302 action: 'LOAD',
303 token: token 303 token: token
304 }).done((data) => {; 304 }).done((data) => {;
305 $('#trumbowyg') 305 $('#trumbowyg')
306 .trumbowyg('html', data); 306 .trumbowyg('html', data);
307 $('#trumbowyg').trumbowyg('enable'); 307 $('#trumbowyg').trumbowyg('enable');
308 $('#trumbowyg').show(); 308 $('#trumbowyg').show();
309 309
310 if(fingerprint == nick) 310 if(fingerprint == nick)
311 $('#home-icon').addClass("text-success").removeClass("text-danger"); 311 $('#home-icon').addClass("text-success").removeClass("text-danger");
312 else 312 else
313 $('#home-icon').addClass("text-danger").removeClass("text-success"); 313 $('#home-icon').addClass("text-danger").removeClass("text-success");
314 314
315 }).fail(() => { 315 }).fail(() => {
316 $('#trumbowyg').trumbowyg('enable'); 316 $('#trumbowyg').trumbowyg('enable');
317 $('#trumbowyg').show(); 317 $('#trumbowyg').show();
318 }); 318 });
319 }); 319 });
320 }); 320 });
321 321
322 // When the form is submitted, naigate to the fingerprint. 322 // When the form is submitted, naigate to the fingerprint.
323 $('#nick-form').submit((e) => { 323 $('#nick-form').submit((e) => {
324 e.preventDefault(); 324 e.preventDefault();
325 325
326 nick = $('#nick').val(); 326 nick = $('#nick').val();
327 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 327 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
328 return; 328 return;
329 Cookies.set('nick', nick, { path: '' }); 329 Cookies.set('nick', nick, { path: '' });
330 result = nick; 330 result = nick;
331 331
332 // Retrieve the contents of the shared file. 332 // Retrieve the contents of the shared file.
333 $('#editor').trumbowyg('disable'); 333 $('#editor').trumbowyg('disable');
334 $.get('session.php').then((token) => { 334 $.get('session.php').then((token) => {
335 $.post('text.php', 335 $.post('text.php',
336 { 336 {
337 timestamp: window.performance.now(), 337 timestamp: window.performance.now(),
338 fingerprint: nick, 338 fingerprint: nick,
339 action: 'LOAD', 339 action: 'LOAD',
340 token: token 340 token: token
341 }).done((data) => {; 341 }).done((data) => {;
342 $('#trumbowyg') 342 $('#trumbowyg')
343 .trumbowyg('html', data); 343 .trumbowyg('html', data);
344 $('#trumbowyg').trumbowyg('enable'); 344 $('#trumbowyg').trumbowyg('enable');
345 $('#trumbowyg').show(); 345 $('#trumbowyg').show();
346 346
347 if(fingerprint == nick) 347 if(fingerprint == nick)
348 $('#home-icon').addClass("text-success").removeClass("text-danger"); 348 $('#home-icon').addClass("text-success").removeClass("text-danger");
349 else 349 else
350 $('#home-icon').addClass("text-danger").removeClass("text-success"); 350 $('#home-icon').addClass("text-danger").removeClass("text-success");
351 351
352 }).fail(() => { 352 }).fail(() => {
353 $('#trumbowyg').trumbowyg('enable'); 353 $('#trumbowyg').trumbowyg('enable');
354 $('#trumbowyg').show(); 354 $('#trumbowyg').show();
355 }); 355 });
356 }); 356 });
357 }); 357 });
358 358
359 // While the nick is changing, navigate to the changed fingerprint. 359 // While the nick is changing, navigate to the changed fingerprint.
360 $("#nick").on('input', () => { 360 $("#nick").on('input', () => {
361 nick = $('#nick').val(); 361 nick = $('#nick').val();
362 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 362 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
363 return; 363 return;
364 Cookies.set('nick', nick, { path: '' }); 364 Cookies.set('nick', nick, { path: '' });
365 result = nick; 365 result = nick;
366 366
367 // Retrieve the contents of the shared file. 367 // Retrieve the contents of the shared file.
368 $('#editor').trumbowyg('disable'); 368 $('#editor').trumbowyg('disable');
369 $.get('session.php').then((token) => { 369 $.get('session.php').then((token) => {
370 $.post('text.php', 370 $.post('text.php',
371 { 371 {
372 timestamp: window.performance.now(), 372 timestamp: window.performance.now(),
373 fingerprint: nick, 373 fingerprint: nick,
374 action: 'LOAD', 374 action: 'LOAD',
375 token: token 375 token: token
376 }).done((data) => {; 376 }).done((data) => {;
377 $('#trumbowyg') 377 $('#trumbowyg')
378 .trumbowyg('html', data); 378 .trumbowyg('html', data);
379 $('#trumbowyg').trumbowyg('enable'); 379 $('#trumbowyg').trumbowyg('enable');
380 $('#trumbowyg').show(); 380 $('#trumbowyg').show();
381 381
382 if(fingerprint == nick) 382 if(fingerprint == nick)
383 $('#home-icon').addClass("text-success").removeClass("text-danger"); 383 $('#home-icon').addClass("text-success").removeClass("text-danger");
384 else 384 else
385 $('#home-icon').addClass("text-danger").removeClass("text-success"); 385 $('#home-icon').addClass("text-danger").removeClass("text-success");
386 }).fail(() => { 386 }).fail(() => {
387 $('#trumbowyg').trumbowyg('enable'); 387 $('#trumbowyg').trumbowyg('enable');
388 $('#trumbowyg').show(); 388 $('#trumbowyg').show();
389 }); 389 });
390 }); 390 });
391 }); 391 });
392 392
393 // When the reset button is pressed, navigate to the fingerprint. 393 // When the reset button is pressed, navigate to the fingerprint.
394 $('#reset').click(() => { 394 $('#reset').click(() => {
395 Cookies.set('nick', fingerprint, { path: '' }); 395 Cookies.set('nick', fingerprint, { path: '' });
396 $('#nick').val(fingerprint); 396 $('#nick').val(fingerprint);
397 result = fingerprint; 397 result = fingerprint;
398 nick = fingerprint; 398 nick = fingerprint;
399 399
400 // Retrieve the contents of the shared file. 400 // Retrieve the contents of the shared file.
401 $('#editor').trumbowyg('disable'); 401 $('#editor').trumbowyg('disable');
402 $.get('session.php').then((token) => { 402 $.get('session.php').then((token) => {
403 $.post('text.php', 403 $.post('text.php',
404 { 404 {
405 timestamp: window.performance.now(), 405 timestamp: window.performance.now(),
406 fingerprint: fingerprint, 406 fingerprint: fingerprint,
407 action: 'LOAD', 407 action: 'LOAD',
408 token: token 408 token: token
409 }).done((data) => {; 409 }).done((data) => {;
410 $('#trumbowyg') 410 $('#trumbowyg')
411 .trumbowyg('html', data); 411 .trumbowyg('html', data);
412 $('#trumbowyg').trumbowyg('enable'); 412 $('#trumbowyg').trumbowyg('enable');
413 $('#trumbowyg').show(); 413 $('#trumbowyg').show();
414 if(fingerprint == nick) 414 if(fingerprint == nick)
415 $('#home-icon').addClass("text-success").removeClass("text-danger"); 415 $('#home-icon').addClass("text-success").removeClass("text-danger");
416 else 416 else
417 $('#home-icon').addClass("text-danger").removeClass("text-success"); 417 $('#home-icon').addClass("text-danger").removeClass("text-success");
418 }).fail(() => { 418 }).fail(() => {
419 $('#trumbowyg').trumbowyg('enable'); 419 $('#trumbowyg').trumbowyg('enable');
420 $('#trumbowyg').show(); 420 $('#trumbowyg').show();
421 }); 421 });
422 }); 422 });
423 }); 423 });
424 }); 424 });
425 425
426 // Scroll to the panel. 426 // Scroll to the panel.
427 $('html, body').animate({ 427 $('html, body').animate({
428 scrollTop: $('#main-panel').offset().top 428 scrollTop: $('#main-panel').offset().top
429 }, 'slow'); 429 }, 'slow');
430 }); 430 });
431 </script> 431 </script>
432 <!-- Jumbotron parallax effect --> 432 <!-- Jumbotron parallax effect -->
433 <script> 433 <script>
434 var jumboHeight = $('.jumbotron').outerHeight(); 434 var jumboHeight = $('.jumbotron').outerHeight();
435 function parallax(){ 435 function parallax(){
436 var scrolled = $(window).scrollTop(); 436 var scrolled = $(window).scrollTop();
437 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px'); 437 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px');
438 } 438 }
439   439  
440 $(window).scroll(function(e){ 440 $(window).scroll(function(e){
441 parallax(); 441 parallax();
442 }); 442 });
443 </script> 443 </script>
444 </body> 444 </body>
445 </html> 445 </html>
446   446