-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.html
149 lines (148 loc) · 8.14 KB
/
calculator.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Calculator LM</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body class="w3-sepia">
<div class="w3-row" ng-app="myApp" ng-controller="myCtrl">
<div class="w3-col w3-container w3-card">
<h2>Calculator for Lords Mobile Game</h2>
</div>
<div class="w3-col">
<hr>
</div>
<div class="w3-col m4 w3-container">
<div class="w3-cell-row">
<div class="w3-cell">
<div class="w3-bar-block">
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(1)">{{1|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(5)">{{5|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(15)">{{15|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(60)">{{60|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(480)">{{480|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(1440)">{{1440|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(10080)">{{10080|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="saveOnMemory()">> Memory</button>
</div>
</div>
<div class="w3-cell">
<div class="w3-bar-block">
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(3)">{{3|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(10)">{{10|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(30)">{{30|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(180)">{{180|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(900)">{{900|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(4320)">{{4320|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="addCard(43200)">{{43200|interval}}</button>
<button class="w3-bar-item w3-btn w3-ripple" ng-click="clearMemory()">Clear Memory</button>
</div>
</div>
</div>
</div>
<div class="w3-col m6 w3-container">
<form novalidate>
<input type="submit" hidden>
<table class="w3-table w3-striped w3-hoverable">
<tr ng-show="cards.length">
<th class="w3-right-align">Quantity</th>
<th class="w3-right-align">Resource</th>
<th><button class="w3-tooltip w3-btn w3-ripple" ng-click="removeAllCards()">×<span class="w3-text">Remove all lines</span></button></th>
</tr>
<tr ng-repeat="x in cards">
<td class="w3-right-align"><input id="{{'card'+$index}}" type="number" class="w3-right-align" ng-model="x.qty"><span ng-if="$last && shouldFocus">{{focusCard('card'+$index)}}</span></td>
<td class="w3-right-align">{{x.value|interval}}</td>
<td><button class="w3-tooltip w3-btn w3-ripple" ng-click="removeCard($index)">×<span class="w3-text">Remove this line</span></button></td>
</tr>
</table>
</form>
</div>
<div ng-show="total" class="w3-col m2 w3-container w3-card">
<h4>Sum</h4>
<h3>{{sum()|interval}}</h3>
<div ng-show="memory">
<h5>Memory</h5>
<p>{{memory|interval}}</p>
<h5>Total</h5>
<p>{{total|interval}}</p>
</div>
</div>
<div class="w3-col w3-container w3-card">
<hr>
<button class="w3-btn w3-ripple" ng-click="toggleAbout()">About & Help</button>
<div ng-show="about">
<h3>Calculator for Lords Mobile Game v0.3.4</h3>
<p>This calculator can helps you sum up the accelerators/speed ups from Lords Mobile game. It runs on most modern browsers and should work equally well on desktops, laptops, tablets and mobiles.</p>
<p>Use the Time Interval buttons (minutes, hours and days), then place the correspondig quantity of accelerators and see the result on the display at the end (near the word "Sum").</p>
<p>Press the Remove buttons (×) to delete each accelerator. To remove all them at once, choose the Remove button located at the top, near the "Resource" header.</p>
<p>The buttons Store to Memory and Clear Memory can reserve a previous result to add up to another set of accelerators.</p>
<p>If necessary you can ask for support by sending a message to the <a href="email:alvfig666@gmail.com">author</a> or contacting Lady WB on Lords Mobile game.</p>
<p>This project is on <a href="https://github.com/alvfig/calclm">Github</a>.</p>
<p>Copyright © 2018 by <a href="email:alvfig666@gmail.com">Alvaro Figueiredo</a></p>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.about = false;
$scope.shouldFocus = false;
$scope.memory = 0;
$scope.total = 0;
$scope.cards = [];
$scope.toggleAbout = function() {
$scope.about = !$scope.about;
};
$scope.focusCard = function(id) {
document.getElementById(id).focus();
$scope.shouldFocus = false;
};
$scope.saveOnMemory = function() {
$scope.memory = $scope.sum();
};
$scope.clearMemory = function() {
$scope.memory = 0;
};
$scope.addCard = function(v) {
$scope.cards.push({value: v, qty: ''})
$scope.shouldFocus = true;
};
$scope.removeCard = function(id) {
$scope.cards.splice(id, 1);
};
$scope.removeAllCards = function() {
$scope.cards.splice(0, $scope.cards.length);
};
$scope.sum = function() {
var sum = $scope.cards.reduce(function(sum, card) {
return sum + card.qty * card.value;
}, 0);
$scope.total = sum + $scope.memory;
return sum;
};
});
app.filter("interval", function() {
return function(minutes) {
var str = '';
var remain = minutes;
var formatPart = function(divisor, unit) {
var value = Math.floor(remain / divisor);
remain %= divisor;
if (value) {
str = str && str + ' ';
str += value + ' ' + unit;
str += (1 < value)? 's': '';
}
};
formatPart(1440, 'day');
formatPart(60, 'hour');
formatPart(1, 'minute');
return str;
};
});
</script>
</body>
</html>