Excluir script.js
This commit is contained in:
65
script.js
65
script.js
@@ -1,65 +0,0 @@
|
||||
$(document).ready(function () {
|
||||
let lista = JSON.parse(localStorage.getItem("lista")) || [];
|
||||
|
||||
function updatelist() {
|
||||
$("#add ul").empty();
|
||||
lista.forEach((lista, index) => {
|
||||
$("#add ul").append(
|
||||
`<li><a>` + lista + `</a > <input type="submit" value="X" /></li > `,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function saveLocalStorage() {
|
||||
localStorage.setItem("lista", JSON.stringify(lista));
|
||||
}
|
||||
|
||||
$("#btnadd").click(function () {
|
||||
let inputText = $("#addUser").val().trim();
|
||||
if (inputText) {
|
||||
lista.push(inputText);
|
||||
saveLocalStorage();
|
||||
updatelist();
|
||||
$("#addUser").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$("#central input").click(function () {
|
||||
if (lista.length < 2) {
|
||||
alert("erro, falta 1");
|
||||
return;
|
||||
}
|
||||
|
||||
let sorte = [];
|
||||
while (sorte.length < 2) {
|
||||
let index = Math.floor(Math.random() * lista.length);
|
||||
if (!sorte.includes(index)) {
|
||||
sorte.push(index);
|
||||
}
|
||||
}
|
||||
$("#players").html(
|
||||
`
|
||||
<div id="users">
|
||||
<h2 id="user1">` +
|
||||
lista[sorte[0]] +
|
||||
`/a</h2>
|
||||
</div>
|
||||
<h1>VS</h1>
|
||||
<div id="users">
|
||||
<h2 id="user2">` +
|
||||
lista[sorte[1]] +
|
||||
`</h2>
|
||||
</div>
|
||||
`,
|
||||
);
|
||||
lista = lista.filter((_, index) => !sorte.includes(index));
|
||||
});
|
||||
|
||||
window.remove = function (index) {
|
||||
lista.splice(index, 1);
|
||||
saveLocalStorage();
|
||||
updatelist();
|
||||
};
|
||||
|
||||
updatelist();
|
||||
});
|
||||
Reference in New Issue
Block a user