Skip to content

Commit

Permalink
v1.0.1: add help command
Browse files Browse the repository at this point in the history
  • Loading branch information
Areas committed Nov 9, 2017
1 parent 1a95b7d commit efe4d88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<style type="text/css">
html,body { padding: 0px; margin: 0px; height: 100%; }
body {
overflow: hidden;
background-color: rgba(255, 120, 192, 0.3);
}
#container {
Expand Down
31 changes: 18 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var commandNode = document.getElementById("command");

// configeration parameters
var STORAGE_SUPPORT = false;


document.addEventListener("DOMContentLoaded", function() {
// code...
// alert("hello");
STORAGE_SUPPORT = typeof("Storage") !== 'undefined';
document.addEventListener("keypress", key, false);
commandNode.focus();
Expand All @@ -19,21 +19,14 @@ function key (e) {
if (e.keyCode == 13) {
// run
extractCommand();
// var command = document.getElementById("command");
commandNode.value = "";
}
}

function run() {
// var btn = document.getElementById("btn");
btn.addEventListener("click", extractCommand);
}

// function test() {
// var command = document.getElementById("command").value;
// alert(command);
// }

function extractCommand() {

var command = commandNode.value;
Expand Down Expand Up @@ -65,15 +58,15 @@ function extractCommand() {
case "clear":
clear();
break;
case "help":
help();
break;
default:
nothing();
}

}

function command(command) {
add(extractCommand(command));
}

// 1-layer command
function add(item) {
Expand All @@ -89,7 +82,6 @@ function list() {
return;
}
for(var idx in items) {
// item.list();
show(items[idx]);
}
}
Expand All @@ -113,6 +105,19 @@ function done(item) {
clearAndShow("item has been done.");
}

function help() {
clearUl();
show("help: show command usage")
show("add task: task can be something like 'drink water' or 'listen to music' (without quotes)")
show("list: get a list of what you added before")
show("get: randomly choose one item from list and display. you can rerun `get` to change current item.")
show("done: mark current item done and remove it from list")
show("clear: remove all the items in your list")
show("save: save current list in local storage")
show("restore: restore list from local storage. This will override current list.")
current = -1
}

function nothing() {
// nothing here
clearAndShow("invalid command..");
Expand Down

0 comments on commit efe4d88

Please sign in to comment.