mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
load file to edit async to prevent browser page caching issues
This commit is contained in:
parent
83ee577a14
commit
21299e3abc
1 changed files with 33 additions and 27 deletions
|
@ -92,7 +92,7 @@
|
|||
|
||||
<div class="row editor">
|
||||
<div class="col col-100">
|
||||
<div id="editor"><%==encoding_fix(@file_data) %></div>
|
||||
<div id="editor"><h3>Loading...</h3></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -154,35 +154,41 @@
|
|||
|
||||
var editor = {}
|
||||
|
||||
$(document).ready(function() {
|
||||
editor = ace.edit("editor")
|
||||
setTheme()
|
||||
<% if @ace_mode %>
|
||||
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
|
||||
<% end %>
|
||||
editor.getSession().setTabSize(2)
|
||||
editor.getSession().setUseWrapMode(true)
|
||||
editor.setFontSize(14)
|
||||
editor.setShowPrintMargin(false)
|
||||
editor.setOptions({
|
||||
maxLines: Infinity,
|
||||
autoScrollEditorIntoView: true
|
||||
})
|
||||
$.get('/site_files/download/<%= @filename %>', function(resp) {
|
||||
$(document).ready(function() {
|
||||
$.get('/site_files/download/<%= @filename %>', function(resp) {
|
||||
editor = ace.edit("editor")
|
||||
setTheme()
|
||||
<% if @ace_mode %>
|
||||
editor.getSession().setMode("ace/mode/<%= @ace_mode %>")
|
||||
<% end %>
|
||||
editor.getSession().setTabSize(2)
|
||||
editor.getSession().setUseWrapMode(true)
|
||||
editor.setFontSize(14)
|
||||
editor.setShowPrintMargin(false)
|
||||
editor.setOptions({
|
||||
maxLines: Infinity,
|
||||
autoScrollEditorIntoView: true
|
||||
})
|
||||
|
||||
// Disable autocomplete
|
||||
editor.setBehavioursEnabled(false)
|
||||
// Disable autocomplete
|
||||
editor.setBehavioursEnabled(false)
|
||||
|
||||
editor.on('change', function(obj) {
|
||||
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
|
||||
unsavedChanges = true
|
||||
})
|
||||
editor.setValue(resp, -1)
|
||||
|
||||
editor.commands.addCommand({
|
||||
name: 'saveCommand',
|
||||
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
||||
exec: function(editor) {
|
||||
saveTextFile(false)
|
||||
}
|
||||
editor.on('change', function(obj) {
|
||||
$('a#saveButton,a#saveAndExitButton').css('opacity', 1)
|
||||
unsavedChanges = true
|
||||
})
|
||||
|
||||
editor.commands.addCommand({
|
||||
name: 'saveCommand',
|
||||
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
||||
exec: function(editor) {
|
||||
saveTextFile(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue