> For the complete documentation index, see [llms.txt](https://javascriptuse.gitbook.io/javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascriptuse.gitbook.io/javascript/viet-mot-ung-dung-thoi-tiet-weather-su-dung-panel-ok.md).

# Viết một ứng dụng thời tiết, Weather sử dụng panel (ok)

C:\xampp\htdocs\oec\index.html

```
<!doctype html>
<html>
	<head>
		<title>My Weather</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="apple-touch-icon" href="images/icon.png" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<link rel="stylesheet" href="//code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
		<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
		<script src="//code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
		<script type="text/javascript">
			var icons = {
				"clear-day": "B ",
				"clear-night": "C ",
				"rain": "R ",
				"snow": "G ",
				"sleet": "X ",
				"wind": "S ",
				"fog": "N ",
				"cloudy": "Y ",
				"partly-cloudy-day": "H ",
				"partly-cloudy-night": "I "
			};
			var cities = {
				"new york": { coords: { latitude: 40.672060, longitude: -73.983898 } },
				"los angeles": { coords: { latitude: 34.101422, longitude: -118.341224 } },
				"chicago": { coords: { latitude: 41.879003, longitude: -87.63675 } },
				"san francisco": { coords: { latitude: 37.788531, longitude: -122.407237 } },
				"miami": { coords: { latitude: 25.790176, longitude: -80.140133 } },
				"current location": ""
			};
			function loadWeather(cityCoords) {
				console.log(cityCoords);
				var latlng = cityCoords.coords.latitude + "," + cityCoords.coords.longitude;
				// forecast URL
				var forecastURL = "https://api.forecast.io/forecast/7d94e61948eb1e8dda90cff8207973d7/" + latlng;
				$.ajax({
					url: forecastURL,
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					success: function(json) {
						console.log(json);
						$("#current_temp").html(Math.round(json.currently.temperature) + "&#176;F");
						$("#current_summary").html(json.currently.summary);
						$("#current_precipitation").html("Precipitation: " + (Math.round(json.currently.precipProbability) * 100) + "%");
						$("#current_humidity").html("Humidity: " + ((json.currently.humidity) * 100) + "%");
						$("#current_wind").html("Wind: " + (json.currently.windSpeed) + " mph");
						$("#current_cloudcover").html("Cloud Cover: " + (Math.round(json.currently.cloudCover) * 100) + "%");
						$("#current_temp").attr("data-icon", icons[json.currently.icon]);
					},
					error: function(e) {
						console.log(e.message);
					}
				});
			}
			function loadCity(city) {
				$("#location").html(city);
				if (city.toLowerCase() == "current location") {
					if (navigator.geolocation) navigator.geolocation.getCurrentPosition(loadWeather, loadDefaultCity);
					else {
						loadDefaultCity();
					}
				} else {
					loadWeather(cities[city.toLowerCase()]);
				}
			}
			function loadDefaultCity() {
				loadCity("New York");
			}
			$(document).ready(function() {
				loadCity("Chicago");
				$("a.city").bind("click", function() {
					loadCity($(this).html());
				});
			});
		</script>
	</head>
	<body>
		<div data-role="page">
			<div data-role="panel" id="left-panel" data-theme="c">
				<ul data-theme="d" data-role="listview">
					<li data-icon="delete"><a href="#" data-rel="close">Close</a></li>
					<li data-role="list-divider">Select a City</li>
					<li><a href="#" class="city" data-rel="close">Current Location</a></li>
					<li><a href="#" class="city" data-rel="close">Chicago</a></li>
					<li><a href="#" class="city" data-rel="close">Los Angeles</a></li>
					<li><a href="#" class="city" data-rel="close">Miami</a></li>
					<li><a href="#" class="city" data-rel="close">New York</a></li>
					<li><a href="#" class="city" data-rel="close">San Francisco</a></li>
				</ul>
			</div><!-- /panel -->
			<div data-role="header" data-position="fixed" data-theme="c">
				<h1>My Weather</h1>
				<a href="#left-panel" data-icon="bars" data-role="button" data-iconshadow="false">Location</a>
			</div>
			<div data-role="content" class="content">
				<h1 id="current_temp" class="icon" data-icon="B ">...&#176;F</h1>
				<p id="current_summary">Condition ...</p>
				<p id="location">Location: ...</p>
				<p id="current_precipitation">Precipitation: ...</p>
				<p id="current_humidity">Humidity: ...</p>
				<p id="current_wind">Wind: ...</p>
				<p id="current_cloudcover">Cloud Cover: ...</p>
			</div>
		</div>
	</body>
</html>
```

![](/files/w7ildLbIsiPenMNM508I)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/javascript/viet-mot-ung-dung-thoi-tiet-weather-su-dung-panel-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
