Skip to content

Commit

Permalink
removed extra lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Crucial-hash committed May 28, 2024
1 parent 07d82d7 commit b2c5051
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ info.txt export-ignore
LICENSE export-ignore
images/ export-ignore
.gitattributes export-ignore
.github/ export-ignore
.github/ export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/trigger-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/Crucial-hash/crucial/actions/workflows/update-submodule-push.yml/dispatches \
-d '{"ref":"main"}'
-d '{"ref":"main"}'
20 changes: 0 additions & 20 deletions adhan.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@
while True:
try:


from bs4 import BeautifulSoup
import requests
from datetime import datetime, time


website = 'https://www.halaltrip.com/prayertimes/muslim-salat-prayer-times/?name=Slough&f=Slough%2C+UK&l=Slough&s=&c=United+Kingdom&lat=51.4989355&lng=-0.5612772&no_days=7&cal_method=3&asr_method=2&higher_lat=2&cruising_height=11800' #Change the URL to the placve you live
result = requests.get(website)
content = result.text


soup = BeautifulSoup(content, 'lxml')


prayerTime = soup.find('ul', class_='tm-horizontal-listitem clearfix highlighted').get_text()


lines = prayerTime.split('\n')[1:-1]
lines = prayerTime.split('\n')[1:-1]
lines = prayerTime.split('\n')[1:-1]
del lines[0]
lines = [line.replace(':00', ':0') for line in lines]


fajrHour, fajrMin = map(int, lines[0].split(':'))
sunriseHour, sunriseMin = map(int, lines[1].replace('00', '0').split(':'))
zuhrHour, zuhrMin = map(int, lines[2].replace('00', '0').split(':'))
asrHour, asrMin = map(int, lines[3].split(':'))
maghribHour, maghribMin = map(int, lines[4].split(':'))
ishaHour, ishaMin = map(int, lines[5].split(':'))


lines = [line.lstrip('0') if line[0] == '0' else line for line in lines]
lines = [line[:-2] + line[-1] if line[-2] == '0' else line for line in lines]


fajrHour, fajrMin = map(int, lines[0].split(':'))
sunriseHour, sunriseMin = map(int, lines[1].split(':'))
zuhrHour, zuhrMin = map(int, lines[2].split(':'))
asrHour, asrMin = map(int, lines[3].split(':'))
maghribHour, maghribMin = map(int, lines[4].split(':'))
ishaHour, ishaMin = map(int, lines[5].split(':'))


current_time = datetime.now().time()


fajr_time = time(fajrHour, fajrMin)
sunrise_time = time(sunriseHour, sunriseMin)
zuhr_time = time(zuhrHour, zuhrMin)
asr_time = time(asrHour, asrMin)
maghrib_time = time(maghribHour, maghribMin)
isha_time = time(ishaHour, ishaMin)


if current_time < fajr_time:
next_prayer = "Fajr"
next_prayer_hour = fajrHour
Expand All @@ -81,18 +70,15 @@
next_prayer_hour = fajrHour
next_prayer_min = fajrMin


