ErrorsManager/Public/test.html

77 lines
2.5 KiB
HTML

<script type="module" charset="utf-8">
"use strict";
import {ErrorsManager} from "./ecma/ErrorsManager.ecma.js";
/** @type {ErrorsManager} */
const errors_manager = new ErrorsManager();
console.log(errors_manager.to_string(105));
console.log(errors_manager.to_array(105));
console.log(errors_manager.to_array_binary(105));
console.log(errors_manager.process(105, "0123456789abcdef".split("").map((_, i) => "error_message_" + i)));
console.log(errors_manager.bits(105));
console.log(errors_manager.bits("pB"));
console.log(errors_manager.bits([41, 1]));
/** @type {Array.<number>} */
const options = [-10, -5, -3, -1, 0, 1, 3, 5, 10],
/** @type {Array.<number|string|Array.<number>} */
results = [];
/** @type {string} */
let filler = "";
while(filler.length < 30)
filler += " ";
/**
* @param {!string} value
* @param {!number} character
* @returns string
* @access public
*/
const format = (value, characters) => " " + (
JSON.stringify(value).replace(/,/g, ", ") + filler
).slice(0, characters) + " ";
[105, "pB", [41, 1]].forEach((value, i) => options.forEach(bits => {
/** @type {string|number|Array.<number>} */
const new_value = errors_manager.bitwise(value, bits);
results.push([
format(value, 7),
format(errors_manager.to_array_binary(value), 20),
format(bits, 4),
format(new_value, 12),
format(errors_manager.to_array_binary(new_value), 30)
]);
// console.log(results[results.length - 1]);
}));
console.log(results);
// console.log(results.map(result => result.join("|")).join("\n"));
// if ('speechSynthesis' in window) {
// console.log("CARGANDO...");
// window.speechSynthesis.onvoiceschanged = () => {
// console.log("CARGADO");
// const voices = window.speechSynthesis.getVoices();
// console.log(voices);
// const selectedVoice = voices.find(voice => voice.name === 'Google español'); // Ejemplo de selección de voz
// // Crear un objeto de síntesis de voz
// const utterance = new SpeechSynthesisUtterance('Hola, mundo!');
// utterance.voice = selectedVoice;
// // Iniciar la síntesis de voz
// window.speechSynthesis.speak(utterance);
// };
// } else {
// console.error('La API de SpeechSynthesis no es compatible con este navegador.');
// };
</script>