Browse Source

Fix recognization of local file

Gerald 9 years ago
parent
commit
e2b1d40bf5
2 changed files with 5 additions and 11 deletions
  1. 0 2
      src/options/editor.js
  2. 5 9
      src/options/views/confirm.js

+ 0 - 2
src/options/editor.js

@@ -75,8 +75,6 @@
         lineNumbers: true,
         mode: 'javascript',
         lineWrapping: true,
-        indentUnit: 4,
-        indentWithTabs: true,
         styleActiveLine: true,
         foldGutter: true,
         gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],

+ 5 - 9
src/options/views/confirm.js

@@ -37,11 +37,10 @@ var ConfirmView = BaseView.extend({
       require: {},
       resources: {},
       dependencyOK: false,
-      isLocal: false,
+      isLocal: /^file:\/\/\//.test(_this.url),
     };
-    return _this.getScript(_this.url).then(function (res) {
-      _this.data.isLocal = !res.status;
-      _this.data.code = res.responseText;
+    return _this.getScript(_this.url).then(function (text) {
+      _this.data.code = text;
       _this.loadedEditor.then(function () {
         _this.editor.setValueAndFocus(_this.data.code);
       });
@@ -143,17 +142,14 @@ var ConfirmView = BaseView.extend({
       data: url,
     })
     .then(function (text) {
-      return text ? {
-        status: 200,
-        responseText: text,
-      } : Promise.reject();
+      return text || Promise.reject();
     })
     .catch(function () {
       return new Promise(function (resolve, reject) {
         var xhr = new XMLHttpRequest;
         xhr.open('GET', url, true);
         xhr.onload = function () {
-          resolve(this);
+          resolve(this.responseText);
         };
         xhr.onerror = function () {
           _this.showMessage(_.i18n('msgErrorLoadingData'));