Skip to content

Commit

Permalink
sssddd
Browse files Browse the repository at this point in the history
  • Loading branch information
SMsajjadSM committed Dec 18, 2023
1 parent a45ef4a commit cc74310
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion assets/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const api_key = "8c2afaacf65df1976579f048d2fc4e25";
@param {function} callback callback
*/
export const fetchData = function (URl, callback) {
fetch(`${URL}&appid=${api_key}`)
fetch(`${URl}&appid=${api_key}`)
.then((res) => res.json())
.then((data) => callback(data));
};
Expand Down
22 changes: 12 additions & 10 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const searchView = document.querySelector("[data-search-view]");
const searchTogglers = document.querySelectorAll("[data-search-toggler]");
const toggleSearch = () => searchView.classList.toggle("active");
addEventOnElements(searchTogglers, "click", toggleSearch);
// ---searching---
const searchFeild = document.querySelector("[data-search-field]");
const searchResult = document.querySelector("[data-search-result]");
let searchTimeOut = null;
Expand All @@ -24,23 +25,24 @@ searchFeild.addEventListener("input", function () {
} else {
searchFeild.classList.add("searching");
}
if (searchFeild.Value) {
if (searchFeild.value) {
searchTimeOut = setTimeout(() => {
fetchData(url.geo(searchFeild.value), function (location) {
// console.log(searchFeild.value);
searchFeild.classList.remove("searching");
searchResult.classList.add("active");
searchResult.innerHTML = ` <ul class="view-list" data-search-list>
<li class="view-item">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<div>
<p class="item-title">London</p>
<p class="label-2 item-subtitle">State of London, GB</p>
</div>
<a href="#" class="item-link has-state" data-search-toggler></a>
</li>
</ul>`;
<li class="view-item">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<div>
<p class="item-title">London</p>
<p class="label-2 item-subtitle">State of London, GB</p>
</div>
<a href="#" class="item-link has-state" data-search-toggler></a>
</li>
</ul>`;
const items = [];
console.log(location);
for (const { name, lat, lon, country, state } of location) {
const searchItem = document.createElement("li");
searchItem.classList.add("view-item");
Expand Down
2 changes: 1 addition & 1 deletion assets/js/route.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
import { updateWeather, error404 } from "./app";
import { updateWeather, error404 } from "./app.js";
const defaultLocation = "#/weather?lat=51.5073219&lon=-0.1276474";

const currentLocation = function () {
Expand Down

0 comments on commit cc74310

Please sign in to comment.