{"size": 1840, "ext": "js", "max_stars_repo_path": "src/Scripts/background.js", "max_stars_repo_name": "EranCohenSW/Shift", "max_stars_repo_stars_event_min_datetime": "2021-02-20T17:09:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-20T17:09:33.000Z", "max_issues_repo_path": "src/Scripts/background.js", "max_issues_repo_name": "EranCohenSW/Shift", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Scripts/background.js", "max_forks_repo_name": "EranCohenSW/Shift", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.0588235294, "max_line_length": 132, "alphanum_fraction": 0.6184782609}
chrome.notifications.onButtonClicked.addListener(onButtonClicked);
chrome.runtime.onMessage.addListener(onMessage);
chrome.runtime.onInstalled.addListener(function() {
    chrome.storage.local.set({ 'useCount': 0 });
    chrome.storage.local.set({ 'didRanked': false });
    chrome.storage.local.set({ 'languages': [] });
    chrome.storage.local.set({ 'capitalLetters': [] });
});

function onButtonClicked(notificationId, buttonIndex){
    switch(notificationId){
        case 'Report': 
            handleReportButtons(buttonIndex);
            break;
        case 'Like it?':
            handleLikeItButtons(buttonIndex);
            break;
    }
}

function onMessage({type,data}){
    switch(type){
        case 'notification':
            sendNotification(data);
            break;
    }
}

function sendNotification(options){
    switch(options.title){
        case 'Like it?':
            chrome.notifications.create('Like it?', options);
            break;
        case 'Report':
            chrome.notifications.create('Report', options);
            break;
        default:break;
    }
}

function handleReportButtons(buttonIndex){
    switch(buttonIndex){
        case 0:
            sendEmailReport();
            break;
        case 1: break;
        default: break;
    }
}

function sendEmailReport(){
    let body="";
    window.open('mailto:EranCohenSW@gmail.com?subject=Report&body='+body);
}

function handleLikeItButtons(buttonIndex){
    switch(buttonIndex){
        case 0:
            chrome.tabs.create({ url: "https://chrome.google.com/webstore/detail/shift/pdfkiaeohjkkcbgckkehnkcdjdnjifjm/reviews" });
            break;
        case 1:
            chrome.tabs.create({ url: "https://chrome.google.com/webstore/detail/shift/pdfkiaeohjkkcbgckkehnkcdjdnjifjm" }); 
        break;
        default: break;
    }
}

