<commit_before><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
"use strict";

var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}};

function clearStatus() {
    showStatus("");
}

/**
* Displays the given status message in the sidebar.
*
* @param {String} msg The status message to display.
* @param {String} classId The message type (class id) that the message
*   should be displayed as.
*/
function showStatus(msg, classId) {
    var $status = $('#sb-status');

    $status.removeClass().html(msg);
    if (classId) {
        $status.addClass(classId);
    }
}

function isEmpty(v) {
    return v === undefined || v === null || (v.hasOwnProperty('length') && v.length === 0);
}
function isAllSet() {
    var args = Array.prototype.slice.call(arguments);
    return args.every(function(i) { return (!isEmpty(i)); } );
}

function onLiveClick() {

    // Gather any information that needs to be sent to the server here.
    var uri = $('#sb-uri').val(),
        usr = $('#sb-usr').val(),
        pwd = $('#sb-pwd').val(),
        keep = $('#sb-keep').is(':checked'),
        headers = {};


    if (!isAllSet(uri)) {
        showStatus("please enter uri to load");
        return;
    }
    if (isAllSet(usr, pwd)) {
        headers.Authorization = "Basic " + Base64.encode(usr + ":" + pwd);
    }

    clearStatus();
    this.disabled = true;
    // Send the value to the server and handle the response.
    google.script.run
        .withSuccessHandler(
            function(msg, element) {
                // Respond to success conditions here.
                showStatus('load & merge: ' + msg, 'succes');
                element.disabled = false;
            })
        .withFailureHandler(
            function(msg, element) {
                // Respond to failure conditions here.
                showStatus(msg, 'error');
                element.disabled = false;
            })
        .withUserObject(this)
        .mergeFromURI(uri, headers, keep);
  }

function onManuClick() {

    // Gather any information that needs to be sent to the server here.
    var json = $('#sb-json').val();
    if (json === undefined || json === null || json.length === 0) {
        showStatus("please enter json to load");
        return;
    }

    clearStatus();
    this.disabled = true;
    // Send the value to the server and handle the response.
    google.script.run
        .withSuccessHandler(
            function(msg, element) {
                // Respond to success conditions here.
                showStatus('send & merge: ' + msg, 'succes');
                element.disabled = false;
            })
        .withFailureHandler(
            function(msg, element) {
                // Respond to failure conditions here.
                showStatus(msg, 'error');
                element.disabled = false;
            })
        .withUserObject(this)
        .mergeFromJSON(json);
}


function showControlled($pnl, $ctrl) {
    function updateView() {
        var doShow = $ctrl.is(':checked');
        if (doShow) {
            $pnl.show();
        } else {
            $pnl.hide();
        }
    }

    $ctrl.change(updateView);
    updateView();
}


/**
 * Run initializations on sidebar load.
 */
$(function() {
    $('#sb-btn-live').click(onLiveClick);
    $('#sb-btn-manu').click(onManuClick);

    showControlled($('#sb-opt-link'), $('#sb-chk-live'));
    showControlled($('#sb-opt-manu'), $('#sb-chk-manu'));
});
</script><commit_msg>some refactoring, styling and linting<commit_after><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
"use strict";

var Base64 = {
        _keyStr: "<KEY>
        encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},
        decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}
    };

/**
* Displays the given status message in the sidebar.
*
* @param {String} msg The status message to display.
* @param {String} classId The message type (class id) that the message
*   should be displayed as.
*/
function showStatus(msg, classId) {
    var $status = $('#sb-status');

    $status.removeClass().html(msg);
    if (classId) {
        $status.addClass(classId);
    }
}

function isEmpty(v) {
    return v === undefined || v === null || (v.hasOwnProperty('length') && v.length === 0);
}
function isAllSet() {
    var args = Array.prototype.slice.call(arguments);
    return args.every(function (i) { return (!isEmpty(i));} );
}

function clearStatus() {
    showStatus("");
}

function callStart(element) {
    showStatus("remote call started...");
    element.disabled = true;
}

function callReturn(pfx, cls) {
    cls = cls || 'success';
    pfx = pfx || '';
    return function (msg, element) {
        clearStatus();
        if (cls === 'success') {
            msg = msg + JSON.stringify(msg, undefined, 4);
        }
        showStatus(pfx + msg, cls);
        element.disabled = false;
    };
}

function callFailure(pfx) {
    return callReturn(pfx, 'error');
}

function onLiveClick() {

    // Gather any information that needs to be sent to the server here.
    var uri = $('#sb-uri').val(),
        usr = $('#sb-usr').val(),
        pwd = $('#sb-pwd').val(),
        keep = $('#sb-keep').is(':checked'),
        headers = {};

    if (!isAllSet(uri)) {
        showStatus("please enter uri to load");
        return;
    }
    if (isAllSet(usr, pwd)) {
        headers.Authorization = "Basic " + Base64.encode(usr + ":" + pwd);
    }

    callStart(this);
    // Send the value to the server and handle the response.
    google.script.run
        .withSuccessHandler(callReturn('load & merge: '))
        .withFailureHandler(callFailure())
        .withUserObject(this)
        .mergeFromURI(uri, headers, keep);
}

function onManuClick() {

    // Gather any information that needs to be sent to the server here.
    var json = $('#sb-json').val();
    if (json === undefined || json === null || json.length === 0) {
        showStatus("please enter json to load");
        return;
    }

    callStart(this);
    // Send the value to the server and handle the response.
    google.script.run
        .withSuccessHandler(callReturn('send & merge: '))
        .withFailureHandler(callFailure())
        .withUserObject(this)
        .mergeFromJSON(json);
}

function showControlled($pnl, $ctrl) {
    function updateView() {
        var doShow = $ctrl.is(':checked');
        if (doShow) {
            $pnl.show();
        } else {
            $pnl.hide();
        }
    }

    $ctrl.change(updateView);
    updateView();
}


/**
 * Run initializations on sidebar load.
 */
$(function () {
    $('#sb-btn-live').click(onLiveClick);
    $('#sb-btn-manu').click(onManuClick);

    showControlled($('#sb-opt-link'), $('#sb-chk-live'));
    showControlled($('#sb-opt-manu'), $('#sb-chk-manu'));
});
</script>
{'fraction_non_alphanumeric': 0.20867069796043866, 'fraction_numerical': 0.02593010146561443, 'mean_word_length': 3.484375, 'pattern_counts': {'":': 2, '<': 60, '<?xml version=': 0, '>': 48, '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': '6188628', 'n_tokens_mistral': 3707, 'n_tokens_neox': 3564, 'n_words': 542}