scratch
/text.html |
@@ -81,7 +81,7 @@ |
</div> |
</form> |
</div> |
<div class="panel-body" id="editorpanel"> |
<div class="panel-body" id="editorpanel"> |
<div id="trumbowyg"> |
</div> |
</div> |
@@ -99,8 +99,6 @@ |
<script src="bower_components/jquery/dist/jquery.min.js"></script> |
<!-- BootStrap --> |
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
<!-- Velocity --> |
<script src="bower_components/velocity/velocity.min.js"></script> |
|
<!-- Trumbowyg --> |
<script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
@@ -170,37 +168,15 @@ |
else |
$('#home-icon').addClass("text-danger"); |
|
var autoSaveTimeoutID; |
|
function saveTextFile() { |
$.post('text.php', { |
data: $('#trumbowyg').trumbowyg('html'), |
fingerprint: result, |
action: 'SAVE' |
}).done((data) => { |
|
// 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); |
action: 'SAVE', |
timeout: 0 |
}); |
} |
var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
// Load the editor. |
$('#trumbowyg').trumbowyg({ |
@@ -211,9 +187,8 @@ |
// Clear the value of the URL box because the URL will have changed. |
$('#URL').val(''); |
// Reschedule saving of the file. |
if(autoSaveTimeoutID) |
window.clearTimeout(autoSaveTimeoutID); |
autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000); |
window.clearTimeout(autoSaveTimeoutID); |
autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
}); |
|
// Retrieve the contents of the shared file. |