From 8b8e477880fb0cea68025e02ddb58db7952b15fd Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 1 Oct 2016 11:00:30 -0400 Subject: [PATCH] Clean up stuff using jQuery.getScript --- main.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 0744252..9f6458f 100644 --- a/main.js +++ b/main.js @@ -13,12 +13,8 @@ $.get({ url: `https://raw.githubusercontent.com/${repo}/${filePath}`, success: (code) => { let lang = getLanguageByExtension(getFileExtension()); - $.get({ - url: `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, - success: (data) => { - eval(data); - setup(code, lang.mime); - } + $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, () => { + setup(code, lang.mime); }); } }); @@ -247,13 +243,9 @@ function markInvalid(pos) { } function setLanguage(lang) { - $.get({ - url: `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, - success: (data) => { - eval(data); - editor.setOption("mode", lang.mime); - console.log(`Changed language to ${lang.mime}`); - } + $.getScript(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.19.0/mode/${lang.file}/${lang.file}.min.js`, () => { + editor.setOption("mode", lang.mime); + console.log(`Changed language to ${lang.mime}`); }); }