Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
978b15cb1e | ||
|
|
72477a5692 | ||
|
|
f71ac358a8 | ||
|
|
e9c44c3a11 | ||
|
|
940c95e015 | ||
|
|
57a5c06712 | ||
| 9c3071e2d1 | |||
| 7804d9208e | |||
| 4fcb90e380 | |||
|
|
c4b8f36815 |
31
index.html
31
index.html
@@ -31,6 +31,13 @@
|
|||||||
<form>
|
<form>
|
||||||
<button type="submit" id="add">Add item</button>
|
<button type="submit" id="add">Add item</button>
|
||||||
</form>
|
</form>
|
||||||
|
<h3 style="margin-top: 2rem;margin-bottom: 1rem;">
|
||||||
|
Presets
|
||||||
|
</h3>
|
||||||
|
<div style="block">
|
||||||
|
<button type="submit" id="presetFootball">Football </button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box2">
|
<div class="box2">
|
||||||
@@ -45,13 +52,35 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<h3 id="result"></h3>
|
<h3 id="result"></h3>
|
||||||
<form>
|
<form>
|
||||||
<button type="submit" id="submit">Randomize</button>
|
<select id="selectNumber" class="dropdown">
|
||||||
|
<option value="1">
|
||||||
|
Pick 1
|
||||||
|
</option>
|
||||||
|
<option value="2">
|
||||||
|
Pick 2
|
||||||
|
</option>
|
||||||
|
<option value="3">
|
||||||
|
Pick 3
|
||||||
|
</option>
|
||||||
|
<option value="4">
|
||||||
|
Pick 4
|
||||||
|
</option>
|
||||||
|
<option value="5">
|
||||||
|
Pick 5
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
<button type="submit" id="submit">Randomize</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="reset">Reset</button>
|
<button id="reset">Reset</button>
|
||||||
|
|
||||||
|
<div style="text-align: left; font-size:1rem;position:fixed;bottom:0">
|
||||||
|
© 2023 Oskar Boström
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
41
script.js
41
script.js
@@ -37,6 +37,26 @@ $(document).on('click', 'img.delete', function () {
|
|||||||
console.log(itemValue)
|
console.log(itemValue)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('button#presetFootball').click(function () {
|
||||||
|
let ul = $('#itemlist');
|
||||||
|
console.log(ul)
|
||||||
|
items = [];
|
||||||
|
items.push('Oskar', 'Emil', 'Kim', 'Mads', 'Mads C', 'Michal',)
|
||||||
|
// let ul = $('#itemlist');
|
||||||
|
items.forEach(function (item) {
|
||||||
|
let li = document.createElement('li');
|
||||||
|
let img = document.createElement('img')
|
||||||
|
li.append(item);
|
||||||
|
ul.append(li);
|
||||||
|
li.append(img);
|
||||||
|
$(img).addClass('delete')
|
||||||
|
$(img).attr('src', 'close.png');
|
||||||
|
$(input).css('border', '1px solid black');
|
||||||
|
$(input).val('');
|
||||||
|
$('#inputError').html("")
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +72,7 @@ function addItem() {
|
|||||||
ul.append(li);
|
ul.append(li);
|
||||||
li.append(img);
|
li.append(img);
|
||||||
$(img).addClass('delete')
|
$(img).addClass('delete')
|
||||||
$(img).attr('src', '/close.png');
|
$(img).attr('src', 'close.png');
|
||||||
$(input).css('border', '1px solid black');
|
$(input).css('border', '1px solid black');
|
||||||
$(input).val('');
|
$(input).val('');
|
||||||
$('#inputError').html("")
|
$('#inputError').html("")
|
||||||
@@ -63,10 +83,19 @@ function displayResult() {
|
|||||||
if (items.length < 1) {
|
if (items.length < 1) {
|
||||||
$('#result').html('Error: Add atleast 1 item')
|
$('#result').html('Error: Add atleast 1 item')
|
||||||
$(input).css('border', '2px solid red');
|
$(input).css('border', '2px solid red');
|
||||||
} else {
|
return;
|
||||||
result = items[Math.floor(Math.random() * items.length)];
|
|
||||||
$('#result').html(result)
|
|
||||||
$('#result').hide().fadeIn(1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selectNumber = $('#selectNumber').val()
|
||||||
|
const shuffled = items.sort(() => 0.5 - Math.random());
|
||||||
|
result = shuffled.slice(0, selectNumber)
|
||||||
|
|
||||||
|
let resultText = '';
|
||||||
|
result.forEach(function (item) {
|
||||||
|
resultText += item + ', ';
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#result').html(resultText.slice(0, -2))
|
||||||
|
$('#result').hide().fadeIn(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
14
style.css
14
style.css
@@ -56,6 +56,20 @@ ol>li {
|
|||||||
color: rgb(0, 0, 0);
|
color: rgb(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
height: 50px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
color: #555;
|
||||||
|
background-color: rgb(255, 255, 255);
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid rgb(41, 18, 18);
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width:768px) {
|
@media screen and (max-width:768px) {
|
||||||
#grid {
|
#grid {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
|||||||
Reference in New Issue
Block a user