Skip to content

Commit 8c7351e

Browse files
committed
1.0.89
1 parent d8cdb3c commit 8c7351e

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/js/handlers/editors.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ var EditorsHandler = function () {
4848

4949
$.get('/src/settings/ace.defaults.json', function (data) {
5050

51+
data = that.isJsonString(data) ? JSON.parse(data) : data;
52+
5153
that.defaultTheme = data.theme;
5254
that.defaultFont = data.fontFamily;
5355
that.defaultFontSize = data.fontSize;
@@ -385,6 +387,7 @@ var EditorsHandler = function () {
385387
idx = parseInt(idx);
386388

387389
this.getAllEditorModes().then(function (data) {
390+
data = that.isJsonString(data) ? JSON.parse(data) : data;
388391
var ext = that._getTabFileExtension(idx);
389392
if (typeof ext === typeof undefined) {
390393
deferred.resolve(JSON.stringify({
@@ -409,6 +412,7 @@ var EditorsHandler = function () {
409412
var that = this;
410413

411414
this.getAllEditorModes().done(function (data) {
415+
data = that.isJsonString(data) ? JSON.parse(data) : data;
412416
that.getAddTabDropDownContainer().html('');
413417
$.each(data, function (i, v) {
414418
that.getAddTabDropDownContainer().append(
@@ -569,6 +573,15 @@ var EditorsHandler = function () {
569573
);
570574
};
571575

576+
this.isJsonString = function (str) {
577+
try {
578+
JSON.parse(str);
579+
} catch (e) {
580+
return false;
581+
}
582+
return true;
583+
};
584+
572585
this.startup = function () {
573586

574587
var that = this;

src/js/handlers/ide.settings.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ var IdeSettingsHandler = function () {
201201

202202
if (key === 'theme') {
203203
$.get('/src/settings/ace.themes.json', function (data) {
204-
$.each(JSON.parse(data), function (i1, v1) {
204+
data = that.Editors.isJsonString(data) ? JSON.parse(data) : data;
205+
$.each(data, function (i1, v1) {
205206
themeOps += '<optgroup label="' + i1 + '">';
206207
$.each(v1, function (i2, v2) {
207208
themeOps += '<option value="' + i2 + '">' + v2 + '</option>';
@@ -214,7 +215,8 @@ var IdeSettingsHandler = function () {
214215
}
215216
else if (key === 'fontSize') {
216217
$.get('/src/settings/ace.font.sizes.json', function (data) {
217-
$.each(JSON.parse(data), function (i1, v1) {
218+
data = that.Editors.isJsonString(data) ? JSON.parse(data) : data;
219+
$.each(data, function (i1, v1) {
218220
fontSizeOpts += '<option value="' + i1 + '">' + v1 + '</option>';
219221
});
220222
$el.html(fontSizeOpts);
@@ -223,7 +225,8 @@ var IdeSettingsHandler = function () {
223225
}
224226
else if (key === 'fontFamily') {
225227
$.get('/src/settings/ace.fonts.json', function (data) {
226-
$.each(JSON.parse(data), function (i1, v1) {
228+
data = that.Editors.isJsonString(data) ? JSON.parse(data) : data;
229+
$.each(data, function (i1, v1) {
227230
fontOpts += '<optgroup label="' + i1 + '">';
228231
$.each(v1, function (i2, v2) {
229232
fontOpts += '<option value="' + i2 + '">' + v2 + '</option>';

src/js/handlers/sidebar.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var SidebarHandler = function () {
44
this.Editors = undefined;
55
this.Files = undefined;
66

7-
this.bootstrapMenu = null;
87
this.dirEntry = null;
98
this.isInitialised = false;
109

@@ -51,7 +50,7 @@ var SidebarHandler = function () {
5150
});
5251
};
5352

54-
this.bootstrapMenu = new BootstrapMenu('.node-sidebar', {
53+
new BootstrapMenu('.node-sidebar', {
5554
fetchElementData: function ($el) {
5655
return $el
5756
},
@@ -248,7 +247,7 @@ var SidebarHandler = function () {
248247
};
249248

250249
that.Editors.getAllEditorModes().then(function (data) {
251-
modes = data;
250+
modes = that.Editors.isJsonString(data) ? JSON.parse(data) : data;
252251
buildTreeViewJson(dirEntry, function (treeViewJson) {
253252
that._initTreeView(treeViewJson, dirEntry.name);
254253
that.Editors.clearAllOpenTabs();

0 commit comments

Comments
 (0)