Skip to content

Instantly share code, notes, and snippets.

@kousik10702b
Created June 29, 2025 05:13
Show Gist options
  • Save kousik10702b/b57866bb1f96690c57eeaed893138506 to your computer and use it in GitHub Desktop.
Save kousik10702b/b57866bb1f96690c57eeaed893138506 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nari Suraksha</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: #fbeaea;
}
h1 {
color: #d90000;
}
.form-group {
margin-bottom: 15px;
}
input {
padding: 10px;
width: 80%;
margin: 5px 0;
}
button {
padding: 15px 30px;
font-size: 16px;
margin: 10px;
border: none;
border-radius: 5px;
}
#helpBtn {
background-color: #d90000;
color: white;
}
#alarmBtn {
background-color: #333;
color: white;
}
</style>
</head>
<body>
<h1>Nari Suraksha</h1>
<div id="form-section">
<div class="form-group">
<input type="text" id="name" placeholder="Your Name">
</div>
<div class="form-group">
<input type="number" id="age" placeholder="Your Age">
</div>
<div class="form-group">
<input type="text" id="contact1" placeholder="Contact 1 (with country code)">
</div>
<div class="form-group">
<input type="text" id="contact2" placeholder="Contact 2 (with country code)">
</div>
<div class="form-group">
<input type="text" id="contact3" placeholder="Contact 3 (with country code)">
</div>
<button onclick="saveData()">Submit</button>
</div>
<div id="main-section" style="display:none;">
<button id="helpBtn" onclick="sendHelp()">HELP ME</button><br>
<button id="alarmBtn" onclick="playAlarm()">🔊 Alarm</button>
<audio id="alarmSound" src="https://actions.google.com/sounds/v1/alarms/alarm_clock.ogg"></audio>
</div>
<script>
const name = localStorage.getItem('name');
const age = localStorage.getItem('age');
if (name && age) {
document.getElementById('form-section').style.display = 'none';
document.getElementById('main-section').style.display = 'block';
}
function saveData() {
const name = document.getElementById('name').value;
const age = document.getElementById('age').value;
const contact1 = document.getElementById('contact1').value;
const contact2 = document.getElementById('contact2').value;
const contact3 = document.getElementById('contact3').value;
if (!name || !age || !contact1 || !contact2 || !contact3) {
alert("Please fill in all fields.");
return;
}
localStorage.setItem('name', name);
localStorage.setItem('age', age);
localStorage.setItem('contact1', contact1);
localStorage.setItem('contact2', contact2);
localStorage.setItem('contact3', contact3);
document.getElementById('form-section').style.display = 'none';
document.getElementById('main-section').style.display = 'block';
}
function sendHelp() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
const lat = position.coords.latitude;
const lon = position.coords.longitude;
const locationMessage = `🚨 Nari Suraksha Alert!\nMy location: https://maps.google.com/?q=${lat},${lon}`;
const contact1 = localStorage.getItem('contact1');
const contact2 = localStorage.getItem('contact2');
const contact3 = localStorage.getItem('contact3');
const whatsappLinks = [
`https://wa.me/${contact1}?text=${encodeURIComponent(locationMessage)}`,
`https://wa.me/${contact2}?text=${encodeURIComponent(locationMessage)}`,
`https://wa.me/${contact3}?text=${encodeURIComponent(locationMessage)}`
];
whatsappLinks.forEach(link => window.open(link, '_blank'));
}, () => {
alert("Location access denied. Please allow location access.");
});
} else {
alert("Geolocation is not supported by this device.");
}
}
function playAlarm() {
const audio = document.getElementById("alarmSound");
if (audio.paused) {
audio.play();
} else {
audio.pause();
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment