kontakt: [email protected]
Widżet:Orgonity: Różnice pomiędzy wersjami
Przejdź do nawigacji
Przejdź do wyszukiwania
imported>Sługa szatana mNie podano opisu zmian |
imported>Sługa szatana mNie podano opisu zmian |
||
(Nie pokazano 14 pośrednich wersji utworzonych przez tego samego użytkownika) | |||
Linia 1: | Linia 1: | ||
<includeonly><div id="orgonity"></div><script type="text/javascript"> | <includeonly><div id="orgonity"></div><script type="text/javascript"> | ||
let timer; | |||
let format = arr => { | let format = arr => { | ||
let wynik = []; | let wynik = []; | ||
let sec = interval / 1000; | let sec = interval / 1000; | ||
let plural = (value, a, b, c) => { | |||
return {"one": a, "other": b, "few": b, "many": c || b}[new Intl.PluralRules("en-us").select(value)]; | |||
} | |||
let [days, hours, minutes, seconds] = arr; | let [days, hours, minutes, seconds] = arr; | ||
if (days > 0) { | if (days > 0) { | ||
wynik.push(days + " days"); | wynik.push(days + plural(days, " day", " days")); | ||
} | } | ||
if (hours > 0) { | if (hours > 0) { | ||
wynik.push(hours + " hours"); | wynik.push(hours + plural(hours, " hour", " hours")); | ||
} | } | ||
if (minutes > 0) { | if (minutes > 0) { | ||
wynik.push(minutes + " minutes"); | wynik.push(minutes + plural(minutes, " minute", " minutes")); | ||
} | } | ||
if (seconds > 0) { | if (seconds > 0) { | ||
wynik.push(seconds + " seconds"); | wynik.push(seconds + plural(seconds, " second", " seconds")); | ||
} | } | ||
return wynik.join(", "); | return wynik.join(", "); | ||
Linia 29: | Linia 34: | ||
} | } | ||
let update = () => { | let update = () => { | ||
if (orgonity()) { | |||
jupi(document.getElementById("orgonity")); | |||
clearInterval(timer); | |||
return; | |||
} | |||
let a = new Date(); | let a = new Date(); | ||
a.setHours(0); | a.setHours(0); | ||
Linia 34: | Linia 44: | ||
a.setSeconds(0); | a.setSeconds(0); | ||
a.setMilliseconds(0); | a.setMilliseconds(0); | ||
let b = new Date(); | |||
// zajebane ze stackoverflow | // zajebane ze stackoverflow | ||
a.setDate(a.getDate() + ( | a.setDate(a.getDate() + (12 - b.getDay()) % 7 + 1); | ||
let r = interval(Math.abs(b - a)); | let r = interval(Math.abs(b - a)); | ||
let formatted = format(r); | let formatted = format(r); | ||
let orgonit = document.getElementById("orgonity"); | let orgonit = document.getElementById("orgonity"); | ||
orgonit.innerText = formatted; | |||
}; | }; | ||
update(); | let orgonity = () => { | ||
let now = new Date(); | |||
</script></includeonly> | return now.getDay() == 6 && now.getHours() < 4; | ||
} | |||
let jupi = el => { | |||
el.classList.add("pulse"); | |||
el.style.color = "green"; | |||
el.style.fontSize = "1.25em"; | |||
el.style.fontWeight = "bold"; | |||
el.innerText = "ORGONITY JUPI"; | |||
} | |||
if (orgonity()) { | |||
jupi(document.getElementById("orgonity")); | |||
} else { | |||
update(); | |||
timer = setInterval(update, 1000); | |||
console.debug(timer); | |||
} | |||
</script><style>.pulse { | |||
animation-name: pulse; | |||
animation-iteration-count: infinite; | |||
animation-duration: 1s; | |||
} | |||
@keyframes pulse { | |||
0% { | |||
opacity: 1; | |||
} | |||
50% { | |||
opacity: 0; | |||
} | |||
100% { | |||
opacity: 1; | |||
} | |||
} | |||
</style></includeonly> |