scratch – Diff between revs 94 and 96
?pathlinks?
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', |
|
185 | 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) |
|
- | 209 | window.clearTimeout(autoSaveTimeoutID); |
||
206 | window.clearTimeout(autoSaveTimeoutID); |
210 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
207 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
211 | }); |
|
Line 208... | Line 212... | |||
208 | }); |
212 | }); |
|
209 | } |
213 | } |
|
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'); |
|
- | 245 | $('#trumbowyg').show(); |
||
239 | $('#trumbowyg').show(); |
246 | }); |
|
Line 240... | Line 247... | |||
240 | }); |
247 | }); |
|
241 | |
248 | |
|
242 | $('#save').click(() => { |
249 | $('#save').click(() => { |
|
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) => { |
|
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 | }); |
|
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. |
|
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'); |
|
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'); |
|
- | 317 | $('#trumbowyg').show(); |
||
306 | $('#trumbowyg').show(); |
318 | }); |
|
307 | }); |
319 | }); |
|
Line 308... | Line 320... | |||
308 | }); |
320 | }); |
|
309 | |
321 | |
|
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'); |
|
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'); |
|
- | 354 | $('#trumbowyg').show(); |
||
340 | $('#trumbowyg').show(); |
355 | }); |
|
341 | }); |
356 | }); |
|
Line 342... | Line 357... | |||
342 | }); |
357 | }); |
|
343 | |
358 | |
|
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'); |
|
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'); |
|
- | 388 | $('#trumbowyg').show(); |
||
371 | $('#trumbowyg').show(); |
389 | }); |
|
372 | }); |
390 | }); |
|
Line 373... | Line 391... | |||
373 | }); |
391 | }); |
|
374 | |
392 | |
|
Line 379... | Line 397... | |||
379 | result = fingerprint; |
397 | result = fingerprint; |
|
380 | nick = fingerprint; |
398 | nick = fingerprint; |
|
Line 381... | Line 399... | |||
381 | |
399 | |
|
382 | // Retrieve the contents of the shared file. |
400 | // 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(), |
|
387 | fingerprint: fingerprint, |
406 | 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); |
|
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'); |
|
- | 420 | $('#trumbowyg').show(); |
||
400 | $('#trumbowyg').show(); |
421 | }); |
|
401 | }); |
422 | }); |
|
402 | }); |
423 | }); |
|
Line 403... | Line 424... | |||
403 | }); |
424 | }); |