Browse Source

improve browser compability

moononournation 7 years ago
parent
commit
8cb560aab9
2 changed files with 6 additions and 9 deletions
  1. BIN
      bin/index.js.gz
  2. 6 9
      src/index.js

BIN
bin/index.js.gz


+ 6 - 9
src/index.js

@@ -111,7 +111,12 @@ function handleSaveCallback() {
         params = "action=compile&filename=" + savingFilename;
         var xhr = new XMLHttpRequest();
         xhr.open("POST", "file-api.lc", true);
-        xhr.onreadystatechange = handleCompileCallback;
+        xhr.onreadystatechange = function() {
+          if (isXhrSuccess(xhr)) {
+            setLocalStatus("");
+          }
+          setRemoteStatus(xhr.responseText);
+        };
         xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
         setLocalStatus("<span class=\"icon icon-loading\"></span> Compiling file: " + savingFilename);
         xhr.send(params);
@@ -124,13 +129,6 @@ function handleSaveCallback() {
   }
 }
 
-function handleCompileCallback() {
-  if (isXhrSuccess(xhr)) {
-    setLocalStatus("");
-  }
-  setRemoteStatus(xhr.responseText);
-}
-
 function handleFileCallback(xhr) {
   setRemoteStatus(xhr.responseText);
   if (isXhrSuccess(xhr)) {
@@ -139,7 +137,6 @@ function handleFileCallback(xhr) {
   }
 }
 
-
 function loadFile() {
   var filename = curFileItem.id;
   var params = "action=load&filename=" + filename;