Guest User

Untitled

a guest
Apr 7th, 2021
17
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2. let inputTask = document.getElementById('task');
  3. let inputDescription = document.getElementById('description');
  4. let inputDate = document.getElementById('date');
  5. let addBtn = document.getElementById('add');
  6. let mainOpen = document.querySelectorAll('div')[4];
  7. let mainInProgress = document.querySelectorAll('div')[6];
  8. let mainComplete = document.querySelectorAll('div')[8];
  9.  
  10.  
  11. addBtn.addEventListener('click', (event) => {
  12. event.preventDefault();
  13. if (inputTask.value == '' || inputDescription.value == '' || inputDate.value == '') {
  14. return;
  15. }
  16.  
  17. createArticleOpen();
  18. inputTask.value = '';
  19. inputDescription.value = '';
  20. inputDate.value = '';
  21.  
  22. });
  23.  
  24. mainOpen.addEventListener('click', (event) => {
  25. event.preventDefault();
  26.  
  27. if (event.target.tagName == 'BUTTON' && event.target.textContent == 'Start') {
  28. createArticleInProgress();
  29.  
  30.  
  31. } else if (event.target.tagName == 'BUTTON' && event.target.textContent == 'Delete') {
  32. event.target.parentNode.parentNode.remove();
  33. }
  34.  
  35. });
  36.  
  37. mainInProgress.addEventListener('click', (event) => {
  38. event.preventDefault();
  39.  
  40. if (event.target.tagName == 'BUTTON' && event.target.textContent == 'Delete') {
  41. event.target.parentNode.parentNode.remove();
  42.  
  43. } else if (event.target.tagName == 'BUTTON' && event.target.textContent == 'Finish') {
  44. createArticleFinish();
  45. }
  46. })
  47.  
  48.  
  49. function createArticleFinish() {
  50. let article = event.target.parentNode.parentNode;
  51. mainComplete.appendChild(article);
  52. article.querySelector('div').remove();
  53. }
  54.  
  55. function createArticleInProgress() {
  56. let article = event.target.parentNode.parentNode;
  57. mainInProgress.appendChild(article);
  58. let [delBtn, finishBtn] = article.querySelectorAll('button');
  59. console.log(delBtn, finishBtn);
  60. delBtn.className = 'red';
  61. delBtn.textContent = 'Delete';
  62. finishBtn.className = 'orange';
  63. finishBtn.textContent = 'Finish';
  64.  
  65. }
  66.  
  67. function createArticleOpen() {
  68. let article = document.createElement('article');
  69. mainOpen.appendChild(article);
  70. let h3 = document.createElement('h3');
  71. h3.textContent = inputTask.value;
  72. article.appendChild(h3);
  73.  
  74. let p1 = document.createElement('p');
  75. p1.textContent = `Description: ${inputDescription.value}`;
  76. article.appendChild(p1);
  77.  
  78. let p2 = document.createElement('p');
  79. p2.textContent = `Due Date: ${inputDate.value}`;
  80. article.appendChild(p2);
  81.  
  82. let div = document.createElement('div');
  83. div.className = 'flex';
  84. article.appendChild(div);
  85.  
  86. let startBtn = document.createElement('button');
  87. startBtn.className = 'green';
  88. startBtn.textContent = 'Start';
  89. div.appendChild(startBtn);
  90.  
  91. let delBtn = document.createElement('button');
  92. delBtn.className = 'red';
  93. delBtn.textContent = 'Delete';
  94. div.appendChild(delBtn);
  95. }
  96. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×