{"size": 1324, "ext": "js", "max_stars_repo_path": "commandfoxWE.js", "max_stars_repo_name": "giovannimeo/commandfoxWE", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commandfoxWE.js", "max_issues_repo_name": "giovannimeo/commandfoxWE", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commandfoxWE.js", "max_forks_repo_name": "giovannimeo/commandfoxWE", "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": 37.8285714286, "max_line_length": 92, "alphanum_fraction": 0.5732628399}
//////////////////////////////////////////////////////////////////////////
// Script invoked in the popup page, it listen to the user input in the //
// textarea 'edit-box' and send to the background script for processing //
//////////////////////////////////////////////////////////////////////////
console.log("Launching commandfoxWE.js");

var inputArea = document.getElementById("edit-box");
inputArea.addEventListener('keyup', function onkeyup(event) {
    if (event.keyCode == 13) {
        // Remove the newline.
        var text = inputArea.value.replace(/(\r\n|\n|\r)/gm,"");
        text = text.trim();
        console.log(`Send message to background script: ${text}`);
        var toBackgroundScript = browser.runtime.connect({name: "commandfoxWESendEditBox"});
        toBackgroundScript.postMessage({command: text});
        toBackgroundScript.onMessage.addListener(function(m) {
            console.log("Text Box processed by background script");
            console.log(m.result);
        });
        inputArea.value = '';
        window.close();
    }
}, false);

// Trick to make sure the textarea has the focus, for now the
// auto-focus doesn't yet work reliably, so this is a measure to
// address it
setTimeout(() => {
    inputArea.focus();
}, 100);

setTimeout(() => {
    inputArea.focus();
}, 200);
