<commit_before>(function() {
    var fiddle = null,
        runBtn = document.querySelector('.run'),
        lintBtn = document.querySelector('.lint'),
        saveBtn = document.querySelector('.save'),
        vertBtn = document.querySelector('.vertical'),
        horzBtn = document.querySelector('.horizontal'),
        fiddleWrap = document.querySelector('.fiddle-wrapper'),
        resultWrap = document.querySelector('.result-wrapper'),
        savedLayout = localStorage.getItem('es6fiddleLayout'),
        themeChanger = document.querySelector('.change-theme'),
        iDoc = document.querySelector('.result').contentDocument,
        iHead = iDoc.getElementsByTagName('head')[0],
        babel = document.createElement('script'),
        babelPolyfill = document.createElement('script'),
        logger = document.createElement('script'),
        style = document.createElement('style'),
        lintLog = null,
        userInput = null,
        savedTheme = localStorage.getItem('theme'),
        pathArr = location.pathname.split('/'),
        fiddleId = pathArr[pathArr.length - 2],
        embedded = pathArr[1] === 'embed',
        bootstrap = null;

    //set the global examples object
    window.es6Example = {};
    window.exampleSelector = document.querySelector('.examples');
    window.embedded = embedded;

    //check to see if the share button should be shown
    if (fiddleId && !embedded) {
        var share = document.querySelector('.share'),
            src = document.location.protocol + '//' + document.location.host + '/embed/' + fiddleId + '/',
            iframe = '<iframe width="100%" height="300" frameborder="0" allowfullscreen src="' + src + '"></iframe>';

        if (share) {
            var embed = share.querySelector('#share-embed'),
                link = share.querySelector('#share-link'),
                twitter = share.querySelector('.tweet');

            share.style.display = 'inline-block';
            link.value = document.location.href;
            embed.value = iframe;
            link.onclick = link.select;
            embed.onclick = embed.select;
            twitter.href = 'http://twitter.com/home?status=ES6%20fiddle:%20' + document.location.href;
        }
    }

    //handle the embedded buttons
    if (embedded) {
        var es6Btn = document.querySelector('.es6-click-btn'),
            consoleBtn = document.querySelector('.console-click-btn'),
            editLink = document.querySelector('.edit-at-es6');

        editLink.href = document.location.href.replace('/embed', '');

        es6Btn.onclick = function() {
            document.querySelector('.fiddle').style.display = 'block';
            document.querySelector('.result-wrapper').style.display = 'none';
            es6Btn.className += ' selected';
            consoleBtn.className = consoleBtn.className.replace(' selected', '');
        };

        consoleBtn.onclick = function() {
            document.querySelector('.fiddle').style.display = 'none';
            document.querySelector('.result-wrapper').style.display = 'block';
            es6Btn.className = es6Btn.className.replace(' selected', '');
            consoleBtn.className += ' selected';
        };
    }

    // Change the layout of the page based on the type clicked.
    // Save this layout choice in localStorage
    // By default this will be vertical
    vertBtn.onclick = function() {
        setVerticalStyle();
        saveLayoutOption('vertical');
    }

    horzBtn.onclick = function() {
        setHorizontalStyle();
        saveLayoutOption('horizontal');
    }

    function saveLayoutOption(layoutType) {
        localStorage.setItem('es6fiddleLayout', layoutType);
    }

    function setHorizontalStyle() {
        fiddleWrap.style.width = '100%';
        resultWrap.style.width = '100%';
    }

    function setVerticalStyle() {
        fiddleWrap.style.width = '49%';
        resultWrap.style.width = '49%';
    }

    //add the fiddle area
    fiddle = window.CodeMirror(document.querySelector('.fiddle'), {
        lineNumbers: !embedded,
        readOnly: embedded ? 'nocursor' : false,
        theme: savedTheme || 'default'
    });
    fiddle.focus();


    if (savedLayout === 'horizontal') {
        setHorizontalStyle();
    } else {
        setVerticalStyle();
    }

    // Set the saved theme in the theme changer dropdown
    if (savedTheme) {
        themeChanger.value = savedTheme;
    }

    //add the logger script to the iframe
    logger.innerHTML =
        'window.console.log = (function() {\n' +
        '\tvar escaped = {"&": "&amp;", "<": "&lt;", ">": "&gt;", "\\\"": "&quot;", "\'": "&#39", "/": "&#x2F;"};\n' +
        '\tvar escapeHTML = function(str) {\n' +
        '\t\treturn String(str).replace(/[&<>"\'\/]/g, function (s) {\n' +
        '\t\t\t\treturn escaped[s];\n' +
        '\t\t});\n' +
        '\t};' +
        '\tvar log = console.log;\n' +
        '\treturn function() {\n' +
        '\t\tlog.apply(window.console, arguments);\n' +
        '\t\tdocument.body.innerHTML +=\n' +
        '\t\t\t"<div>" + \n' +
        '\t\t\t\tescapeHTML(Array.prototype.slice.call(arguments).join(" ")) + \n' +
        '\t\t\t"</div>";\n' +
        '\t};\n' +
        '})();\n\n' +
        'window.console.error = (function() {\n' +<commit_msg>Fixed jshitn rules. Forgot to test before commit. Doh!<commit_after>(function() {
    var fiddle = null,
        runBtn = document.querySelector('.run'),
        lintBtn = document.querySelector('.lint'),
        saveBtn = document.querySelector('.save'),
        vertBtn = document.querySelector('.vertical'),
        horzBtn = document.querySelector('.horizontal'),
        fiddleWrap = document.querySelector('.fiddle-wrapper'),
        resultWrap = document.querySelector('.result-wrapper'),
        savedLayout = localStorage.getItem('es6fiddleLayout'),
        themeChanger = document.querySelector('.change-theme'),
        iDoc = document.querySelector('.result').contentDocument,
        iHead = iDoc.getElementsByTagName('head')[0],
        babel = document.createElement('script'),
        babelPolyfill = document.createElement('script'),
        logger = document.createElement('script'),
        style = document.createElement('style'),
        lintLog = null,
        userInput = null,
        savedTheme = localStorage.getItem('theme'),
        pathArr = location.pathname.split('/'),
        fiddleId = pathArr[pathArr.length - 2],
        embedded = pathArr[1] === 'embed',
        bootstrap = null;

    //set the global examples object
    window.es6Example = {};
    window.exampleSelector = document.querySelector('.examples');
    window.embedded = embedded;

    //check to see if the share button should be shown
    if (fiddleId && !embedded) {
        var share = document.querySelector('.share'),
            src = document.location.protocol + '//' + document.location.host + '/embed/' + fiddleId + '/',
            iframe = '<iframe width="100%" height="300" frameborder="0" allowfullscreen src="' + src + '"></iframe>';

        if (share) {
            var embed = share.querySelector('#share-embed'),
                link = share.querySelector('#share-link'),
                twitter = share.querySelector('.tweet');

            share.style.display = 'inline-block';
            link.value = document.location.href;
            embed.value = iframe;
            link.onclick = link.select;
            embed.onclick = embed.select;
            twitter.href = 'http://twitter.com/home?status=ES6%20fiddle:%20' + document.location.href;
        }
    }

    //handle the embedded buttons
    if (embedded) {
        var es6Btn = document.querySelector('.es6-click-btn'),
            consoleBtn = document.querySelector('.console-click-btn'),
            editLink = document.querySelector('.edit-at-es6');

        editLink.href = document.location.href.replace('/embed', '');

        es6Btn.onclick = function() {
            document.querySelector('.fiddle').style.display = 'block';
            document.querySelector('.result-wrapper').style.display = 'none';
            es6Btn.className += ' selected';
            consoleBtn.className = consoleBtn.className.replace(' selected', '');
        };

        consoleBtn.onclick = function() {
            document.querySelector('.fiddle').style.display = 'none';
            document.querySelector('.result-wrapper').style.display = 'block';
            es6Btn.className = es6Btn.className.replace(' selected', '');
            consoleBtn.className += ' selected';
        };
    }

    // Change the layout of the page based on the type clicked.
    // Save this layout choice in localStorage
    // By default this will be vertical
    vertBtn.onclick = function() {
        setVerticalStyle();
        saveLayoutOption('vertical');
    };

    horzBtn.onclick = function() {
        setHorizontalStyle();
        saveLayoutOption('horizontal');
    };

    function saveLayoutOption(layoutType) {
        localStorage.setItem('es6fiddleLayout', layoutType);
    }

    function setHorizontalStyle() {
        fiddleWrap.style.width = '100%';
        resultWrap.style.width = '100%';
    }

    function setVerticalStyle() {
        fiddleWrap.style.width = '49%';
        resultWrap.style.width = '49%';
    }

    //add the fiddle area
    fiddle = window.CodeMirror(document.querySelector('.fiddle'), {
        lineNumbers: !embedded,
        readOnly: embedded ? 'nocursor' : false,
        theme: savedTheme || 'default'
    });
    fiddle.focus();

    if (savedLayout === 'horizontal') {
        setHorizontalStyle();
    } else {
        setVerticalStyle();
    }

    // Set the saved theme in the theme changer dropdown
    if (savedTheme) {
        themeChanger.value = savedTheme;
    }

    //add the logger script to the iframe
    logger.innerHTML =
        'window.console.log = (function() {\n' +
        '\tvar escaped = {"&": "&amp;", "<": "&lt;", ">": "&gt;", "\\\"": "&quot;", "\'": "&#39", "/": "&#x2F;"};\n' +
        '\tvar escapeHTML = function(str) {\n' +
        '\t\treturn String(str).replace(/[&<>"\'\/]/g, function (s) {\n' +
        '\t\t\t\treturn escaped[s];\n' +
        '\t\t});\n' +
        '\t};' +
        '\tvar log = console.log;\n' +
        '\treturn function() {\n' +
        '\t\tlog.apply(window.console, arguments);\n' +
        '\t\tdocument.body.innerHTML +=\n' +
        '\t\t\t"<div>" + \n' +
        '\t\t\t\tescapeHTML(Array.prototype.slice.call(arguments).join(" ")) + \n' +
        '\t\t\t"</div>";\n' +
        '\t};\n' +
        '})();\n\n' +
        'window.console.error = (function() {\n' +
{'fraction_non_alphanumeric': 0.1638125705683101, 'fraction_numerical': 0.007150922092585623, 'mean_word_length': 2.3487712665406426, 'pattern_counts': {'":': 12, '<': 15, '<?xml version=': 0, '>': 15, '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': '1308973', 'n_tokens_mistral': 3059, 'n_tokens_neox': 2949, 'n_words': 574}