X Tutup
Skip to content
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a2f9026
added funtionality and styling to drumkit
shb1383 May 16, 2024
1f98709
added functionality and styling to clock hands
shb1383 May 16, 2024
9ba8afe
created handle documents and function to update its properties
shb1383 May 20, 2024
9e61433
created various methods to sort given data
shb1383 May 21, 2024
a383123
added styling and toggle functions to panels
shb1383 May 22, 2024
314b55f
created fetch and functions to retieve data and display results for s…
shb1383 May 24, 2024
3aa1f51
created code using various array methods to complete tasks
shb1383 May 24, 2024
fc562b0
created and styled drawing function on canvas
shb1383 May 26, 2024
6a64ccd
coded various console tricks
shb1383 May 27, 2024
e307d73
created handle check function and applied event listener to it
shb1383 May 28, 2024
4e762e8
grabbed elements, created functions, and attached event listeners
shb1383 May 29, 2024
db3f228
created event listener on keys to detect secret code
shb1383 May 29, 2024
ec11536
grabbed image elements and created sliding function
shb1383 May 30, 2024
6661813
created copies
shb1383 Jun 5, 2024
edbcfb4
created functions to add, populate, and toggle
shb1383 Jun 8, 2024
5f81ef5
created mouse move shadow function
shb1383 Jun 9, 2024
f623d74
created function to sort without articles
shb1383 Jun 10, 2024
6ae3a81
added up times with reduce
shb1383 Jun 11, 2024
b6dfea8
created various functions for webcam
shb1383 Jun 11, 2024
716a343
implemented speech detection
shb1383 Jun 13, 2024
016b0f1
created function to access speed and postion watch accordingly
shb1383 Jun 14, 2024
ef4589a
created highlight link function
shb1383 Jun 15, 2024
5ca590b
created functions to populate and set voice plus function to toggle a…
shb1383 Jun 15, 2024
6329c50
created sticky nav function and applied it to css elements
shb1383 Jun 16, 2024
c12783c
applied event listeners utilizing capture, once, propagation and bubb…
shb1383 Jun 16, 2024
20cc873
created functions for nav dropdowns to transition in and out smoothly
shb1383 Jun 17, 2024
e60d93f
added event listeners to create click and drage feature
shb1383 Jun 17, 2024
2e738bf
created function to control video speed via speed bar
shb1383 Jun 17, 2024
2528c23
created various functions for countdown timer
shb1383 Jun 18, 2024
dd3efce
created various functions for whack a mole gameplay
shb1383 Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
created functions to add, populate, and toggle
  • Loading branch information
shb1383 committed Jun 8, 2024
commit edbcfb46c7e551d83c9b17e9481170e4a8b2c585
50 changes: 44 additions & 6 deletions 15 - LocalStorage/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,52 @@ <h2>LOCAL TAPAS</h2>
</form>
</div>

<script>
const addItems = document.querySelector('.add-items');
const itemsList = document.querySelector('.plates');
const items = [];
<script>
const addItems = document.querySelector('.add-items');
const itemsList = document.querySelector('.plates');
const items = JSON.parse(localStorage.getItem('items')) || [];

</script>
function addItem(e) {
e.preventDefault();
const text = (this.querySelector('[name=item]')).value;
const item = {
text,
done: false
};

items.push(item);
populateList(items, itemsList);
localStorage.setItem('items', JSON.stringify(items));
this.reset();
}

function populateList(plates = [], platesList) {
platesList.innerHTML = plates.map((plate, i) => {
return `
<li>
<input type="checkbox" data-index=${i} id="item${i}" ${plate.done ? 'checked' : ''} />
<label for="item${i}">${plate.text}</label>
</li>
`;
}).join('');
}

function toggleDone(e) {
if (!e.target.matches('input')) return; // skip this unless it's an input
const el = e.target;
const index = el.dataset.index;
items[index].done = !items[index].done;
localStorage.setItem('items', JSON.stringify(items));
populateList(items, itemsList);
}

addItems.addEventListener('submit', addItem);
itemsList.addEventListener('click', toggleDone);

populateList(items, itemsList);

</script>


</body>
</html>

X Tutup