First commit
This commit is contained in:
parent
cf97b64877
commit
cc69770608
1468 changed files with 265316 additions and 128 deletions
13
www/human/abl-human.css
Normal file
13
www/human/abl-human.css
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* CSS Document */
|
||||
.human-boxed-text {
|
||||
display: inline-block;
|
||||
}
|
||||
.human-boxed-text span {
|
||||
display: inline-block;
|
||||
border: 1px solid black;
|
||||
padding: 2px;
|
||||
width: 20px;
|
||||
height: 30px;
|
||||
text-align: center;
|
||||
color: black; /* Colore del testo */
|
||||
}
|
||||
90
www/human/abl-human.js
Normal file
90
www/human/abl-human.js
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// human
|
||||
|
||||
// JavaScript Document
|
||||
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
/*catica il challenge*/
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
function fetchChallenge() {
|
||||
|
||||
$("#cmd").val("sendChallenge");
|
||||
console.log($("#hkForm").serialize());
|
||||
Ab.fetch4("HumanCeck.abl", $("#hkForm").serialize(), "_challenge", null, true);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
/*invia la risposta*/
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
function checkChallenge() {
|
||||
|
||||
$("#cmd").val("checkChallenge");
|
||||
//alert( $("#h_answer").val());
|
||||
//alert($("#hkForm").serialize());
|
||||
console.log($("#hkForm").serialize());
|
||||
Ab.fetch4("HumanCeck.abl", $("#hkForm").serialize(), null, "postCheckChallenge()",false);
|
||||
|
||||
}
|
||||
|
||||
function postCheckChallenge(response) {
|
||||
//ricarico l'ordine
|
||||
//Ab.swal($("#msgWarn").val(), $("#procedi").val()+" "+response, "warning");
|
||||
console.log(response);
|
||||
var jObj = $.parseJSON(response);
|
||||
|
||||
//
|
||||
var res = jObj.res;
|
||||
var page = jObj.page;
|
||||
if (res == "true") {
|
||||
//alert("ok..."+page);
|
||||
location.href=page;
|
||||
} else {
|
||||
alert('NOOOOO');
|
||||
fetchChallenge();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
/*preparazione challenge*/
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
function getRandomColor() {
|
||||
const letters = '0123456789ABCDEF';
|
||||
let color = '#';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
color += letters[Math.floor(Math.random() * 16)];
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
function isColorTooDark(color) {
|
||||
// Calcola la luminosità del colore basandosi sulla formula WCAG
|
||||
const luminance = (0.299 * parseInt(color.substr(1, 2), 16))
|
||||
+ (0.587 * parseInt(color.substr(3, 2), 16))
|
||||
+ (0.114 * parseInt(color.substr(5, 2), 16));
|
||||
|
||||
// Restituisce true se il colore è abbastanza scuro da rendere il testo illeggibile
|
||||
return luminance < 128;
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
const spans = document.querySelectorAll('.human-boxed-text span');
|
||||
|
||||
spans.forEach(span => {
|
||||
let randomColor;
|
||||
do {
|
||||
randomColor = getRandomColor();
|
||||
} while (isColorTooDark(randomColor));
|
||||
|
||||
span.style.backgroundColor = randomColor;
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue