-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayers.html
More file actions
245 lines (231 loc) · 8 KB
/
Copy pathplayers.html
File metadata and controls
245 lines (231 loc) · 8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Players</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 20px;
background-color: #f0f0f0;
}
.container {
max-width: 800px;
margin: auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 10px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #eee;
}
.button {
padding: 8px 16px;
text-decoration: none;
color: white;
background-color: #4CAF50;
border: none;
cursor: pointer;
margin-right: 5px;
}
.button:hover {
background-color: #45a049;
}
.button.red {
background-color: #f44336;
}
.button.red:hover {
background-color: #d32f2f;
}
.button.orange {
background-color: #FF9800;
}
.button.orange:hover {
background-color: #FB8C00;
}
.button.blue {
background-color: #2196F3;
}
.button.blue:hover {
background-color: #1976D2;
}
.op {
background-color: #E1F5FE; /* Light blue for OP players */
}
.banned {
background-color: #FFEBEE; /* Light red for banned players */
}
.form-input {
margin-bottom: 10px;
}
input[type="text"], input[type="number"] {
padding: 8px;
width: calc(100% - 16px);
box-sizing: border-box;
}
label {
display: block;
margin-bottom: 5px;
}
</style>
</head>
<body>
<style>
/* Basic styling for the navbar */
.navbar {
background-color: #333;
overflow: hidden;
}
/* Navbar links styling */
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
/* Change color on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
</style>
<div class="navbar">
<a href="options.html">Options</a>
<a href="console.html">Console</a>
<a href="players.html">Players</a>
<a href="worlds.html">Worlds</a>
<a href="access.html">Access</a>
</div>
<div class="container">
<h1>Player Management</h1>
<div class="form-input">
<label for="playerName">Add New Player:</label>
<input type="text" id="playerName" placeholder="Enter player name">
<button class="button" onclick="addPlayer()">Add Player</button>
</div>
<h2>Active Players</h2>
<table id="playersTable">
<thead>
<tr>
<th>Player Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- Player rows will be added here -->
</tbody>
</table>
<h2>Banned Players</h2>
<div class="banned-list">
<table id="bannedPlayersTable">
<thead>
<tr>
<th>Player Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- Banned player rows will be added here -->
</tbody>
</table>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
loadPlayers();
});
function addPlayer() {
const input = document.getElementById('playerName');
const playerName = input.value.trim();
if (playerName === '') {
alert('Please enter a valid player name.');
return;
}
const player = { name: playerName, isOp: false, isBanned: false };
addPlayerToTable(player);
input.value = ''; // Clear input field
savePlayers();
}
function addPlayerToTable(player) {
const tableId = player.isBanned ? 'bannedPlayersTable' : 'playersTable';
const table = document.getElementById(tableId).getElementsByTagName('tbody')[0];
const row = table.insertRow();
row.className = player.isOp ? 'op' : ''; // Set class for OP players
const cell1 = row.insertCell(0);
const cell2 = row.insertCell(1);
cell1.textContent = player.name;
cell2.innerHTML = `
<button class="button blue" onclick="toggleOpStatus(this.parentNode.parentNode)">${player.isOp ? 'Demote OP' : 'Promote OP'}</button>
<button class="button orange" onclick="banPlayer(this.parentNode.parentNode)">Ban</button>
<button class="button red" onclick="removePlayer(this.parentNode.parentNode)">Remove</button>
`;
row.dataset.op = player.isOp;
row.dataset.banned = player.isBanned;
}
function toggleOpStatus(row) {
const isOp = row.dataset.op === 'true';
row.dataset.op = !isOp;
row.className = !isOp ? 'op' : ''; // Change background color when OP status is toggled
row.cells[1].children[0].textContent = !isOp ? 'Demote OP' : 'Promote OP';
savePlayers();
}
function banPlayer(row) {
row.dataset.banned = true;
moveRowToTable(row, 'bannedPlayersTable');
savePlayers();
}
function unbanPlayer(row) {
row.dataset.banned = false;
moveRowToTable(row, 'playersTable');
savePlayers();
}
function moveRowToTable(row, tableId) {
const table = document.getElementById(tableId).getElementsByTagName('tbody')[0];
const newRow = table.insertRow(table.rows.length);
newRow.innerHTML = row.innerHTML;
newRow.dataset.op = row.dataset.op;
newRow.dataset.banned = row.dataset.banned;
newRow.className = row.dataset.op === 'true' ? 'op' : ''; // Ensure OP visual cue is maintained across tables
removePlayer(row);
}
function removePlayer(row) {
row.parentNode.removeChild(row);
savePlayers();
}
function savePlayers() {
const activePlayers = Array.from(document.querySelector('#playersTable tbody').rows).map(row => {
return {
name: row.cells[0].textContent,
isOp: row.dataset.op === 'true',
isBanned: false
};
});
const bannedPlayers = Array.from(document.querySelector('#bannedPlayersTable tbody').rows).map(row => {
return {
name: row.cells[0].textContent,
isOp: row.dataset.op === 'true',
isBanned: true
};
});
localStorage.setItem('players', JSON.stringify([...activePlayers, ...bannedPlayers]));
}
function loadPlayers() {
const players = JSON.parse(localStorage.getItem('players') || '[]');
players.forEach(player => addPlayerToTable(player));
}
</script>
</body>
</html>