<commit_before>const { electron } = require('electron');
window.$ = window.jQuery = require('./libs/jquery');

let viewParams = {
    zoomLevel: 1,
    topOffset: 0,
    leftOffset: 0
};
let zoomStep = 0.2;
let offsetStep = 2;
let saves = {};

// Keys affecting zoom level and panning the view
let zoomInCodes = [43, 9]; // + and ctrl+i
let zoomOutCodes = [45, 15]; // - and /ctrl+o
let W = 119;
let S = 115;
let A = 97;
let D = 100;

let mainContainer = $('#MAIN');
$(document).ready(function () {
    mainContainer = $('#MAIN');
    let slidesRoot = $('#slides');
    slidesLoader.init(slidesRoot, () => {
        setTimeout(() => {
            $('#step-1').click();
            Prism.highlightAll();
        }, 1000);
        slidesRoot.jmpress({
            viewPort: {
                maxScale: 1,
                zoomable: 10
            }
        });
    });


    window.addEventListener('keypress', (event) => {
        console.log(event.keyCode);
        if (zoomInCodes.indexOf(event.keyCode) > -1) {
            viewParams.zoomLevel += zoomStep;
            let el = require('electron');
            require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);

        } else if (zoomOutCodes.indexOf(event.keyCode) > -1) {
            viewParams.zoomLevel -= zoomStep;
            require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);

        } else if (event.keyCode === W) {
            viewParams.topOffset -= offsetStep;
            mainContainer.css('top', viewParams.topOffset + '%');

        } else if (event.keyCode === S) {
            viewParams.topOffset += offsetStep;
            mainContainer.css('top', viewParams.topOffset + '%');

        } else if (event.keyCode === A) {
            viewParams.leftOffset -= offsetStep;
            mainContainer.css('left', viewParams.leftOffset + '%');

        } else if (event.keyCode === D) {
            viewParams.leftOffset += offsetStep;
            mainContainer.css('left', viewParams.leftOffset + '%');

        // ctrl + digit from 1 to 9 save current view settings
        } else if (event.keyCode >= 17 && event.keyCode <= 25) {
            saveView(event.keyCode - 16);

        // digit from 1 to 9 loads saved view settings
        } else if (event.keyCode >= 49 && event.keyCode <= 57) {
            loadView(event.keyCode - 48);
        }


    })
});

let saveView = function (saveId) {
    saves[saveId] = JSON.stringify(viewParams);
};

let loadView = function (saveId) {
    if (saves[saveId]) {
        viewParams = JSON.parse(saves[saveId]);
        require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);
        mainContainer.css('top', viewParams.topOffset + '%');
        mainContainer.css('left', viewParams.leftOffset + '%');
    }
};

let slidesLoader = {<commit_msg>Reverting panning directions and switching browser zoom to scaling<commit_after>const { electron } = require('electron');
window.$ = window.jQuery = require('./libs/jquery');

let viewParams = {
    zoomLevel: 1,
    topOffset: 0,
    leftOffset: 0
};
let zoomStep = 0.2;
let offsetStep = 2;
let saves = {};

// Keys affecting zoom level and panning the view
let zoomInCodes = [43, 9]; // + and ctrl+i
let zoomOutCodes = [45, 15]; // - and /ctrl+o
let W = 119;
let S = 115;
let A = 97;
let D = 100;

let mainContainer = $('#MAIN');
$(document).ready(function () {
    mainContainer = $('#MAIN');
    let slidesRoot = $('#slides');
    slidesLoader.init(slidesRoot, () => {
        setTimeout(() => {
            $('#step-1').click();
            Prism.highlightAll();
        }, 1000);
        slidesRoot.jmpress({
            viewPort: {
                maxScale: 1,
                zoomable: 10
            }
        });
    });


    window.addEventListener('keypress', (event) => {
        console.log(event.keyCode);
        if (zoomInCodes.indexOf(event.keyCode) > -1) {
            viewParams.zoomLevel += zoomStep;
            // require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);
            mainContainer.css('transform', 'scale(' + viewParams.zoomLevel + ')');

        } else if (zoomOutCodes.indexOf(event.keyCode) > -1) {
            viewParams.zoomLevel -= zoomStep;
            // require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);
            mainContainer.css('transform', 'scale(' + viewParams.zoomLevel + ')');

        } else if (event.keyCode === W) {
            viewParams.topOffset += offsetStep;
            mainContainer.css('top', viewParams.topOffset + '%');

        } else if (event.keyCode === S) {
            viewParams.topOffset -= offsetStep;
            mainContainer.css('top', viewParams.topOffset + '%');

        } else if (event.keyCode === A) {
            viewParams.leftOffset += offsetStep;
            mainContainer.css('left', viewParams.leftOffset + '%');

        } else if (event.keyCode === D) {
            viewParams.leftOffset -= offsetStep;
            mainContainer.css('left', viewParams.leftOffset + '%');

        // ctrl + digit from 1 to 9 save current view settings
        } else if (event.keyCode >= 17 && event.keyCode <= 25) {
            saveView(event.keyCode - 16);

        // digit from 1 to 9 loads saved view settings
        } else if (event.keyCode >= 49 && event.keyCode <= 57) {
            loadView(event.keyCode - 48);
        }


    })
});

let saveView = function (saveId) {
    saves[saveId] = JSON.stringify(viewParams);
};

let loadView = function (saveId) {
    if (saves[saveId]) {
        viewParams = JSON.parse(saves[saveId]);
        // require('electron').webFrame.setZoomFactor(viewParams.zoomLevel);
        mainContainer.css('transform', 'scale(' + viewParams.zoomLevel + ')');
        mainContainer.css('top', viewParams.topOffset + '%');
        mainContainer.css('left', viewParams.leftOffset + '%');
    }
};

let slidesLoader = {
{'fraction_non_alphanumeric': 0.15439795046968402, 'fraction_numerical': 0.017079419299743808, 'mean_word_length': 2.338654503990878, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6360252', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1692, 'n_words': 376}