scratch – Diff between revs 94 and 96

Subversion Repositories:
Rev:
Show entire fileRegard whitespace
Rev 94 Rev 96
Line 177... Line 177...
177 $('#home-icon').addClass("text-danger"); 177 $('#home-icon').addClass("text-danger");
Line 178... Line 178...
178 178
Line 179... Line 179...
179 var autoSaveTimeoutID; 179 var autoSaveTimeoutID;
-   180
180 181 function saveTextFile() {
181 function saveTextFile() { 182 $.get('session.php').then((token) => {
-   183 $.post('text.php', {
182 $.post('text.php', { 184 data: $('#trumbowyg').trumbowyg('html'),
183 data: $('#trumbowyg').trumbowyg('html'), 185 token: token,
-   186 fingerprint: result,
184 fingerprint: result, 187 action: 'SAVE',
Line 185... Line 188...
185 action: 'SAVE' 188 token: token
186 }).done((data) => { 189 }).done((data) => {
187 190
Line 204... Line 207...
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);
208 }); 211 });
-   212 });
209 } 213 }
Line 210... Line 214...
210 214
211 // Load the editor. 215 // Load the editor.
212 $('#trumbowyg').trumbowyg({ 216 $('#trumbowyg').trumbowyg({
Line 222... Line 226...
222 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); 226 autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000);
223 }); 227 });
Line 224... Line 228...
224 228
225 // Retrieve the contents of the shared file. 229 // Retrieve the contents of the shared file.
-   230 $('#trumbowyg').trumbowyg('disable');
226 $('#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,
-   236 action: 'LOAD',
231 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 });
Line 240... Line 247...
240 }); 247 });
241 248
242 $('#save').click(() => { 249 $('#save').click(() => {
243 $('#editor').trumbowyg('disable'); 250 $('#editor').trumbowyg('disable');
Line 247... Line 254...
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) => {
Line 272... Line 280...
272 $('#trumbowyg').trumbowyg('enable'); 280 $('#trumbowyg').trumbowyg('enable');
273 }).fail(() => { 281 }).fail(() => {
274 $('#trumbowyg').trumbowyg('enable'); 282 $('#trumbowyg').trumbowyg('enable');
275 }); 283 });
276 }); 284 });
-   285 });
Line 277... Line 286...
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();
Line 283... Line 292...
283 Cookies.set('nick', nick, { path: '' }); 292 Cookies.set('nick', nick, { path: '' });
284 result = nick; 293 result = nick;
Line 285... Line 294...
285 294
286 // Retrieve the contents of the shared file. 295 // Retrieve the contents of the shared file.
-   296 $('#editor').trumbowyg('disable');
287 $('#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,
-   302 action: 'LOAD',
292 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');
Line 304... Line 315...
304 }).fail(() => { 315 }).fail(() => {
305 $('#trumbowyg').trumbowyg('enable'); 316 $('#trumbowyg').trumbowyg('enable');
306 $('#trumbowyg').show(); 317 $('#trumbowyg').show();
307 }); 318 });
308 }); 319 });
-   320 });
Line 309... Line 321...
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) => {
Line 317... Line 329...
317 Cookies.set('nick', nick, { path: '' }); 329 Cookies.set('nick', nick, { path: '' });
318 result = nick; 330 result = nick;
Line 319... Line 331...
319 331
320 // Retrieve the contents of the shared file. 332 // Retrieve the contents of the shared file.
-   333 $('#editor').trumbowyg('disable');
321 $('#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,
-   339 action: 'LOAD',
326 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');
Line 338... Line 352...
338 }).fail(() => { 352 }).fail(() => {
339 $('#trumbowyg').trumbowyg('enable'); 353 $('#trumbowyg').trumbowyg('enable');
340 $('#trumbowyg').show(); 354 $('#trumbowyg').show();
341 }); 355 });
342 }); 356 });
-   357 });
Line 343... Line 358...
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();
Line 349... Line 364...
349 Cookies.set('nick', nick, { path: '' }); 364 Cookies.set('nick', nick, { path: '' });
350 result = nick; 365 result = nick;
Line 351... Line 366...
351 366
352 // Retrieve the contents of the shared file. 367 // Retrieve the contents of the shared file.
-   368 $('#editor').trumbowyg('disable');
353 $('#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,
-   374 action: 'LOAD',
358 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');
Line 369... Line 386...
369 }).fail(() => { 386 }).fail(() => {
370 $('#trumbowyg').trumbowyg('enable'); 387 $('#trumbowyg').trumbowyg('enable');
371 $('#trumbowyg').show(); 388 $('#trumbowyg').show();
372 }); 389 });
373 }); 390 });
-   391 });
Line 374... Line 392...
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;
Line 380... Line 398...
380 nick = fingerprint; 398 nick = fingerprint;
381 399
-   400 // Retrieve the contents of the shared file.
382 // Retrieve the contents of the shared file. 401 $('#editor').trumbowyg('disable');
383 $('#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(),
-   406 fingerprint: fingerprint,
387 fingerprint: fingerprint, 407 action: 'LOAD',
388 action: 'LOAD' 408 token: token
389 }).done((data) => {; 409 }).done((data) => {;
390 $('#trumbowyg') 410 $('#trumbowyg')
391 .trumbowyg('html', data); 411 .trumbowyg('html', data);
Line 399... Line 419...
399 $('#trumbowyg').trumbowyg('enable'); 419 $('#trumbowyg').trumbowyg('enable');
400 $('#trumbowyg').show(); 420 $('#trumbowyg').show();
401 }); 421 });
402 }); 422 });
403 }); 423 });
-   424 });
Line 404... Line 425...
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