Let's go gambling!
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
zad4SprawdzParzystosc();
|
||||
zad7Przesun();
|
||||
zad8Przelicz();
|
||||
})
|
||||
|
||||
function zad4SprawdzParzystosc() {
|
||||
@@ -21,5 +22,67 @@ function zad7Koniec() {
|
||||
} else if (wiek < 11) {
|
||||
alert("Jesteś dzieckiem! Akysz, nie niszcz sobie życia");
|
||||
}
|
||||
document.getElementById('pornhub').id = 'pornhub-nieaktywne';
|
||||
document.getElementById('aktywne').id = 'nieaktywne';
|
||||
}
|
||||
|
||||
|
||||
function regexDlugosc(str, patern) {
|
||||
const wynik = str.match(patern);
|
||||
if (wynik == null) {
|
||||
return 0;
|
||||
}
|
||||
return wynik.length;
|
||||
}
|
||||
|
||||
function zad8Przelicz() {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const haslo = document.getElementById("zad8-haslo").value ?? "";
|
||||
const lista = document.getElementById("zad8-lista");
|
||||
const sila = document.getElementById("zad8-sila");
|
||||
|
||||
lista.innerHTML = "";
|
||||
|
||||
let maleLitery = regexDlugosc(haslo, /[a-z]/g);
|
||||
let duzeLitery = regexDlugosc(haslo, /[A-Z]/g);
|
||||
let cyfry = regexDlugosc(haslo, /[0-9]/g);
|
||||
let znakiSpecialne = regexDlugosc(haslo, /[!-/]|[;-@]|[\[-`]|[{-~]|ą|ę|ś|ż|ź|ó/g);
|
||||
|
||||
if (maleLitery + duzeLitery + cyfry + znakiSpecialne < 8) {
|
||||
const element = document.createElement("li");
|
||||
element.appendChild(document.createTextNode("Twoje hasło musi zawierać minimum 8 znaków"));
|
||||
lista.appendChild(element);
|
||||
} else if (maleLitery >= 1 && duzeLitery >= 1 && cyfry >= 1 && znakiSpecialne >= 1) {
|
||||
lista.append(document.createTextNode("Twoje hasło jest wystarczająco silne 💪"));
|
||||
}
|
||||
if (maleLitery < 1) {
|
||||
const element = document.createElement("li");
|
||||
element.appendChild(document.createTextNode("Twoje hasło musi zawierać minimum jedną małą litere"));
|
||||
lista.appendChild(element);
|
||||
}
|
||||
if (duzeLitery < 1) {
|
||||
const element = document.createElement("li");
|
||||
element.appendChild(document.createTextNode("Twoje hasło musi zawierać minimum jedną dużą litere"));
|
||||
lista.appendChild(element);
|
||||
}
|
||||
if (cyfry < 1) {
|
||||
const element = document.createElement("li");
|
||||
element.appendChild(document.createTextNode("Twoje hasło musi zawierać minimum jedną cyfre"));
|
||||
lista.appendChild(element);
|
||||
}
|
||||
if (znakiSpecialne < 1) {
|
||||
const element = document.createElement("li");
|
||||
element.appendChild(document.createTextNode("Twoje hasło musi zawierać minimum jeden znak specjalny"));
|
||||
lista.appendChild(element);
|
||||
}
|
||||
|
||||
let algorytm = Math.floor(Math.ceil(maleLitery / 3.5) + Math.ceil(duzeLitery / 2.5) + Math.ceil(cyfry / 0.75) + znakiSpecialne * 2);
|
||||
if (algorytm > 10) {
|
||||
algorytm = 10;
|
||||
}
|
||||
sila.innerText = "";
|
||||
for (let i = 0; i < algorytm; i++) {
|
||||
sila.innerText += "🏋️";
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,20 @@ class Obliczanie extends HTMLElement {
|
||||
|
||||
wylicz() {
|
||||
let operacja = this.dzialanie;
|
||||
let pelne = true;
|
||||
for (const znak in this.elementy)
|
||||
{
|
||||
const element = this.shadow.getElementById(znak);
|
||||
if (element == null) {
|
||||
return;
|
||||
if (element == null || element.value == "") {
|
||||
pelne = false;
|
||||
continue;
|
||||
}
|
||||
operacja = operacja.replaceAll(znak, element == null ? "" : element.value);
|
||||
}
|
||||
if (!pelne) {
|
||||
this.wynik.innerText = operacja;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.wynik.innerText = eval(operacja);
|
||||
} catch {
|
||||
|
||||
0
assets/js/liczby.js
Normal file
0
assets/js/liczby.js
Normal file
@@ -8,6 +8,7 @@ const linki = [
|
||||
[
|
||||
{ nazwa: "JS. Podstawowe Zad.", link: "/js-podstawy.html" },
|
||||
{ nazwa: "JS. Zad. Warunkowe", link: "/js-warunkowe.html" },
|
||||
{ nazwa: "Liczby", link: "/liczby.html" },
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user