JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
<header>
<h1>Steemit Zufallsgenerator</h1>
</header>
<section>
<h2>Steemians eingeben</h2>
<div class="sectionInnerWrapper">
<label for="teilnehmer">Name des Teilnehmers:</label>
<input type="text" id="teilnehmer" placeholder="Snackaholic"/>
<button id="knopf">Steemian hinzufügen</button>
</div>
</section>
<section>
<h2>Upvoter hinzufügen</h2>
<div class="sectionInnerWrapper">
<label for="link">Link zum Post</label>
<input type="text" id="upvoterLink" placeholder="Bitte Link einfügen"/>
<button id="upvoterHinzufuegen">Upvoter hinzufügen</button>
</div>
</section>
<section>
<h2>Kommentatoren hinzufügen</h2>
<div class="sectionInnerWrapper">
<label for="link">Link zum Post</label>
<input type="text" id="kommentatorenLink" placeholder="Bitte Link einfügen"/>
<button id="kommentatorenHinzufuegen">Kommentatoren hinzufügen</button>
</div>
</section>
<section class="teilnehmerlisteWrapper">
<h2>Teilnehmerliste</h2>
<div class="sectionInnerWrapper">
<ul id="teilnehmerliste"></ul>
<button id="loeschen">Liste leeren</button>
</div>
</section>
<section>
<h2>Ermittlung der Gewinner</h2>
<div class="sectionInnerWrapper">
<label for="anzahlGewinner">Anzahl der Gewinner:</label>
<input type="text" id="anzahlGewinner" placeholder="0"/>
<button id="ermitteln">Gewinner ermitteln</button>
</div>
</section>
CSS
*{
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
body {
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
padding:0;
margin:0;
background-color: #484848;
color: #9f9f9f;
padding-bottom:50px;
}
h1,h2,h3 {
font-weight:700;
margin:0;
padding:16px;
}
header {
background:#000000;
padding: 16px 0;
}
section {
max-width:80%;
margin: 0 auto;
margin-top:32px;
-webkit-box-shadow: 0px 0px 16px 5px rgba(0,0,0,0.25);
-moz-box-shadow: 0px 0px 16px 5px rgba(0,0,0,0.25);
box-shadow: 0px 0px 16px 5px rgba(0,0,0,0.25);
background:#212121;
}
section h2 {
display:block;
padding:16px;
background:#111;
}
section .sectionInnerWrapper {
padding: 16px;
}
#teilnehmerliste {
margin:0;
padding:0;
max-height:300px;
overflow-y:scroll;
}
#teilnehmerliste li {
position:relative;
display:block;
padding:16px;;
padding-right:66px;
color:#fff;
}
#teilnehmerliste li:nth-child(odd) {
background-color:#484848;
}
#teilnehmerliste li .delete {
cursor: pointer;
position: absolute;
right: 16px;
top: 8px;
width: 50px;
height: 32px;
text-align: center;
line-height: 32px;
color:#fff;
}
/* Formelemente */
input, select, textarea {
font-family: inherit;
font-size: 16px;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
background-color: white;
border-radius: 0;
}
input {
display:block;
width: 50%;
padding: 8px;
height: 48px;
outline: none;
border: 0;
border-bottom: 2px solid rgba(0,0,0,0.16);
background: rgba(0,0,0,0.09);
border-radius: 2px 2px 0px 0px;
color: #fff;
}
label {
display: block;
color: rgba(0,0,0,0.87);
margin-bottom: 0.5rem;
text-align: left;
color:#9f9f9f;
}
button {
color: #fff;
background-color: #00e676;
text-decoration: none;
text-align:...
JavaScript
var teilnehmerliste = [];
knopf.addEventListener("click", function(){
// feld holen
var eingabefeld = document.getElementById("teilnehmer");
var wert = eingabefeld.value;
// feld leeren
eingabefeld.value = "";
// wenn wert nicht leer, in liste eintragen!
if (wert != "") {
teilnehmerliste.push(wert);
}
// liste darstellen
stelleListedar();
});
var loeschenknopf = document.getElementById("loeschen");
loeschenknopf.addEventListener("click", function(){
listeLeeren();
});
function listeLeeren() {
teilnehmerliste = [];
sichtbareListeLeeren();
}
function sichtbareListeLeeren () {
var guiTeilnehmerliste = document.getElementById("teilnehmerliste");
while (guiTeilnehmerliste.firstChild) {
guiTeilnehmerliste.removeChild(guiTeilnehmerliste.firstChild);
}
}
function loescheEintrag (index) {
teilnehmerliste.splice(index, 1);
stelleListedar();
}
function stelleListedar() {
// ul liste holen
var guiTeilnehmerliste = document.getElementById("teilnehmerliste");
// ul liste leeren
while (guiTeilnehmerliste.firstChild) {
guiTeilnehmerliste.removeChild(guiTeilnehmerliste.firstChild);
}
// ul liste füllen
for (var i=0; i < teilnehmerliste.length; i++) {
var li = document.createElement("li");
var textKnoten = document.createTextNode(teilnehmerliste[i]);
li.appendChild(textKnoten);
// remove x an li hängen
var span = document.createElement("span");
var txt = document.createTextNode("x");
span.className = "delete";
span.appendChild(txt);
li.appendChild(span);
// li mit data index ausstatten
li.setAttribute('data-array-index', i);
// li in gui platzieren
guiTeilnehmerliste.appendChild(li);
}
// deletes funktion anhängen
var deletes = document.getElementsByClassName("delete");
for (var j = 0; j < deletes .length; j++) {
deletes [j].onclick = function() {
var eintrag = this.parentElement;...