Skip to content

Commit

Permalink
Merge pull request #3 from viv2005ek/new
Browse files Browse the repository at this point in the history
updating datalist
  • Loading branch information
viv2005ek authored Jun 16, 2024
2 parents 3d51497 + 4b0bfb6 commit ddc4d4a
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 109 deletions.
218 changes: 119 additions & 99 deletions JS/cities.js
Original file line number Diff line number Diff line change
@@ -1,115 +1,135 @@
let cities = [
"Mumbai",
"Delhi",
"Bangalore",
"Hyderabad",
"Ahmedabad",
"Chennai",
"Kolkata",
"Pune",
"Jaipur",
"Lucknow",
"Kanpur",
"Nagpur",
"Indore",
"Thane",
"Bhopal",
"Visakhapatnam",
"Pimpri-Chinchwad",
"Patna",
"Vadodara",
"Ghaziabad",
"Ludhiana",
"Agartala",
"Agra",
"Nashik",
"Faridabad",
"Meerut",
"Rajkot",
"Kalyan-Dombivli",
"Vasai-Virar",
"Varanasi",
"Srinagar",
"Aurangabad",
"Dhanbad",
"Amritsar",
"Navi Mumbai",
"Ahmedabad",
"Aizawl",
"Ajmer",
"Akola",
"Alappuzha",
"Aligarh",
"Allahabad",
"Howrah",
"Ranchi",
"Coimbatore",
"Jabalpur",
"Gwalior",
"Vijayawada",
"Jodhpur",
"Madurai",
"Raipur",
"Kota",
"Guwahati",
"Chandigarh",
"Solapur",
"Hubli–Dharwad",
"Mysore",
"Tiruchirappalli",
"Ambala",
"Ambattur",
"Amravati",
"Amritsar",
"Amroha",
"Anand",
"Anantapur",
"Arrah",
"Asansol",
"Aurangabad (Bihar)",
"Aurangabad (Maharashtra)",
"Bareilly",
"Aligarh",
"Tiruppur",
"Moradabad",
"Jalandhar",
"Bhubaneswar",
"Salem",
"Warangal",
"Guntur",
"Belgaum",
"Bellary",
"Bhagalpur",
"Bhavnagar",
"Bhilai",
"Bhiwandi",
"Saharanpur",
"Gorakhpur",
"Bhiwadi",
"Bhopal",
"Bhubaneswar",
"Bikaner",
"Amravati",
"Noida",
"Jamshedpur",
"Bhilai",
"Bilaspur",
"Bokaro Steel City",
"Buxar",
"Chandigarh",
"Chennai",
"Chhapra",
"Coimbatore",
"Cuttack",
"Firozabad",
"Kochi",
"Bhavnagar",
"Davanagere",
"Dehradun",
"Delhi",
"Dhanbad",
"Dhule",
"Durgapur",
"Asansol",
"Nanded",
"Kolhapur",
"Ajmer",
"Faridabad",
"Firozabad",
"Gandhinagar",
"Ghaziabad",
"Gorakhpur",
"Gopalpur",
"Gulbarga",
"Jamnagar",
"Ujjain",
"Loni",
"Siliguri",
"Jhansi",
"Ulhasnagar",
"Guntur",
"Gwalior",
"Guwahati",
"Hubli–Dharwad",
"Hyderabad",
"Imphal",
"Indore",
"Jabalpur",
"Jaipur",
"Jalandhar",
"Jalgaon",
"Jammu",
"Sangli-Miraj & Kupwad",
"Mangalore",
"Erode",
"Belgaum",
"Kurnool",
"Ambattur",
"Rajahmundry",
"Tirunelveli",
"Malegaon",
"Gaya",
"Udaipur",
"Jamnagar",
"Jamshedpur",
"Jodhpur",
"Jorhat",
"Kakinada",
"Davanagere",
"Kalyan-Dombivli",
"Kanpur",
"Karimnagar",
"Kharagpur",
"Kochi",
"Kollam",
"Kolhapur",
"Kolkata",
"Kota",
"Kozhikode",
"Akola",
"Kurnool",
"Bokaro Steel City",
"Bellary",
"Patiala",
"Gopalpur",
"Agartala",
"Bhagalpur",
"Loni",
"Lucknow",
"Ludhiana",
"Madurai",
"Malegaon",
"Mangalore",
"Meerut",
"Moradabad",
"Mumbai",
"Muzaffarnagar",
"Korba",
"Mysore",
"Nagpur",
"Nanded",
"Nashik",
"Navi Mumbai",
"Noida",
"Panipat",
"Patiala",
"Patna",
"Pimpri-Chinchwad",
"Pune",
"Raipur",
"Rajahmundry",
"Rajkot",
"Ranchi",
"Rohtak",
"Saharanpur",
"Salem",
"Sangli-Miraj & Kupwad",
"Shimla",
"Silchar",
"Siliguri",
"Solapur",
"Srinagar",
"Surat",
"Thane",
"Thiruvananthapuram",
"Thrissur",
"Aligarh",
"Mangalore"
]
"Tiruchirappalli",
"Tirunelveli",
"Tiruppur",
"Tirupati",
"Udaipur",
"Ujjain",
"Ulhasnagar",
"Vadodara",
"Varanasi",
"Vasai-Virar",
"Vellore",
"Vijayawada",
"Visakhapatnam",
"Warangal",
"Yamunanagar"
];
30 changes: 20 additions & 10 deletions JS/weatherFind.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition((position) => {
let lat = position.coords.latitude;
let long = position.coords.longitude;
console.log(lat, long);
function live_location() {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition((position) => {
let lat = position.coords.latitude;
let long = position.coords.longitude;
console.log(lat, long);

const URL_Location = `https://api.geoapify.com/v1/geocode/reverse?lat=${lat}&lon=${long}&apiKey=0d7e0434effa4ea3825e16245d95ba24`;

console.log("Location:-" + URL_Location);
getLoc(URL_Location);
});
}
};
live_location();


const URL_Location = `https://api.geoapify.com/v1/geocode/reverse?lat=${lat}&lon=${long}&apiKey=0d7e0434effa4ea3825e16245d95ba24`;

console.log("Location:-" + URL_Location);
getLoc(URL_Location);
});
}


let city;
Expand Down Expand Up @@ -106,6 +112,10 @@ async function weatherAPI(city) {
};

function callWeatherApiByButton() {
if (searchCityInHtml.value == "Current Location") {
live_location();
return;
}
cityNameToSearch = searchCityInHtml.value;
cityIndiaCheckVar = 0;
checkCity(cityNameToSearch)
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<div class="search">
<input type="text" list="citiesList" placeholder="Search Location..." onkeydown="callWeatherApiByEnter(event)">
<datalist id="citiesList">
<option value="Current Location">Current Location</option>
</datalist>

<button onclick="callWeatherApiByButton()"> <i class="fa-solid fa-magnifying-glass"></i> </button>
Expand Down

0 comments on commit ddc4d4a

Please sign in to comment.