SHARE
TWEET

ccccccc

a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const funWyporzycz = (event) => {
  2.     if (event.target.classList.contains("wyporzycz")){
  3.         let book = JSON.parse(localStorage.getItem('book'))
  4.         if (book !== null ){
  5.             let flag = false;
  6.             for (let i = 0; i < book.length; i++) {
  7.                 let el = book[i];
  8.                 if (el.id === event.target.parentElement.parentElement.getAttribute('id') && flag === false) {
  9.                     el.length += 1;
  10.                     localStorage.setItem('book', JSON.stringify(book))
  11.                     flag = true
  12.                     break;
  13.                 } else if (i === book.length-1 && flag === false) {
  14.                     book.push({
  15.                         id: `${event.target.parentElement.parentElement.getAttribute('id')}`,
  16.                         length: 1,    
  17.                     })
  18.                     localStorage.setItem('book', JSON.stringify(book))        
  19.                     flag = true;
  20.                     break;
  21.                 }
  22.             }
  23.         } else if (book === null) {
  24.             book = [];
  25.             book.push({
  26.                 id: `${event.target.parentElement.parentElement.getAttribute('id')}`,
  27.                 length: 1,    
  28.             })
  29.             localStorage.setItem('book', JSON.stringify(book))
  30.         }
  31.     }
  32.  
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top