Fix saving of empty files (#612)

When you have a file without content, for example when you cleared you were unable to save it because of an incorrect if-statement. This is the fix for that problem.
This commit is contained in:
Agent Smith 2021-08-06 04:13:22 +02:00 committed by GitHub
parent 9ee41b14d6
commit 09e2b9a107
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3804,8 +3804,8 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
//Save file
function edit_save(e, t) {
var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value;
if (n) {
if(true){
if (typeof n !== 'undefined' && n !== null) {
if (true) {
var data = {ajax: true, content: n, type: 'save'};
$.ajax({
@ -3819,9 +3819,7 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
failure: function(mes) {toast("Error: try again");},
error: function(mes) {toast(`<p style="background-color:red">${mes.responseText}</p>`);}
});
}
else{
} else {
var a = document.createElement("form");
a.setAttribute("method", "POST"), a.setAttribute("action", "");
var o = document.createElement("textarea");