Skip to content

Commit

Permalink
Fixes #28 #9
Browse files Browse the repository at this point in the history
Co-authored-by: Farhan Alvi <farhanalvi005@gmail.com>
Co-authored-by: flxp49 <emxdahmad@gmail.com>
  • Loading branch information
3 people committed Jan 6, 2021
1 parent 84c6175 commit 7e98b92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
17 changes: 13 additions & 4 deletions PrayerWindow/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@ export function startUpdating(currentTimestamp, currentDayPrayerData, arr) {
// console.log(`${waqt}: ${currentDayPrayerData[`${waqt}`]}`)
}

// Displaying the current and next prayers
$("#first-prayer").text(getKeyByValue(currentDayPrayerData, currentPrayerTime))
$("#second-prayer").text(`left until ${getKeyByValue(currentDayPrayerData, nextPrayerTime)}`)

let hourInMs = nextPrayerTime.getHours() * 60 * 60 * 1000 - currentHour * 60 * 60 * 1000
let minInMs = nextPrayerTime.getMinutes() * 60 * 1000 - currentMinute * 60 * 1000
// getting the time in ms and taking account of 0 hour value
let nextPrayerTimeHour = nextPrayerTime.getHours() == 0 ? 24 : nextPrayerTime.getHours()
let nextPrayerTimeinMs = nextPrayerTimeHour * 60 * 60 * 1000 + nextPrayerTime.getMinutes() * 60 * 1000
let currentTimeinMs = currentHour * 60 * 60 * 1000 + currentMinute * 60 * 1000

let hoursDifference = Math.floor(hourInMs / 1000 / 60 / 60)
let minutesDifference = Math.floor(minInMs / 1000 / 60)
//calculating the final time in ms
let finalTimeInMs = nextPrayerTimeinMs - currentTimeinMs

// getting the final hour and minutes
let hoursDifference = Math.floor(finalTimeInMs / 1000 / 60 / 60)
let minutesDifference = Math.floor(finalTimeInMs / 1000 / 60) - hoursDifference * 60

// Displaying the time left
$("#time-left").text(`${hoursDifference}h${minutesDifference}m`)
}, 1000)

Expand Down
12 changes: 6 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { initPrayerModel } from "./PrayerWindow/model";
import { initPrayerView } from "./PrayerWindow/processing";
import { initPrayerModel } from "./PrayerWindow/model"
import { initPrayerView } from "./PrayerWindow/processing"

document.addEventListener(
"deviceready",
function () {
// update the file system
initPrayerModel();
// update the frontend
setTimeout(initPrayerView, 100);
initPrayerModel()
// update the frontend after a delay to let I/O complete
setTimeout(initPrayerView, 50)
},
false
);
)

0 comments on commit 7e98b92

Please sign in to comment.