scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 76  →  ?path2? @ 77
/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,6 +99,8 @@
<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>
@@ -168,15 +170,37 @@
else
$('#home-icon').addClass("text-danger");
var autoSaveTimeoutID;
function saveTextFile() {
$.post('text.php', {
data: $('#trumbowyg').trumbowyg('html'),
fingerprint: result,
action: 'SAVE',
timeout: 0
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);
});
}
var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250);
// Load the editor.
$('#trumbowyg').trumbowyg({
@@ -187,8 +211,9 @@
// Clear the value of the URL box because the URL will have changed.
$('#URL').val('');
// Reschedule saving of the file.
window.clearTimeout(autoSaveTimeoutID);
autoSaveTimeoutID = window.setTimeout(saveTextFile, 250);
if(autoSaveTimeoutID)
window.clearTimeout(autoSaveTimeoutID);
autoSaveTimeoutID = window.setTimeout(saveTextFile, 1000);
});
// Retrieve the contents of the shared file.