-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworlds.html
More file actions
116 lines (110 loc) · 3.83 KB
/
Copy pathworlds.html
File metadata and controls
116 lines (110 loc) · 3.83 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>World Creator</title>
<style>
body {
font-family: Arial, sans-serif;
}
.world {
margin-bottom: 10px;
}
.world input[type="text"] {
width: 200px;
margin-right: 10px;
}
.world button {
cursor: pointer;
}
</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>
<h1>Create Worlds</h1>
<div>
<input type="text" id="world-name" placeholder="Enter world name">
<select id="world-extension">
<option value="lpp">overworld.lpp</option>
<option value="opl">nether.opl</option>
<option value="csp">end.csp</option>
</select>
<button onclick="addWorld()">Add World</button>
</div>
<ul id="worlds-list"></ul>
<script>
function addWorld() {
var worldNameInput = document.getElementById('world-name');
var worldName = worldNameInput.value.trim();
var worldExtension = document.getElementById('world-extension').value;
if (worldName !== '') {
var world = document.createElement('li');
world.className = 'world';
world.innerHTML = '<input type="text" value="' + worldName + '.' + worldExtension + '" disabled>' +
'<button onclick="removeWorld(this)">Remove</button>';
document.getElementById('worlds-list').appendChild(world);
saveWorlds();
worldNameInput.value = '';
} else {
alert('Please enter a valid world name.');
}
}
function removeWorld(btn) {
var listItem = btn.parentNode;
listItem.parentNode.removeChild(listItem);
saveWorlds();
}
function saveWorlds() {
var worlds = [];
var worldElements = document.getElementsByClassName('world');
for (var i = 0; i < worldElements.length; i++) {
var worldName = worldElements[i].querySelector('input[type="text"]').value;
worlds.push(worldName);
}
localStorage.setItem('savedWorlds', JSON.stringify(worlds));
}
// Load saved worlds on page load
window.onload = function() {
var savedWorlds = localStorage.getItem('savedWorlds');
if (savedWorlds) {
savedWorlds = JSON.parse(savedWorlds);
savedWorlds.forEach(function(worldName) {
var world = document.createElement('li');
world.className = 'world';
world.innerHTML = '<input type="text" value="' + worldName + '" disabled>' +
'<button onclick="removeWorld(this)">Remove</button>';
document.getElementById('worlds-list').appendChild(world);
});
}
};
</script>
</body>
</html>