///
Failed to load ' + mode.modeId + ' sample
'); } }).done(function (data) { if (!editor) { $('#editor').empty(); editor = monaco.editor.create(document.getElementById('editor'), { model: null, }); } var oldModel = editor.getModel(); var newModel = monaco.editor.createModel(data, mode.modeId); editor.setModel(newModel); if (oldModel) { oldModel.dispose(); } $('.loading.editor').fadeOut({ duration: 300 }); }); } function loadDiffSample() { var onError = function() { $('.loading.diff-editor').fadeOut({ duration: 200 }); $('#diff-editor').append('Failed to load diff editor sample
'); }; $('.loading.diff-editor').show(); var lhsData = null, rhsData = null, jsMode = null; $.ajax({ type: 'GET', url: 'index/samples/diff.lhs.txt', dataType: 'text', error: onError }).done(function (data) { lhsData = data; onProgress(); }); $.ajax({ type: 'GET', url: 'index/samples/diff.rhs.txt', dataType: 'text', error: onError }).done(function (data) { rhsData = data; onProgress(); }); function onProgress() { if (lhsData && rhsData) { diffEditor = monaco.editor.createDiffEditor(document.getElementById('diff-editor'), { enableSplitViewResizing: false }); var lhsModel = monaco.editor.createModel(lhsData, 'text/javascript'); var rhsModel = monaco.editor.createModel(rhsData, 'text/javascript'); diffEditor.setModel({ original: lhsModel, modified: rhsModel }); $('.loading.diff-editor').fadeOut({ duration: 300 }); } } } function changeTheme(theme) { var newTheme = (theme === 1 ? 'vs-dark' : ( theme === 0 ? 'vs' : 'hc-black' )); if (editor) { editor.updateOptions({ 'theme' : newTheme }); } if (diffEditor) { diffEditor.updateOptions({ 'theme': newTheme }); } }