Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
inventionpro authored Jul 27, 2024
1 parent acb61aa commit b50053a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ if (!localStorage.getItem('order')) {
/* Show cards */
function reload() {
let data = JSON.parse(localStorage.getItem('todo')) || [];
if (localStorage.getItem('order') === 'newest') data = data.reverse();
document.getElementById('preview').innerHTML = `<p>${data.length} tasks left</p>
<div style="display:none" class="order">
<div>
<div onclick="localStorage.setItem('order', '${localStorage.getItem('order') === 'newest' ? 'newest' : 'oldest'}');reload()">
${localStorage.getItem('order') === 'newest' ? `<svg height="25" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"><!--Fsh icons--><path d="M120.878 91.8996C123.982 86.7001 131.513 86.7001 134.617 91.8996L173.352 156.791C176.535 162.124 172.693 168.892 166.483 168.892H89.0123C82.802 168.892 78.96 162.124 82.143 156.791L120.878 91.8996Z"/></svg>` : `<svg height="25" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"><!--Fsh icons--><path d="M120.878 164.992C123.982 170.192 131.513 170.192 134.617 164.992L173.352 100.1C176.535 94.7679 172.693 88 166.483 88H89.0123C82.802 88 78.96 94.7679 82.143 100.1L120.878 164.992Z"/></svg>`}
<p>${localStorage.getItem('order') === 'newest' ? 'Newest' : 'Oldest'}</p>
</div>
Expand Down

0 comments on commit b50053a

Please sign in to comment.