scratch – Diff between revs 94 and 96

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 94 Rev 96
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 $.post('text.php', { 183 $.post('text.php', {
183 data: $('#trumbowyg').trumbowyg('html'), 184 data: $('#trumbowyg').trumbowyg('html'),
-   185 token: token,
184 fingerprint: result, 186 fingerprint: result,
185 action: 'SAVE' 187 action: 'SAVE',
-   188 token: token
186 }).done((data) => { 189 }).done((data) => {
187 190
188 // Visual feedback for a successful save. 191 // Visual feedback for a successful save.
189 $('#editorpanel') 192 $('#editorpanel')
190 .delay(250) 193 .delay(250)
191 .velocity( 194 .velocity(
192 { 195 {
193 borderColor: '#ff99ff' 196 borderColor: '#ff99ff'
194 }, 197 },
195 200) 198 200)
196 .delay(500) 199 .delay(500)
197 .velocity( 200 .velocity(
198 { 201 {
199 borderColor: '#ecf0f1' 202 borderColor: '#ecf0f1'
200 }, 203 },
201 200); 204 200);
202 205
203 }).fail(() => { 206 }).fail(() => {
204 // Reschedule saving of the file. 207 // Reschedule saving of the file.
205 if(autoSaveTimeoutID) 208 if(autoSaveTimeoutID)
206 window.clearTimeout(autoSaveTimeoutID); 209 window.clearTimeout(autoSaveTimeoutID);
207 autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); 210 autoSaveTimeoutID = window.setTimeout(saveTextFile, 250);
-   211 });
208 }); 212 });
209 } 213 }
210 214
211 // Load the editor. 215 // Load the editor.
212 $('#trumbowyg').trumbowyg({ 216 $('#trumbowyg').trumbowyg({
213 semantic: true, 217 semantic: true,
214 autogrow: true, 218 autogrow: true,
215 disabled: true 219 disabled: true
216 }).on('tbwchange', () => { 220 }).on('tbwchange', () => {
217 // 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.
218 $('#URL').val(''); 222 $('#URL').val('');
219 // Reschedule saving of the file. 223 // Reschedule saving of the file.
220 if(autoSaveTimeoutID) 224 if(autoSaveTimeoutID)
221 window.clearTimeout(autoSaveTimeoutID); 225 window.clearTimeout(autoSaveTimeoutID);
222 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); 226 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000);
223 }); 227 });
224 228
225 // Retrieve the contents of the shared file. 229 // Retrieve the contents of the shared file.
226 $('#trumbowyg').trumbowyg('disable'); 230 $('#trumbowyg').trumbowyg('disable');
-   231 $.get('session.php').then((token) => {
227 $.post('text.php', 232 $.post('text.php',
228 { 233 {
229 timestamp: window.performance.now(), 234 timestamp: window.performance.now(),
230 fingerprint: result, 235 fingerprint: result,
231 action: 'LOAD' 236 action: 'LOAD',
-   237 token: token
232 }).done((data) => {; 238 }).done((data) => {;
233 $('#trumbowyg') 239 $('#trumbowyg')
234 .trumbowyg('html', data); 240 .trumbowyg('html', data);
235 $('#trumbowyg').trumbowyg('enable'); 241 $('#trumbowyg').trumbowyg('enable');
236 $('#trumbowyg').show(); 242 $('#trumbowyg').show();
237 }).fail(() => { 243 }).fail(() => {
238 $('#trumbowyg').trumbowyg('enable'); 244 $('#trumbowyg').trumbowyg('enable');
239 $('#trumbowyg').show(); 245 $('#trumbowyg').show();
-   246 });
240 }); 247 });
241 248
242 $('#save').click(() => { 249 $('#save').click(() => {
243 $('#editor').trumbowyg('disable'); 250 $('#editor').trumbowyg('disable');
244 var formData = new FormData(); 251 var formData = new FormData();
245 formData.append('file', new Blob( 252 formData.append('file', new Blob(
246 [ 253 [
247 $('#trumbowyg').trumbowyg('html') 254 $('#trumbowyg').trumbowyg('html')
248 ] 255 ]
249 ), 256 ),
250 '.html' 257 '.html'
251 ); 258 );
252 -  
-   259 $.get('session.php').then((token) => {
-   260 formData.append('token', token);
253 $.ajax({ 261 $.ajax({
254 url: 'file.php', 262 url: 'file.php',
255 type: 'POST', 263 //type: 'POST',
256 data: formData, 264 data: formData,
257 // cache: false // FF 265 // cache: false // FF
258 processData: false, 266 processData: false,
259 contentType: false 267 contentType: false
260 }).done((data) => { 268 }).done((data) => {
261 // Serialize JSON to object. 269 // Serialize JSON to object.
262 data = JSON.parse(data); 270 data = JSON.parse(data);
263 271
264 $('#URL') 272 $('#URL')
265 .val( 273 .val(
266 location.protocol 274 location.protocol
267 .concat("//") 275 .concat("//")
268 .concat(window.location.hostname) 276 .concat(window.location.hostname)
269 .concat("/") 277 .concat("/")
270 .concat(data.hash) 278 .concat(data.hash)
271 ); 279 );
272 $('#trumbowyg').trumbowyg('enable'); 280 $('#trumbowyg').trumbowyg('enable');
273 }).fail(() => { 281 }).fail(() => {
274 $('#trumbowyg').trumbowyg('enable'); 282 $('#trumbowyg').trumbowyg('enable');
-   283 });
275 }); 284 });
276 }); 285 });
277 286
278 // When the button is clicked, navigate to the fingerprint. 287 // When the button is clicked, navigate to the fingerprint.
279 $('#go').click(() => { 288 $('#go').click(() => {
280 nick = $('#nick').val(); 289 nick = $('#nick').val();
281 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 290 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
282 return; 291 return;
283 Cookies.set('nick', nick, { path: '' }); 292 Cookies.set('nick', nick, { path: '' });
284 result = nick; 293 result = nick;
285 294
286 // Retrieve the contents of the shared file. 295 // Retrieve the contents of the shared file.
287 $('#editor').trumbowyg('disable'); 296 $('#editor').trumbowyg('disable');
-   297 $.get('session.php').then((token) => {
288 $.post('text.php', 298 $.post('text.php',
289 { 299 {
290 timestamp: window.performance.now(), 300 timestamp: window.performance.now(),
291 fingerprint: nick, 301 fingerprint: nick,
292 action: 'LOAD' 302 action: 'LOAD',
-   303 token: token
293 }).done((data) => {; 304 }).done((data) => {;
294 $('#trumbowyg') 305 $('#trumbowyg')
295 .trumbowyg('html', data); 306 .trumbowyg('html', data);
296 $('#trumbowyg').trumbowyg('enable'); 307 $('#trumbowyg').trumbowyg('enable');
297 $('#trumbowyg').show(); 308 $('#trumbowyg').show();
298 309
299 if(fingerprint == nick) 310 if(fingerprint == nick)
300 $('#home-icon').addClass("text-success").removeClass("text-danger"); 311 $('#home-icon').addClass("text-success").removeClass("text-danger");
301 else 312 else
302 $('#home-icon').addClass("text-danger").removeClass("text-success"); 313 $('#home-icon').addClass("text-danger").removeClass("text-success");
303 314
304 }).fail(() => { 315 }).fail(() => {
305 $('#trumbowyg').trumbowyg('enable'); 316 $('#trumbowyg').trumbowyg('enable');
306 $('#trumbowyg').show(); 317 $('#trumbowyg').show();
-   318 });
307 }); 319 });
308 }); 320 });
309 321
310 // When the form is submitted, naigate to the fingerprint. 322 // When the form is submitted, naigate to the fingerprint.
311 $('#nick-form').submit((e) => { 323 $('#nick-form').submit((e) => {
312 e.preventDefault(); 324 e.preventDefault();
313 325
314 nick = $('#nick').val(); 326 nick = $('#nick').val();
315 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 327 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
316 return; 328 return;
317 Cookies.set('nick', nick, { path: '' }); 329 Cookies.set('nick', nick, { path: '' });
318 result = nick; 330 result = nick;
319 331
320 // Retrieve the contents of the shared file. 332 // Retrieve the contents of the shared file.
321 $('#editor').trumbowyg('disable'); 333 $('#editor').trumbowyg('disable');
-   334 $.get('session.php').then((token) => {
322 $.post('text.php', 335 $.post('text.php',
323 { 336 {
324 timestamp: window.performance.now(), 337 timestamp: window.performance.now(),
325 fingerprint: nick, 338 fingerprint: nick,
326 action: 'LOAD' 339 action: 'LOAD',
-   340 token: token
327 }).done((data) => {; 341 }).done((data) => {;
328 $('#trumbowyg') 342 $('#trumbowyg')
329 .trumbowyg('html', data); 343 .trumbowyg('html', data);
330 $('#trumbowyg').trumbowyg('enable'); 344 $('#trumbowyg').trumbowyg('enable');
331 $('#trumbowyg').show(); 345 $('#trumbowyg').show();
332 346
333 if(fingerprint == nick) 347 if(fingerprint == nick)
334 $('#home-icon').addClass("text-success").removeClass("text-danger"); 348 $('#home-icon').addClass("text-success").removeClass("text-danger");
335 else 349 else
336 $('#home-icon').addClass("text-danger").removeClass("text-success"); 350 $('#home-icon').addClass("text-danger").removeClass("text-success");
337 351
338 }).fail(() => { 352 }).fail(() => {
339 $('#trumbowyg').trumbowyg('enable'); 353 $('#trumbowyg').trumbowyg('enable');
340 $('#trumbowyg').show(); 354 $('#trumbowyg').show();
-   355 });
341 }); 356 });
342 }); 357 });
343 358
344 // While the nick is changing, navigate to the changed fingerprint. 359 // While the nick is changing, navigate to the changed fingerprint.
345 $("#nick").on('input', () => { 360 $("#nick").on('input', () => {
346 nick = $('#nick').val(); 361 nick = $('#nick').val();
347 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick)) 362 if(!nick || !/^[A-Za-z0-9]{32}$/.test(nick))
348 return; 363 return;
349 Cookies.set('nick', nick, { path: '' }); 364 Cookies.set('nick', nick, { path: '' });
350 result = nick; 365 result = nick;
351 366
352 // Retrieve the contents of the shared file. 367 // Retrieve the contents of the shared file.
353 $('#editor').trumbowyg('disable'); 368 $('#editor').trumbowyg('disable');
-   369 $.get('session.php').then((token) => {
354 $.post('text.php', 370 $.post('text.php',
355 { 371 {
356 timestamp: window.performance.now(), 372 timestamp: window.performance.now(),
357 fingerprint: nick, 373 fingerprint: nick,
358 action: 'LOAD' 374 action: 'LOAD',
-   375 token: token
359 }).done((data) => {; 376 }).done((data) => {;
360 $('#trumbowyg') 377 $('#trumbowyg')
361 .trumbowyg('html', data); 378 .trumbowyg('html', data);
362 $('#trumbowyg').trumbowyg('enable'); 379 $('#trumbowyg').trumbowyg('enable');
363 $('#trumbowyg').show(); 380 $('#trumbowyg').show();
364 381
365 if(fingerprint == nick) 382 if(fingerprint == nick)
366 $('#home-icon').addClass("text-success").removeClass("text-danger"); 383 $('#home-icon').addClass("text-success").removeClass("text-danger");
367 else 384 else
368 $('#home-icon').addClass("text-danger").removeClass("text-success"); 385 $('#home-icon').addClass("text-danger").removeClass("text-success");
369 }).fail(() => { 386 }).fail(() => {
370 $('#trumbowyg').trumbowyg('enable'); 387 $('#trumbowyg').trumbowyg('enable');
371 $('#trumbowyg').show(); 388 $('#trumbowyg').show();
-   389 });
372 }); 390 });
373 }); 391 });
374 392
375 // When the reset button is pressed, navigate to the fingerprint. 393 // When the reset button is pressed, navigate to the fingerprint.
376 $('#reset').click(() => { 394 $('#reset').click(() => {
377 Cookies.set('nick', fingerprint, { path: '' }); 395 Cookies.set('nick', fingerprint, { path: '' });
378 $('#nick').val(fingerprint); 396 $('#nick').val(fingerprint);
379 result = fingerprint; 397 result = fingerprint;
380 nick = fingerprint; 398 nick = fingerprint;
381 399
382 // Retrieve the contents of the shared file. 400 // Retrieve the contents of the shared file.
383 $('#editor').trumbowyg('disable'); 401 $('#editor').trumbowyg('disable');
-   402 $.get('session.php').then((token) => {
384 $.post('text.php', 403 $.post('text.php',
385 { 404 {
386 timestamp: window.performance.now(), 405 timestamp: window.performance.now(),
387 fingerprint: fingerprint, 406 fingerprint: fingerprint,
388 action: 'LOAD' 407 action: 'LOAD',
-   408 token: token
389 }).done((data) => {; 409 }).done((data) => {;
390 $('#trumbowyg') 410 $('#trumbowyg')
391 .trumbowyg('html', data); 411 .trumbowyg('html', data);
392 $('#trumbowyg').trumbowyg('enable'); 412 $('#trumbowyg').trumbowyg('enable');
393 $('#trumbowyg').show(); 413 $('#trumbowyg').show();
394 if(fingerprint == nick) 414 if(fingerprint == nick)
395 $('#home-icon').addClass("text-success").removeClass("text-danger"); 415 $('#home-icon').addClass("text-success").removeClass("text-danger");
396 else 416 else
397 $('#home-icon').addClass("text-danger").removeClass("text-success"); 417 $('#home-icon').addClass("text-danger").removeClass("text-success");
398 }).fail(() => { 418 }).fail(() => {
399 $('#trumbowyg').trumbowyg('enable'); 419 $('#trumbowyg').trumbowyg('enable');
400 $('#trumbowyg').show(); 420 $('#trumbowyg').show();
-   421 });
401 }); 422 });
402 }); 423 });
403 }); 424 });
404 425
405 // Scroll to the panel. 426 // Scroll to the panel.
406 $('html, body').animate({ 427 $('html, body').animate({
407 scrollTop: $('#main-panel').offset().top 428 scrollTop: $('#main-panel').offset().top
408 }, 'slow'); 429 }, 'slow');
409 }); 430 });
410 </script> 431 </script>
411 <!-- Jumbotron parallax effect --> 432 <!-- Jumbotron parallax effect -->
412 <script> 433 <script>
413 var jumboHeight = $('.jumbotron').outerHeight(); 434 var jumboHeight = $('.jumbotron').outerHeight();
414 function parallax(){ 435 function parallax(){
415 var scrolled = $(window).scrollTop(); 436 var scrolled = $(window).scrollTop();
416 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px'); 437 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px');
417 } 438 }
418   439  
419 $(window).scroll(function(e){ 440 $(window).scroll(function(e){
420 parallax(); 441 parallax();
421 }); 442 });
422 </script> 443 </script>
423 </body> 444 </body>
424 </html> 445 </html>
425   446