forked from justinpavatte/pmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilverbullion.html
113 lines (108 loc) · 3.69 KB
/
silverbullion.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
<!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>
<label for="tozs">Pure Weight (toz):</label>
</div>
<div>
<input id="tozs" 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="prsdInpt">parsed toz input:</label>
</div>
<div>
<input readonly id="prsdInpt" />
</div>
<div>
<label for="silkverBullionFactor">silver bullion factor:</label>
</div>
<div>
<input readonly id="silverBullionFactor" />
</div>
<div>
<br>
<label><i>Dale's Bullion Verification Method</i></label>
</div>
<div>1. Find it on the internet</div>
<div>2. Get its details</div>
<div style="text-indent: 1em;">
<div>a. Diameter</div>
<div>b. Thickness</div>
<div>c. Gross wgt</div>
<div style="text-indent: 2em;">Silver wgt (often 90% of Gross)</div>
</div>
<div>3. If a. b. c. are right, I count it as 'real'.</div>
<div>4. Pay customer 2/3 of 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>
<script src="metalprices.js"></script>
<script src="todoist.js"></script>
<script>
async function calcPrice() {
let parsedValue = document.getElementById('tozs').value;
let silverBullionFactor = 2.0 / 3.0;
let parsedNumber = parseFloat(parsedValue);
let curSpt = await fetchBidPrice("silver");
let purchasePrice = parsedNumber * curSpt * silverBullionFactor;
let purPrcDisp = purchasePrice.toFixed(2);
let curSptDisp = curSpt.toFixed(2);
document.getElementById('purchasePrice').value = "$" + purPrcDisp;
document.getElementById('sptPrc').value = "$" + curSptDisp;
document.getElementById('prsdInpt').value = parsedValue;
document.getElementById('silverBullionFactor').value = silverBullionFactor;
writeToLog(`
SILVER BULLION
Purchase Price: ${purPrcDisp}
Spot Price: ${curSptDisp}
Gold Weight: ${parsedValue}
Bullion Factor: ${silverBullionFactor}
`);
}
//make enter the accept button
document.getElementById('tozs').onkeydown = function (event) {
if (event.key === 'Enter') {
event.preventDefault();
calcPrice();
}
};
</script>
</body>
</html>