Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

todo challenge #143

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bower_components
/node_modules
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@
"yui" : false, // Yahoo User Interface

// Custom Globals
"globals" : { "toDoList": true, "angular": true } // additional predefined global variables
"globals" : { "todoList": true, "angular": true } // additional predefined global variables
}
44 changes: 1 addition & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
# Todo Challenge

* Deadline: submit completed pull request by 9am on Monday
* You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript

Steps
-------

1. Fill out your learning plan self review for the week: https://github.com/makersacademy/learning_plan
2. Fork this repo, and clone to your local machine
3. Complete the following challenge:

## Challenge

![Todo mockup](https://makersacademy.mybalsamiq.com/mockups/2914603.png?key=afabb09aef2901a2732515ae4349c1ec0458294b)
# Makers Academy Weekend Challenge: Todo List

Build a Todo list as a mini front-end application. You don't have to use a database, the front-end is more important - you can use an appropriate data structure stored somewhere in your JavaScript (this time only!)

Expand All @@ -30,11 +16,7 @@ So that I have more time to think about other things
As a person who actually gets stuff done
I want to mark my tasks as done
So that I don't do them twice
```

Here are some other user stories you may choose to implement:

```
As a person with a lot of tasks
I want to be able to filter my tasks by "All", "Active", "Complete"
So that I only see the relevant tasks
Expand All @@ -47,27 +29,3 @@ As someone who has done lots of stuff
I want to be able to clear my completed tasks
So I never see them again
```

As you may imagine, implementing a To-do list is very much a solved problem. However, we are mainly interested in seeing how you approach testing and design. We are looking for:

* well written, well structured acceptance and unit tests
* clear and expressive JavaScript
* good HTML5 markup

Don't worry about deployment, and make sure you read the CONTRIBUTING.md when submitting a pull request.

## Extensions

* Deploy the app
* Create a persistance layer (e.g. MongoDB), or use LocalStorage or the filesystem through Node
* Make it look purdy (CSS) - try a framework like Bootstrap or Foundation

## CI

Read the `.travis.yml` if any of the steps below don't make sense!

* Make sure you have set up `npm test` in your `package.json` so that it runs your Karma tests
* Make sure you have your Protractor config file at `e2e/conf.js`
* Make sure `npm start` spins up whatever serves up your app - `http-server`, Sinatra or Node

Good luck!
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "todo_challenge",
"homepage": "https://github.com/TY231618/todo_challenge",
"authors": [
"Tony Young <[email protected]>"
],
"description": "",
"main": "",
"moduleType": [],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "^2.2.0",
"bootstrap": "^3.3.6",
"angular": "^1.4.9",
"angular-resource": "^1.4.9"
},
"devDependencies": {
"angular-mocks": "^1.4.9",
"angular-route": "^1.4.9"
}
}
23 changes: 23 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
body {
text-align: center;
background-image: url(/Users/TY/Desktop/stickynote.jpg);
}

h2 {
font-family: Consolas, Sans-Serif;
width:800px;
margin:10px auto;
text-align:left;
padding:10px;
padding-left: 400px;
}

.done {
text-decoration: line-through; color: #ccc;
}

/*.center{
width:200px;
margin:0 auto;
text-align:left;
}*/
47 changes: 47 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!doctype html>
<html lang="en" ng-app="TodoList">
<head>

<meta charset="utf-8">

<title>Todo List Challenge</title>

<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">

<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="js/app.js"></script>
<script src="js/todoListController.js"></script>

</head>

<body ng-controller="TodoListController as todoCtrl">
<br>
<div class="center">
<form class="form-horizontal" name="frm" ng-submit="todoCtrl.addTodo(todoCtrl.newTodo)">
<input type="text" name="newTodo" ng-model="todoCtrl.newTodo" placeholder="Add a todo..." required/>
<br><br>
<button class="btn btn-success btn-xs" ng-click="todoCtrl.allTodo()">All</button>
<button class="btn btn-success btn-xs" ng-click="todoCtrl.activeTodo()">Active</button>
<button class="btn btn-success btn-xs" ng-click="todoCtrl.completedTodo()">Completed</button>
<button class="btn btn-info btn-xs" ng-click="todoCtrl.addTodo(todoCtrl.newTodo)">Add Todo</button>
<button class="btn btn-info btn-xs" ng-click="todoCtrl.removeTodo()">Remove Todo</button>
<button class="btn btn-danger btn-xs" ng-click="todoCtrl.clearAll()">Clear List</button>

</form>

<br><br>
<h2>My list of todos.....</h2>
<ul ng-repeat="list in todoCtrl.todos">
<li>
<span ng-class="{'done': list.done}">{{list.title}}</span>
<input type="checkbox" ng-model="list.done"/>
</li>
</ul>
<p>Number of Todos: {{todoCtrl.countTodo()}}</p>

</div>
</body>
</html>
1 change: 1 addition & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var todoList = angular.module('TodoList', ['ngResource']);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'angular' is not defined.

65 changes: 65 additions & 0 deletions js/todoListController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
todoList.controller('TodoListController', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has too many statements. (11)
'todoList' is not defined.

var self = this;

self.todos = [];
self.filteredTodoList = [];
self.oldList = [];

self.addTodo = function(newTodo){
self.allTodo();
self.todos.push({title: newTodo, done: false});
self.newTodo = '';
self.filteredTodoList = self.todos;

};

self.removeTodo = function () {
self.allTodo();
self.oldList = self.todos;
self.todos = [];


for (var i = 0; i < self.oldList.length; i++) {
if (!self.oldList[i].done) {
self.todos.push(self.oldList[i]);
}
}
self.filteredTodoList = self.todos;

}

self.completedTodo = function () {
self.oldList = self.filteredTodoList;
self.todos = [];

for (var i = 0; i < self.oldList.length; i++) {
if (self.oldList[i].done) {
self.todos.push(self.oldList[i]);
}
}
}

self.activeTodo = function () {
self.oldList = self.filteredTodoList;
self.todos = [];

for (var i = 0; i < self.oldList.length; i++) {
if (!self.oldList[i].done) {
self.todos.push(self.oldList[i]);
}
}
}

self.allTodo = function () {
self.todos = self.filteredTodoList;
}

self.countTodo = function () {
return self.todos.length;
}

self.clearAll = function() {
self.todos = [];
self.filteredTodoList = [];
}
});
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "todo_challenge",
"version": "1.0.0",
"description": "* Deadline: submit completed pull request by 9am on Monday * You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/TY231618/todo_challenge.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/TY231618/todo_challenge/issues"
},
"homepage": "https://github.com/TY231618/todo_challenge#readme",
"devDependencies": {
"jasmine-core": "^2.4.1",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^1.0.0",
"phantomjs": "^2.1.3",
"protractor": "^3.0.0"
},
"dependencies": {
"http-server": "^0.8.5"
}
}
4 changes: 4 additions & 0 deletions test/e2e/conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todoListFeature.js']
}
12 changes: 12 additions & 0 deletions test/e2e/todoListFeature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('Todo List', function() {


beforeEach(function() {
browser.get('http://localhost:8080');
});

it('has a title', function() {
expect(browser.getTitle()).toEqual('Todo List Challenge');
});

});
68 changes: 68 additions & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Karma configuration
// Generated on Thu Nov 27 2014 10:43:21 GMT+0000 (GMT)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.js',
'bower_components/angular-route/angular-route.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-mocks/angular-mocks.js',
'js/**/*.js',
'test/**/*.spec.js'
],


// list of files to exclude
exclude: [],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
Loading