//text.html |
@@ -179,32 +179,36 @@ |
var autoSaveTimeoutID; |
|
function saveTextFile() { |
$.post('text.php', { |
data: $('#trumbowyg').trumbowyg('html'), |
fingerprint: result, |
action: 'SAVE' |
}).done((data) => { |
$.get('session.php').then((token) => { |
$.post('text.php', { |
data: $('#trumbowyg').trumbowyg('html'), |
token: token, |
fingerprint: result, |
action: 'SAVE', |
token: token |
}).done((data) => { |
|
// Visual feedback for a successful save. |
$('#editorpanel') |
.delay(250) |
.velocity( |
{ |
borderColor: '#ff99ff' |
}, |
200) |
.delay(500) |
.velocity( |
{ |
borderColor: '#ecf0f1' |
}, |
200); |
// Visual feedback for a successful save. |
$('#editorpanel') |
.delay(250) |
.velocity( |
{ |
borderColor: '#ff99ff' |
}, |
200) |
.delay(500) |
.velocity( |
{ |
borderColor: '#ecf0f1' |
}, |
200); |
|
}).fail(() => { |
// Reschedule saving of the file. |
if(autoSaveTimeoutID) |
window.clearTimeout(autoSaveTimeoutID); |
autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
}).fail(() => { |
// Reschedule saving of the file. |
if(autoSaveTimeoutID) |
window.clearTimeout(autoSaveTimeoutID); |
autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
}); |
}); |
} |
|
@@ -224,19 +228,22 @@ |
|
// Retrieve the contents of the shared file. |
$('#trumbowyg').trumbowyg('disable'); |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: result, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
$.get('session.php').then((token) => { |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: result, |
action: 'LOAD', |
token: token |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
|
$('#save').click(() => { |
@@ -249,29 +256,31 @@ |
), |
'.html' |
); |
|
$.ajax({ |
url: 'file.php', |
type: 'POST', |
data: formData, |
// cache: false // FF |
processData: false, |
contentType: false |
}).done((data) => { |
// Serialize JSON to object. |
data = JSON.parse(data); |
$.get('session.php').then((token) => { |
formData.append('token', token); |
$.ajax({ |
url: 'file.php', |
//type: 'POST', |
data: formData, |
// cache: false // FF |
processData: false, |
contentType: false |
}).done((data) => { |
// Serialize JSON to object. |
data = JSON.parse(data); |
|
$('#URL') |
.val( |
location.protocol |
.concat("//") |
.concat(window.location.hostname) |
.concat("/") |
.concat(data.hash) |
); |
$('#trumbowyg').trumbowyg('enable'); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#URL') |
.val( |
location.protocol |
.concat("//") |
.concat(window.location.hostname) |
.concat("/") |
.concat(data.hash) |
); |
$('#trumbowyg').trumbowyg('enable'); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
}); |
}); |
}); |
|
@@ -285,25 +294,28 @@ |
|
// Retrieve the contents of the shared file. |
$('#editor').trumbowyg('disable'); |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
$.get('session.php').then((token) => { |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD', |
token: token |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
|
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
}); |
|
@@ -319,25 +331,28 @@ |
|
// Retrieve the contents of the shared file. |
$('#editor').trumbowyg('disable'); |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
$.get('session.php').then((token) => { |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD', |
token: token |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
|
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
}); |
|
@@ -351,24 +366,27 @@ |
|
// Retrieve the contents of the shared file. |
$('#editor').trumbowyg('disable'); |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
$.get('session.php').then((token) => { |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: nick, |
action: 'LOAD', |
token: token |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
|
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
}); |
|
@@ -381,23 +399,26 @@ |
|
// Retrieve the contents of the shared file. |
$('#editor').trumbowyg('disable'); |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: fingerprint, |
action: 'LOAD' |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
$.get('session.php').then((token) => { |
$.post('text.php', |
{ |
timestamp: window.performance.now(), |
fingerprint: fingerprint, |
action: 'LOAD', |
token: token |
}).done((data) => {; |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
if(fingerprint == nick) |
$('#home-icon').addClass("text-success").removeClass("text-danger"); |
else |
$('#home-icon').addClass("text-danger").removeClass("text-success"); |
}).fail(() => { |
$('#trumbowyg').trumbowyg('enable'); |
$('#trumbowyg').show(); |
}); |
}); |
}); |
}); |