Files
Elite-Gaming-FiveM-Backup/resources/BigDaddy-EAS/nui/nui.html
T
2025-08-14 07:32:45 -07:00

164 lines
4.8 KiB
HTML

<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700,900&display=swap" id="font">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<style>
body {
font-family: Montserrat, sans-serif;
background: transparent;
}
#ticker {
background: black;
color: white;
font-weight: bold;
font-size: 20px;
height: 35px;
position: absolute;
top: 0;
left: 0;
width: 100%;
opacity: 0;
transition: opacity linear .5s;
overflow: hidden;
}
#tickertext {
right: 0;
position: absolute;
margin-top: 5px;
color: white;
font-weight: bold;
font-size: 20px;
left: unset;
white-space: nowrap;
text-shadow: 3px 3px 2px rgb(0 0 0 / 68%);
}
#entryform {
width: 40%;
margin-left: 50%;
transform: translateX(-50%);
margin-top: 20%;
opacity: 0;
transition: opacity 1s;
}
input, textarea {
margin-bottom: 15px;
}
</style>
<div id="ticker"><div id="tickertext">test</div></div>
<div id="entryform">
<select class="form-control" id="Agency"></select>
<!--<input type="text" class="form-control" id="Agency" placeholder="What Agency is issuing this alert? (optional)" maxlength="25" />-->
<input type="text" class="form-control" id="Type" placeholder="What type of alert is being issued? (required)" maxlength="50" />
<textarea class="form-control" id="Text" placeholder="What is the alert text? (required)" maxlength="350" rows="3"></textarea>
<div class="btn btn-success" onclick="SendAlert()">SEND</div> <div class="btn btn-warning" onclick="CancelAlert()">CANCEL</div>
</div>
<audio id="sounds"><source type="audio/ogg"></audio>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
var audio = null;
var eventCallback = {
alert: function (data) {
$('#tickertext').html('');
$('#tickertext').css('left', 'unset');
alertstring = data.alertagency + ' ' + data.alerttype + ': ' + data.alerttext;
alertstring += '&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;' + alertstring;
$('#tickertext').html(alertstring);
$('#tickertext').css('right', $('#tickertext').width() * -1);
$('#ticker').css('opacity', 1);
$('#tickertext').animate({ left: $('#tickertext').width() * -1 }, 60000, 'linear',
function () {
$('#ticker').css('opacity', 0);
$('#tickertext').html('');
$('#tickertext').css('left', 'unset');
}
);
var file = data.alertagency.replace(' ', '').toLowerCase() + '.ogg';
if (fileExists('sounds/' + file)) {
eventCallback.sound(file);
} else {
eventCallback.sound('alert.mp3');
}
},
sound: function (file = null) {
if (audio != null) {
audio.pause();
}
audio = new Audio('sounds/' + file);
audio.volume = .5;
audio.play();
},
showform: function (data) {
var aa = data.alertagency;
var a = null;
if (aa != null) {
a = aa.split(',');
}
if (a != null && a.length > 0) {
$('#Agency option').remove();
for (var i = 0; i < a.length; i++) {
$('#Agency').append('<option value="' + a[i] + '">' + a[i] + '</option>');
}
}
$('#entryform').css('opacity', '1');
},
}
function CancelAlert() {
$('#Agency').val('');
$('#Type').val( '');
$('#Text').val('');
fetch(`https://${GetParentResourceName()}/BuildEAS`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
easdata: ',,'
})
});
$('#entryform').css('opacity', '0');
}
function SendAlert() {
fetch(`https://${GetParentResourceName()}/BuildEAS`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({
easdata: $('#Agency').val().replace(/,/g, '~comma~').replace(/:/g, '~colon~') + ',' + $('#Type').val().replace(/,/g, '~comma~').replace(/:/g, '~colon~') + ',' + $('#Text').val().replace(/,/g, '~comma~').replace(/:/g, '~colon~')
})
});
$('#entryform').css('opacity','0');
$('#Agency').val('');
$('#Type').val('');
$('#Text').val('');
}
function fileExists(file_url) {
var http = new XMLHttpRequest();
http.open('HEAD', file_url, false);
http.send();
return http.status != 404;
}
window.onload = function () {
window.addEventListener('message', function (event) {
eventCallback[event.data.action](event.data);
});
}
</script>
</body>
</html>