<commit_before>var options = document.getElementsByClassName('button');

for (var i = 0; i < options.length; i++) {
    options[i].onclick = function (e) {
        alert(e);
    }
}

var sounds = document.getElementsByName('sound'),
    notify = document.getElementsByName('notify'),
    loop = document.getElementsByName('loop'),
    reset = document.getElementById('reset'),
    minutes = [1,2,5,10,20,30];

checkStorage(sounds,'sound');
checkStorage(notify,'notify');
checkLoop();
configButton(sounds,'sound');
configButton(notify,'notify');

for (var i = 0; i < loop.length; i++) {
    configLoop(loop[i],minutes[i]);
}

reset.onclick = mythReset;

function checkStorage(element, storage){
    if(localStorage[storage]){
        element[0].className = "pressed";
    }else{
        element[1].className = "pressed";
    }
}

function configLoop(element, min){
    element.onclick = function(){
        this.className = "pressed";
        localStorage.setItem('interval',min);
        chrome.alarms.clearAll();
        chrome.alarms.create("mainLoop", {delayInMinutes: 0.3,periodInMinutes: min});
        for (var i = 0; i < loop.length; i++) {
            if(loop[i].innerHTML !== min+" min"){
                loop[i].className = '';
            }
        }
    }
}

function checkLoop(){
    var loopMin = parseInt(localStorage.interval);
    if(loopMin == 1){
        loop[0].className = "pressed";
    }else if(loopMin == 2){
        loop[1].className = "pressed";
    }else if(loopMin == 5){
        loop[2].className = "pressed";
    }else if(loopMin == 10){
        loop[3].className = "pressed";
    }else if(loopMin == 20){
        loop[4].className = "pressed";
    }else if(loopMin == 30){
        loop[5].className = "pressed";
    }
}

function configButton(element,storage){
    element[0].onclick = function(){
        localStorage.setItem(storage,true);
        this.className = "pressed";
        element[1].className = '';
    };
    element[1].onclick = function(){
        localStorage.removeItem(storage);
        this.className = "pressed";
        element[0].className = '';
    };
}

function mythReset(){
    localStorage.clear();
    localStorage.setItem('persist',true);
    localStorage.setItem('sound',true);
    localStorage.setItem('notify',true);
    localStorage.setItem('interval',1);
    window.location.reload();
}
<commit_msg>Fix reset alarms on restore default configs<commit_after>var options = document.getElementsByClassName('button');

for (var i = 0; i < options.length; i++) {
    options[i].onclick = function (e) {
        alert(e);
    }
}

var sounds = document.getElementsByName('sound'),
    notify = document.getElementsByName('notify'),
    loop = document.getElementsByName('loop'),
    reset = document.getElementById('reset'),
    minutes = [1,2,5,10,20,30];

checkStorage(sounds,'sound');
checkStorage(notify,'notify');
checkLoop();
configButton(sounds,'sound');
configButton(notify,'notify');

for (var i = 0; i < loop.length; i++) {
    configLoop(loop[i],minutes[i]);
}

reset.onclick = mythReset;

function checkStorage(element, storage){
    if(localStorage[storage]){
        element[0].className = "pressed";
    }else{
        element[1].className = "pressed";
    }
}

function configLoop(element, min){
    element.onclick = function(){
        this.className = "pressed";
        localStorage.setItem('interval',min);
        chrome.alarms.clearAll();
        chrome.alarms.create("mainLoop", {delayInMinutes: 0.3,periodInMinutes: min});
        for (var i = 0; i < loop.length; i++) {
            if(loop[i].innerHTML !== min+" min"){
                loop[i].className = '';
            }
        }
    }
}

function checkLoop(){
    var loopMin = parseInt(localStorage.interval);
    if(loopMin == 1){
        loop[0].className = "pressed";
    }else if(loopMin == 2){
        loop[1].className = "pressed";
    }else if(loopMin == 5){
        loop[2].className = "pressed";
    }else if(loopMin == 10){
        loop[3].className = "pressed";
    }else if(loopMin == 20){
        loop[4].className = "pressed";
    }else if(loopMin == 30){
        loop[5].className = "pressed";
    }
}

function configButton(element,storage){
    element[0].onclick = function(){
        localStorage.setItem(storage,true);
        this.className = "pressed";
        element[1].className = '';
    };
    element[1].onclick = function(){
        localStorage.removeItem(storage);
        this.className = "pressed";
        element[0].className = '';
    };
}

function mythReset(){
    chrome.alarms.clearAll();
    chrome.alarms.create("mainLoop", {delayInMinutes: 0.3,periodInMinutes: 1});
    localStorage.clear();
    localStorage.setItem('persist',true);
    localStorage.setItem('sound',true);
    localStorage.setItem('notify',true);
    localStorage.setItem('interval',1);
    window.location.reload();
}

{'fraction_non_alphanumeric': 0.16892446633825944, 'fraction_numerical': 0.01539408866995074, 'mean_word_length': 3.168520102651839, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5901978', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1488, 'n_words': 269}