{"size": 1345, "ext": "js", "max_stars_repo_path": "html/listener.js", "max_stars_repo_name": "H0ppp/hop_licenseplates", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "html/listener.js", "max_issues_repo_name": "H0ppp/hop_licenseplates", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "html/listener.js", "max_forks_repo_name": "H0ppp/hop_licenseplates", "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": 25.8653846154, "max_line_length": 62, "alphanum_fraction": 0.5026022305}

$(function() {
    var $container = $("#container");
    var $oldPlate = $("#oldPlate");
    var $newPlate = $("#newPlate");
    var $btn = $("#btn");
    $container.hide();


	window.addEventListener('message', function(event){
		var item = event.data;

		if (item.type === "show") {
            $container.show();
            $oldPlate.val(item.currentPlate);
            $btn.html("Purchase ($"+item.price+")");
	    } else if (item.type === "valid") {
            Close();
	    } else if (item.type === "notValid") {
            $newPlate.val("");
	    }
    }); 
});

function Submitted() {
    var $newPlate = $("#newPlate");
    fetch(`https://${GetParentResourceName()}/plateRequest`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json; charset=UTF-8',
        },
        body: JSON.stringify({
            itemId: $newPlate.val()
        })
    }).then(resp => resp.json());
}

function Close() {
    var $container = $("#container");
    var $newPlate = $("#newPlate");
    $container.hide();
    $newPlate.val("");
    fetch(`https://${GetParentResourceName()}/close`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json; charset=UTF-8',
        },
        body: JSON.stringify({
            itemId: 'close'
        })
    }).then(resp => resp.json());
}