Skip to content

Commit

Permalink
1.2.1 updated
Browse files Browse the repository at this point in the history
  • Loading branch information
PranshulGG committed Jul 15, 2024
1 parent f66d96b commit 80e1dc2
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 100 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 22
targetSdk 33
versionCode 2
versionName "1.2.0 (W)"
versionName "1.2.1 (W)"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 2,
"versionName": "1.1.8 (W)",
"versionName": "1.2.0 (W)",
"outputFile": "app-release.apk"
}
],
Expand Down
145 changes: 79 additions & 66 deletions app/src/main/assets/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ window.addEventListener('popstate', function (event) {
document.getElementById('search-container').style.display = 'none'
document.getElementById('search-container').style.opacity = '1'

}, 200);
}, 250);

});

Expand Down Expand Up @@ -223,9 +223,8 @@ function getWeather(city, latitude, longitude) {
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${apiKey}&units=metric`;

setTimeout(() => {
updateMoonTrackProgress(latitude, longitude)
updateSunTrackProgress(latitude, longitude);

Fetchmoonphases(latitude, longitude)
}, 500);


Expand Down Expand Up @@ -587,7 +586,7 @@ function getWeatherByCoordinates(latitude, longitude) {


setTimeout(() => {
updateMoonTrackProgress(latitude, longitude)
Fetchmoonphases(latitude, longitude)
updateSunTrackProgress(latitude, longitude);
}, 500);

Expand Down Expand Up @@ -1195,68 +1194,6 @@ document.getElementById('forecast').addEventListener('scroll', function () {




function updateMoonTrackProgress(lat, long) {
fetch(`https://api.ipgeolocation.io/astronomy?apiKey=f22c81e7a0b5448e812ad5e0e1c25242&lat=${lat}&long=${long}`)
.then(response => response.json())
.then(data => {
const moonriseTime = parseTime(data.moonrise);
const moonsetTime = parseTime(data.moonset);
const currentTime = new Date();

const totalMoonlight = moonsetTime - moonriseTime;

let timeSinceMoonrise = currentTime - moonriseTime;

if (currentTime > moonsetTime && currentTime < new Date(currentTime.getFullYear(), currentTime.getMonth(), currentTime.getDate(), 23, 59, 59)) {
timeSinceMoonrise = totalMoonlight;
}

const percentageOfMoonlight = (timeSinceMoonrise / totalMoonlight) * 100;

const moonProgressWidth = Math.min(Math.max(percentageOfMoonlight, 0), 100);

document.querySelector('moontrackprogress').style.width = `${moonProgressWidth}%`;

const moonrise = formatTimeMoonRiseMoonSet(data.moonrise);
const moonset = data.moonset === "-:-" ? "Not available" : formatTimeMoonRiseMoonSet(data.moonset);
document.getElementById('moonrise').textContent = `${moonrise}`;
document.getElementById('moonset').textContent = `${moonset}`;

})
.catch(error => {
console.error('Error fetching moonrise/moonset data:', error);
});
}


function parseTime(time24) {
const [hours, minutes] = time24.split(':').map(Number);
const currentDate = new Date();
const time = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), hours, minutes);
return time;
}

function formatTimeMoonRiseMoonSet(time24) {
let [hours, minutes] = time24.split(':').map(Number);

minutes = Math.round(minutes);

if (minutes === 60) {
minutes = 0;
hours += 1;
}

const period = hours >= 12 ? 'PM' : 'AM';

hours = hours % 12 || 12;

minutes = minutes.toString().padStart(2, '0');

return `${hours}:${minutes} ${period}`;
}


