Browse Source

Fixes #9: handle errors correctly, fix scss file name

Alex Dima 9 years ago
parent
commit
4e34ca8bdf
2 changed files with 10 additions and 1 deletions
  1. 10 1
      website/index/index.js
  2. 0 0
      website/index/samples/sample.scss.txt

+ 10 - 1
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('<p class="alert alert-error">Failed to load ' + mode.name + ' sample</p>');
+			$('#editor').empty();
+			$('#editor').append('<p class="alert alert-error">Failed to load ' + mode.modeId + ' sample</p>');
 		}
 	}).done(function (data) {
 		if (!editor) {
+			$('#editor').empty();
 			editor = monaco.editor.create(document.getElementById('editor'), {
 				model: null,
 			});

+ 0 - 0
website/index/samples/sample.sass.txt → website/index/samples/sample.scss.txt