{"id":5969,"date":"2024-09-28T21:00:39","date_gmt":"2024-09-28T12:00:39","guid":{"rendered":"https:\/\/taiwan-bopomofo.com\/?page_id=5969"},"modified":"2024-09-28T21:09:56","modified_gmt":"2024-09-28T12:09:56","slug":"%e4%bb%8a%e6%97%a5%e3%81%ae%e5%8f%b0%e6%b9%be%e3%81%af%e3%81%a9%e3%82%93%e3%81%aa%e5%a4%a9%e6%b0%97%ef%bc%9f","status":"publish","type":"page","link":"https:\/\/taiwan-bopomofo.com\/?page_id=5969","title":{"rendered":"\u4eca\u65e5\u306e\u53f0\u6e7e\u306f\u3069\u3093\u306a\u5929\u6c17\uff1f"},"content":{"rendered":"\n<p>\u4eca\u65e5\u306e\u53f0\u6e7e\u306e\u5929\u6c17\u4e88\u5831\u3092\u5404\u90fd\u5e02\u3054\u3068\u306b\u63b2\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<br>\u6ede\u5728\u306e\u969b\u306b\u304a\u5f79\u7acb\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<div id=\"weather\" style=\"display: flex; flex-wrap: wrap; gap: 20px;\"><\/div>\n\n<script>\n  const cities = ['Taipei', 'Taichung', 'Taitung', 'Tainan', 'Kaohsiung', 'Hualien'];\n  const apiKey = '7c89fca1948f33d6d07c3213be9d4489';  \/\/ OpenWeatherMap\u304b\u3089\u53d6\u5f97\u3057\u305fAPI\u30ad\u30fc\u3092\u5165\u529b\n  const weatherDiv = document.getElementById('weather');\n  \n  async function fetchWeather(city) {\n    \/\/ 5\u65e5\u9593\u306e\u5929\u6c17\u4e88\u5831\uff083\u6642\u9593\u6bce\uff09\u3092\u53d6\u5f97\n    const response = await fetch(`https:\/\/api.openweathermap.org\/data\/2.5\/forecast?q=${city},TW&appid=${apiKey}&units=metric`);\n    const data = await response.json();\n    return data;\n  }\n\n  function displayWeather(data, city) {\n    const currentWeather = data.list[0];  \/\/ \u6700\u65b0\u306e\u5929\u6c17\u4e88\u5831\u3092\u4f7f\u7528\n    const iconCode = currentWeather.weather[0].icon;\n    const iconUrl = `http:\/\/openweathermap.org\/img\/wn\/${iconCode}@2x.png`;\n    const sunrise = new Date(data.city.sunrise * 1000).toLocaleTimeString();  \/\/ \u65e5\u306e\u51fa\u306e\u6642\u9593\n    const sunset = new Date(data.city.sunset * 1000).toLocaleTimeString();    \/\/ \u65e5\u306e\u5165\u308a\u306e\u6642\u9593\n    const windSpeed = Math.round(currentWeather.wind.speed);  \/\/ \u98a8\u901f\u3092\u56db\u6368\u4e94\u5165\n    const rainProbability = Math.round(currentWeather.pop * 100);  \/\/ \u964d\u6c34\u78ba\u7387\uff08\uff05\uff09\u3092\u56db\u6368\u4e94\u5165\n    const temp = Math.round(currentWeather.main.temp);  \/\/ \u6e29\u5ea6\u3092\u56db\u6368\u4e94\u5165\n    const tempMax = Math.round(currentWeather.main.temp_max);  \/\/ \u6700\u9ad8\u6c17\u6e29\u3092\u56db\u6368\u4e94\u5165\n    const tempMin = Math.round(currentWeather.main.temp_min);  \/\/ \u6700\u4f4e\u6c17\u6e29\u3092\u56db\u6368\u4e94\u5165\n    const humidity = Math.round(currentWeather.main.humidity);  \/\/ \u6e7f\u5ea6\u3092\u56db\u6368\u4e94\u5165\n\n    \/\/ \u5098\u30de\u30fc\u30af\uff08\u964d\u6c34\u78ba\u7387\u304c\u9ad8\u3044\u5834\u5408\u306b\u8868\u793a\uff09\n    const umbrellaIcon = rainProbability > 30 ? '\u2602\ufe0f' : '';\n\n    \/\/ \u65e5\u306e\u51fa\u3068\u65e5\u306e\u5165\u308a\u306e\u30a2\u30a4\u30b3\u30f3\n    const sunriseIcon = '\ud83c\udf05';\n    const sunsetIcon = '\ud83c\udf07';\n\n    const cityWeather = `\n      <div style=\"border: 1px solid #ccc; padding: 10px; width: 200px;\">\n        <h2>${city}<\/h2>\n        <img decoding=\"async\" src=\"${iconUrl}\" alt=\"Weather icon\">\n        <p>\u964d\u6c34\u78ba\u7387: ${rainProbability}% ${umbrellaIcon}<\/p>\n        <p>\u6e29\u5ea6: ${temp} \u00b0C<\/p>\n        <p>\u6700\u9ad8\u6c17\u6e29: ${tempMax} \u00b0C<\/p>\n        <p>\u6700\u4f4e\u6c17\u6e29: ${tempMin} \u00b0C<\/p>\n        <p>\u6e7f\u5ea6: ${humidity} %<\/p>\n        <p>\u98a8\u901f: ${windSpeed} m\/s<\/p>\n        <p>${sunriseIcon} \u65e5\u306e\u51fa: ${sunrise}<\/p>\n        <p>${sunsetIcon} \u65e5\u306e\u5165\u308a: ${sunset}<\/p>\n      <\/div>\n    `;\n    weatherDiv.innerHTML += cityWeather;\n  }\n\n  async function getWeather() {\n    for (const city of cities) {\n      const data = await fetchWeather(city);\n      displayWeather(data, city);\n    }\n  }\n\n  getWeather();\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306e\u53f0\u6e7e\u306e\u5929\u6c17\u4e88\u5831\u3092\u5404\u90fd\u5e02\u3054\u3068\u306b\u63b2\u8f09\u3057\u3066\u3044\u307e\u3059\u3002\u6ede\u5728\u306e\u969b\u306b\u304a\u5f79\u7acb\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"author":1,"featured_media":5993,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jinr_url_youtube":"","_jinr_pip_youtube":false,"_jinr_time_youtube":"","_jinr_thumb_youtube":"","_jinr_media_youtube":"","_jinr_category_edit":false,"_jinr_category":"","_jinr_title_display":false,"_jinr_snsbutton_display":false,"_jinr_ads_display":false,"_jinr_thumbnail_display":false,"_jinr_profile_display":false,"_jinr_representations_display":false,"_jinr_relatedpost_display":false,"_jinr_sidebar1col_display":false,"_jinr_sidebar2col_display":false,"_jinr_seotitle_display":"\u4eca\u65e5\u306e\u53f0\u6e7e\u306f\u3069\u3093\u306a\u5929\u6c17\uff1f","_jinr_description_display":"\u53f0\u6e7e\u306e\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u5929\u6c17\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u304a\u304a\u3088\u305d\u306e\u5404\u5730\u306e\u5929\u6c17\u304c\u308f\u304b\u308b\u306e\u3067\u65c5\u884c\u4e2d\u3084\u6ede\u5728\u4e2d\u306b\u304a\u5f79\u7acb\u3066\u304f\u3060\u3055\u3044\u3002","_jinr_keyword_display":"\u53f0\u6e7e,\u5404\u5730,\u5929\u6c17,\u6674\u308c,\u96e8,\u66c7\u308a,\u304f\u3082\u308a,\u96ea,\u964d\u6c34\u78ba\u7387,\u6e7f\u5ea6,\u65e5\u306e\u51fa,\u65e5\u306e\u5165\u308a,\u98a8\u901f,\u884c\u697d\u5730,\u884c\u697d\u65e5\u548c,\u30d4\u30af\u30cb\u30c3\u30af,\u30a6\u30a9\u30fc\u30ad\u30f3\u30b0,\u65c5\u884c,\u6ede\u5728,\u99d0\u5728,\u7559\u5b66","_jinr_hastag_display":"","_jinr_canonical_display":"","_jinr_noindex_display":false,"_jinr_paidpost":false,"_jinr_paidpost_product_id":"","_jinr_headtag_article":"","footnotes":""},"class_list":["post-5969","page","type-page","status-publish","has-post-thumbnail","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/pages\/5969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5969"}],"version-history":[{"count":21,"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/pages\/5969\/revisions"}],"predecessor-version":[{"id":5991,"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/pages\/5969\/revisions\/5991"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=\/wp\/v2\/media\/5993"}],"wp:attachment":[{"href":"https:\/\/taiwan-bopomofo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}