diff = datetime.combine(datetime.today(), time(next_prayer_hour, next_prayer_min)) - datetime.combine(datetime.today(), current_time)
diff_seconds = diff.total_seconds()
diff_hour = int(diff_seconds // 3600)
diff_minute = int((diff_seconds % 3600) // 60)


if diff_hour < 0:
diff_hour += 24
diff_minute *= 1


with open('name.txt', 'w') as file:
file.write(f'{next_prayer}\n')

Expand All @@ -102,7 +88,6 @@
with open('minutes.txt', 'w') as file:
file.write(f'{diff_minute}\n')


if current_time < sunrise_time:
sun_state = "Sunrise"
sun_state_hour = sunriseHour
Expand All @@ -116,18 +101,15 @@
sun_state_hour = sunriseHour
sun_state_min = sunriseMin


diff2 = datetime.combine(datetime.today(), time(sun_state_hour, sun_state_min)) - datetime.combine(datetime.today(), current_time)
diff_seconds2 = diff2.total_seconds()
diff_hour2 = int(diff_seconds2 // 3600)
diff_minute2 = int((diff_seconds2 % 3600) // 60)


if diff_hour2 < 0:
diff_hour2 += 24
diff_minute2 *= 1


with open('sunstate.txt', 'w') as file:
file.write(f'{sun_state}\n')

Expand All @@ -137,9 +119,7 @@
with open('sunminutes.txt', 'w') as file:
file.write(f'{diff_minute2}\n')


print("finished")


except Exception as e:
print("error")
45 changes: 11 additions & 34 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ function displayTime(){
var hrs = dateTime.getHours();
var min = dateTime.getMinutes();


function isDaylightSavingTime() {
const today = new Date();
const month = today.getMonth();
Expand All @@ -16,10 +15,8 @@ function displayTime(){
return dstResult;
}


isDaylightSavingTime();


if (hrs == 0){
hrs = hrs +12
}
Expand All @@ -36,19 +33,16 @@ function displayTime(){
min = "0" + min
}


document.getElementById('hours').innerHTML = hrs;
document.getElementById('minutes').innerHTML = min;

}


setInterval(displayTime, 10);
var width = screen.width;
var height = screen.height;
document.documentElement.style.cursor = 'none';


var root = document.querySelector(':root');
var rootStyles = getComputedStyle(root);
var trackurl = rootStyles.getPropertyValue('--trackurl');
Expand All @@ -57,10 +51,8 @@ var tracknameallign = rootStyles.getPropertyValue('--tracknameallign');
var flagallign = rootStyles.getPropertyValue('--flagallign');
var raceweekend = rootStyles.getPropertyValue('--raceweekend');


function setProperties(trackImage,trackNameAllignX,trackNameAllignY,flagAllignX,flagAllignY,flagImage,raceWeekendX,raceWeekendY,raceWeekendTime,session,trackName){


root.style.setProperty('--trackurl', 'url(' + trackImage + ')')
root.style.setProperty('--tracknameallign', 'translate(' + trackNameAllignX + ',' + trackNameAllignY + ')')
root.style.setProperty('--flagallign', 'translate(' + flagAllignX + ',' + flagAllignY + ')')
Expand All @@ -71,13 +63,11 @@ document.getElementById('session').innerHTML = session;
document.getElementById('trackname').innerHTML = trackName;
}


const button = document.getElementById("prayerbutton");
const prayer = document.getElementById("prayertext");
const sun = document.getElementById("suntext");
let state = 0;


button.addEventListener("click", function() {
if (state === 0) {
state = 1;
Expand All @@ -101,10 +91,8 @@ button.addEventListener("click", function() {
}
});


minuteChanged()


function minuteChanged() {

if (state === 1) {
Expand All @@ -113,73 +101,68 @@ function minuteChanged() {
prayer.style.transform = "none";
}


if (state === 2) {
sun.style.transform = "translate(1%, 2260%)";
} else {
sun.style.transform = "none";
}


var xhrName = new XMLHttpRequest();
xhrName.open("GET", "./name.txt", false);
xhrName.send();

if(xhrName.readyState === 4 && xhrName.status === 200) {
var prayerName = xhrName.responseText;
}

var xhrHours = new XMLHttpRequest();
xhrHours.open("GET", "./hours.txt", false);
xhrHours.send();

if(xhrHours.readyState === 4 && xhrHours.status === 200) {
var prayerHours = parseInt(xhrHours.responseText);
}

var xhrMinutes = new XMLHttpRequest();
xhrMinutes.open("GET", "./minutes.txt", false);
xhrMinutes.send();

if(xhrMinutes.readyState === 4 && xhrMinutes.status === 200) {
var prayerMinutes = parseInt(xhrMinutes.responseText);
}


var xhrSunState = new XMLHttpRequest();
xhrSunState.open("GET", "./sunstate.txt", false);
xhrSunState.send();

if(xhrSunState.readyState === 4 && xhrSunState.status === 200) {
var sunState = xhrSunState.responseText;
}

var xhrSunHours = new XMLHttpRequest();
xhrSunHours.open("GET", "./sunhours.txt", false);
xhrSunHours.send();

if(xhrSunHours.readyState === 4 && xhrSunHours.status === 200) {
var sunHours = parseInt(xhrSunHours.responseText);
}

var xhrSunMinutes = new XMLHttpRequest();
xhrSunMinutes.open("GET", "./sunminutes.txt", false);
xhrSunMinutes.send();

if(xhrSunMinutes.readyState === 4 && xhrSunMinutes.status === 200) {
var sunMinutes = parseInt(xhrSunMinutes.responseText);
}


document.getElementById('prayertext').innerHTML = prayerName + " In " +
(prayerHours === 1 ? prayerHours + " Hour, " : prayerHours + " Hours, ") +
(prayerMinutes === 1 ? prayerMinutes + " Minute" : prayerMinutes + " Minutes").replace("1 Minutes", "1 Minute");

document.getElementById('suntext').innerHTML = sunState + " In " +
(sunHours === 1 ? sunHours + " Hour, " : sunHours + " Hours, ") +
(sunMinutes === 1 ? sunMinutes + " Minute" : sunMinutes + " Minutes").replace("1 Minutes", "1 Minute");


function isDaylightSavingTime() {
const today = new Date();
const month = today.getMonth();
Expand All @@ -192,7 +175,6 @@ function minuteChanged() {
return false;
}


var tracktime;
var hrs24;
if (isDaylightSavingTime()) {
Expand All @@ -203,7 +185,6 @@ function minuteChanged() {
hrs24 = moment().format('HHmm');
}


if (
hrs24 == '0645' ||
hrs24 == '1000' ||
Expand All @@ -219,7 +200,6 @@ function minuteChanged() {
document.body.style.backgroundColor = '#000000';
}


//BAHRAIN

if (tracktime < '03021630') { setProperties("./image/bahrain.png","37.5%","-24%","630%","140%","./image/bahrainflag.png","54.1%","145%","29 - 02 Feb/March","P1 P2 P3 Q R","Bahrain") }
Expand Down Expand Up @@ -320,7 +300,6 @@ function minuteChanged() {

if (tracktime >= '12081430') { setProperties("./image/australia.png","37.5%","-24%","640%","140%","./image/australiaflag.png","60%","145%"," ","P1 P2 P3 Q R","Australia") }


function boldString(str, find){
var re = new RegExp(find, 'g');
return str.replace(re, '<b>'+find+'</b>');
Expand All @@ -330,12 +309,10 @@ function minuteChanged() {
document.getElementById("session").innerHTML = result;
}


function getCurrentMinute() {
return new Date().getMinutes();
}


let currentMinute = getCurrentMinute();
setInterval(function() {
const newMinute = getCurrentMinute();
Expand Down
Loading

0 comments on commit b2c5051

Please sign in to comment.