diff --git a/js/script.js b/js/script.js index 4af6c2c5..01a4e0b9 100644 --- a/js/script.js +++ b/js/script.js @@ -1,6 +1,9 @@ -$.ajaxSetup({cache: false, dataType: "text"}); +$.ajaxSetup({ + cache: false, + dataType: "text" +}); -$(document).on('click', 'a', function (e) { +$(document).on('click', 'a', function(e) { e.preventDefault(); if (!window.open($(this).attr('href'), '_blank')) { @@ -10,19 +13,21 @@ $(document).on('click', 'a', function (e) { var tm = new TracerManager(); -$('#btn_interval input').on('change', function () { +$('#btn_interval input').on('change', function() { tm.interval = Number.parseFloat($(this).val() * 1000); showInfoToast('Tracing interval has been set to ' + tm.interval / 1000 + ' second(s).'); }); var $module_container = $('.module_container'); ace.require("ace/ext/language_tools"); -var initEditor = function (id) { +var initEditor = function(id) { var editor = ace.edit(id); editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true, - enableLiveAutocompletion: true + enableLiveAutocompletion: true, + fontFamily: "Source Code Pro", + fontSize: "10pt" }); editor.setTheme("ace/theme/tomorrow_night_eighties"); editor.session.setMode("ace/mode/javascript"); @@ -32,37 +37,36 @@ var initEditor = function (id) { var dataEditor = initEditor('data'); var codeEditor = initEditor('code'); var lastFile = null; -dataEditor.on('change', function () { +dataEditor.on('change', function() { var data = dataEditor.getValue(); if (lastFile) cachedFile[lastFile].data = data; try { tm.deallocateAll(); eval(data); - } catch (err) { - } finally { + } catch (err) {} finally { tm.visualize(); tm.removeUnallocated(); } }); -codeEditor.on('change', function () { +codeEditor.on('change', function() { var code = codeEditor.getValue(); if (lastFile) cachedFile[lastFile].code = code; }); var cachedFile = {}; var loading = false; -var isScratchPaper = function (category, algorithm) { +var isScratchPaper = function(category, algorithm) { return category == null && algorithm == 'scratch_paper'; }; -var getAlgorithmDir = function (category, algorithm) { +var getAlgorithmDir = function(category, algorithm) { if (isScratchPaper(category, algorithm)) return './algorithm/scratch_paper/'; return './algorithm/' + category + '/' + algorithm + '/'; }; -var getFileDir = function (category, algorithm, file) { +var getFileDir = function(category, algorithm, file) { if (isScratchPaper(category, algorithm)) return './algorithm/scratch_paper/'; return './algorithm/' + category + '/' + algorithm + '/' + file + '/'; }; -var loadFile = function (category, algorithm, file, explanation) { +var loadFile = function(category, algorithm, file, explanation) { if (checkLoading()) return; $('#explanation').html(explanation); @@ -76,15 +80,15 @@ var loadFile = function (category, algorithm, file, explanation) { cachedFile[dir] = {}; dataEditor.setValue(''); codeEditor.setValue(''); - var onFail = function (jqXHR, textStatus, errorThrown) { + var onFail = function(jqXHR, textStatus, errorThrown) { loading = false; alert("AJAX call failed: " + textStatus + ", " + errorThrown); }; - $.get(dir + 'data.js', function (data) { + $.get(dir + 'data.js', function(data) { cachedFile[dir].data = data; dataEditor.setValue(data, -1); - $.get(dir + 'code.js', function (code) { + $.get(dir + 'code.js', function(code) { cachedFile[dir].code = code; codeEditor.setValue(code, -1); loading = false; @@ -92,14 +96,14 @@ var loadFile = function (category, algorithm, file, explanation) { }).fail(onFail); } }; -var checkLoading = function () { +var checkLoading = function() { if (loading) { showErrorToast('Wait until it completes loading of previous file.'); return true; } return false; }; -var showDescription = function (data) { +var showDescription = function(data) { var $container = $('#tab_desc > .wrapper'); $container.empty(); for (var key in data) { @@ -110,7 +114,7 @@ var showDescription = function (data) { } else if (Array.isArray(value)) { var $ul = $('