Skip to content

Commit

Permalink
fix lass extension
Browse files Browse the repository at this point in the history
  • Loading branch information
estea8968 committed Sep 9, 2020
1 parent c5c9ad1 commit cb6c7fc
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 74 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" value="notranslate">
<link rel="shortcut icon" href="static/favicon.ico">
<title>OSEP_Code Editor 1090908</title>
<title>OSEP_Code Editor 10909009</title>

</head>
<body>
Expand Down
73 changes: 38 additions & 35 deletions app/lib.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -308500,7 +308500,7 @@ var blockIconURI = null; // https://widget.airmap.g0v.tw/create/LASS%24WF_127435
var LASS_URI = 'https://pm25.lass-net.org/data/last.php?device_id=';
var AQI_URI = 'https://data.epa.gov.tw/api/v1/aqx_p_432?limit=1000&api_key=9be7b239-557b-4c10-9775-78cadfc555e9&format=json';
var defaultId = 'WF_12743501';
var defaultCity = '板橋';
var defaultsiteName = '板橋';
var theLocale = null;
/**
* Enum for LASS specification.
Expand All @@ -308517,11 +308517,10 @@ var LassAttr = {
};
var aqiAttr = {
AQI: 'AQI',
PM25: 'PM2.5' // PM10: 'PM10',
//tempc: 's_t0',
// tempf: 'tempf',
//humidity: 's_h0'

PM25: 'PM2.5',
PM10: 'PM10',
o3: 'o3',
PublishTime: 'PublishTime'
};

var gasoLASS = /*#__PURE__*/function () {
Expand Down Expand Up @@ -308656,9 +308655,9 @@ var gasoLASS = /*#__PURE__*/function () {
opcode: 'aqiLASS',
blockType: BlockType.REPORTER,
arguments: {
city: {
siteName: {
type: ArgumentType.STRING,
defaultValue: defaultCity
defaultValue: defaultsiteName
},
attr: {
type: ArgumentType.STRING,
Expand Down Expand Up @@ -308715,19 +308714,16 @@ var gasoLASS = /*#__PURE__*/function () {
}, {
text: 'PM2.5',
value: aqiAttr.PM25
} //{
// text: msg.tempc[theLocale],
// value: aqiAttr.tempc
//},
// {
// text: '溫度 F',
// value: LassAttr.tempf
// },
//{
// text: msg.humidity[theLocale],
// value: LassAttr.humidity
//}
]
}, {
text: 'PM10',
value: aqiAttr.PM10
}, {
text: 'o3',
value: aqiAttr.o3
}, {
text: 'PublishTime',
value: aqiAttr.PublishTime
}]
}
}
};
Expand Down Expand Up @@ -308757,7 +308753,7 @@ var gasoLASS = /*#__PURE__*/function () {
value: function aqiLASS(args) {
var _this4 = this;

var city = args.city;
var siteName = args.siteName;
var attr = args.attr;
var url = "".concat(AQI_URI);
return fetch(url).then(function (res) {
Expand All @@ -308778,7 +308774,7 @@ var gasoLASS = /*#__PURE__*/function () {
_key = _Object$entries2$_i[0],
_value = _Object$entries2$_i[1];

if ("".concat(_key, ": ").concat(_value) == "".concat(_key, ": ").concat(city)) {
if ("".concat(_key, ": ").concat(_value) == "".concat(_key, ": ").concat(siteName)) {
console.log("".concat(_key, ": ").concat(_value));
_this4.aqidata = bdata;
console.log(_this4.aqidata);
Expand All @@ -308789,22 +308785,29 @@ var gasoLASS = /*#__PURE__*/function () {

}
});
var returndata = [];

for (x in _this4.aqidata) {
returndata.push(_this4.aqidata[x]);
}

;
console.log('returndata:', returndata);

if (attr == 'AQI') {
return returndata[2]; //return typeof data === 'string' ? data : JSON.stringify(this.aqidata.AQI);
return _this4.aqidata.AQI; //return typeof data === 'string' ? data : JSON.stringify(this.aqidata.AQI);
}

if (attr == 'PM2.5') {
console.log('PM2.5');
return returndata[11]; //return typeof data === 'string' ? data : JSON.stringify(this.aqidata[11]');
return _this4.aqidata['PM2.5'];
}

if (attr == 'PM10') {
console.log('PM10');
return _this4.aqidata.PM10;
}

if (attr == 'o3') {
console.log('o3');
return _this4.aqidata.O3;
}

if (attr == 'PublishTime') {
console.log('PublishTime');
return _this4.aqidata.PublishTime;
} ///return this.aqidata.AQI;

}
Expand Down Expand Up @@ -308876,8 +308879,8 @@ var fetchLASS = {
'zh-tw': 'LASS 設備編號 [id]'
};
var aqiLASS = {
'en': 'LASS AQI city [city] read [attr]',
'zh-tw': 'LASS AQI 城市 [city] 讀取 [attr]'
'en': 'LASS AQI city [siteName] read [attr]',
'zh-tw': '環保署測站 [siteName] 讀取 [attr]'
};
var onLASSReceived = {
'en': 'When received data from LASS',
Expand Down
2 changes: 1 addition & 1 deletion app/lib.min.js.map

Large diffs are not rendered by default.

75 changes: 40 additions & 35 deletions node_modules/scratch-vm/src/extensions/scratch3_lass/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb6c7fc

Please sign in to comment.