Skip to content

Commit

Permalink
update raining
Browse files Browse the repository at this point in the history
  • Loading branch information
hokou committed Dec 12, 2023
1 parent 3f71cd1 commit d90352c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/raining.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const rain_url = "https://opendata.cwa.gov.tw/api/v1/rest/datastore/O-A0002-001?
let B1 = document.querySelector(".B1");
let C4 = document.querySelector(".C4");

let area_list = ["臺北","臺中","高雄","桃園","新竹","臺南"]
let div_list = ["B2","B3","B4","C1","C2","C3"]

for (let i=0; i<area_list.length; i++) {
rain_data(area_list[i], div_list[i]);
}

image(B1, "P7010089_min.jpg");
image(C4,"P5090484_min.jpg");

Expand All @@ -18,13 +25,6 @@ function image(block, img){
block.style.backgroundAttachment="scroll";
}

let area_list = ["臺北","臺中","高雄","桃園","新竹","臺南"]
let div_list = ["B2","B3","B4","C1","C2","C3"]

for (let i=0; i<area_list.length; i++) {
rain_data(area_list[i], div_list[i]);
}

function rain_data(locationName, block) {
fetch(rain_url + CWA_API_KEY + '&' + 'StationName=' + locationName).then((response) => {
return response.json();
Expand Down

0 comments on commit d90352c

Please sign in to comment.