{"size": 1006, "ext": "js", "max_stars_repo_path": "script/script.js", "max_stars_repo_name": "Lin-H/Chrome-dictionary", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "script/script.js", "max_issues_repo_name": "Lin-H/Chrome-dictionary", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "script/script.js", "max_forks_repo_name": "Lin-H/Chrome-dictionary", "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": 30.4848484848, "max_line_length": 129, "alphanum_fraction": 0.6242544732}
$('body').append($.create('audio', {id: '_audio'}));

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    switch (request.type) {
        case 'playsound':
            playSound(request);
            return false;
        case 'iciba':
            iciba(request, sender, sendResponse); return true;
        default:
            return false;
    }
    return true;
});

function iciba(request, sender, sendResponse) {
    $.fetch('http://fy.iciba.com/ajax.php?a=fy&w=' + request.word).then(function(res) {
        sendResponse(JSON.parse(res.responseText));
    }).catch(function(err) {});;
}

function merriam(request, sender, sendResponse) {
    $.fetch('http://www.dictionaryapi.com/api/v1/references/collegiate/xml/' + request.word + '?key=APIKEY').then(function(res) {
        sendResponse(JSON.parse(res.responseText));
    }).catch(function(err) {});
}

function playSound(request) {
    var audio = $('#_audio');
    audio.src = request.audioSrc;
    audio.play();
}
