forked from JCharante/haulers-channel-reward-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
203 lines (185 loc) · 8.03 KB
/
index.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<head>
<title>Haulers Channel - Base Rate Calculator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="hauling.css">
<script src="utils.js"></script>
<script>
$(document).ready(function(){
// Used by the auto copy to clipboard
var stuff_to_copy_to_clipboard = "";
// Puts commas in input field
$('#collateral').keyup(function(event) {
// skip for arrow keys
if(event.which >= 37 && event.which <= 40) return;
// format number
$(this).val(function(index, value) {
return value
.replace(/\D/g, "")
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
;
});
});
// Puts commas in input field
$('#jumps').keyup(function(event) {
// skip for arrow keys
if(event.which >= 37 && event.which <= 40) return;
// format number
$(this).val(function(index, value) {
return value
.replace(/\D/g, "")
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
;
});
});
$('.output_area').click(function() {
// Copies price to clipboard when the output area is clicked
copyTextToClipboard(stuff_to_copy_to_clipboard);
});
$('.disclaimer_footer').click(function() {
// Copies price to clipboard when the output area is clicked
copyTextToClipboard(stuff_to_copy_to_clipboard);
});
$('.header').click(function() {
// Copies price to clipboard when the output area is clicked
copyTextToClipboard(stuff_to_copy_to_clipboard);
});
$('#collateral_label').click(function() {
$('#collateral_label').addClass('active');
})
$('#jumps_label').click(function() {
$('#jumps_label').addClass('active');
})
$('html').click(function() {
// Reward Rates by Rita Jita, site made by Rashad Charante
var collateral = $('#collateral').val();
// Sanitizes inputs by getting rid of commas and other stuff
collateral = collateral.replace(/[^\d\.\-\ ]/g, '');
var jumps = $('#jumps').val();
jumps = jumps.replace(/[^\d\.\-\ ]/g, '');
// Set a basic minimum percentage of the collateral that we will take.
var baseColPercentage = 0.005;
// Set a basic pickup fee to this percentage of the collateral
// This will be capped to 1% maximum further down.
var pickupFee = 0;
// Set the minimum/basic price per jump
var pricePerJump = 500000;
// Increase the precentage of the collateral that we take based on jumps by this percentage
// This is to reflect the increased risk and time spent by the hauler.
var incPerJump = 1.002;
var pickupReward = 0;
var reward = 0;
var baseRate = 0;
// Shamelessly ripped from stack overflow
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
// Let's do some magic then
baseRate = pricePerJump*jumps;
for (i = 1; i < jumps; i++) {
baseColPercentage += 0.001;
if (baseColPercentage >= 0.01) { break; }
}
pickupFee = collateral*baseColPercentage;
pickupReward = pickupFee*incPerJump^jumps;
reward = baseRate+pickupReward;
if (collateral*0.001*jumps > reward) {
reward = collateral*0.001*jumps;
}
if (reward >= (collateral*0.5) ) {
reward = collateral*0.3;
}
// Let's round up to make it look purdy
reward = Math.round(reward/1000)*1000;
// Extra Fees
if ($('#rush').prop('checked')) {
reward = reward * 2;
}
if ($('#lowsec').prop('checked')) {
reward = reward * 2;
}
// updates prices displayed in text
if (reward > 0) {
$('#reward_label').addClass('active');
$('#reward_ipj_label').addClass('active');
$('#reward').val(numberWithCommas(reward.toFixed(2)));
var ipj = reward / jumps
ipj = ipj.toFixed(2);
$('#reward_ipj').val(numberWithCommas(ipj));
stuff_to_copy_to_clipboard = reward;
}
});
});
</script>
</head>
<body class="grey darken-3">
<div class="container">
<div class="row">
<div class="round_box grey darken-3 col s12" style="margin-top: 0px;">
<div class="row">
<!-- Header -->
<div class="header col s12">
<h1 class="center-align title" style="color: #FFFFFF; font-size: 8em">Haulers Channel</h1>
<h4 class="grey-text darken-3 center-align title" style="margin-top: -20px; margin-bottom: 60px; font-size: 4.5em">Base Rate Calculator</h4>
</div>
<!--<hr>-->
<!-- Input Area -->
<div class="col s12 input_area" style="margin-left: 15px;">
<div class="row">
<!-- Left Side -->
<div class="col s2 offset-s4">
<form class="col s12">
<div class="row">
<div class="input-field col s12">
<input id="collateral" type="text" class="validate">
<label id="collateral_label" for="collateral">Collateral</label>
</div>
<div class="input-field col s12">
<input id="jumps" type="text" class="validate">
<label id="jumps_label" for="jumps"># of Jumps</label>
</div>
<p class="left-align" style="margin-left: 10px">
<input type="checkbox" class="filled-in" id="rush"/>
<label for="rush">Rush Delivery </label>
</p>
</div>
</form>
</div>
<!-- Right Side -->
<div class="col s2" style="margin-left: -21px">
<!-- Output Area -->
<div class="col s12 output_area">
<div class="row bottom_area">
<!-- Bottom Area -->
<div class="input-field col s12">
<input style="color: green;" id="reward" type="text" class="validate">
<label id="reward_label" for="reward">Reward</label>
</div>
<div class="input-field col s12">
<input style="color: green;" id="reward_ipj" type="text" class="validate">
<label id="reward_ipj_label" for="reward_ipj">Reward Per Jump</label>
</div>
<p class="left-align" style="margin-left: 10px">
<input type="checkbox" class="filled-in" id="lowsec"/>
<label for="lowsec">Lowsec</label>
</p>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div class="disclaimer_footer">
<p class="center-align" style="color: #FFFFFF"><span style="color: yellow">Disclaimer: </span>The Final Price is entirely up to yourself.</p>
<p class="center-align" style="color: #FFFFFF"> This calculator is intended for people new to courier contracts, anything under</p>
<p class="center-align" style="color: #FFFFFF">these values will normally move slower than normal., and possibly not at all.</p>
<p class="center-align" style="color: #FFFFFF"><strong>Note: <i>The more you pay </i> = the less you wait.</strong></p>
</div>
</div>
</div>
</div>
</div>
</body>