Skip to content

Commit 9ea8713

Browse files
author
Your Full Name
committed
todoist logging complete
1 parent c1316f2 commit 9ea8713

File tree

6 files changed

+107
-58
lines changed

6 files changed

+107
-58
lines changed

goldbullion.html

+16-4
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,33 @@
7474
</div>
7575
<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>
7676
<script src="metalprices.js"></script>
77+
<script src="todoist.js"></script>
7778
<script>
7879
async function calcPrice() {
7980
let parsedValue = document.getElementById('tozs').value;
8081
let goldBullionFactor = 0.8;
8182

8283
let parsedNumber = parseFloat(parsedValue);
83-
let currentSpotGoldPricePerTroyOunce = await fetchBidPrice("gold");
84-
let purchasePrice = parsedNumber * currentSpotGoldPricePerTroyOunce * goldBullionFactor;
84+
let curSpt = await fetchBidPrice("gold");
85+
let purchasePrice = parsedNumber * curSpt * goldBullionFactor;
86+
let purPrcDisp = purchasePrice.toFixed(2);
87+
let curSptDisp = curSpt.toFixed(2);
8588

86-
document.getElementById('purchasePrice').value = "$" + purchasePrice.toFixed(2);;
89+
document.getElementById('purchasePrice').value = "$" + purPrcDisp;
8790

88-
document.getElementById('gldSptPrc').value = "$" + currentSpotGoldPricePerTroyOunce.toFixed(2);;
91+
document.getElementById('gldSptPrc').value = "$" + curSptDisp;
8992
document.getElementById('prsdInpt').value = parsedValue;
9093
document.getElementById('goldBullionFactor').value = goldBullionFactor;
94+
95+
writeToLog(`
96+
GOLD BULLION
97+
Purchase Price: ${purPrcDisp}
98+
Spot Price: ${curSptDisp}
99+
Gold Weight: ${parsedValue}
100+
Bullion Factor: ${goldBullionFactor}
101+
`);
91102
}
103+
92104
//make enter the accept button
93105
document.getElementById('tozs').onkeydown = function (event) {
94106
if (event.key === 'Enter') {

goldscrap.html

+22-5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
</div>
9595
<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>
9696
<script src="metalprices.js"></script>
97+
<script src="todoist.js"></script>
9798
<script>
9899
async function calcPrice() {
99100
const troyOuncesToGramsFactor = 0.0322;
@@ -114,20 +115,36 @@
114115
else if (karatValue == "18K") {
115116
karatFactor = 18.0 / 24.0;
116117
}
117-
let currentSpotGoldPricePerTroyOunce = await fetchBidPrice("gold");
118-
let fullValueForTrade = gramNumber * (currentSpotGoldPricePerTroyOunce - fluctuatingPriceFactor) * troyOuncesToGramsFactor * karatFactor * refineryFeeAndDirtFactor;
118+
let curSpt = await fetchBidPrice("gold");
119+
let fullValueForTrade = gramNumber * (curSpt - fluctuatingPriceFactor) * troyOuncesToGramsFactor * karatFactor * refineryFeeAndDirtFactor;
119120
let halfValueForScrap = fullValueForTrade / 2.0;
121+
let tradePriceDisp = fullValueForTrade.toFixed(2);
122+
let scrapPriceDisp = halfValueForScrap.toFixed(2);
123+
let curSptDisp = curSpt.toFixed(2);
120124

121-
document.getElementById('tradeValue').value = "$" + fullValueForTrade.toFixed(2);;
122-
document.getElementById('scrapValue').value = "$" + halfValueForScrap.toFixed(2);;
125+
document.getElementById('tradeValue').value = "$" + tradePriceDisp;
126+
document.getElementById('scrapValue').value = "$" + scrapPriceDisp;
123127

124-
document.getElementById('gldSptPrc').value = "$" + currentSpotGoldPricePerTroyOunce.toFixed(2);;
128+
document.getElementById('gldSptPrc').value = "$" + curSptDisp;
125129
document.getElementById('spotFluc').value = fluctuatingPriceFactor;
126130
document.getElementById('prsdGrmInpt').value = gramNumber;
127131
document.getElementById('troyOzToGrmsFctr').value = troyOuncesToGramsFactor;
128132
document.getElementById('krtFct').value = karatFactor;
129133
document.getElementById('rfDrt').value = refineryFeeAndDirtFactor;
134+
135+
writeToLog(`
136+
GOLD SCRAP
137+
Trade: ${tradePriceDisp}
138+
Scrap: ${scrapPriceDisp}
139+
Spot: ${curSptDisp}
140+
Fluc: ${fluctuatingPriceFactor}
141+
Grams: ${gramNumber}
142+
Gram Factor: ${troyOuncesToGramsFactor}
143+
Karat Factor: ${karatFactor}
144+
Refine/Dirt Factor: ${refineryFeeAndDirtFactor}
145+
`);
130146
}
147+
131148
//make enter the accept button
132149
document.getElementById('grams').onkeydown = function (event) {
133150
if (event.key === 'Enter') {

silverbullion.html

+16-4
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,33 @@
7474
</div>
7575
<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>
7676
<script src="metalprices.js"></script>
77+
<script src="todoist.js"></script>
7778
<script>
7879
async function calcPrice() {
7980
let parsedValue = document.getElementById('tozs').value;
8081
let silverBullionFactor = 2.0 / 3.0;
8182

8283
let parsedNumber = parseFloat(parsedValue);
83-
let currentSpotsilverPricePerTroyOunce = await fetchBidPrice("silver");
84-
let purchasePrice = parsedNumber * currentSpotsilverPricePerTroyOunce * silverBullionFactor;
84+
let curSpt = await fetchBidPrice("silver");
85+
let purchasePrice = parsedNumber * curSpt * silverBullionFactor;
86+
let purPrcDisp = purchasePrice.toFixed(2);
87+
let curSptDisp = curSpt.toFixed(2);
8588

86-
document.getElementById('purchasePrice').value = "$" + purchasePrice.toFixed(2);;
89+
document.getElementById('purchasePrice').value = "$" + purPrcDisp;
8790

88-
document.getElementById('sptPrc').value = "$" + currentSpotsilverPricePerTroyOunce.toFixed(2);;
91+
document.getElementById('sptPrc').value = "$" + curSptDisp;
8992
document.getElementById('prsdInpt').value = parsedValue;
9093
document.getElementById('silverBullionFactor').value = silverBullionFactor;
94+
95+
writeToLog(`
96+
SILVER BULLION
97+
Purchase Price: ${purPrcDisp}
98+
Spot Price: ${curSptDisp}
99+
Gold Weight: ${parsedValue}
100+
Bullion Factor: ${silverBullionFactor}
101+
`);
91102
}
103+
92104
//make enter the accept button
93105
document.getElementById('tozs').onkeydown = function (event) {
94106
if (event.key === 'Enter') {

silverscrap.html

+21-5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
</div>
7979
<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>
8080
<script src="metalprices.js"></script>
81+
<script src="todoist.js"></script>
8182
<script>
8283
async function calcPrice() {
8384
const troyOuncesToGramsFactor = 0.0322;
@@ -87,19 +88,34 @@
8788
let sterlingFactor = 0.925
8889

8990
let gramNumber = parseFloat(gramValue);
90-
let currentSpotPricePerTroyOunce = await fetchBidPrice("silver");
91-
let fullValueForTrade = gramNumber * currentSpotPricePerTroyOunce * troyOuncesToGramsFactor * sterlingFactor * refineryFeeAndDirtFactor;
91+
let curSpt = await fetchBidPrice("silver");
92+
let fullValueForTrade = gramNumber * curSpt * troyOuncesToGramsFactor * sterlingFactor * refineryFeeAndDirtFactor;
9293
let halfValueForScrap = fullValueForTrade / 2.0;
94+
let tradePriceDisp = fullValueForTrade.toFixed(2);
95+
let scrapPriceDisp = halfValueForScrap.toFixed(2);
96+
let curSptDisp = curSpt.toFixed(2);
9397

94-
document.getElementById('tradeValue').value = "$" + fullValueForTrade.toFixed(2);;
95-
document.getElementById('scrapValue').value = "$" + halfValueForScrap.toFixed(2);;
98+
document.getElementById('tradeValue').value = "$" + tradePriceDisp;
99+
document.getElementById('scrapValue').value = "$" + scrapPriceDisp;
96100

97-
document.getElementById('sptPrc').value = "$" + currentSpotPricePerTroyOunce.toFixed(2);;
101+
document.getElementById('sptPrc').value = "$" + curSptDisp;
98102
document.getElementById('prsdGrmInpt').value = gramNumber;
99103
document.getElementById('troyOzToGrmsFctr').value = troyOuncesToGramsFactor;
100104
document.getElementById('sterFctr').value = sterlingFactor;
101105
document.getElementById('rfDrt').value = refineryFeeAndDirtFactor;
106+
107+
writeToLog(`
108+
SILVER SCRAP
109+
Trade: ${tradePriceDisp}
110+
Scrap: ${scrapPriceDisp}
111+
Spot: ${curSptDisp}
112+
Grams: ${gramNumber}
113+
Gram Factor: ${troyOuncesToGramsFactor}
114+
Sterling Factor: ${sterlingFactor}
115+
Refine/Dirt Factor: ${refineryFeeAndDirtFactor}
116+
`);
102117
}
118+
103119
//make enter the accept button
104120
document.getElementById('grams').onkeydown = function (event) {
105121
if (event.key === 'Enter') {

td.html

+2-40
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,10 @@
77
</head>
88
<body>
99
<button onclick="addComment()" >Add Comment</button>
10+
<script src="todoist.js"></script>
1011
<script>
1112
async function addComment() {
12-
let apiUrl = "https://api.todoist.com/rest/v2/comments";
13-
let apiToken = "8972a19cadcc698cf4843761485fd359165c061b";
14-
let taskId = "7994854973";
15-
16-
let data = {
17-
userAgent: navigator.userAgent,
18-
appVersion: navigator.appVersion,
19-
appName: navigator.appName,
20-
platform: navigator.platform,
21-
language: navigator.language || navigator.languages[0],
22-
cookieEnabled: navigator.cookieEnabled,
23-
online: navigator.onLine,
24-
screen: {
25-
width: screen.width,
26-
height: screen.height,
27-
colorDepth: screen.colorDepth,
28-
},
29-
viewport: {
30-
width: window.innerWidth,
31-
height: window.innerHeight,
32-
},
33-
localStorageEnabled: typeof localStorage !== 'undefined',
34-
sessionStorageEnabled: typeof sessionStorage !== 'undefined',
35-
timeZoneEnabled: typeof Intl !== 'undefined' && Intl.DateTimeFormat().resolvedOptions().timeZone,
36-
};
37-
let commentContent = JSON.stringify(data, null, 2);
38-
39-
let commentData = {
40-
task_id: taskId,
41-
content: commentContent
42-
};
43-
let response = await fetch(apiUrl, {
44-
method: 'POST',
45-
headers: {
46-
'Authorization': `Bearer ${apiToken}`,
47-
'Content-Type': 'application/json',
48-
},
49-
body: JSON.stringify(commentData),
50-
});
51-
console.log(response.status);
13+
await writeToLog("hi");
5214
}
5315
</script>
5416
</body>

todoist.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
async function writeToLog(message) {
2+
let apiUrl = "https://api.todoist.com/rest/v2/comments";
3+
//Todoist account is Curtis Google
4+
let apiToken = "8972a19cadcc698cf4843761485fd359165c061b";
5+
let taskId = "7994854973";
6+
7+
let environmentString = `
8+
User Agent: ${navigator.userAgent}
9+
App Name: ${navigator.appName}
10+
Platform: ${navigator.platform}
11+
Language: ${navigator.language || navigator.languages[0]}
12+
Screen: ${screen.width}x${screen.height} @ ${screen.colorDepth} bits
13+
Viewport: ${window.innerWidth}x${window.innerHeight}
14+
Time Zone Enabled: ${typeof Intl !== 'undefined' && Intl.DateTimeFormat().resolvedOptions().timeZone}
15+
`;
16+
17+
let commentData = {
18+
task_id: taskId,
19+
content: message + environmentString
20+
};
21+
let response = await fetch(apiUrl, {
22+
method: 'POST',
23+
headers: {
24+
'Authorization': `Bearer ${apiToken}`,
25+
'Content-Type': 'application/json',
26+
},
27+
body: JSON.stringify(commentData),
28+
});
29+
console.log(response.status);
30+
}

0 commit comments

Comments
 (0)