laradb

script pour établir une bdd Ãà partir d'un tsv avec différent format - retour accueil

git clone git://bebou.netlib.re/laradb
Log | Files | Refs |

cssVarFilledCookies.js (1553B)


      1 function filterEntriesWithCSSVariables(obj) {
      2     return Object.entries(obj).filter(([key, value]) => {
      3         return typeof value === 'string' && value.startsWith('--');
      4     });
      5 }
      6 const resetVars = () => {
      7 	localStorage.clear();
      8 	location.reload();
      9 }
     10 
     11 const style = getComputedStyle(document.documentElement)
     12 const cssVars = filterEntriesWithCSSVariables(style).map((v) => v[1]);
     13 
     14 const container = document.createElement('section')
     15 const reset = document.createElement('button');
     16 reset.textContent = "reset";
     17 reset.onclick = resetVars
     18 
     19 container.innerHTML = '<p></p>'
     20 container.setAttribute('id','cvfc')
     21 container.appendChild(reset)
     22 document.body.appendChild(container)
     23 const table = document.createElement('table')
     24 container.appendChild(table)
     25 
     26 cssVars.reverse().forEach((cssVar) => {
     27     let val = style.getPropertyValue(cssVar)
     28     document.body.style.setProperty(cssVar,localStorage.getItem(cssVar) || val)
     29 
     30     const tr = document.createElement('tr')
     31 
     32     const key = document.createElement('td')
     33     const value = document.createElement('td')
     34 
     35     const value_textArea = document.createElement('textarea')
     36     value_textArea.setAttribute('rows',1)
     37     value_textArea.addEventListener("input", function(){
     38         localStorage.setItem(cssVar, this.value);
     39         document.body.style.setProperty(cssVar, this.value);    
     40     });
     41 
     42     value_textArea.innerHTML = localStorage.getItem(cssVar) || val
     43     value.appendChild(value_textArea)
     44 
     45     key.innerHTML = cssVar
     46 
     47     tr.appendChild(key)
     48     tr.appendChild(value)
     49 
     50     table.appendChild(tr)
     51 })
     52