-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscripts.js
More file actions
28 lines (26 loc) · 736 Bytes
/
Copy pathscripts.js
File metadata and controls
28 lines (26 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var myApp = angular.module('LetterCounterApp', ['ui.bootstrap']);
myApp.controller('LetterCounter', ['$scope', function ($scope) {
$scope.checkboxModel = {
ignoreCapitals: false
}
$scope.letterCounts = {};
$scope.countLetters = function (title = '') {
var textIn = title;
if ($scope.checkboxModel.ignoreCapitals) {
textIn = textIn.toLowerCase();
}
var charCount = {};
var i;
for (i = 0; i < textIn.length; i++) {
if (!(textIn.charAt(i) == ' ')) {
charCount[textIn.charAt(i)] = 0;
}
}
for (i = 0; i < textIn.length; i++) {
if (!(textIn.charAt(i) == ' ')) {
charCount[textIn.charAt(i)] += 1;
}
}
$scope.letterCounts = charCount;
}
}]);