<commit_before>$(document).ready(function() {
    applyTranslations();
    var opt;
    chrome.storage.sync.get('chromeboardPrefs', function (obj) {
        opt = obj.chromeboardPrefs.urlCol;
        
        if (opt.length > 0 && opt != "") {
            for (var i = 0; i < opt.length; i++) {
                $("#site-collection").append("<iframe id=\"site-" + (i + 1) + "\" src=\"" + opt[i] + "\"></iframe>");
            }
        } else {
            $("#site-collection").append("<iframe id=\"site-1\" src=\"blankingpage.html\" class=\"active\"></iframe>");
        }

        slide(10, opt.length, -1, obj.chromeboardPrefs.transitionTime);
    });
      
});

// -- Settings button and background handlers --
$("#settclick").click(function(event) {
    toggleSettingsFrame(event);
});

$(".settings-modal-close-shadow").click(function(event) {
    toggleSettingsFrame(event);
});
// -- End of settings button and background handlers --

// -- Lockstate handlers --
$("#setlockstate").click(function(event) {
    event.preventDefault();
    $('#sb-unlocked').addClass('hidden');
    $('#sb-locked').removeClass('hidden');
    //window.alert("TODO");
});

$("#setunlockstate").click(function(event) {
    event.preventDefault();
    $('#sb-unlocked').removeClass('hidden');
    $('#sb-locked').addClass('hidden');
    //window.alert("TODO");
});

$(document).on({
    "contextmenu": function(e) {
        if($('#sb-unlocked').hasClass('hidden')) {
            e.preventDefault();
        }
    }
});

// --  End of lockstate handlers --

function toggleSettingsFrame(event) {
    event.preventDefault();
    if( $('.settings-modal').hasClass('active') ) {
        $('.settings-modal-close-shadow').removeClass('active');
        $('.settings-modal').removeClass('active');
        window.location.reload();
    } else {
        $('.settings-modal-close-shadow').addClass('active');
        $('.settings-modal').addClass('active');
    }
}

function applyTranslations() {
    var tsl = chrome.i18n;
    document.title = tsl.getMessage("appName");
    document.getElementById("settclick").setAttribute('aria-label', tsl.getMessage("rSettings"));
    document.getElementById("settclick").title = tsl.getMessage("rSettings");

    document.getElementById("setlockstate").setAttribute('aria-label', tsl.getMessage("rScreenUnlocked"));
    document.getElementById("setlockstate").title = tsl.getMessage("rScreenUnlocked");
    document.getElementById("setunlockstate").setAttribute('aria-label', tsl.getMessage("rScreenLocked"));
    document.getElementById("setunlockstate").title = tsl.getMessage("rScreenLocked");
}

function slide(repeats, count, current, duration) {
    nextActive = current + 1;
    if (nextActive > (count -1)) {
        nextActive = 0;
    }

    if (duration < 1) {
        duration = 1;
    }

    if (repeats > 0) {
        for (var i = 0; i < count; i++) {    	
            $('#site-'+(i + 1)).removeClass('active');<commit_msg>Made lock state code re-usable.<commit_after>$(document).ready(function() {
    applyTranslations();
    var opt;
    chrome.storage.sync.get('chromeboardPrefs', function (obj) {
        opt = obj.chromeboardPrefs.urlCol;
        
        if (opt.length > 0 && opt != "") {
            for (var i = 0; i < opt.length; i++) {
                $("#site-collection").append("<iframe id=\"site-" + (i + 1) + "\" src=\"" + opt[i] + "\"></iframe>");
            }
        } else {
            $("#site-collection").append("<iframe id=\"site-1\" src=\"blankingpage.html\" class=\"active\"></iframe>");
        }

        slide(10, opt.length, -1, obj.chromeboardPrefs.transitionTime);
    });
      
});

// -- Settings button and background handlers --
$("#settclick").click(function(event) {
    toggleSettingsFrame(event);
});

$(".settings-modal-close-shadow").click(function(event) {
    toggleSettingsFrame(event);
});
// -- End of settings button and background handlers --

// -- Lockstate handlers --
$("#setlockstate").click(function(event) {
    toggleLockstate(event);
});

$("#setunlockstate").click(function(event) {
    toggleLockstate(event);
});

$(document).on({
    "contextmenu": function(e) {
        if($('#sb-unlocked').hasClass('hidden')) {
            e.preventDefault();
        }
    }
});

// --  End of lockstate handlers --

function toggleSettingsFrame(event) {
    event.preventDefault();
    if( $('.settings-modal').hasClass('active') ) {
        $('.settings-modal-close-shadow').removeClass('active');
        $('.settings-modal').removeClass('active');
        window.location.reload();
    } else {
        $('.settings-modal-close-shadow').addClass('active');
        $('.settings-modal').addClass('active');
    }
}

function toggleLockstate(event) {
    event.preventDefault();
    if( $('#sb-unlocked').hasClass('hidden') ) {
        $('#sb-unlocked').removeClass('hidden');
        $('#sb-locked').addClass('hidden');
    } else {
        $('#sb-unlocked').addClass('hidden');
        $('#sb-locked').removeClass('hidden');
    }
}

function applyTranslations() {
    var tsl = chrome.i18n;
    document.title = tsl.getMessage("appName");
    document.getElementById("settclick").setAttribute('aria-label', tsl.getMessage("rSettings"));
    document.getElementById("settclick").title = tsl.getMessage("rSettings");

    document.getElementById("setlockstate").setAttribute('aria-label', tsl.getMessage("rScreenUnlocked"));
    document.getElementById("setlockstate").title = tsl.getMessage("rScreenUnlocked");
    document.getElementById("setunlockstate").setAttribute('aria-label', tsl.getMessage("rScreenLocked"));
    document.getElementById("setunlockstate").title = tsl.getMessage("rScreenLocked");
}

function slide(repeats, count, current, duration) {
    nextActive = current + 1;
    if (nextActive > (count -1)) {
        nextActive = 0;
    }

    if (duration < 1) {
        duration = 1;
    }

    if (repeats > 0) {
        for (var i = 0; i < count; i++) {    	
            $('#site-'+(i + 1)).removeClass('active');
{'fraction_non_alphanumeric': 0.20056450273949858, 'fraction_numerical': 0.005645027394985887, 'mean_word_length': 3.126027397260274, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, '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': '5124466', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1784, 'n_words': 275}