Advertisement
1xptolevitico69

Weekly Todo List

Jun 17th, 2022
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.05 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <meta charset="UTF-8">
  6.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.   <link rel="stylesheet" href="https://1xpto.netlify.app/articles/html/css default/default.css">
  9.   <title>Weekly Todo List</title>
  10.   <style>
  11.     .box {
  12.       margin: 10px auto;
  13.       border: 1px solid;
  14.       display: block;
  15.       width: 80%;
  16.       height: 200px;
  17.       position: relative;
  18.     }
  19.  
  20.     .area {
  21.       width: 100%;
  22.       height: 150px;
  23.       box-sizing: border-box;
  24.       position: absolute;
  25.       bottom: 0;
  26.       padding: 0 20px;
  27.     }
  28.  
  29.     .h1 {
  30.       font-size: 20px;
  31.       position: absolute;
  32.       left: 20px;
  33.     }
  34.  
  35.     .btn {
  36.       position: absolute;
  37.       right: 0;
  38.       bottom: 0;
  39.       margin: 20px;
  40.       background-color: red;
  41.       color: white;
  42.       padding: 2px 20px;
  43.     }
  44.  
  45.     #header {
  46.       text-align: center;
  47.       margin: 30px;
  48.       font-size: 40px;
  49.     }
  50.  
  51.     .clear {
  52.       background-color: red;
  53.       color: white;
  54.       padding: 2px 20px;
  55.       transform: translate(0, -4px);
  56.     }
  57.   </style>
  58. </head>
  59.  
  60. <body>
  61.  
  62.   <h1 id='header'>Weekly Todo List <button class='clear' onclick='localStorage.clear();location.reload()'>Clear</button></h1>
  63.  
  64.   <script>
  65.     weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
  66.     for (i = 0; i < weekday.length; i++) {
  67.      document.body.appendChild(box = document.createElement('div'));
  68.      box.appendChild(h1 = document.createElement('h1'));
  69.      box.appendChild(area = document.createElement('textarea'));
  70.      box.appendChild(btn = document.createElement('button'));
  71.      box.className = 'box';
  72.      area.className = 'area';
  73.      h1.className = 'h1';
  74.      btn.className = 'btn';
  75.      btn.innerHTML = 'Store';
  76.      h1.innerHTML = weekday[i];
  77.    }
  78.    btn = document.getElementsByClassName('btn');
  79.    area = document.getElementsByClassName('area');
  80.    btn[0].onclick = () => {
  81.       localStorage.setItem('key0', area[0].value)
  82.     }
  83.     btn[1].onclick = () => {
  84.       localStorage.setItem('key1', area[1].value)
  85.     }
  86.     btn[2].onclick = () => {
  87.       localStorage.setItem('key2', area[2].value)
  88.     }
  89.     btn[3].onclick = () => {
  90.       localStorage.setItem('key3', area[3].value)
  91.     }
  92.     btn[4].onclick = () => {
  93.       localStorage.setItem('key4', area[4].value)
  94.     }
  95.     btn[5].onclick = () => {
  96.       localStorage.setItem('key5', area[5].value)
  97.     }
  98.     btn[6].onclick = () => {
  99.       localStorage.setItem('key6', area[6].value)
  100.     }
  101.     window.addEventListener('load', () => {
  102.       area[0].value = localStorage.getItem('key0');
  103.       area[1].value = localStorage.getItem('key1');
  104.       area[2].value = localStorage.getItem('key2');
  105.       area[3].value = localStorage.getItem('key3');
  106.       area[4].value = localStorage.getItem('key4');
  107.       area[5].value = localStorage.getItem('key5');
  108.       area[6].value = localStorage.getItem('key6');
  109.     });
  110.   </script>
  111. </body>
  112. </html>
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement