{"size": 1004, "ext": "js", "max_stars_repo_path": "modules/module.js", "max_stars_repo_name": "asus4/variable_font_exp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/module.js", "max_issues_repo_name": "asus4/variable_font_exp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/module.js", "max_forks_repo_name": "asus4/variable_font_exp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.5294117647, "max_line_length": 75, "alphanum_fraction": 0.577689243}

export function wrapBySpan(selector, className) {
    const elements = document.querySelectorAll(selector)
    const replaceText = `<span class="${className}">$1</span>`
    for (const element of elements) {
        element.innerHTML = element.innerText.replace(/(\S)/g, replaceText)
    }
}

export function convertToAbsolute(selector) {
    const elements = document.querySelectorAll(selector)
    const bounds = []
    for (const elm of elements) {
        bounds.push(elm.getBoundingClientRect())                    
    }
    const elementsPositions = []
    for (let i = 0; i < bounds.length; i++) {
        const elm = elements[i]
        const b = bounds[i]
        elm.style.position = 'absolute'
        elm.style.left = b.left + 'px'
        elm.style.top = b.top + 'px'

        elementsPositions.push({
            element: elm,
            // return center point
            x: b.x + b.width * 0.5,
            y: b.y + b.height * 0.5,
        })
    }
    
    return elementsPositions
}