function refreshWeather(){
const latSend = localStorage.getItem('currentLat')
const longSend = localStorage.getItem('currentLong')
Expand Down Expand Up @@ -1389,6 +1326,12 @@ function toggleMapTypeChips(element) {
function openLivemap(){
document.querySelector('.liveMapScreen').hidden = false;
window.history.pushState({ LiveMapOpen: true }, "");

var passChips = document.getElementsByName('MapType');
passChips.forEach((passChip) => {
passChip.selected = false;
});
document.querySelector('[label="Temperature"]').selected = true;
}

function closeLiveMap(){
Expand Down Expand Up @@ -1429,4 +1372,74 @@ if(document.querySelector('[label="Rain"]').selected){

}

}


function Fetchmoonphases(lat, long){
fetch(`https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/${lat},${long}?unitGroup=metric&include=days&key=4KMES28T2K3PXBCXTNYZCZFW8&contentType=json`)
.then(response => response.json())
.then(data => {

const moon_phase_img = document.getElementById('moon_phase_img');

if(data.days[0].moonphase === 0 && data.days[0].moonphase <= 0){
document.getElementById('moonPhaseText').innerHTML = 'New Moon';
moon_phase_img.src = 'moon_phases/moon_new.svg';
} else if(data.days[0].moonphase > 0 && data.days[0].moonphase <= 0.25){
document.getElementById('moonPhaseText').innerHTML = 'Waxing Crescent';
moon_phase_img.src = 'moon_phases/moon_waxing_crescent.svg';
} else if(data.days[0].moonphase === 0.25 && data.days[0].moonphase <= 0.25){
document.getElementById('moonPhaseText').innerHTML = 'First Quarter';
moon_phase_img.src = 'moon_phases/moon_first_quarter.svg';
} else if(data.days[0].moonphase > 0.25 && data.days[0].moonphase <= 0.5){
document.getElementById('moonPhaseText').innerHTML = 'Waxing Gibbous';
moon_phase_img.src = 'moon_phases/moon_waxing_gibbous.svg';
} else if(data.days[0].moonphase === 0.5 && data.days[0].moonphase <= 0.5){
document.getElementById('moonPhaseText').innerHTML = 'Full Moon';
moon_phase_img.src = 'moon_phases/moon_full.svg';
} else if(data.days[0].moonphase > 0.5 && data.days[0].moonphase <= 0.75){
document.getElementById('moonPhaseText').innerHTML = 'Waning Gibbous';
moon_phase_img.src = 'moon_phases/moon_waning_gibbous.svg';
} else if(data.days[0].moonphase === 0.75 && data.days[0].moonphase <= 0.75){
document.getElementById('moonPhaseText').innerHTML = 'Last Quarter';
moon_phase_img.src = 'moon_phases/moon_last_quarter.svg';
} else if(data.days[0].moonphase > 0.75 && data.days[0].moonphase <= 1){
document.getElementById('moonPhaseText').innerHTML = 'Waning Crescent';
moon_phase_img.src = 'moon_phases/moon_waning_crescent.svg';
}

console.log(data)

})
.catch(error => console.error(error));



fetch(`https://api.ipgeolocation.io/astronomy?apiKey=63a7210d2b104646a1099d5ba223d221&lat=${lat}8&long=${long}`)
.then(response => response.json())
.then(data => {
const moonRise = data.moonrise;
const moonSet = data.moonset;

const moonRiseAmPm = convertToAmPm(moonRise);
const moonSetAmPm = convertToAmPm(moonSet);


document.getElementById('moonriseText').innerHTML = moonRiseAmPm;
document.getElementById('moonsetText').innerHTML = moonSetAmPm;


})
.catch(error => console.error(error));


}

function convertToAmPm(time) {
let [hour, minute] = time.split(':');
hour = parseInt(hour);
const ampm = hour >= 12 ? 'PM' : 'AM';
hour = hour % 12;
hour = hour ? hour : 12;
return `${hour}:${minute} ${ampm}`;
}
Binary file removed app/src/main/assets/icons/moon.png
Binary file not shown.
32 changes: 14 additions & 18 deletions app/src/main/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,32 +201,28 @@ <h2 id="city-name" style="margin-right: 3px;">

<div class="setRiseDivWrap" style="border-radius: 5px 5px 10px 10px; margin-top: 5px;">
<div class="h1">
<p>Moonrise & Moonset</p>
<p>Moon phase</p>
</div>

<div class="wrapTimingdiv">
<div class="timingWrap">
<span>Moonrise</span>
<div class="timingItem">
<p id="moonrise"></p>
<div class="moonSideWrap">
<div class="leftWrapMoon">

<div class="moonPhaseNameWrap">
<p id="moonPhaseText"></p>
</div>
</div>

<div class="timingWrap">
<span>Moonset</span>
<div class="timingItem">
<p id="moonset"></p>
<div class="moonrise-Set">
<p>Moonrise: <span id="moonriseText"></span></p>
<p>Moonset: <span id="moonsetText"></span></p>
</div>
</div>
</div>

</div>

<moontrack>
<moontrackprogress>
<moon></moon>
</moontrackprogress>
</moontrack>

<div class="rightWrapMoon">
<img src="moon_phases/moon_full.svg" alt="" id="moon_phase_img">
</div>
</div>
<br>
</div>

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_first_quarter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/assets/moon_phases/moon_full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_last_quarter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/src/main/assets/moon_phases/moon_new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_waning_crescent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_waning_gibbous.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_waxing_crescent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/assets/moon_phases/moon_waxing_gibbous.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/assets/pages/AboutPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<md-list-item id="show_time_toast">
<md-icon slot="start" icon-filled>info</md-icon>
<div slot="headline" style="margin-bottom: 2px;">Version</div>
<div slot="supporting-text">1.2.0 (W)</div>
<div slot="supporting-text">1.2.1 (W)</div>
</md-list-item>

</md-list>
Expand Down
Loading

0 comments on commit 80e1dc2

Please sign in to comment.