From 4e34ca8bdfeac768dd377f02c5c20d370d0d8a5b Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 21 Jun 2016 01:08:02 +0200 Subject: [PATCH] Fixes #9: handle errors correctly, fix scss file name --- website/index/index.js | 11 ++++++++++- .../samples/{sample.sass.txt => sample.scss.txt} | 0 2 files changed, 10 insertions(+), 1 deletion(-) rename website/index/samples/{sample.sass.txt => sample.scss.txt} (100%) diff --git a/website/index/index.js b/website/index/index.js index 32fd7955..6533f2d1 100644 --- a/website/index/index.js +++ b/website/index/index.js @@ -66,11 +66,20 @@ function loadSample(mode) { $('.loading.editor').show(); }, error: function () { + if (editor) { + if (editor.getModel()) { + editor.getModel().dispose(); + } + editor.dispose(); + editor = null; + } $('.loading.editor').fadeOut({ duration: 200 }); - $('#editor').append('

Failed to load ' + mode.name + ' sample

'); + $('#editor').empty(); + $('#editor').append('

Failed to load ' + mode.modeId + ' sample

'); } }).done(function (data) { if (!editor) { + $('#editor').empty(); editor = monaco.editor.create(document.getElementById('editor'), { model: null, }); diff --git a/website/index/samples/sample.sass.txt b/website/index/samples/sample.scss.txt similarity index 100% rename from website/index/samples/sample.sass.txt rename to website/index/samples/sample.scss.txt