scratch – Diff between revs 121 and 125

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