let alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'], consonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','z'], vowels = ['a','e','i','o','u','y'] const replace = (string='', pattern='', replacement='')=>string.replace(pattern, replacement) const replaceAll = (string='', pattern='', replacement='')=>string.split(pattern).join(replacement) const repeater = (number=2, callback=(index)=>index)=>{ if(number <= 0) return false for(let i = 0; i < number; i++) callback(i, number) return callback } const twice = (callback=(argument=0)=>argument)=>repeater(2) const isPositive = (number=0)=>number > 0 const isNegative = (number=0)=>number < 0 const isZero = (number=0)=>number == 0 const shuffle = array=>array.sort(()=>Math.random()) function forEach(array=[], callback=(argument=0)=>argument, initial=0, limit=0) { const recursive = (each)=>{ if(each < array.length) { callback(array[each], each, array) recursive(each + 1) } } recursive(initial) return callback } function numberOf(item='key', array=[]) { if(item === null) { item = array[Math.floor(Math.random()*array.length)] } return array.filter(each=>each === item).length } function synthesize(arrayOfObjects=[{key: 'value'}], property='key') { return arrayOfObjects.reduce((accumulator, each)=>{ accumulator[each[property]] = (accumulator[each[property]] || 0) + 1 return accumulator }, {}) } function sheduler(...array) { const first = array[0] if(first === Number(first)) { setTimeout(()=>{ return sheduler(...array.slice(1)) }, first) return ('Waiting', first) } else if(typeof first === 'function') { first(array) return sheduler(...array.slice(1)) } else if(typeof first === 'string') { console.log(first) return sheduler(...array.slice(1)) } else if(first !== undefined) { console.error(`"${first.toString()}" est invalide`) return sheduler(...array.slice(1)) } return 'Erreur' } const counterGenerator = function*() { let count = 0 while(count < 1000000) { yield ++count } } const counter = counterGenerator() function displayOnDOMElement(content='', container=document.querySelector('.et--reload-container')) { if(typeof container === 'object') { container.innerHTML = content } else { document.querySelector(container).innerHTML = content } return content } const dODE = (content, container)=>displayOnDOMElement(content, container) function copy(textToCopy='Copié') { const element = document.createElement('textarea') element.value = textToCopy.trim() document.querySelector('body').appendChild(element) element.select() document.execCommand('copy') document.querySelector('body').removeChild(element) return textToCopy } function audio(src='./audio.mp3', autoplay=true, loop=false, autoRemovePercent=100, checkTimeMillis=1000) { const element = document.createElement('audio') element.src = src element.autoplay = autoplay element.loop = loop document.querySelector('body').appendChild(element) if(!loop && autoRemovePercent > 0 && checkTimeMillis > 0) { const timer = setInterval(()=>{ if(100*element.currentTime/element.duration >= autoRemovePercent || isNaN(element.duration)) { document.querySelector('body').removeChild(element) clearInterval(timer) return autoRemovePercent } }, checkTimeMillis) } return element } function onEvent(eventName='click', element=document.querySelector('body'), callback=(argument=0)=>argument) { element.addEventListener(eventName, function(event) { callback(this, event, eventName) }) return callback } const onClick = (element=document.querySelector('body'), callback=(argument=0)=>argument)=>onEvent('click', element, callback) const onDoubleClick = (element=document.querySelector('body'), callback=(argument=0)=>argument)=>onEvent('dblclick', element, callback) function convert(valueFrom=0, unitFrom='m', unitTo='m', unitName='') { const unitsPrefixes = [ [10000000000, 'yotta', 'Y'], [1000000000, 'zetta', 'Z'], [100000000, 'exa', 'E'], [10000000, 'peta', 'P'], [1000000, 'tera', 'T'], [100000, 'giga', 'G'], [10000, 'mega', 'M'], [1000, 'kilo', 'k'], [100, 'hecto', 'h'], [10, 'deca', 'da'], [1, ' ', '1'], [.1, 'deci', 'd'], [.01, 'centi', 'c'], [.001, 'milli', 'm'], [.0001, 'micro', 'µ'], [.00001, 'nano', 'n'], [.000001, 'pico', 'p'], [.0000001, 'femto', 'f'], [.00000001, 'atto', 'a'], [.000000001, 'zepto', 'z'], [.0000000001, 'tocto', 'y'] ] unitsPrefixes.forEach(each=>{ if(unitFrom.startsWith(each[1]) || unitFrom.startsWith(each[2])) { valueFrom *= each[0] } }) unitsPrefixes.forEach(each=>{ if(unitTo.startsWith(each[1]) || unitTo.startsWith(each[2])) { valueFrom /= each[0] } }) return valueFrom+unitTo+unitName } function checkSEO(page=document) { console.info('L\'URL de la page jolie', page.URL) const protocole = (page.URL && page.URL.startsWith('https://')) ? ['sécurisé', 'https'] : ['non sécurisé', 'http'] console.info('Protocole de l\'URL '+protocole[0], protocole[1]) if(page.all === undefined) return page Array.from(page.all).forEach(each=>{ if(each.tagName === 'TITLE') console.info('1