Skip to content

Commit

Permalink
Pused the 1.0.2 update
Browse files Browse the repository at this point in the history
Made everything opensource (uploaded the v1.0.1 accidentally encoded).
I made some minor changes to both the client and server code
  • Loading branch information
N0edL committed Sep 2, 2024
1 parent 2f3aa97 commit c2fdfaf
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 33 deletions.
96 changes: 95 additions & 1 deletion client.lua

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ lua54 "yes"
use_fxv2_oal "yes"

author "NoedL"
version "1.0.1"
version "1.0.2"
license "MIT"
repository "https://github.com/N0edL/ndl_adminduty"


shared_scripts {
'@es_extended/imports.lua',
'settings.lua'
'@es_extended/imports.lua'
}

client_script "client.lua"
server_script "server.lua"
ui_page "html/index.html"
Expand Down
4 changes: 1 addition & 3 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
</head>
Expand All @@ -15,7 +13,7 @@ <h1>Hey,</h1>
<h2 id="name"></h2>
</div>
<div id="playerList">
<h1>Online Staff</h1>
<h1>Online Admins</h1>
<div id="players">
</div>
</div>
Expand Down
95 changes: 81 additions & 14 deletions html/script.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,81 @@
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

$(function(){function display(bool){if(bool){$("#container").fadeIn(300)}else{$("#container").fadeOut(0)}}
display(!1);window.addEventListener('message',function(event){var item=event.data;if(item.type==="ui"){if(item.status==!0){display(!0)}else{display(!1)}}
if(item.type==="Info"){$("#name").html(item.name+"!");if(item.dienst==!0){$("#dutybutton").html("Go off duty");$("#dutybutton").css("background-color","#ca0d26");$("#dutybutton:hover").css("background-color","#c20d25")}else $("#dutybutton").html("Go on duty");if(item.logs==!0){$("#extrabutton").html("Extras <br>On");$("#extrabutton").css("background-color","#0d4535");$("#extrabutton:hover").css("background-color","#c20d25")}else $("#extrabutton").html("Extras <br>Off")}
if(item.type==='updatePlayerInfo'){updatePlayerList(event.data.playerList)}})
document.addEventListener('keyup',function(event){if(event.code==='Escape'){$.post('https://ndl_adminduty/exit',JSON.stringify({}));return}});$("#dutybutton").click(function(){$.post('https://ndl_adminduty/dutybutton',JSON.stringify({}));return})
$("#extrabutton").click(function(){$.post('https://ndl_adminduty/extrabutton',JSON.stringify({}));return})})
function updatePlayerList(playerList){const playerListElement=document.getElementById('players');playerListElement.innerHTML='';if(playerList&&Array.isArray(playerList)){playerList.forEach(playerInfo=>{const playerDiv=document.createElement('div');playerDiv.id='player'
const playerName=document.createElement('p');playerName.innerText=playerInfo.name;if(playerInfo.self){playerName.style.color='#1d735b'}
playerDiv.appendChild(playerName);playerListElement.appendChild(playerDiv)})}}
$(function () {
function display(bool) {
if (bool) {
$("#container").fadeIn(300);
} else {
$("#container").fadeOut(0);
}
}
display(false);
window.addEventListener('message', function (event) {
var item = event.data;
if (item.type === "off") {
if (item.status == true) {
display(true);
} else {
display(false);
}
}

if (item.type === "Info") {
$("#name").html(item.name + "!");
if (item.dienst == true) {
$("#dutybutton").html("Go off duty");
$("#dutybutton").css("background-color", "#ca0d26");
$("#dutybutton:hover").css("background-color", "#c20d25");
} else
$("#dutybutton").html("Go on duty");

if (item.logs == true) {
$("#extrabutton").html("Extras <br>On");
$("#extrabutton").css("background-color", "#0d4535");
$("#extrabutton:hover").css("background-color", "#c20d25");
}
else
$("#extrabutton").html("Extras <br>Off");


}

if (item.type === 'updatePlayerInfo') {
updateadminList(event.data.adminList);
}
})
document.onkeyup = function (data) {
if (data.which == 27) {
$.post('https://ndl_adminui/exit', JSON.stringify({}));
return;
}
};

$("#dutybutton").click(function () {
$.post('https://ndl_adminui/dutybutton', JSON.stringify({}));
return
})

$("#extrabutton").click(function () {
$.post('https://ndl_adminui/extrabutton', JSON.stringify({}));
return
})
})
function updateadminList(adminList) {
const adminListElement = document.getElementById('players');
adminListElement.innerHTML = '';

if (adminList && Array.isArray(adminList)) {
adminList.forEach(playerInfo => {
// console.log(playerInfo);
const playerDiv = document.createElement('div');
playerDiv.id = 'player'
const playerName = document.createElement('p');

playerName.innerText = playerInfo.name;

if (playerInfo.self) {
playerName.style.color = '#1d735b';
}
playerDiv.appendChild(playerName);
adminListElement.appendChild(playerDiv);
});
}
}
46 changes: 45 additions & 1 deletion server.lua

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions settings.lua

This file was deleted.

0 comments on commit c2fdfaf

Please sign in to comment.