From d75ca0866526160ee5b9452d16779b739716261f Mon Sep 17 00:00:00 2001 From: Sivaprasath R Date: Sat, 15 Jun 2024 15:04:14 +0000 Subject: [PATCH] finished --- .../GlobalHolidayAPI/index.html | 8 ++++++++ .../GlobalHolidayAPI/script.js | 20 ++++++++++++------- .../GlobalHolidayAPI/style.css | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Existing_API_Collection/GlobalHolidayAPI/index.html b/Existing_API_Collection/GlobalHolidayAPI/index.html index f684b95..fd1c546 100644 --- a/Existing_API_Collection/GlobalHolidayAPI/index.html +++ b/Existing_API_Collection/GlobalHolidayAPI/index.html @@ -12,6 +12,7 @@

Holiday List For Countries

+
+
+
+ +
+
diff --git a/Existing_API_Collection/GlobalHolidayAPI/script.js b/Existing_API_Collection/GlobalHolidayAPI/script.js index 59ae765..56e2177 100644 --- a/Existing_API_Collection/GlobalHolidayAPI/script.js +++ b/Existing_API_Collection/GlobalHolidayAPI/script.js @@ -2,19 +2,25 @@ document.addEventListener("DOMContentLoaded", () => { const searchButton = document.getElementById("search-button"); const countryInput = document.getElementById("country-input"); const holidaysList = document.getElementById("holidays-list"); - + const Year_container=document.getElementById('year-input') searchButton.addEventListener("click", () => { const countryCode = countryInput.value; - - if (countryCode) { - fetchHolidays(countryCode); + const Year=Year_container.value + if (countryCode && Year) { + fetchHolidays(countryCode,Year); } }); - - function fetchHolidays(countryCode) { + const year=new Date().getFullYear() + for(let i=year;i>=2010;i--){ + const option=document.createElement('option') + option.setAttribute('value',i) + option.textContent='year: ' +i + Year_container.appendChild(option) + } + function fetchHolidays(countryCode,Year) { //API KEY const apiKey = 'akio9k5qVkY8dCwDGw657ZGC3M8LWOcY'; - const apiUrl = `https://calendarific.com/api/v2/holidays?country=${countryCode}&year=2023&api_key=${apiKey}`; + const apiUrl = `https://calendarific.com/api/v2/holidays?country=${countryCode}&year=${Year}&api_key=${apiKey}`; fetch(apiUrl) .then(response => { diff --git a/Existing_API_Collection/GlobalHolidayAPI/style.css b/Existing_API_Collection/GlobalHolidayAPI/style.css index 0ae385d..e6a04d8 100644 --- a/Existing_API_Collection/GlobalHolidayAPI/style.css +++ b/Existing_API_Collection/GlobalHolidayAPI/style.css @@ -27,7 +27,7 @@ label { font-size: 18px; } -#country-input { +#country-input ,#year-input{ padding: 10px; margin: 10px 0; border: 1px solid #ccc;