Skip to content

Commit a3d1ba0

Browse files
committed
fixing read from cloud, update google analytics
1 parent c6f1e11 commit a3d1ba0

2 files changed

Lines changed: 45 additions & 41 deletions

File tree

smith_chart/index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
<head>
55

6-
<!-- Global site tag (gtag.js) - Google Analytics -->
7-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118860421-1"></script>
8-
<script>
9-
window.dataLayer = window.dataLayer || [];
10-
function gtag() { dataLayer.push(arguments); }
11-
gtag('js', new Date());
12-
13-
gtag('config', 'UA-118860421-1');
14-
</script>
6+
<!-- Google tag (gtag.js) -->
7+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JHF1DVMYL7"></script>
8+
<script>
9+
window.dataLayer = window.dataLayer || [];
10+
function gtag(){dataLayer.push(arguments);}
11+
gtag('js', new Date());
12+
13+
gtag('config', 'G-JHF1DVMYL7');
14+
</script>
1515

1616
<meta charset="utf-8">
1717
<meta name="author" content="Will Kelsey">

smith_chart/js/smith_tool.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function readFromJsonBin(id) {
3333
const objBin = JSON.parse(req.responseText);
3434
console.log(req.responseText, objBin);
3535
schematic = objBin.record;
36-
update_smith_chart();
36+
updateFromOldState();
3737
}
3838
};
3939
req.open("GET", `https://api.jsonbin.io/v3/b/${id}/latest`, true);
@@ -183,42 +183,46 @@ function readFile() {
183183
reader.onload = function (event) {
184184

185185
schematic = JSON.parse(event.target.result);
186-
//check for old version of file
187-
for (i = 1; i < schematic.length; i++) {
188-
if (!(Array.isArray(schematic[i].abs))) {
189-
schematic[i].abs = [schematic[i].abs];
190-
}
191-
if ('abs_bb_i' in schematic[i]) schematic[i].abs.push(schematic[i].abs_bb_i);
192-
if (!(Array.isArray(schematic[i].unit))) {
193-
schematic[i].unit = [schematic[i].unit];
194-
}
195-
}
186+
console.log("READING", schematic);
187+
updateFromOldState()
188+
}
189+
reader.readAsText(file);
190+
}
196191

197-
//update freq units
198-
var opts = domFreqSel.options;
199-
for (var opt, j = 0; opt = opts[j]; j++) {
200-
if (opt.value == freqUnitToText(schematic[0].freq_unit.multiplier)) {
201-
domFreqSel.selectedIndex = j;
202-
break;
203-
}
192+
function updateFromOldState() {
193+
//check for old version of file
194+
for (i = 1; i < schematic.length; i++) {
195+
if (!(Array.isArray(schematic[i].abs))) {
196+
schematic[i].abs = [schematic[i].abs];
204197
}
205-
opts = domSpanSel.options;
206-
for (opt, j = 0; opt = opts[j]; j++) {
207-
if (opt.value == freqUnitToText(schematic[0].span_unit.multiplier)) {
208-
domSpanSel.selectedIndex = j;
209-
break;
210-
}
198+
if ('abs_bb_i' in schematic[i]) schematic[i].abs.push(schematic[i].abs_bb_i);
199+
if (!(Array.isArray(schematic[i].unit))) {
200+
schematic[i].unit = [schematic[i].unit];
211201
}
202+
}
212203

213-
domFreq.value = Number(schematic[0].freq);
214-
domSpan.value = Number(schematic[0].span);
215-
domEr.value = Number(schematic[0].er);
216-
zo = Number(schematic[0].zo);
217-
domZo.value = zo;
218-
console.log("READING", schematic);
219-
updateFromDom();
204+
//update freq units
205+
var opts = domFreqSel.options;
206+
for (var opt, j = 0; opt = opts[j]; j++) {
207+
if (opt.value == freqUnitToText(schematic[0].freq_unit.multiplier)) {
208+
domFreqSel.selectedIndex = j;
209+
break;
210+
}
220211
}
221-
reader.readAsText(file);
212+
opts = domSpanSel.options;
213+
for (opt, j = 0; opt = opts[j]; j++) {
214+
if (opt.value == freqUnitToText(schematic[0].span_unit.multiplier)) {
215+
domSpanSel.selectedIndex = j;
216+
break;
217+
}
218+
}
219+
220+
domFreq.value = Number(schematic[0].freq);
221+
domSpan.value = Number(schematic[0].span);
222+
domEr.value = Number(schematic[0].er);
223+
zo = Number(schematic[0].zo);
224+
domZo.value = zo;
225+
updateFromDom();
222226
}
223227

224228

0 commit comments

Comments
 (0)