lunes, 12 de junio de 2023

Variaciones con repetición 2 elementos para cuatro espacios

 function generateCombinations(gaps, currentCombination = '') {
  if (gaps === 0) {
    return currentCombination + '<br>';
  }

  const combinations = [];
  combinations.push(...generateCombinations(gaps - 1, currentCombination + 'C'));
  combinations.push(...generateCombinations(gaps - 1, currentCombination + '+'));

  return combinations;
}

// Generate combinations for 4 gaps
const combinations = generateCombinations(4);

// Open a new window with the results
const newWindow = window.open();
newWindow.document.write('<html><body>');
newWindow.document.write('<pre>' + combinations.join('') + '</pre>');
newWindow.document.write('</body></html>');
newWindow.document.close();


viernes, 9 de junio de 2023

X Y pointer position on Chrome

 // Create the rectangle element
var rectangle = document.createElement("div");
rectangle.style.position = "fixed";
rectangle.style.top = "50px";
rectangle.style.left = "50px";
rectangle.style.width = "200px";
rectangle.style.height = "100px";
rectangle.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
rectangle.style.color = "#fff";
rectangle.style.padding = "10px";
rectangle.style.fontFamily = "Arial";
rectangle.style.fontSize = "16px";
rectangle.style.zIndex = "9999";

// Append the rectangle to the document body
document.body.appendChild(rectangle);

// Update the mouse position values in the rectangle
document.onmousemove = function(e) {
    var position = {
        x: e.clientX,
        y: e.clientY
    };
    rectangle.innerHTML = "Mouse Position: X = " + position.x + ", Y = " + position.y;
};


martes, 6 de junio de 2023

parágrafos del REBT que coinciden con una palabra "motor", se incluyen el parágrafo previo y el posterior, así como título

//https://www.boe.es/buscar/act.php?id=BOE-A-2002-18099

 function copyToClipboard(text) {
    const el = document.createElement('textarea');
    el.value = text;
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);

    console.log('Data copied to clipboard.');
}

var headers = document.querySelectorAll('h3, h4, h5');
var plainText = '';

for (var i = 0; i < headers.length; i++) {
    var header = headers[i];
    var correspondingParagraph = header.nextElementSibling;
    var codeBefore = '';
    var codeAfter = '';

    while (correspondingParagraph) {
        if (
            correspondingParagraph.nodeName === 'P' &&
            correspondingParagraph.classList.length > 0 &&
            correspondingParagraph.textContent.includes('motor')
        ) {
            var prevSibling = correspondingParagraph.previousElementSibling;
            var nextSibling = correspondingParagraph.nextElementSibling;

            if (prevSibling && prevSibling.tagName === 'P') {
                codeBefore = prevSibling.textContent;
            }

            if (nextSibling && nextSibling.tagName === 'P') {
                codeAfter = nextSibling.textContent;
            }

            plainText += header.textContent + ':\n';
            plainText += codeBefore + '\n';
            plainText += correspondingParagraph.textContent + '\n';
            plainText += codeAfter + '\n';
            break;
        }
        correspondingParagraph = correspondingParagraph.nextElementSibling;
    }
}

copyToClipboard(plainText);


capítulos del REBT 842/2002 en los que se menciona "tierra" > to be run as prompt in Console DevTools

//https://www.boe.es/buscar/act.php?id=BOE-A-2002-18099
function copyToClipboard(text) {
    const el = document.createElement('textarea');
    el.value = text;
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);

    console.log('Data copied to clipboard.');
}

var headers = document.querySelectorAll('h3, h4, h5');
var plainText = '';

for (var i = 0; i < headers.length; i++) {
    var header = headers[i];
    var correspondingParagraph = header.nextElementSibling;

    while (correspondingParagraph) {
        if (
            correspondingParagraph.nodeName === 'P' &&
            correspondingParagraph.classList.length > 0 &&
            correspondingParagraph.textContent.includes('tierra')
        ) {
            plainText += header.textContent + ': ' + correspondingParagraph.textContent + '\n';
            break;
        }
        correspondingParagraph = correspondingParagraph.nextElementSibling;
    }
}

copyToClipboard(plainText);