This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tryAgain(fn, times = 2){ | |
try { | |
return fn(times); | |
} catch (e) { | |
if (times > 1) return tryAgain(fn, times-1); | |
throw e; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// better a "WordObserver" that can better handle chanching targets? | |
let word = ''; | |
let wordClearTimeout = null; | |
let wordTarget = null; | |
addEventListener('keyup', e=>{ | |
const isChar = /^.$/u.test(e.key); | |
// if (wordTarget !== e.target) { // clear if target changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function computedLang(el){ | |
let root = el.closest('[lang]'); | |
let lang = root ? root.getAttribute('lang') : navigator.language; | |
if (!el.matches(':lang('+lang+')')) { | |
console.warn('lang missmatch!'); | |
for (let l of ['de','en','it','es', /*...*/ ]) if (el.matches(':lang('+l+')')) return l; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c1.c1Use('onElement',function(){ 'use strict'; | |
// check supported | |
var x = document.createElement('input'); | |
x.type = 'datetime-local'; | |
if (x.type === 'datetime-local') return; | |
document.head.insertAdjacentHTML( | |
'afterbegin', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!('onscrollend' in document.documentElement)) { | |
document.addEventListener('scroll',function(e){ | |
var scrollPort = e.target | |
clearTimeout(scrollPort._scrollEndTimeout); | |
scrollPort._scrollEndTimeout = setTimeout(function () { | |
const event = new Event('scrollend'); | |
Object.defineProperty(event,'snapTarget',{ | |
get(){ | |
return 'todo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('load',function(e){ | |
if (e.target.tagName !== 'LINK') return; | |
if (e.target.rel !== 'stylesheet') return; | |
console.log(e.target.sheet) | |
},true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const selector = 'link[rel="stylesheet"], style'; | |
onElement(selector, function(el){ // NOT IMPLEMENTED IN THIS SCRIPT | |
// checks all styleSheets and importRules, todo store urls global and check all if used url found | |
// console.log(el.sheet) | |
checkAllSheets() | |
}); | |
function checkAllSheets(){ | |
const urls = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ussage | |
<div flex-gap=fallback-margin style="--x-gap:10px"> | |
<span>a</span> | |
<span>b</span> | |
</div> | |
*/ | |
var div = document.createElement('div'); | |
div.innerHTML = '<i></i><i></i>'; | |
div.style.display = 'inline-flex'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2016 Tobias Buschor https://goo.gl/gl0mbf | MIT License https://goo.gl/HgajeK */ | |
/** | |
ussage: | |
<table> | |
<tr data-c1-href="https://example.com" data-c1-target="_blank"> | |
<td> <a href="https://example.com" target="_blank">example.com</a> | |
<td> Do not forget to add a real link so that your content is accessible. | |
</table> | |
*/ | |
c1 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!HTMLFormElement.prototype.requestSubmit) { | |
HTMLFormElement.prototype.requestSubmit = function(submitter) { | |
let submitBtn = submitter; | |
if (!submitBtn) { | |
submitBtn = document.createElement('input'); | |
submitBtn.type = 'submit'; | |
submitBtn.hidden = true; | |
this.appendChild(submitBtn); | |
} | |
submitBtn.click(); |
NewerOlder