-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsilvercoins.html
123 lines (117 loc) · 4.27 KB
/
silvercoins.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PMC</title>
<!-- https://favicon.io/favicon-converter/ -->
<link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
<link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon.png">
<link rel="manifest" href="site.webmanifest">
<link rel="stylesheet" type="text/css" href="styles.css">
<style>
label {
color: silver;
}
</style>
</head>
<body>
<div class="container">
<h1 style="color: silver;">Silver Coins</h1>
<div>
<label for="grams">Grams (Pure Wgt):</label>
</div>
<div>
<input id="grams" inputmode="numeric" autofocus />
</div>
<div>
<button id="calcPriceBtn" onclick="calcPrice()">Calculate</button>
</div>
<div>
<label for="purchasePrice">Purchase Price:</label>
</div>
<div>
<input readonly id="purchasePrice" />
</div>
<div>
<br>
<label><i>Details...</i></label>
</div>
<div>
<label for="sptPrc">silver spot price:</label>
</div>
<div>
<input readonly id="sptPrc" />
</div>
<div>
<label for="prsdGrmInpt">parsed gram input:</label>
</div>
<div>
<input readonly id="prsdGrmInpt" />
</div>
<div>
<label for="troyOzToGrmsFctr">toz to grm factor:</label>
</div>
<div>
<input readonly id="troyOzToGrmsFctr" />
</div>
<div>
<label for="coinFctr">silver coin factor:</label>
</div>
<div>
<input readonly id="coinFctr" />
</div>
<div>
<br>
<label><i>Dale's Coin Verification Method</i></label>
</div>
<div>1. We do silver in nickels, dimes, quarters, and half dollars</div>
<div style="text-indent: 1em;">
<div>(Treat pure silver coins as bullion)</div>
</div>
<div>2. Different years have a different percentage of silver.</div>
<div>3. Find it on the internet.</div>
<div>4. Pay customer 2/3 of its silver value. No trade value.</div>
<div>
<br>
<label><i>Notes...</i></label>
</div>
<div>The spot price is set by calling a web service to get the current bid price at the moment. This price is in dollars per troy ounce. The bid price shows what buyers are currently willing to pay. Therefore, this is the foundation for what we are willing to pay the customer.</div>
</div>
<script src="metalprices.js"></script>
<script src="todoist.js"></script>
<script>
async function calcPrice() {0
const troyOuncesToGramsFactor = 1.0 / 31.1035;
let gramValue = document.getElementById('grams').value;
let silverCoinFactor = 2.0 / 3.0
let gramNumber = parseFloat(gramValue);
let curSpt = await fetchBidPrice("silver");
let purchasePrice = gramNumber * curSpt * troyOuncesToGramsFactor * silverCoinFactor;
let purPrcDisp = purchasePrice.toFixed(2);
let curSptDisp = curSpt.toFixed(2);
document.getElementById('purchasePrice').value = "$" + purPrcDisp;
document.getElementById('sptPrc').value = "$" + curSptDisp;
document.getElementById('prsdGrmInpt').value = gramNumber;
document.getElementById('troyOzToGrmsFctr').value = troyOuncesToGramsFactor;
document.getElementById('coinFctr').value = silverCoinFactor;
writeToLog(`
SILVER COINS
Grams: ${gramNumber}
Purchase Price: ${purPrcDisp}
Spot Price: ${curSptDisp}
Gram Factor: ${troyOuncesToGramsFactor}
Coin Factor: ${silverCoinFactor}
`);
}
//make enter the accept button
document.getElementById('grams').onkeydown = function (event) {
if (event.key === 'Enter') {
event.preventDefault();
calcPrice();
}
};
</script>
</body>
</html>