From 9eab0caf10cd66e8b7da824d317f6b480ab428db Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Fri, 25 Sep 2015 16:43:45 -0500 Subject: [PATCH 01/10] update test #168 --- test/test.js | 75 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/test/test.js b/test/test.js index 1b98485..3558b31 100644 --- a/test/test.js +++ b/test/test.js @@ -26,32 +26,53 @@ describe("Validating JSON Schema", function() { "content": { "type": "array", "items": [ + { "type": "string" }, + { "type": "string" }, + { "type": "string" }, { "type": "string" }, { "type": "string" }, { "type": "string" }, { "type": "string"} ] }, - "tips": { "type": "string" } + "tips": { "type": "string" }, + "commands": { + "type": "array", + "items": [ + { "command": { "type": "string" } }, + { "command": { "type": "string" } }, + { "command": { "type": "string" } } + ] + } } - } + }, + "laststep": { "type": "boolean" } }, "required": [ "step", "content" ] }); var step = { - "step": "0", + "step": "1", "content": { - "title": "Setup: Install Aurora 0", + "title": "Setup: Install Aurora", "content": [ " You use the Aurora client and web UI to interact with Aurora jobs. ", - " To install it locally, see vagrant.md. The remainder of this Tutorial ", - " assumes you are running Aurora using Vagrant. Unless otherwise stated, ", - " all commands are to be run from the root of the aurora repository clone." + " To install it locally, see ", + " vagrant.md ", + " The remainder of this Tutorial assumes you are running ", + " Aurora using Vagrant. Unless otherwise stated, ", + " all commands are to be run from the root ", + " of the aurora repository clone. " ], - "tips": "You can run $ aurora for see all commands" - } - } + "tips": "let's try with following commands", + "commands": [ + {"command":"git clone git://git.apache.org/aurora.git"}, + {"command":"cd aurora"}, + {"command":"vagrant up"} + ] + }, + "laststep": false + }; // validation var errors = env.validate('step', step); @@ -68,16 +89,38 @@ describe("Validating JSON Schema", function() { env.addSchema('command', { "type": "object", "properties": { - "command": { "type": "string" }, - "result": { "type": "string" }, + "step": { "type": "string" }, + "count": { "type": "string" }, + "commands": { + "type": "array", + "items": { + "type": "object", + "properties": { + "order": { "type": "number" }, + "command": { "type": "string" }, + "type": { "type": "string" }, + "depend": { "type": "string" }, + "lastCommand": { "type": "boolean" }, + } + } + } }, - "required": [ "command", "result" ] + "required": [ "step", "commands" ] }); var command = { - "command":"cordova platform add android", - "result": "Creating Cordova project for the Android platform" - } + "step": "2", + "count": "1", + "commands": [ + { + "order" : 0, + "command":"ls", + "type": "native", + "depend": "", + "lastCommand": true + } + ] + }; // validation var errors = env.validate('command', command); From 01e71fe601502da4f523a9b06c1cec2af89c62d0 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Sun, 4 Oct 2015 04:35:36 -0500 Subject: [PATCH 02/10] fixes #169 a new test for Validating Preload-Files --- test/test.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/test.js b/test/test.js index 3558b31..abc9cde 100644 --- a/test/test.js +++ b/test/test.js @@ -129,4 +129,39 @@ describe("Validating JSON Schema", function() { expect(errors).toBe(null); }); + it("Validating Preload-Files", function() { + + // create new JJV environment + var env = jjv(); + + env.addSchema('file', { + "type": "object", + "properties": { + "name": { "type": "string" }, + "language": { "type": "string" }, + "content": { + "type": "array", + "items": [ + { "command": { "type": "string" } } + ] + } + }, + "required": [ "name", "content" ] + }); + + var file = { + "name":"hello_world.py", + "language": "python", + "content": [ + "print \"Hello, World!\"" + ] + }; + + // validation + var errors = env.validate('file', file); + + // null = It has not errors + expect(errors).toBe(null); + + }); }); From ace64c3402b426b09b6fb3772f4940ac531b3418 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Sun, 4 Oct 2015 06:36:47 -0500 Subject: [PATCH 03/10] fixes #170, added Validating Preload-Files --- test/test.js | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/test/test.js b/test/test.js index abc9cde..3517447 100644 --- a/test/test.js +++ b/test/test.js @@ -164,4 +164,122 @@ describe("Validating JSON Schema", function() { expect(errors).toBe(null); }); + it("Validating List of Commands", function() { + + // create new JJV environment + var env = jjv(); + + env.addSchema('command', { + "type": "object", + "properties": { + "step": { "type": "string" }, + "count": { "type": "string" }, + "commands": { + "type": "array", + "items": { + "type": "object", + "properties": { + "order": { "type": "number" }, + "command": { "type": "string" }, + "type": { "type": "string" }, + "depend": { "type": "string" }, + "lastCommand": { "type": "boolean" }, + } + } + } + }, + "required": [ "step", "commands" ] + }); + + var command = { + "step": "2", + "count": "1", + "commands": [ + { + "order" : 0, + "command":"ls", + "type": "native", + "depend": "", + "lastCommand": true + } + ] + }; + + // validation + var errors = env.validate('command', command); + + // null = It has not errors + expect(errors).toBe(null); + + }); + it("Validating Preload-Files", function() { + + // create new JJV environment + var env = jjv(); + + env.addSchema('file', { + "type": "object", + "properties": { + "name": { "type": "string" }, + "language": { "type": "string" }, + "content": { + "type": "array", + "items": [ + { "command": { "type": "string" } } + ] + } + }, + "required": [ "name", "content" ] + }); + + var file = { + "name":"hello_world.py", + "language": "python", + "content": [ + "print \"Hello, World!\"" + ] + }; + + // validation + var errors = env.validate('file', file); + + // null = It has not errors + expect(errors).toBe(null); + + }); + it("Validating Commands(Validations)", function() { + + // create new JJV environment + var env = jjv(); + + env.addSchema('command_validation', { + "type": "object", + "properties": { + "command": { "type": "string" }, + "regexp": { "type": "string" }, + "regexp_message": { + "type": "array", + "items": [ + { "command": { "type": "string" } } + ] + } + }, + "required": [ "command", "regexp", "regexp_message" ] + }); + + var command_validation = { + "command":"aurora job create", + "regexp": "aurora\\sjob\\screate\\s[a-z-.-_--]+\/[a-z-.-_--]+\/[a-z-.-_--]+\/[a-z-.-_--]+\\s[a-zA-Z-.-_--]{0,}(\\.aurora)", + "regexp_message": [ + "aurora job create: error: too few arguments" + ] + }; + + // validation + var errors = env.validate('command_validation', command_validation); + + // null = It has not errors + expect(errors).toBe(null); + + }); }); From ec0625c65b95ecbd5824262eca9b3c5b552147ec Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Mon, 5 Oct 2015 16:16:30 -0500 Subject: [PATCH 04/10] update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b97e2c..c2a7e50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cli-guide.js", - "version": "0.1.2", + "version": "0.1.3", "description": "A Javascript library for creating interactive command line tutorials that run in your web browser.", "directories": { "test": "test" From 0b50e60100a0b136c71f38eb68ec05512ca5d78d Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Mon, 5 Oct 2015 17:53:40 -0500 Subject: [PATCH 05/10] replace content.content to content.body closes #171 --- src/cli-guide.js | 2 +- templates/apache_aurora.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli-guide.js b/src/cli-guide.js index 203e8eb..69f20be 100755 --- a/src/cli-guide.js +++ b/src/cli-guide.js @@ -107,7 +107,7 @@ $.getJSON(stepsFile,function(data){ $.each(data,function(k,v){ if(v.step == step){ - Step.showInfoTemplate(step,v.step,skipStepArray,v.content.title,v.content.content, + Step.showInfoTemplate(step,v.step,skipStepArray,v.content.title,v.content.body, v.content.tips,v.content.commands,v.content.moreinfo); } }); diff --git a/templates/apache_aurora.json b/templates/apache_aurora.json index 1c42517..abbbfd2 100644 --- a/templates/apache_aurora.json +++ b/templates/apache_aurora.json @@ -3,7 +3,7 @@ "step": "1", "content": { "title": "Setup: Install Aurora", - "content": [ + "body": [ " You use the Aurora client and web UI to interact with Aurora jobs. ", " To install it locally, see ", " vagrant.md ", @@ -25,7 +25,7 @@ "step": "2", "content": { "title": "Initial Configuration", - "content": [ + "body": [ "

