-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
489 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<html> | ||
|
||
<head> | ||
<title>NUI Keep-jobgarages</title> | ||
<link href="style.css" rel="stylesheet" type="text/css" /> | ||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<div id="container"> | ||
<div id="doorlock" style="display: none; background: rgb(19, 28, 74);"></div> | ||
</div> | ||
|
||
<audio id="sounds"><source type="audio/ogg"></audio> | ||
|
||
<div id="formContainer" style="display: none;"> | ||
<form id="newDoor"> | ||
<div> | ||
<text>Vehicle Name</text> | ||
<input id="vehiclename" type="text" name="vehiclename" placeholder='Name In Menu'><br> | ||
</div> | ||
|
||
<div> | ||
<text>Vehicle's Plate</text> | ||
<div class="namegen"> | ||
<input id="platevalue" type="text" name="platevalue" placeholder='Plate'><br> | ||
<button id="randomize" type="button">randomize</button> | ||
</div> | ||
|
||
</div> | ||
|
||
<div> | ||
<text>Plate Type</text> | ||
<select id='platetype' name='platetype' class='dropdown'> | ||
<option option value='none'>None</option> | ||
<option value='PD'>PD</option> | ||
<option value='SP'>SP</option> | ||
</select> | ||
</div> | ||
|
||
<div> | ||
<text>Job Authorisation</text> | ||
<input id="job" type="text" name="job" placeholder='police'><br> | ||
</div> | ||
|
||
<div> | ||
<text>Grade Authorisation</text> | ||
<input id="grades" type="text" name="grades" placeholder='1,2,3,...'><br> | ||
</div> | ||
|
||
<div> | ||
<text>CitizenID Authorisation</text> | ||
<input id="cids" type="text" name="cids" placeholder='PZT37891,PZT37891,....'><br> | ||
</div> | ||
|
||
<div> | ||
<button id="submit" type="submit">Submit</button> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<script src="main.js" type="text/javascript"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
const formContainer = document.getElementById('formContainer'); | ||
const newDoorForm = document.getElementById('newDoor'); | ||
const doorlockContainer = document.getElementById('container'); | ||
const doorlock = document.getElementById('doorlock'); | ||
|
||
var formInfo = { | ||
vehiclename: document.getElementById('vehiclename'), | ||
platevalue: document.getElementById('platevalue'), | ||
platetype: document.getElementById('doortype'), | ||
job: document.getElementById('job'), | ||
grades: document.getElementById('grades'), | ||
cids: document.getElementById('cids'), | ||
} | ||
|
||
window.addEventListener('message', ({ data }) => { | ||
if (data.color) { | ||
doorlock.style.background = data.color; | ||
} | ||
if (data.type == "newDoorSetup") { | ||
data.enable ? formContainer.style.display = "flex" : formContainer.style.display = "none"; | ||
data.enable ? doorlockContainer.style.display = "none" : doorlockContainer.style.display = "block"; | ||
return | ||
} | ||
if (data.type == "audio") { | ||
var volume = (data.audio['volume'] / 10) * data.sfx | ||
if (volume > 1.0) { | ||
volume = 1.0 | ||
} | ||
if (data.distance !== 0) { | ||
var volume = volume / data.distance | ||
} | ||
var sound = new Audio('sounds/' + data.audio['file']); | ||
sound.volume = volume; | ||
sound.play(); | ||
} else if (data.type == "display") { | ||
if (data.text !== undefined) { | ||
doorlock.style.display = 'block'; | ||
doorlock.innerHTML = data.text; | ||
doorlock.classList.add('slide-in'); | ||
} | ||
} else if (data.type == "hide") { | ||
doorlock.classList.add('slide-out'); | ||
setTimeout(function() { | ||
doorlock.innerHTML = ''; | ||
doorlock.style.display = 'none'; | ||
doorlock.classList.remove('slide-in'); | ||
doorlock.classList.remove('slide-out'); | ||
}, 1000) | ||
} | ||
}) | ||
|
||
document.addEventListener('keyup', (e) => { | ||
if (e.key == 'Escape') { | ||
sendNUICB('close'); | ||
} | ||
}); | ||
|
||
document.getElementById('newDoor').addEventListener('submit', (e) => { | ||
e.preventDefault(); | ||
sendNUICB('saveNewVehicle', { | ||
vehiclename: formInfo.vehiclename.value, | ||
platevalue: formInfo.platevalue.value, | ||
job: formInfo.job.value, | ||
grades: formInfo.grades.value, | ||
cids: formInfo.cids.value, | ||
}); | ||
}) | ||
|
||
function sendNUICB(event, data = {}, cb = () => {}) { | ||
fetch(`https://${GetParentResourceName()}/${event}`, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json; charset=UTF-8', }, | ||
body: JSON.stringify(data) | ||
}).then(resp => resp.json()).then(resp => cb(resp)); | ||
} | ||
|
||
function makeid(length) { | ||
var result = ''; | ||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
var charactersLength = characters.length; | ||
for (var i = 0; i < length; i++) { | ||
result += characters.charAt(Math.floor(Math.random() * | ||
charactersLength)); | ||
} | ||
return result; | ||
} | ||
|
||
const reandomize = document.getElementById('randomize') | ||
reandomize.addEventListener('click', (event) => { | ||
const platetype = document.getElementById('platetype') | ||
const reandomize = document.getElementById('platevalue') | ||
|
||
if (platetype.value === 'none') reandomize.value = makeid(8) | ||
else if (platetype.value === 'PD') { | ||
reandomize.value = makeid(6) | ||
reandomize.value += 'PD' | ||
} else if (platetype.value === 'SP') { | ||
reandomize.value = makeid(6) | ||
reandomize.value += 'SP' | ||
} | ||
}); | ||
|
||
window.onload = (event) => { | ||
const reandomize = document.getElementById('platevalue') | ||
const job = document.getElementById('job') | ||
reandomize.value = makeid(8) | ||
job.value = 'police' | ||
}; | ||
|
||
const platetype = document.getElementById('platetype') | ||
platetype.addEventListener('change', (event) => { | ||
const platetype = document.getElementById('platetype') | ||
const reandomize = document.getElementById('platevalue') | ||
|
||
if (platetype.value === 'none') reandomize.value = makeid(8) | ||
else if (platetype.value === 'PD') { | ||
reandomize.value = makeid(6) | ||
reandomize.value += 'PD' | ||
} else if (platetype.value === 'SP') { | ||
reandomize.value = makeid(6) | ||
reandomize.value += 'SP' | ||
} | ||
}); |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.