114 lines
3.7 KiB
HTML
114 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>View Elections</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: #1a1a1a;
|
|
color: #9f9f9f;
|
|
}
|
|
.container {
|
|
width: 60em;
|
|
margin: 5em auto;
|
|
padding: 3em;
|
|
background-color: #2b2b2b;
|
|
border-radius: 0.3125em;
|
|
box-shadow: 0 0.125em 0.3125em rgba(0, 0, 0, 0.1);
|
|
}
|
|
h2 {
|
|
text-align: center;
|
|
margin-bottom: 1.25em;
|
|
}
|
|
#searchInput {
|
|
width: 100%;
|
|
padding: 0.5em;
|
|
margin-bottom: 4em;
|
|
background-color: #363535;
|
|
color: #9f9f9f;
|
|
border: 0.0625em solid #9f9f9f;
|
|
}
|
|
|
|
.card {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 1em;
|
|
background-color: #333;
|
|
border-radius: 0.3125em;
|
|
margin-bottom: 1em;
|
|
}
|
|
button {
|
|
padding: 0.3125em 0.625em;
|
|
margin: 0 0.3125em;
|
|
border: none;
|
|
border-radius: 0.3125em;
|
|
color: white;
|
|
cursor: pointer;
|
|
}
|
|
.details-btn {
|
|
background-color: #4CAF50; /* Green */
|
|
}
|
|
.delete-btn {
|
|
background-color: #f44336; /* Red */
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h2>View Elections</h2>
|
|
<input id="searchInput" type="text" placeholder="Search elections..." oninput="searchElections(this.value)">
|
|
<div id="electionsContainer">
|
|
<!-- Election cards will be inserted here dynamically -->
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const elections = [
|
|
{ name: "Election 1", username: "user", namespace: "namespace2" },
|
|
{ name: "Election 2", username: "user", namespace: "namespace" },
|
|
{ name: "Election 3", username: "user2", namespace: "namespace" }
|
|
];
|
|
const currentUsername = "user";
|
|
|
|
function renderElections(elections) {
|
|
const container = document.querySelector("#electionsContainer");
|
|
container.innerHTML = "";
|
|
elections.forEach(election => {
|
|
const card = document.createElement("div");
|
|
card.className = "card";
|
|
card.innerHTML = `
|
|
<div>
|
|
<h3>${election.name}</h3>
|
|
<p>Created by ${election.username} in ${election.namespace}</p>
|
|
</div>
|
|
<div>
|
|
<button class="details-btn" onclick="viewDetails('${election.name}')">Details</button>
|
|
${election.username === currentUsername ?
|
|
`<button class="delete-btn" onclick="if(confirm('Are you sure you want to delete this election?')) { deleteElection('${election.name}') }">Delete</button>`
|
|
: ''}
|
|
</div>
|
|
`;
|
|
container.appendChild(card);
|
|
});
|
|
}
|
|
|
|
function searchElections(query) {
|
|
const filtered = elections.filter(election => election.name.toLowerCase().includes(query.toLowerCase()));
|
|
renderElections(filtered);
|
|
}
|
|
|
|
function viewDetails(name) {
|
|
// Implement the logic to view the details of the election
|
|
}
|
|
|
|
function deleteElection(name) {
|
|
// Implement the logic to delete the election
|
|
}
|
|
|
|
renderElections(elections);
|
|
</script>
|
|
</body>
|
|
</html> |