The Script

", " Our 'hello world' application is a simple Python script that loops ", " forever, displaying the time every few seconds.

", @@ -59,7 +59,7 @@ "step": "3", "content": { "title": "Creating the Job", - "content": [ + "body": [ " We’re ready to launch our job! To do so, we use the Aurora Client to issue a ", " Job creation request to the Aurora scheduler.

", " Many Aurora Client commands take a job key argument, which uniquely identifies a Job. ", @@ -84,7 +84,7 @@ "step": "4", "content": { "title": "Watching the Job Run", - "content": [ + "body": [ " Now that our job is running, let’s see what it’s doing. Access the scheduler web interface at ", " http://$scheduler_hostname:$scheduler_port/scheduler Or when using vagrant, ", " http://192.168.33.7:8081/scheduler First we see what Jobs are scheduled:
", @@ -124,7 +124,7 @@ "step": "5", "content": { "title": "Cleanup", - "content": [ + "body": [ " Now that we’re done, we kill the job using the Aurora client.
", " The job page now shows the hello_world tasks as completed. ", " aurora job killall " From 1acc9b4345e3936b067930cdcfa0a1e05502fb14 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Mon, 5 Oct 2015 17:55:19 -0500 Subject: [PATCH 06/10] update test (Validating List of Steps) --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 3517447..1ff0590 100644 --- a/test/test.js +++ b/test/test.js @@ -23,7 +23,7 @@ describe("Validating JSON Schema", function() { "type": "object", "properties": { "title": { "type": "string" }, - "content": { + "body": { "type": "array", "items": [ { "type": "string" }, @@ -55,7 +55,7 @@ describe("Validating JSON Schema", function() { "step": "1", "content": { "title": "Setup: Install Aurora", - "content": [ + "body": [ " You use the Aurora client and web UI to interact with Aurora jobs. ", " To install it locally, see ", " vagrant.md ", From f169792b81a3b263b86100f7316c93724baeb542 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Thu, 8 Oct 2015 03:15:25 -0500 Subject: [PATCH 07/10] by default div editable is false but after click event it changes for 'true', fixes #173 --- src/cli-guide.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cli-guide.js b/src/cli-guide.js index 69f20be..3c54805 100755 --- a/src/cli-guide.js +++ b/src/cli-guide.js @@ -543,7 +543,7 @@ if(input == "") { Cli.newline(""); - } else if(localStorage.getItem("step-"+input.replace(/\s\s+/g,' ')) != null){ + } else if(localStorage.getItem("step-"+input.replace(/\s\s+/g,' ')) != null) { var object = JSON.parse(localStorage.getItem("step-"+input.replace(/\s\s+/g,' '))); @@ -799,7 +799,7 @@ }, openFile: function(filename){ $("#terminal").hide(); - $('#editor-content').html(''); + $('#editor-content-parent').html(''); $('#editor-header-filename').html("File: "); $('#namefile-x').html(''); $("#editor").show(); @@ -808,12 +808,12 @@ if(localStorage.getItem(filename) != null) { var file = JSON.parse(localStorage.getItem(filename)); - $('#editor-content').html( - '
'
+            $('#editor-content-parent').html(
+              '
'
               +'
' ); - $('#lang').html(file.content.split("
").join("\n")); - Prism.highlightElement($('#lang')[0]); + $('#editor-content').html(file.content.split("
").join("\n")); + Prism.highlightElement($('#editor-content')[0]); // show the name of the file in header $('#editor-header-filename').html("File: " + filename); // show the name of the file again @@ -892,6 +892,11 @@ Modal.showImg($(this).data('image'),$(this).data('size')); }); + // active editable in nano editor for open a file + $(document).on('click','#editor-content',function(){ + $(this).attr('contenteditable',true); + }); + var id = 0; self.on('keydown', '[contenteditable]', function(event){ @@ -1175,7 +1180,7 @@ + '
' + '
' - + '
' + + '
' + '
' + '
' From 8782dbc6e3e0b9443acedbdc11b91cf79668f211 Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Thu, 8 Oct 2015 09:52:42 -0500 Subject: [PATCH 08/10] update devDependencies and gulp tasks --- gulpfile.js | 38 +++++++++++++---------- package.json | 4 ++- src/cli-guide.js | 78 ++++++++++++++++++++++++------------------------ 3 files changed, 65 insertions(+), 55 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 292eb8d..a57aeb3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,24 +1,32 @@ -var gulp = require('gulp'); -var jsmin = require('gulp-jsmin'); -var rename = require('gulp-rename'); -var minifyCss = require('gulp-minify-css'); +var gulp = require('gulp'), + jsmin = require('gulp-jsmin'), + rename = require('gulp-rename'), + minifyCss = require('gulp-minify-css'), + jshint = require('gulp-jshint'), + uglify = require('gulp-uglify'); -gulp.task('copy-fonts', function() { - return gulp.src('src/*.{ttf,otf}') - .pipe(gulp.dest('dist')); +gulp.task('copy-original-files', function() { + return gulp.src('src/*.{css,js,ttf,otf}') + .pipe(gulp.dest('dist')); }); gulp.task('minify-css', function() { return gulp.src('src/*.css') - .pipe(minifyCss()) - .pipe(gulp.dest('dist')); + .pipe(minifyCss()) + .pipe(gulp.dest('dist')); }); -gulp.task('js', function () { - gulp.src('src/*.js') - .pipe(jsmin()) - .pipe(rename({suffix: '.min'})) - .pipe(gulp.dest('dist')); +gulp.task('lint', function() { + return gulp.src(['src/*.js']) + .pipe(jshint()) + .pipe(jshint.reporter('default')); }); -gulp.task('default', ['minify-css', 'js', 'copy-fonts']); +gulp.task('compress-js', function() { + return gulp.src('src/*.js') + .pipe(uglify()) + .pipe(rename({suffix: '.min'})) + .pipe(gulp.dest('dist')) +}); + +gulp.task('default', ['minify-css', 'lint', 'compress-js', 'copy-original-files']); diff --git a/package.json b/package.json index c2a7e50..b8b81f2 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,9 @@ "gulp": "3.8.11", "gulp-jsmin": "0.1.5", "gulp-rename": "1.2.2", - "gulp-minify-css": "1.1.3" + "gulp-minify-css": "1.1.3", + "gulp-jshint": "1.11.2", + "gulp-uglify": "1.4.1" }, "dependencies": {} } diff --git a/src/cli-guide.js b/src/cli-guide.js index 3c54805..6f74bc8 100755 --- a/src/cli-guide.js +++ b/src/cli-guide.js @@ -1,4 +1,4 @@ -/*! +/* * cli-guide plugin * Original author: @willrre * Further changes, comments: @willrre @@ -71,7 +71,7 @@ if (!effect) effect = $.fn.text; - var loghistory = [] + var loghistory = []; // return focus $("#terminal").click(function(){ @@ -86,7 +86,7 @@ var Step = { list: function(stepsFile){ - if(stepsFile != ""){ + if(stepsFile !== ""){ $.getJSON(stepsFile,function(data){ $.each(data,function(k,v){ Step.listTemplate(v.step); @@ -98,7 +98,7 @@ }, showInfo: function(stepsFile, skipsteps, step){ // select current step - if(stepsFile != ""){ + if(stepsFile !== ""){ localStorage.setItem('actualstep',step); var skipStepArray = JSON.parse("[" + skipsteps + "]"); @@ -129,7 +129,7 @@ } } else { - var command = [{"command":"git clone https://github.com/twitter/cli-guide.js.git"}] + var command = [{"command":"git clone https://github.com/twitter/cli-guide.js.git"}]; Step.showInfoTemplate(1,1,"","CLI-Guide.js","A javascript library for creating interactive "+ "command line tutorials that run in your web browser. ", "tips here!",command,""); @@ -214,12 +214,12 @@ '' + '

'+content+'

' ); - if(moreinfo != undefined){ + if(moreinfo !== undefined){ moreinfo = Array.isArray(moreinfo) ? moreinfo.join("") : moreinfo; Modal.showInfo("moreinfo",moreinfo); } - if(tips != ""){ - var tip = Array.isArray(tips) ? tips.join("") : tips + if(tips !== ""){ + var tip = Array.isArray(tips) ? tips.join("") : tips; $('#stepscontent').append( '
' + '

Tips

' @@ -249,7 +249,7 @@ var dir = ""; - if(command.substring(0, 3) == "cd " && command.substring(3, command.length) != ""){ + if(command.substring(0, 3) == "cd " && command.substring(3, command.length) !== ""){ $("#"+id+".response").html(''); // remove pre and code localStorage.setItem('actualdir', "/"+command.substring(3, command.length)); } @@ -286,7 +286,7 @@ Cli.newline(""); }, rm: function(filename){ - if(localStorage.getItem(filename) != null){ + if(localStorage.getItem(filename) !== null){ var arrayFiles = localStorage.getItem("files").split(','); arrayFiles = arrayFiles.filter(Boolean); Util.removeItemFromArray(arrayFiles, filename); @@ -543,7 +543,7 @@ if(input == "") { Cli.newline(""); - } else if(localStorage.getItem("step-"+input.replace(/\s\s+/g,' ')) != null) { + } else if(localStorage.getItem("step-"+input.replace(/\s\s+/g,' ')) !== null) { var object = JSON.parse(localStorage.getItem("step-"+input.replace(/\s\s+/g,' '))); @@ -553,7 +553,7 @@ $finish.html("Finish ✓"); localStorage.setItem(actualStep,true); } else { - if(actualStep == object.step){ + if(actualStep === object.step){ $finish.addClass("ok-b"); $finish.html("Next ✓"); localStorage.setItem(actualStep,true); @@ -564,7 +564,7 @@ } // verify the command if it is for the correct step - if(object.step == "general"){ + if(object.step === "general"){ if(text.indexOf("cd ") > -1){ Cli.newline(input.replace(/\s\s+/g,' '),id); } else if(!object.animation){ @@ -605,7 +605,7 @@ } return result = restCommand(opts,input.replace(/\s\s+/g,' '),id); } - } else if(object.depend != ""){ + } else if(object.depend !== ""){ // check which command or commands depends var dependCommand = JSON.parse(localStorage.getItem(object.depend)); if(!dependCommand.done){ @@ -648,7 +648,7 @@ } } else { $("#"+id+".response").html(''); // remove pre and code - if(opts.commandStepsFile == "") { + if(opts.commandStepsFile === "") { Cli.newline(input,id); } } @@ -667,12 +667,12 @@ $.each(data,function(key,steps){ $.each(steps,function(k,commands){ for(var i = 0; i < commands.length; i++) { - if(commands[i].command != undefined){ + if(commands[i].command !== undefined){ // when more than one command have the same result if(Array.isArray(commands[i].command)){ for(var c = 0; c < commands[i].command.length; c++){ if(text.trim() == commands[i].command[c]) { - if(commands[i].type != undefined){ + if(commands[i].type !== undefined){ if(commands[i].type === "animation"){ var arrayMultiResult = []; for (var l = 0; l < commands[i].result.length; l++) { @@ -687,8 +687,8 @@ } } if(commands[i].command === text.trim()) { - if(commands[i].result != undefined){ - if(commands[i].type != undefined){ + if(commands[i].result !== undefined){ + if(commands[i].type !== undefined){ if(commands[i].type === "animation"){ var arrayResult = []; for(var l = 0; l < commands[i].result.length; l++) { @@ -728,8 +728,8 @@ type:commands[i].type, depend: commands[i].depend, done:false, - animation: (commands[i].animation == undefined) ? false : commands[i].animation, - lastCommand: (commands[i].lastCommand == undefined) ? false : commands[i].lastCommand + animation: (commands[i].animation === undefined) ? false : commands[i].animation, + lastCommand: (commands[i].lastCommand === undefined) ? false : commands[i].lastCommand })); } } else { @@ -741,8 +741,8 @@ type:commands[i].type, depend: commands[i].depend, done:false, - animation: (commands[i].animation == undefined) ? false : commands[i].animation, - lastCommand: (commands[i].lastCommand == undefined) ? false : commands[i].lastCommand + animation: (commands[i].animation === undefined) ? false : commands[i].animation, + lastCommand: (commands[i].lastCommand === undefined) ? false : commands[i].lastCommand })); } } @@ -764,11 +764,11 @@ // add a python file for show, how to works nano editor localStorage.setItem("files","hello_world.py"); } else { - var files = [] + var files = []; $.ajaxSetup({ async: false }); - if(opts != "") { + if(opts !== "") { $.getJSON(opts,function(data){ $.each(data,function(k,v){ // using .join method to convert array to string without commas @@ -777,7 +777,7 @@ localStorage.setItem(v.name, JSON.stringify({ content: v.content.join(""), - language: (v.language == undefined) ? "markup" : v.language + language: (v.language === undefined) ? "markup" : v.language })); }); }); @@ -806,7 +806,7 @@ // add a new line after open nano editor Cli.newline(filename); - if(localStorage.getItem(filename) != null) { + if(localStorage.getItem(filename) !== null) { var file = JSON.parse(localStorage.getItem(filename)); $('#editor-content-parent').html( '
'
@@ -830,7 +830,7 @@
 
       //  autocomplete (tab) commands, issue #42
       function autocompleteCommands(commands){
-        var listCommands = []
+        var listCommands = [];
         $.ajaxSetup({
           async: false
         });
@@ -840,12 +840,12 @@
               for (var i = 0; i < commands.length; i++) {
                 if(Array.isArray(commands[i].command)){
                   for(var c = 0; c < commands[i].command.length; c++){
-                    if(commands[i].command != undefined){
+                    if(commands[i].command !== undefined){
                       listCommands.push(commands[i].command[c]);
                     }
                   }
                 } else {
-                  if(commands[i].command != undefined){
+                  if(commands[i].command !== undefined){
                     listCommands.push(commands[i].command);
                   }
                 }
@@ -916,19 +916,19 @@
           Prism.highlightElement($('#'+id+'_lang_terminal')[0]);
 
           // print the result of commands
-          if(opts.commandStepsFile != "" && opts.commandValidation != "") {
-            if(CommandValidation.command(opts.commandValidation,input) != "" ) {
+          if(opts.commandStepsFile !== "" && opts.commandValidation !== "") {
+            if(CommandValidation.command(opts.commandValidation,input) !== "" ) {
               $('#'+id+'_lang_terminal').html(CommandValidation.command(opts.commandValidation,input));
               Cli.newline(input,id);
             } else {
               $('#'+id+'_lang_terminal').html(commands(opts.commandStepsFile,input,id));
             }
-          } else if(opts.commandStepsFile != "") {
+          } else if(opts.commandStepsFile !== "") {
             $('#'+id+'_lang_terminal').html(commands(opts.commandStepsFile,input,id));
           } else {
             // git clone return a new line after finish
             // only run commands different from git clone
-            if(input.replace(/\s\s+/g,' ') != "git clone " + input.split(" ").pop()) {
+            if(input.replace(/\s\s+/g,' ') !== "git clone " + input.split(" ").pop()) {
               $("#"+id+".response").html(''); //remove space
               Cli.newline(input,id);
             }
@@ -954,7 +954,7 @@
           }
 
           // list of commands we can't use....
-          Cli.unSupportedCommand(input,id)
+          Cli.unSupportedCommand(input,id);
 
           // delete file remove a key from LocalStorage issue #81
           if(input.replace(/\s\s+/g,' ') == "rm -r " + input.split(" ").pop()) {
@@ -1026,7 +1026,7 @@
       $(document).on('keydown','#editor-content',function(e){
         if($("#editor-content").is(':visible')){
           if (e.keyCode == 88 && e.ctrlKey) {
-            if($("#editor-content").text() != "") {
+            if($("#editor-content").text() !== "") {
               if(!$("#command-x").is(':visible')){
                 $("#commands").hide();
                 $("#command-save-x").show();
@@ -1061,7 +1061,7 @@
           $("#terminal").show();
           $('.textinline').focus();
         }
-        if(event.which != 89 || event.which != 78 ){
+        if(event.which !== 89 || event.which !== 78 ){
           event.preventDefault();
         }
       });
@@ -1078,7 +1078,7 @@
 
       $(document).on('keydown','#namefile-x',function(event){
         if (event.keyCode == 13){
-          if(localStorage.getItem($(this).text()) != null){
+          if(localStorage.getItem($(this).text()) !== null){
             // update file
             var file = JSON.parse(localStorage.getItem($(this).text()));
             localStorage.setItem($(this).text(),
@@ -1103,7 +1103,7 @@
           // prevent duplicate files
           var existDuplicate = true;
           for(var f = 0; f < arrayFiles.length; f++){
-            if(arrayFiles[f] != $(this).text()){
+            if(arrayFiles[f] !== $(this).text()){
               checkDuplicate = false;
             } else {
               return false;

From 0474606ec4d4faef0c0b343619c8e1438e8e4be8 Mon Sep 17 00:00:00 2001
From: Willy Aguirre 
Date: Fri, 9 Oct 2015 02:24:04 -0500
Subject: [PATCH 09/10] only after finish or skip a step you can change of step
 fixes  #172

---
 src/cli-guide.css |  5 +++++
 src/cli-guide.js  | 16 ++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/cli-guide.css b/src/cli-guide.css
index 7ffe063..ba21243 100644
--- a/src/cli-guide.css
+++ b/src/cli-guide.css
@@ -83,6 +83,11 @@ li.step a {
   margin-bottom: 5px;
 }
 
+.not-active {
+   pointer-events: none;
+   cursor: default;
+}
+
 a.btn-step:hover {
   background-color: #ABABAB;
 }
diff --git a/src/cli-guide.js b/src/cli-guide.js
index 6f74bc8..350116f 100755
--- a/src/cli-guide.js
+++ b/src/cli-guide.js
@@ -118,10 +118,12 @@
             var $finish = $("#finish[data-step="+actualStep+"]");
             var finishedStep = JSON.parse(localStorage.getItem(step));
 
-            if(step == Step.getLast() && finishedStep){
+            if(step == Step.getLast() && finishedStep) {
+              $("#"+step).removeClass("not-active");
               $finish.addClass("ok-b");
               $finish.html("Finish ✓");
             } else if(finishedStep){
+              $("#"+step).removeClass("not-active");
               $finish.addClass("ok-b");
               $finish.html("Next ✓");
             } else {
@@ -181,16 +183,20 @@
             });
           });
           localStorage.setItem(step,true);
+          var nextstep = step+1;
           var $finish = $("#finish[data-step="+step+"]");
           $finish.addClass("ok-b");
           $finish.html("Next ✓");
+          // enable the next step
+          $("#"+nextstep).removeClass("not-active");
           // switch to next step
-          Step.showInfo(opts.stepsFile, opts.skipsteps, step+1);
+          Step.showInfo(opts.stepsFile, opts.skipsteps, nextstep);
         },
         listTemplate: function(step){
+          var not_active = ( step == 1 ) ? "": "not-active";
           $("#listofsteps").append(
             '
  • ' - + '' + + '' + step + '' + '
  • ' @@ -885,7 +891,9 @@ }); $(document).on('click','#finish',function(){ - Step.showInfo(opts.stepsFile, opts.skipsteps,$(this).data('nextstep')); + var nextstep = $(this).data('nextstep'); + Step.showInfo(opts.stepsFile, opts.skipsteps, nextstep); + $("#"+nextstep).removeClass("not-active"); }); $(document).on('click','.modalimage',function(){ From 4458f9d5b8f728a8f4f5e4c62b5a72149cd0adfb Mon Sep 17 00:00:00 2001 From: Willy Aguirre Date: Fri, 9 Oct 2015 02:36:25 -0500 Subject: [PATCH 10/10] add publish task --- README.md | 2 +- gulpfile.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f80c11..6aa3975 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CLI Guide jQuery Plugin +# CLI Guide jQuery Plugin v0.1.3 [![npm version](http://marti1125.webfactional.com/npm.svg)](https://www.npmjs.com/package/cli-guide.js) [![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/twitter/cli-guide.js/master/LICENSE) diff --git a/gulpfile.js b/gulpfile.js index a57aeb3..d460048 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,11 @@ var gulp = require('gulp'), jshint = require('gulp-jshint'), uglify = require('gulp-uglify'); +gulp.task('publish', function() { + return gulp.src(['package.json','README.md','LICENSE','nano.gif','terminal.gif']) + .pipe(gulp.dest('dist')); +}); + gulp.task('copy-original-files', function() { return gulp.src('src/*.{css,js,ttf,otf}') .pipe(gulp.dest('dist')); @@ -29,4 +34,4 @@ gulp.task('compress-js', function() { .pipe(gulp.dest('dist')) }); -gulp.task('default', ['minify-css', 'lint', 'compress-js', 'copy-original-files']); +gulp.task('default', ['minify-css', 'lint', 'compress-js', 'copy-original-files', 'publish']);