Skip to content

Commit

Permalink
1.2.0 updated
Browse files Browse the repository at this point in the history
  • Loading branch information
PranshulGG committed Jul 15, 2024
1 parent 00fe400 commit f66d96b
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 41 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.1.8 (W)"
versionName "1.2.0 (W)"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
153 changes: 138 additions & 15 deletions app/src/main/assets/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,20 +911,21 @@ function updateSunTrackProgress(latitude, longitude) {
fetch(apiUrl)
.then(response => response.json())
.then(data => {
const timeZoneOffsetSeconds = data.timezone;
const sunriseUTC = new Date((data.sys.sunrise + timeZoneOffsetSeconds) * 1000);
const sunsetUTC = new Date((data.sys.sunset + timeZoneOffsetSeconds) * 1000);
const sunriseUTC = new Date(data.sys.sunrise * 1000);
const sunsetUTC = new Date(data.sys.sunset * 1000);
const currentTime = new Date();

const totalDaylight = sunsetUTC - sunriseUTC;

const timeSinceSunrise = currentTime - sunriseUTC;
const percentageOfDaylight = (timeSinceSunrise / totalDaylight) * 100;

const progressWidth = Math.min(Math.max(percentageOfDaylight, 0), 100);
let percentageOfDaylight = (timeSinceSunrise / totalDaylight) * 100;

percentageOfDaylight = Math.min(Math.max(percentageOfDaylight, 0), 100);

document.querySelector('suntrackprogress').style.width = `${percentageOfDaylight}%`;

document.querySelector('suntrackprogress').style.width = `${progressWidth}%`;

console.log('updated')
})
.catch(error => {
console.error('Error fetching sunrise/sunset data:', error);
Expand Down Expand Up @@ -1204,28 +1205,31 @@ function updateMoonTrackProgress(lat, long) {
const currentTime = new Date();

const totalMoonlight = moonsetTime - moonriseTime;
const timeSinceMoonrise = currentTime - 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 = formatTimeMoonRiseMoonSet(data.moonset);
const moonset = data.moonset === "-:-" ? "Not available" : formatTimeMoonRiseMoonSet(data.moonset);
document.getElementById('moonrise').textContent = `${moonrise}`;
if (data.moonset === "-:-") {
document.getElementById('moonset').textContent = "Not available";
} else{
document.getElementById('moonset').textContent = `${moonset}`;
}
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();
Expand Down Expand Up @@ -1280,7 +1284,9 @@ function RenderSearhMap() {

map = window.L.map('map', {
center: [latDif, longDif],
zoom: 13
zoom: 13,
zoomControl: false

});

window.L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(map);
Expand All @@ -1307,3 +1313,120 @@ function removeMap() {
map = null;
}
}

var livemap;

function liveMapRender(maptype){

const latDif = localStorage.getItem('currentLat');
const longDif = localStorage.getItem('currentLong');

livemap = window.L.map('livemap', {
center: [latDif, longDif],
zoom: 4,
minZoom: 3,
zoomControl: false
});


window.L.marker([latDif, longDif]).addTo(livemap);


const apiKey = '9458a8b672d3e5ed460b72e7637c6eeb';

window.L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(livemap);


window.L.tileLayer(`https://tile.openweathermap.org/map/${maptype}/{z}/{x}/{y}.png?appid=${apiKey}`).addTo(livemap);




}


function removeLiveMap() {
if (livemap) {
livemap.remove();
livemap = null;
}
}








function Open_RefreshLiveMap(type){
removeLiveMap()

setTimeout(()=>{
liveMapRender(type)
}, 500);

}




function toggleMapTypeChips(element) {
if (element.selected) {
var passChips = document.getElementsByName('MapType');
passChips.forEach((passChip) => {
if (passChip !== element) {
passChip.selected = false;
}

});
} else{
element.selected = true;
}
}


function openLivemap(){
document.querySelector('.liveMapScreen').hidden = false;
window.history.pushState({ LiveMapOpen: true }, "");
}

function closeLiveMap(){
document.querySelector('.liveMapScreen').style.height = '0'
document.querySelector('.liveMapScreen').style.opacity = '0'


setTimeout(()=>{
document.querySelector('.liveMapScreen').hidden = true;
document.querySelector('.liveMapScreen').style.height = ''
document.querySelector('.liveMapScreen').style.opacity = ''

}, 350);

}


window.addEventListener('popstate', function (event) {
if(!document.querySelector('.liveMapScreen').hidden){
closeLiveMap()
}

});

function refreshCurrentMap(){
if(document.querySelector('[label="Rain"]').selected){
Open_RefreshLiveMap('rain')
} else if(document.querySelector('[label="Clouds"]').selected){
Open_RefreshLiveMap('clouds')
} else if(document.querySelector('[label="Temperature"]').selected){
Open_RefreshLiveMap('temp_new')

} else if(document.querySelector('[label="Snow"]').selected){
Open_RefreshLiveMap('snow')

} else if(document.querySelector('[label="Wind"]').selected){
Open_RefreshLiveMap('wind_new')

}

}
91 changes: 91 additions & 0 deletions app/src/main/assets/icons/404.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/icons/prevmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f66d96b

Please sign in to comment.