Fixed error in editing first time saved

This commit is contained in:
Hamid Samak
2016-03-24 16:12:52 +04:30
parent 07c4ba3274
commit 76d965b797
+11 -1
View File
@@ -301,13 +301,18 @@ function openFile(element) {
}
function saveFile() {
var newFile;
var editor = id("editor");
var file = editor.getAttribute("data-file");
editor.innerHTML = editor.innerHTML.replace(/<br(\s*)\/*>/ig, "\n");
if (file.length < 1)
if (file.length < 1) {
newFile = true;
file = prompt("Please enter file name with full path", "new-file.php");
} else
newFile = false;
if (file != null && file.length > 0) {
var xhttp = new XMLHttpRequest();
@@ -317,6 +322,11 @@ function saveFile() {
id("save").setAttribute("disabled", "");
reloadFiles();
if (newFile == true) {
id("status").innerHTML = file;
editor.setAttribute("data-file", file);
}
}
}
xhttp.open("POST", "<?=$_SERVER['PHP_SELF']?>", true);