redoing the logic for the modules settings and storage
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 12 Jun 2018 18:26:57 +0000 (14:26 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 12 Jun 2018 18:26:57 +0000 (14:26 -0400)
30 files changed:
dev/app.scss
dev/custom/action-items/action-items.js [new file with mode: 0644]
dev/custom/action-items/action-items.js.off [deleted file]
dev/custom/glm-member-db-events/_glm-member-db-events.scss [new file with mode: 0644]
dev/custom/glm-member-db-events/events-feed.php [new file with mode: 0644]
dev/custom/glm-member-db-events/functions/glm-member-db-events.php [new file with mode: 0644]
dev/custom/glm-member-db-events/glm-member-db-events.js [new file with mode: 0644]
dev/custom/glm-member-db/_glm-member-db.scss [new file with mode: 0644]
dev/custom/glm-member-db/functions/glm-member-db.php [new file with mode: 0644]
dev/custom/glm-member-db/glm-member-db.js [new file with mode: 0644]
dev/custom/glm-member-db/glm-members-only-login-form.php [new file with mode: 0644]
dev/custom/glm-member-db/glm-members-only-lostpass-form.php [new file with mode: 0644]
dev/custom/glm-member-db/glm-members-only-top-bar.php [new file with mode: 0644]
dev/custom/glma/_glm-member-db-events.scss [deleted file]
dev/custom/glma/_glm-member-db.scss [deleted file]
dev/custom/glma/events-feed.php [deleted file]
dev/custom/glma/functions/glma.php [deleted file]
dev/custom/glma/glm-members-only-login-form.php [deleted file]
dev/custom/glma/glm-members-only-lostpass-form.php [deleted file]
dev/custom/glma/glm-members-only-top-bar.php [deleted file]
dev/custom/nextgen/nextgen.js [new file with mode: 0644]
dev/custom/svg-map/functions/svg-map.php [new file with mode: 0644]
dev/custom/weather/functions/weather.php [new file with mode: 0644]
dev/custom/weather/weather.js [new file with mode: 0644]
dev/custom/woocommerce/woocommerce.js [new file with mode: 0644]
package-lock.json
package.json
setup/index.html
setup/renderer.js
setup/setup.css

index c447ceb..06ac902 100644 (file)
@@ -19,7 +19,7 @@
 @import "custom/weather/weather";
 @import "custom/nextgen/nextgen";
 @import "custom/glma/glm-member-db";
-//@import "custom/glma/glm-member-db-events";
+@import "custom/glma/glm-member-db-events";
 @import "custom/blocks/glm-blocks";
 @import "custom/action-items/action-items";
 @import "custom/svg-map/svg-map";
diff --git a/dev/custom/action-items/action-items.js b/dev/custom/action-items/action-items.js
new file mode 100644 (file)
index 0000000..c3e3049
--- /dev/null
@@ -0,0 +1,3 @@
+$(function() {
+    console.log( "action items!" );
+});
\ No newline at end of file
diff --git a/dev/custom/action-items/action-items.js.off b/dev/custom/action-items/action-items.js.off
deleted file mode 100644 (file)
index c3e3049..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-$(function() {
-    console.log( "action items!" );
-});
\ No newline at end of file
diff --git a/dev/custom/glm-member-db-events/_glm-member-db-events.scss b/dev/custom/glm-member-db-events/_glm-member-db-events.scss
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db-events/events-feed.php b/dev/custom/glm-member-db-events/events-feed.php
new file mode 100644 (file)
index 0000000..8889e18
--- /dev/null
@@ -0,0 +1,6 @@
+<div id="events-sidebar" class="">
+    <h1 class="events-sidebar-title" >Events Calendar</h1>
+    <?php echo do_shortcode("[glm-members-event-list template='eventsFrontPage.html' limit=3]"); ?>
+    <?php ?>
+    <a class="button" id="calendar-link" href="<?php echo get_permalink();?>">View All Events</a>
+</div>
\ No newline at end of file
diff --git a/dev/custom/glm-member-db-events/functions/glm-member-db-events.php b/dev/custom/glm-member-db-events/functions/glm-member-db-events.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db-events/glm-member-db-events.js b/dev/custom/glm-member-db-events/glm-member-db-events.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db/_glm-member-db.scss b/dev/custom/glm-member-db/_glm-member-db.scss
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db/functions/glm-member-db.php b/dev/custom/glm-member-db/functions/glm-member-db.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db/glm-member-db.js b/dev/custom/glm-member-db/glm-member-db.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/glm-member-db/glm-members-only-login-form.php b/dev/custom/glm-member-db/glm-members-only-login-form.php
new file mode 100644 (file)
index 0000000..d44d0ca
--- /dev/null
@@ -0,0 +1,45 @@
+<div class="wp_login_error">
+    <p id="glm-member-login-notification">
+        <?php if( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) { ?>
+            The information you entered is incorrect. Please try again.
+        <?php }
+            else if( isset( $_GET['login'] ) && $_GET['login'] == 'empty' ) { ?>
+            Please enter both username and password.
+        <?php } else { ?>
+            <?php $glmAssociateConfig = apply_filters('glm_associate_config', null);
+                $supportEmail = $glmAssociateConfig['settings']['members_only_support_email'];
+                $supportPhone = $glmAssociateConfig['settings']['members_only_support_phone'];
+                $glmTerm = $glmAssociateConfig['terms']['term_member'];
+            ?>
+            Please log in with your <?php echo $glmTerm; ?> username and password.
+
+            <?php if ($supportEmail || $supportPhone) {
+                echo "<br>If you need assistance, ";
+                if ($supportEmail) {
+                    echo "email (".$supportEmail.")";
+                    if ($supportPhone) {
+                        echo " or ";
+                    }
+                }
+                if ($supportPhone) {
+                    echo "call (".$supportPhone.")";
+                }
+            }
+            ?>
+        <?php } ?>
+    </p>
+    </div>
+    <div id='glm-member-login-form'>
+    <?php
+    update_option('glm_members_database_frontend_login_request', 'true');
+    $args = array(
+        'echo'    => false,
+        'form_id' => 'glm_login_form'
+    );
+    $loginForm = wp_login_form($args);
+    $captcha   = apply_filters('cptch_display', '', 'glm_login_form');
+    $form      = str_replace( '<p class="login-remember">', $captcha . '<p class="login-remember">', $loginForm );
+    echo $form;
+    ?>
+</div>
+<?php get_template_part('parts/glm-members-only-lostpass-form'); ?>
diff --git a/dev/custom/glm-member-db/glm-members-only-lostpass-form.php b/dev/custom/glm-member-db/glm-members-only-lostpass-form.php
new file mode 100644 (file)
index 0000000..6bde7c6
--- /dev/null
@@ -0,0 +1,24 @@
+<a id="glm-member-password-lost-link" title="Lost Password">Lost Password?</a>
+    <div id="glm-member-password-lost-form">
+
+        <p>
+            <?php
+                _e(
+                    "Enter your email address and we'll send you a link you can use to pick a new password.",
+                    'personalize_login'
+                );
+            ?>
+        </p>
+
+        <form id="lostpasswordform" action="<?php echo wp_lostpassword_url(); ?>" method="post">
+            <p class="form-row">
+                <label for="user_login"><?php _e( 'Email', 'personalize-login' ); ?>
+                <input type="text" name="user_login" id="user_login">
+            </p>
+
+            <p class="lostpassword-submit">
+                <input type="submit" name="submit" class="lostpassword-button"
+                       value="<?php _e( 'Reset Password', 'personalize-login' ); ?>"/>
+            </p>
+        </form>
+    </div>
\ No newline at end of file
diff --git a/dev/custom/glm-member-db/glm-members-only-top-bar.php b/dev/custom/glm-member-db/glm-members-only-top-bar.php
new file mode 100644 (file)
index 0000000..6647ba4
--- /dev/null
@@ -0,0 +1,16 @@
+<div id="glm-member-front-header" class="small-12 columns">
+    <?php if(function_exists('bcn_display') && !is_front_page()) {
+         echo "<div class='breadcrumbs small-12 medium-6 columns'>"; 
+         echo '<span class="st_sharethis" st_title="'. get_the_title().'" st_url="'. get_the_permalink() .'"></span>'; 
+         bcn_display();
+         echo "</div>";
+    } ?>
+    <div class="small-12 medium-6 columns members-only-buttons">
+        <a class='button glm-button' href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
+        <?php if (current_user_can("glm_members_member")) { ?>
+            <?php $glmAssociateTerms = apply_filters('glm_associate_terms', "");?>
+            <?php apply_filters('glm_associate_terms', $glmAssociateTerms);?>
+            <a class='button glm-button' href='<?php echo get_admin_url(); ?>'>Enter <?php echo $glmAssociateTerms['term_member_cap']; ?> Admin Area</a> 
+        <?php } ?>
+     </div>
+</div>
\ No newline at end of file
diff --git a/dev/custom/glma/_glm-member-db-events.scss b/dev/custom/glma/_glm-member-db-events.scss
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dev/custom/glma/_glm-member-db.scss b/dev/custom/glma/_glm-member-db.scss
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dev/custom/glma/events-feed.php b/dev/custom/glma/events-feed.php
deleted file mode 100644 (file)
index 8889e18..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<div id="events-sidebar" class="">
-    <h1 class="events-sidebar-title" >Events Calendar</h1>
-    <?php echo do_shortcode("[glm-members-event-list template='eventsFrontPage.html' limit=3]"); ?>
-    <?php ?>
-    <a class="button" id="calendar-link" href="<?php echo get_permalink();?>">View All Events</a>
-</div>
\ No newline at end of file
diff --git a/dev/custom/glma/functions/glma.php b/dev/custom/glma/functions/glma.php
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dev/custom/glma/glm-members-only-login-form.php b/dev/custom/glma/glm-members-only-login-form.php
deleted file mode 100644 (file)
index d44d0ca..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<div class="wp_login_error">
-    <p id="glm-member-login-notification">
-        <?php if( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) { ?>
-            The information you entered is incorrect. Please try again.
-        <?php }
-            else if( isset( $_GET['login'] ) && $_GET['login'] == 'empty' ) { ?>
-            Please enter both username and password.
-        <?php } else { ?>
-            <?php $glmAssociateConfig = apply_filters('glm_associate_config', null);
-                $supportEmail = $glmAssociateConfig['settings']['members_only_support_email'];
-                $supportPhone = $glmAssociateConfig['settings']['members_only_support_phone'];
-                $glmTerm = $glmAssociateConfig['terms']['term_member'];
-            ?>
-            Please log in with your <?php echo $glmTerm; ?> username and password.
-
-            <?php if ($supportEmail || $supportPhone) {
-                echo "<br>If you need assistance, ";
-                if ($supportEmail) {
-                    echo "email (".$supportEmail.")";
-                    if ($supportPhone) {
-                        echo " or ";
-                    }
-                }
-                if ($supportPhone) {
-                    echo "call (".$supportPhone.")";
-                }
-            }
-            ?>
-        <?php } ?>
-    </p>
-    </div>
-    <div id='glm-member-login-form'>
-    <?php
-    update_option('glm_members_database_frontend_login_request', 'true');
-    $args = array(
-        'echo'    => false,
-        'form_id' => 'glm_login_form'
-    );
-    $loginForm = wp_login_form($args);
-    $captcha   = apply_filters('cptch_display', '', 'glm_login_form');
-    $form      = str_replace( '<p class="login-remember">', $captcha . '<p class="login-remember">', $loginForm );
-    echo $form;
-    ?>
-</div>
-<?php get_template_part('parts/glm-members-only-lostpass-form'); ?>
diff --git a/dev/custom/glma/glm-members-only-lostpass-form.php b/dev/custom/glma/glm-members-only-lostpass-form.php
deleted file mode 100644 (file)
index 6bde7c6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<a id="glm-member-password-lost-link" title="Lost Password">Lost Password?</a>
-    <div id="glm-member-password-lost-form">
-
-        <p>
-            <?php
-                _e(
-                    "Enter your email address and we'll send you a link you can use to pick a new password.",
-                    'personalize_login'
-                );
-            ?>
-        </p>
-
-        <form id="lostpasswordform" action="<?php echo wp_lostpassword_url(); ?>" method="post">
-            <p class="form-row">
-                <label for="user_login"><?php _e( 'Email', 'personalize-login' ); ?>
-                <input type="text" name="user_login" id="user_login">
-            </p>
-
-            <p class="lostpassword-submit">
-                <input type="submit" name="submit" class="lostpassword-button"
-                       value="<?php _e( 'Reset Password', 'personalize-login' ); ?>"/>
-            </p>
-        </form>
-    </div>
\ No newline at end of file
diff --git a/dev/custom/glma/glm-members-only-top-bar.php b/dev/custom/glma/glm-members-only-top-bar.php
deleted file mode 100644 (file)
index 6647ba4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<div id="glm-member-front-header" class="small-12 columns">
-    <?php if(function_exists('bcn_display') && !is_front_page()) {
-         echo "<div class='breadcrumbs small-12 medium-6 columns'>"; 
-         echo '<span class="st_sharethis" st_title="'. get_the_title().'" st_url="'. get_the_permalink() .'"></span>'; 
-         bcn_display();
-         echo "</div>";
-    } ?>
-    <div class="small-12 medium-6 columns members-only-buttons">
-        <a class='button glm-button' href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
-        <?php if (current_user_can("glm_members_member")) { ?>
-            <?php $glmAssociateTerms = apply_filters('glm_associate_terms', "");?>
-            <?php apply_filters('glm_associate_terms', $glmAssociateTerms);?>
-            <a class='button glm-button' href='<?php echo get_admin_url(); ?>'>Enter <?php echo $glmAssociateTerms['term_member_cap']; ?> Admin Area</a> 
-        <?php } ?>
-     </div>
-</div>
\ No newline at end of file
diff --git a/dev/custom/nextgen/nextgen.js b/dev/custom/nextgen/nextgen.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/svg-map/functions/svg-map.php b/dev/custom/svg-map/functions/svg-map.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/weather/functions/weather.php b/dev/custom/weather/functions/weather.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/weather/weather.js b/dev/custom/weather/weather.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dev/custom/woocommerce/woocommerce.js b/dev/custom/woocommerce/woocommerce.js
new file mode 100644 (file)
index 0000000..e69de29
index 6e67150..5dfcea9 100644 (file)
     "balanced-match": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
-      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
-      "dev": true
+      "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
     },
     "base": {
       "version": "0.11.2",
       "version": "1.1.11",
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
       "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
-      "dev": true,
       "requires": {
         "balanced-match": "1.0.0",
         "concat-map": "0.0.1"
     "concat-map": {
       "version": "0.0.1",
       "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
-      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
-      "dev": true
+      "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
     },
     "concat-stream": {
       "version": "1.6.2",
       "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==",
       "dev": true
     },
+    "node-dir": {
+      "version": "0.1.17",
+      "resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.17.tgz",
+      "integrity": "sha1-X1Zl2TNRM1yqvvjxxVRRbPXx5OU=",
+      "requires": {
+        "minimatch": "3.0.4"
+      },
+      "dependencies": {
+        "minimatch": {
+          "version": "3.0.4",
+          "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+          "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+          "requires": {
+            "brace-expansion": "1.1.11"
+          }
+        }
+      }
+    },
     "node-gyp": {
       "version": "3.6.2",
       "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz",
index 175820f..9657015 100644 (file)
@@ -22,6 +22,7 @@
     "node-sass": "^3.8.0"
   },
   "dependencies": {
-    "merge-stream": "^1.0.1"
+    "merge-stream": "^1.0.1",
+    "node-dir": "^0.1.17"
   }
 }
index 071da17..6cd61ee 100644 (file)
@@ -11,7 +11,6 @@
 <body>
     <h3>GLM Origin Theme Setup</h3>
     <div id="module-list-container">
-        <ul id="module-list"></ul>
     </div>
     <script src="renderer.js"></script>
 </body>
index f33d4c9..259bfa7 100644 (file)
 const path          = require('path');
 const fs            = require('fs');
 const merge         = require('merge-stream');
-
+const dir           = require('node-dir');
+const appState      = {};
+// PHP Functions File Libraries index file
 var functionsFileReader = require('readline').createInterface({
     input: require('fs').createReadStream('dev/modules.php')
 });
-
+// Sass File Imports index file
 var lineReader = require('readline').createInterface({
     input: require('fs').createReadStream('dev/app.scss')
 });
-
+String.prototype.stringFromToken = function(position, token, lastToken = false){
+    if(lastToken && position === 'before'){
+        return this.substr(0, this.lastIndexOf(token))
+    }else if(lastToken && !postition === 'before'){
+        return this.substr(this.lastIndexOf(token) + 1);
+    }else {
+        if(position === 'before'){
+            return this.substr(0, this.indexOf(token))
+        }else{
+            return this.substr(this.indexOf(token)+1)
+        }
+    }
+}
 String.prototype.stripSlashes = function(){
     return this.replace(/\\(.)/mg, "$1");
 }
-
-// Display Active and In-Active Modules 
-let modName = '';
-function readLines(mode, state){
-    if(mode === 'parse'){
-        lineReader.on('line', function (line) {
-            parseModules(this, line);
-        });
-        // activate or deactivate the JS files for each module
-        functionsFileReader.on('line', function (line) {
-            parsePhpLibs(this, line)
-        });
-
-        // functionsFileReader.on('line', function (line) {
-        //     parseModules(this, line);
-        // });
-    }else if( mode === "edit"){
-        fs.readFile(state.path, 'utf8', function (err,data) {
-            var result;
-            if (err) {
-              return console.log(err);
-            }
-            if(state.active){
-                var newLine = state.line.substr(2);
-            }else{
-                var newLine = "//" + state.line;
-            }
-            result = data.replace(state.line, newLine);
-            state.line = newLine;
-            localStorage.setItem(state.name, JSON.stringify(state));
-
-            fs.writeFile(state.path, result, 'utf8', function (err) {
-               if (err) return console.log(err);
-            });
-        });
-    }  
+function setModules(modType,modName){
+    appState[modType] = modName;
+    return appState;
 }
-let modList = $("#module-list");
-function parseModules(reader,line){
-    let active = true;
-    if(!line.match(/[^ ]/) || line.startsWith('/*') || line.startsWith('<?php') || line.startsWith('?>')){
-        // nothing
-    }else{
-        if(line.startsWith('//')){
-            modName = line.substr(line.lastIndexOf('/') + 1);
-            modName = modName.replace(/[^\w\s\-]/gi, '')
-            active = false;
-        }else if(!line.startsWith('//')){
-            if(line.indexOf("/") > -1){
-                modName = line.substr(line.lastIndexOf('/') + 1);
-                modName = modName.replace(/[^\w\s\-]/gi, '')
-            }else if(line.indexOf(" ") > -1){
-                modName = line.match( /"(.*?)"/ )[1];
-            }
-            active = true;
-        }
-    
-        localStorage.setItem(modName, JSON.stringify({path: reader.input.path, line: line, modName: modName, active: active}))
-        $('<li />', {
-            class: `module-item module-active-${active}`,
-            id: `${modName}`,
-            text: `${modName}`
-        }).appendTo(modList)
-    }
+function storeModules(appState){
+    localStorage.setItem("app", JSON.stringify(appState));
 }
-// true is used for init parsing of theme modules, edit is to activate or de-activate modules
-// true is called initially when scanning the app.scss file for commented modules
-// edit is called when selectively activating and de-activating modules from the GUI
-// last param is the path to the file to be editted since we can't use the readLine Stream again (idk how yet)
-function scanModules(parse, edit, state){
-    if(parse) {
-        readLines("parse");
-    }else if(edit){
-        readLines("edit", state)
-    }
+function getModuleTypes(modules){
+    return Object.keys(modules)
 }
-
-scanModules(true, false, false);
-
-
-// On Click Set Mod State
-$(document).on("click", ".module-item", function(){
-    let _ = $(this);
-    let modName = _.attr("id");
-    let thisMod = JSON.parse(localStorage.getItem(modName))
-
-    let moduleLocation = `dev/${thisMod.line.split("import ").pop().replace(/[;'"]+/g, '')}`;
-    let state = {path: thisMod.path, line: thisMod.line, name: modName}
-    
-    if( _.hasClass("module-active-true") ){
-        state.active = false;
-        _.removeClass("module-active-true");
-        _.addClass("module-active-false");
-    }else if( _.hasClass("module-active-false") ){
-        state.active = true;
-        _.removeClass("module-active-false");
-        _.addClass("module-active-true");
+function getModules(){
+    return JSON.parse(localStorage.getItem("app"));
+}
+function getModuleByName(modName){
+    let mods = JSON.parse(localStorage.getItem("app")), newMods = [];
+    for(modType in mods){
+        newMods.push(getModulesByType(modType).filter(function(mod){
+            return mod.name == modName;
+        }))
     }
+    return newMods[0].concat(newMods[1])[0];
+}
 
-    scanModules(false, true , state)
-
-    // Activate or De-Activate JS Files
-    let jsFile = path.join(__dirname, `../${moduleLocation}.js`);
-    let newJsFile = jsFile+'.off';
-    fs.exists(jsFile, function(exists) {
-        if(exists){
-            fs.rename(jsFile, newJsFile, function(err){
-                if (err) throw err;
-            });
-        }
+// Returns an array of Modules
+function getModulesByType(moduleType){
+    let appState = JSON.parse(localStorage.getItem("app"));
+    return appState[moduleType];
+}
+function getDevDirs(){
+    let fullPath = path.join(__dirname, `../dev`);
+    fs.readdir(fullPath, function(err, item) {
+       console.log(item)
     });
-    fs.exists(newJsFile, function(exists) {
-        if(exists){
-            fs.rename(newJsFile, jsFile, function(err){
-                if (err) throw err;
+}
+function buildList(){
+    getModuleTypes(getModules()).forEach(function(modType){
+        $(`<h2 id="${modType}-title">${modType} </h2>`).appendTo( $("#module-list-container"));
+        $(`<ul class="module-list" id="${modType}-modules" />`).insertAfter( $(`#${modType}-title`));
+        getModulesByType(modType).forEach(function(mod){
+            $('<li>', {
+                text        : mod.name,
+                class       : `module-item module-active`,
+                id          : `${mod.name}-module`,
+                "data-type" : modType
+            }).appendTo( $(`#${modType}-modules`) );
+        })
+    })
+}
+function scanDev(){
+    ['dev/core', 'dev/custom'].forEach(function(dirPath) {
+        let modType = dirPath.stringFromToken('after', "/");
+        let fullPath = path.join(__dirname, `../${dirPath}`);
+        let mods = [];
+        fs.readdir(fullPath, function(err, item) {
+            item.forEach(function(modName){
+                mods.push({name: modName, active: true, path: `${fullPath}/${modName}`});
             });
-        }
-    });
-})
\ No newline at end of file
+            storeModules(setModules(modType,mods));    
+        });
+    })
+}
+$(document).on("click", '.module-item', function(){
+    let modName     = $(this).attr('id').stringFromToken('before', '-', true);
+    let dataType    = $(this).data('type');
+    let thisModule  = getModuleByName(modName);
+    console.log(getModuleByName(modName))
+});
+scanDev();
+buildList();
\ No newline at end of file
index 2c518bb..3fbfdbe 100644 (file)
@@ -1,22 +1,22 @@
 #module-list-container{
 
 }
-#module-list-container ul#module-list{
+#module-list-container ul.module-list{
     list-style-type: none;
     padding: 0;
 }   
-#module-list-container ul#module-list li.module-item{
+#module-list-container ul.module-list li.module-item{
     padding: 5px 8px;
     margin: 5px;
     display: inline-block;
 }
-#module-list-container ul#module-list li.module-item:hover{
+#module-list-container ul.module-list li.module-item:hover{
     cursor: pointer;
 }
-#module-list-container ul#module-list li.module-item.module-active-true{
+#module-list-container ul.module-list li.module-item.module-active{
     background: lightgreen;
     
 }
-#module-list-container ul#module-list li.module-item.module-active-false{
+#module-list-container ul.module-list li.module-item.module-inactive{
     background: tomato;
 }
\ No newline at end of file