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
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
56 changes: 56 additions & 0 deletions testes/cash-machine/app/controllers/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function(angular, $) {
"use strict";

angular.module("cashMachineApp")
.controller("mainController", ["$scope", function($scope) {
var notes = [100, 50, 20, 10];
var minimunNote = notes[notes.length - 1];

$scope.submit = function(e) {
e.preventDefault();
$scope.errorMessage = "";
$scope.result = [];

var value = $scope.value;

if (!value) {
return;
}

if (!$.isNumeric(value)) {
$scope.errorMessage = "Not a number";
return;
}

if (value < minimunNote) {
$scope.errorMessage = "Must be greater than " + minimunNote;
return;
}

if (value % minimunNote != 0) {
$scope.errorMessage = "Unavailable Note";
return;
}

notes.forEach(function(note) {
var rest = Math.floor(value / note);

if (rest == 0) {
return;
}

for (var x = 0; x < rest; x++) {
$scope.result.push({
value: note
});
}

value -= note * rest;
});
};

}]);



})(angular, jQuery);
6 changes: 6 additions & 0 deletions testes/cash-machine/app/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function(angular) {
"use strict";

angular.module("cashMachineApp", ['angular.filter']);

})(angular);
27 changes: 27 additions & 0 deletions testes/cash-machine/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
h1{
text-align: center;
}

.notes{
text-align: center;
}

.notes > div {
display: inline-block;
font-size: 20px;
padding: 20px;
color: green;
}
.notes > div i {
font-size: 30px;
margin-bottom: 5px;
margin-left: 5px;
}

.notes > div i:last-child {
margin-left: 0;
}

.notes > div p {
margin: 0;
}
60 changes: 60 additions & 0 deletions testes/cash-machine/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<html ng-app="cashMachineApp">

<head>
<title>Cash Machine</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="css/custom.css" />


</head>

<body ng-controller="mainController">

<div class="container">

<h1>Cash Machine</h1>


<form ng-submit="submit($event)">

<div class="row">
<div class="col-md-6 col-md-offset-3">

<div class="form-group">
<label class="control-label">Value</label>
<input type="text" ng-model="value" class="form-control" />
</div>
<div class="alert alert-danger" ng-show="errorMessage">{{errorMessage}}</div>


<div class="text-right">
<button class="btn btn-info">Get</button>
</div>

</div>
</div>


</form>

<div class="notes">
<div ng-repeat="note in result | groupBy: 'value'">
<i class="fa fa-money" ng-repeat="i in note"></i>
<p>{{note.length}} x {{note[0].value | currency}}</p>
</div>
</div>

</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.8/angular-filter.min.js"></script>
<script src="app/module.js"></script>
<script src="app/controllers/main.js"></script>

</body>

</html>
43 changes: 43 additions & 0 deletions testes/word-rank/app/controllers/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(function(angular, $) {
"use strict";

angular.module("wordRankApp")
.controller("mainController", ["$scope", "$http", "$filter", function($scope, $http, $filter) {
var resolve = function(fullText) {
var parts = fullText.match(/([A-z]+)/g);
var wordsCount = countWords(parts);

var result = $filter("orderBy")(wordsCount, ['-qty', 'word']);
$scope.words = result.splice(0, 20);
}

var countWords = function(parts) {
var words = {};

parts.forEach(function(word) {
if (words[word]) {
words[word].qty++;
return;
}

words[word] = {
word: word,
qty: 1
};
});

return $.map(words, function(word) {
return word;
});
}

$http.get("/texto.txt").then(function(response) {
resolve(response.data);
});


}]);



})(angular, jQuery);
6 changes: 6 additions & 0 deletions testes/word-rank/app/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function(angular) {
"use strict";

angular.module("wordRankApp", ['angular.filter']);

})(angular);
27 changes: 27 additions & 0 deletions testes/word-rank/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
h1{
text-align: center;
}

.notes{
text-align: center;
}

.notes > div {
display: inline-block;
font-size: 20px;
padding: 20px;
color: green;
}
.notes > div i {
font-size: 30px;
margin-bottom: 5px;
margin-left: 5px;
}

.notes > div i:last-child {
margin-left: 0;
}

.notes > div p {
margin: 0;
}
44 changes: 44 additions & 0 deletions testes/word-rank/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html ng-app="wordRankApp">

<head>
<title>Word Rank</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="css/custom.css" />


</head>

<body ng-controller="mainController">

<div class="container">

<h1>Word Rank</h1>

<table class="table">
<thead>
<tr>
<th>Word</th>
<th>Qty</th>
</tr>
</thead>
<tr ng-repeat="word in words">
<td>{{word.word}}</td>
<td>{{word.qty}}</td>
</tr>
</table>


</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.8/angular-filter.min.js"></script>
<script src="app/module.js"></script>
<script src="app/controllers/main.js"></script>

</body>

</html>