<commit_before>const {
    ipcRenderer
} = require('electron');
const {success,warning,rgb2hex} = require('../custom_modules/utils.js');
const Binder = require('../classes/binder.js');
const SystemFontManager = require('system-font-families').default;
const fonts = new SystemFontManager().getFontsSync();
var fragment = document.createDocumentFragment();
var ipcRendererBinder = new Binder(ipcRenderer,{
    'receive-selected-image':(event,data)=>{
        $("body").css({background:`url(${data}) no-repeat center center fixed`,"background-size":"cover"})
    }
});
$(document).ready(function() {
    var fontList = document.getElementById('font-list');
    var cellFontSizeSlider = document.getElementById('cell-font-size');
    //Check if there are any user preferences to load
    let userPrefs = JSON.parse(localStorage.getItem('ui-preferences'));
    //First create the select box
    fonts.forEach(f => {
        let option = document.createElement('option');
        option.innerText = f;
        fragment.appendChild(option);
    });
    fontList.appendChild(fragment);
    //Now you can check for preferences and select  saved font from font-list
    if(userPrefs){
        //Good 
        //Loaded user preferences.Now apply them
        let tableCellSize = userPrefs['table-cell-size'] || 14;
        let textColor = userPrefs['color'];
        let fontName = userPrefs['font-family'];
        let fontIndex = fonts.indexOf(fontName);
        if(fontIndex != -1){
            fontList[fontIndex].selected = true;
        }
        cellFontSizeSlider.value = tableCellSize;
        $("html,body").css(userPrefs);
        $("table").css("font-size",`${tableCellSize}px`);
        //Use only hex colors
        $("#color-selection").val(rgb2hex(textColor));
    }
    $("#select-bg").on("click",function(){
        ipcRenderer.send('show-open-dialog')
    });
    $(fontList).on("change",function(){
        let font = $(this).val();
        $("html,body").css("font-family", font);
    });
    $(cellFontSizeSlider).on('mousemove input',function(){
        let size = `${$(this).val()}px`;
        $("td").css('font-size',size);
    });
    $("#color-selection").on("input",function(){
        let c = $(this).val();
        $("html,body").css("color",c)
    });
    $("#apply").on("click",function(){
        let cssData = {
            background:$("body").css("background"),
            "background-size":"cover",
            "font-family":$("body,html").css("font-family"),
            "color":$("body,html").css("color"),
            "table-cell-size":$(cellFontSizeSlider).val()
        };
        ipcRenderer.send('apply-ui-settings',cssData);
        //Let's save our css properties to localStorage
        localStorage.setItem('ui-preferences',JSON.stringify(cssData));
        success('User preferences have been saved');
    });
    $("#delete-settings").on("click",function(){
        confirm({
            message:'Are you sure you want to clear your ui preferences?',
            callback:(answer)=>{
                if(answer){
                    localStorage.removeItem('ui-preferences');
                    success('UI preferences cleared.Please restart application');
                }
            }
        });
    });
})<commit_msg>JSformatted<commit_after>const {
    ipcRenderer
} = require('electron');
const {
    success,
    warning,
    rgb2hex
} = require('../custom_modules/utils.js');
const Binder = require('../classes/binder.js');
const SystemFontManager = require('system-font-families').default;
const fonts = new SystemFontManager().getFontsSync();
var fragment = document.createDocumentFragment();
var ipcRendererBinder = new Binder(ipcRenderer, {
    'receive-selected-image': (event, data) => {
        $("body").css({
            background: `url(${data}) no-repeat center center fixed`,
            "background-size": "cover"
        })
    }
});
$(document).ready(function() {
    var fontList = document.getElementById('font-list');
    var cellFontSizeSlider = document.getElementById('cell-font-size');
    //Check if there are any user preferences to load
    let userPrefs = JSON.parse(localStorage.getItem('ui-preferences'));
    //First create the select box
    fonts.forEach(f => {
        let option = document.createElement('option');
        option.innerText = f;
        fragment.appendChild(option);
    });
    fontList.appendChild(fragment);
    //Now you can check for preferences and select  saved font from font-list
    if (userPrefs) {
        //Good 
        //Loaded user preferences.Now apply them
        let tableCellSize = userPrefs['table-cell-size'] || 14;
        let textColor = userPrefs['color'];
        let fontName = userPrefs['font-family'];
        let fontIndex = fonts.indexOf(fontName);
        if (fontIndex != -1) {
            fontList[fontIndex].selected = true;
        }
        cellFontSizeSlider.value = tableCellSize;
        $("html,body").css(userPrefs);
        $("table").css("font-size", `${tableCellSize}px`);
        //Use only hex colors
        $("#color-selection").val(rgb2hex(textColor));
    }
    $("#select-bg").on("click", function() {
        ipcRenderer.send('show-open-dialog')
    });
    $(fontList).on("change", function() {
        let font = $(this).val();
        $("html,body").css("font-family", font);
    });
    $(cellFontSizeSlider).on('mousemove input', function() {
        let size = `${$(this).val()}px`;
        $("td").css('font-size', size);
    });
    $("#color-selection").on("input", function() {
        let c = $(this).val();
        $("html,body").css("color", c)
    });
    $("#apply").on("click", function() {
        let cssData = {
            background: $("body").css("background"),
            "background-size": "cover",
            "font-family": $("body,html").css("font-family"),
            "color": $("body,html").css("color"),
            "table-cell-size": $(cellFontSizeSlider).val()
        };
        ipcRenderer.send('apply-ui-settings', cssData);
        //Let's save our css properties to localStorage
        localStorage.setItem('ui-preferences', JSON.stringify(cssData));
        success('User preferences have been saved');
    });
    $("#delete-settings").on("click", function() {
        confirm({
            message: 'Are you sure you want to clear your ui preferences?',
            callback: (answer) => {
                if (answer) {
                    localStorage.removeItem('ui-preferences');
                    success('UI preferences cleared.Please restart application');
                }
            }
        });
    });
})
{'fraction_non_alphanumeric': 0.17261185006045948, 'fraction_numerical': 0.0015114873035066505, 'mean_word_length': 2.678154530294608, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 9, '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': '4304951', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1840, 'n_words': 363}