From 5de9066fca72522193e62ad56b21308711b04cae Mon Sep 17 00:00:00 2001 From: Kevin Nadro Date: Mon, 4 Jul 2016 15:13:58 -0700 Subject: [PATCH] fixed reloading of the algorithm - changed the save/load of the algorithm for it correctly returns to the example after closing the generate overlay --- js/create/index.js | 30 ++++++++++++++++++++---------- js/index.js | 1 - 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/js/create/index.js b/js/create/index.js index e45f5f6..bc5552c 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 746302c..5c1b53e 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); -- GitLab