diff --git a/js/create/index.js b/js/create/index.js index e45f5f6a0462d345b1773e41ce77bc6103758018..bc5552c038754dd6266c53211f286e310844b30b 100644 --- a/js/create/index.js +++ b/js/create/index.js @@ -3,29 +3,39 @@ const modules = require('../module'); const array2d = require('./array2d'); const util = require('./util'); +const Server = require('../server'); +const DOM = require('../dom'); -const closeCreate = (modules) => { +const { + getPath +} = require('../server/helpers'); + +const closeCreate = () => { const $btnClose = $('#btn_close'); $btnClose.click(() => { $('.sandbox_container').remove(); util.clearModules(); - restoreModules(modules); + reloadAlgorithm(); }); }; -const restoreModules = (modules) => { - for (var i = 0; i < modules.length; i++) { - $('.module_container').append(modules[i]); - } -}; +const reloadAlgorithm = () => { + const { + category, + algorithm, + file + } = getPath(); -const saveModules = () => { - return $('.module_wrapper') + Server.loadAlgorithm(category, algorithm).then((data) => { + DOM.showAlgorithm(category, algorithm, data); + }); }; + + const init = () => { - var moduleWrappers = saveModules(); + var check = $('.sandbox_container'); if(!check.length){ util.clearModules(); diff --git a/js/index.js b/js/index.js index 746302c4f98b73206bffd627d6c6511b54c9b93c..5c1b53e8b74f1e8ce5c81d62d2f435846bf6b5be 100644 --- a/js/index.js +++ b/js/index.js @@ -32,7 +32,6 @@ RSVP.on('error', function (reason) { }); $(() => { - // initialize the application and attach in to the instance module const appConstructor = new AppConstructor(); extend(true, app, appConstructor);