Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lab-khalid/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
21 changes: 21 additions & 0 deletions lab-khalid/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
30 changes: 30 additions & 0 deletions lab-khalid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Created by https://www.gitignore.io/api/node,vim,macos,linux,windows
.DS_Store
node_modules/
.env
### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

Choose a reason for hiding this comment

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

##Build
build/

make sure to ignore the build folder

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript
65 changes: 65 additions & 0 deletions lab-khalid/app/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';

require('./scss/reset.scss');
require('./scss/main.scss');

const
angular = require('angular'),
cowsay = require('cowsay-browser'),

cowsayApp = angular.module('cowsayApp', []);

cowsayApp.controller('CowsayController', ['$log', CowsayController]);

function CowsayController($log){
$log.debug('CowsayController');

this.title = 'Welcome to Cowville';
this.history = [];

cowsay.list((err, cowfiles) => {
this.cowfiles = cowfiles;
this.current = this.cowfiles[0];
});

this.update = function(input){
$log.debug('CowsayController.update()');

return cowsay.say({ text: input || 'MOOOOOOOOOOOOO!' ,f: this.current });
};

this.speak = function(input) {
$log.debug('CowsayController.speak()');

this.spoken = this.update(input);
this.history.push(this.spoken);
};

this.undo = function(){
$log.debug('CowsayController.undo()');

this.history.pop();
this.spoken = this.history.pop() || '';
};
}

cowsayApp.controller('NavController', ['$log', NavController]);

function NavController($log) {
$log.debug('NavController');

this.routes = [
{
name: 'home',
url: '/'
},
{
name: 'about',
url: '/about'
},
{
name: 'contact',
url: '/contact'
}
];
}
52 changes: 52 additions & 0 deletions lab-khalid/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html ng-app="cowsayApp">
<head>
<title>WELCOME TO COWVILLE</title>
</head>
<body>

<header>
<nav ng-controller="NavController as navCtrl">
<ul>
<li ng-repeat="route in navCtrl.routes">
<a href="{{link.url}}"> {{ route.name }} </a>
</li>
</ul>
</nav>
</header>

<main>
<section
class="container"
ng-controller="CowsayController as cowsayCtrl"
ng-init="cowsayCtrl.current = 'squirrel'">
<h2> {{ cowsayCtrl.title }} </h2>

<pre class="cow">
{{ cowsayCtrl.update(cowsayCtrl.text) }}
</pre>

<form
ng-submit="cowsayCtrl.speak(cowsayCtrl.text)"
name="cowsayForm"
novalidate>
<select ng-model="cowsayCtrl.current">
<option ng-repeat="cowfile in cowsayCtrl.cowfiles" value="{{ cowfile }}">
{{ cowfile }}
</option>
</select>

<input type="text" ng-model="cowsayCtrl.text" required>
<button type="submit">SPEAK</button>

<div ng-show="cowsayCtrl.spoken" class="history">
<pre>
{{ cowsayCtrl.spoken }}
</pre>
<button type="button" ng-click="cowsayCtrl.undo()">UNDO</button>
</div>
</form>
</section>
</main>
</body>
</html>
47 changes: 47 additions & 0 deletions lab-khalid/app/scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
$custom: black;

nav {
background-color: $custom;
color: slategray;
ul{
// display: inline-block;
margin-left: 50%;
}
li{
display: inline-block;
// margin-left: 20%;
padding: 0 10% 5% 0;
}
a {
text-decoration: none;
color: slategrey;
}
}

h2 {
font-size: 2vw;
}
pre {
display: inline-block;
border: 2px solid black;
}

.first{
display: inline-block;
background-color: dodgerblue;
}
form{
display: inline;
border: 1px solid black;
aside{
display: inline-block;
margin-top: -200px;
width: 30%;
height: 20vw;
background-color: crimson;
}
}




48 changes: 48 additions & 0 deletions lab-khalid/app/scss/reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
72 changes: 72 additions & 0 deletions lab-khalid/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Karma configuration
// Generated on Wed Mar 22 2017 17:18:36 GMT-0700 (PDT)
const webpackconfig = require('./webpack.config.js');
webpackconfig.entry = {};

module.exports = function(config) {
config.set({
webpack: webpackconfig,
// 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: [
'test/**/*-test.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/**/*-test.js': ['webpack']
},


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


// 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,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
41 changes: 41 additions & 0 deletions lab-khalid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "testing-controllers-demo",
"version": "1.0.0",
"description": "",
"main": "karma.conf.js",
"scripts": {
"build": "./node_modules/webpack/bin/webpack.js",
"watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot",
"test-watch": "./node_modules/karma/bin/karma start",
"test": "./node_modules/karma/bin/karma start --single-run"

Choose a reason for hiding this comment

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

"lint": "./node_modules/eslint/bin/eslint.js ./**/*.js"

missing your lint script

},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular": "^1.6.1",
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"cowsay-browser": "^1.1.8",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.26.0",
"node-sass": "^4.3.0",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.14.0"
},
"devDependencies": {
"angular-mocks": "^1.6.1",
"jasmine-core": "^2.5.2",
"karma": "^1.4.0",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.2",
"karma-webpack": "^2.0.1",
"webpack-dev-server": "^1.16.2"
}
}
Loading