diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1e501e3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bower_components +node_modules \ No newline at end of file diff --git a/testes/cash-machine/app/controllers/main.js b/testes/cash-machine/app/controllers/main.js new file mode 100644 index 00000000..fcfbc3d4 --- /dev/null +++ b/testes/cash-machine/app/controllers/main.js @@ -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); \ No newline at end of file diff --git a/testes/cash-machine/app/module.js b/testes/cash-machine/app/module.js new file mode 100644 index 00000000..d37648c4 --- /dev/null +++ b/testes/cash-machine/app/module.js @@ -0,0 +1,6 @@ +(function(angular) { + "use strict"; + + angular.module("cashMachineApp", ['angular.filter']); + +})(angular); \ No newline at end of file diff --git a/testes/cash-machine/css/custom.css b/testes/cash-machine/css/custom.css new file mode 100644 index 00000000..1360ad27 --- /dev/null +++ b/testes/cash-machine/css/custom.css @@ -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; +} diff --git a/testes/cash-machine/index.html b/testes/cash-machine/index.html new file mode 100644 index 00000000..441b0b8f --- /dev/null +++ b/testes/cash-machine/index.html @@ -0,0 +1,60 @@ + + + + Cash Machine + + + + + + + + + + +
+ +

Cash Machine

+ + +
+ +
+
+ +
+ + +
+
{{errorMessage}}
+ + +
+ +
+ +
+
+ + +
+ +
+
+ +

{{note.length}} x {{note[0].value | currency}}

+
+
+ +
+ + + + + + + + + + + \ No newline at end of file diff --git a/testes/word-rank/app/controllers/main.js b/testes/word-rank/app/controllers/main.js new file mode 100644 index 00000000..953f0733 --- /dev/null +++ b/testes/word-rank/app/controllers/main.js @@ -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); \ No newline at end of file diff --git a/testes/word-rank/app/module.js b/testes/word-rank/app/module.js new file mode 100644 index 00000000..84686236 --- /dev/null +++ b/testes/word-rank/app/module.js @@ -0,0 +1,6 @@ +(function(angular) { + "use strict"; + + angular.module("wordRankApp", ['angular.filter']); + +})(angular); \ No newline at end of file diff --git a/testes/word-rank/css/custom.css b/testes/word-rank/css/custom.css new file mode 100644 index 00000000..1360ad27 --- /dev/null +++ b/testes/word-rank/css/custom.css @@ -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; +} diff --git a/testes/word-rank/index.html b/testes/word-rank/index.html new file mode 100644 index 00000000..e9a0c98b --- /dev/null +++ b/testes/word-rank/index.html @@ -0,0 +1,44 @@ + + + + Word Rank + + + + + + + + + + +
+ +

Word Rank

+ + + + + + + + + + + + +
WordQty
{{word.word}}{{word.qty}}
+ + +
+ + + + + + + + + + + \ No newline at end of file