• Resolved ecasadolopez

    (@ecasadolopez)


    I stopped paying for the plugin because it hasn’t brought me anything new in two years, and now it doesn’t translate with the free version, it always displays the url/#. I would appreciate a solution for this. Thanks.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author edo888

    (@edo888)

    Hi,

    I have checked your website and I have noticed the following code which is messing the on click event listeners on the flags:

    function upDateYear() {
        const date = new Date();
        var currentYear = date.getFullYear();
    
        var head = document.getElementsByTagName("HEAD");
        head[0].innerHTML = head[0].innerHTML.replace(/CurrentYear/g, currentYear);
    		
        var body = document.getElementsByTagName("BODY");
        body[0].innerHTML = body[0].innerHTML.replace(/CurrentYear/g, currentYear);		
    }

    The problem is that when you reset innerHTML for the whole body, it removes all the javascript events from all elements, so it causes issues. Please ask your developer to fix it.

    Thanks! ??

    Thread Starter ecasadolopez

    (@ecasadolopez)

    Thanks, you are right, all events are lost, here is the solution:

    function upDateYear() {
    const date = new Date();
    const currentYear = date.getFullYear();

    // Update HEAD content
    const head = document.getElementsByTagName("HEAD")[0];
    if (head) {
    head.childNodes.forEach(node => {
    if (node.nodeType === Node.TEXT_NODE) {
    node.nodeValue = node.nodeValue.replace(/CurrentYear/g, currentYear);
    }
    });
    }

    // Update the content of the BODY
    const body = document.getElementsByTagName("BODY")[0];
    if (body) {
    const replaceTextNodes = node => {
    if (node.nodeType === Node.TEXT_NODE) {
    node.nodeValue = node.nodeValue.replace(/CurrentYear/g, currentYear);
    } else if (node.nodeType === Node.ELEMENT_NODE) {
    node.childNodes.forEach(replaceTextNodes);
    }
    };
    replaceTextNodes(body);
    }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.