function setupForms()

in ArticleTemplates/assets/js/bootstraps/common.js [748:772]


function setupForms() {
    let fenceElems = document.querySelectorAll('iframe.fenced');
    let checkForLinks;
    let attempts = 0;
    let replaced = false;
    if (fenceElems) {
        checkForLinks = setInterval(() => {
            attempts += 1;
            fenceElems.forEach(elem => {
                elem.contentWindow.document.querySelectorAll('.fsBody link').forEach(link => {
                    replaced = true;
                    if (link.href.startsWith("file:")) {
                        link.href = link.href.replace('file:', 'http:');
                    } else if (link.href.startsWith("//")) {
                        link.href = link.href.replace('//', 'http://');
                    }
                });
            });

            if (attempts >= 20 || replaced) {
                clearInterval(checkForLinks);
            }
        }, 500);
    }
}