Skip to content

Commit

Permalink
#4 Implement detect location automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
GURMEHAR-PEC committed Sep 16, 2023
1 parent e320fbe commit ddbca68
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 42 deletions.
65 changes: 40 additions & 25 deletions css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
-webkit-transform: translate3d(1000px, 0px, 0px);
}
}
*{
font-family: 'Chakra Petch', sans-serif;
}

.background-container {
position: fixed;
Expand Down Expand Up @@ -135,38 +138,50 @@ img {
visibility: hidden;
}
}
.form{
border: 4px solid white;
position: absolute;
left: 40%;
top: 60%;
transform: translate(-50%, -50%);
z-index: 5;
@font-face {
font-family: "style";
src: url();
}
*{
margin:0 ;
padding: 0;
box-sizing: border-box;
}
html,body{
height: 100%;
width: 100%;
font-size: 10px;

}
.left{
height: 100vh;
width: 50vw;
display: flex;
flex-direction: column;
height: 40%;
width: 40%;
border-radius: 15px;
justify-content: center;
align-items: center;


position: absolute;
z-index: 10;
color: #fff;
}
.checklabel{
color: white;
font-size: 35px;
margin: 4px;
padding: 4px;
h1{
font-size: 4rem;
}
.opt1{
margin: 8px;
button{
margin-top: 2rem;
margin-bottom: 2rem;
font-weight: 700;
font-size: 25px;

}
.opt2{
margin: 8px;

#location{
height: 5rem;
width: 23rem;
}
input.box{
height: 25px;
width: 25px;
}
button:hover{
background-color: black;
color: white;
font-weight: bolder;
cursor: pointer;
}
26 changes: 9 additions & 17 deletions html/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Falling Stars</title>
<link rel="stylesheet" href="../css/home.css">
<link href='https://fonts.googleapis.com/css?family=Space Mono' rel='stylesheet'>
<link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;600&display=swap" rel="stylesheet">
</head>

<body>
Expand All @@ -17,25 +18,16 @@
</div>
<div class="twinkling"></div>
<div class="clouds"></div>
<div class="text">
<h1>Welcome to the <strong class="effect">Cosmic Calender</strong></h1>
</div>
<div class="form">
<div class="opt1">
<label for="opt1" class="checklabel"> Detect Location Automatically</label>
<input type="checkbox" id="opt1" name="opt1" value="loc1" class="box">

</div>

<div class="opt2">
<label for="opt2" class="checklabel"> Enter location manually</label>
<input type="checkbox" id="opt2" name="opt2" value="loc2" class="box">


<div class="left">
<h1>Welcome to the <strong class="effect">Cosmic Calendar</strong></h1>
<div class="input">
<button id="location" onclick="myfunction()">Get Location</button>
</div>


</div>



</body>
<script src="../js/home.js"></script>

</html>
26 changes: 26 additions & 0 deletions js/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function myfunction() {
var checkbox = document.getElementById("location");
checkbox.addEventListener("click", ()=>{
const successCallback = (position) => {
// Extract latitude and longitude from the position object
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;

console.log("Latitude: " + latitude);
console.log("Longitude: " + longitude);



};

const errorCallback = (error) => {
console.log(error);
};

navigator.geolocation.getCurrentPosition(successCallback, errorCallback);

});


}

0 comments on commit ddbca68

Please sign in to comment.