<commit_before>/* $Id$ */

HTTP = Class.create(Ajax.Request, {
  request: function(url) {
    this.url = url;
    this.method = this.options.method;
    var params = Object.isString(this.options.parameters) ?
          this.options.parameters :
          Object.toQueryString(this.options.parameters);

    if (params) {
      if (this.method == 'get')
        this.url += (this.url.include('?') ? '&' : '?') + params;
      else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
        params += '&_=';
    }

    this.parameters = params.toQueryParams();

    try {
      var response = new Ajax.Response(this);
      if (this.options.onCreate) this.options.onCreate(response);
      Ajax.Responders.dispatch('onCreate', this, response);

      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);

      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);

      this.transport.onreadystatechange = this.onStateChange.bind(this);
      this.setRequestHeaders();

      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
      this.body = this.body || this.options.body || '';
      this.transport.send(this.body);

      /* Force Firefox to handle ready state 4 for synchronous requests */
      if (!this.options.asynchronous && this.transport.overrideMimeType)
        this.onStateChange();

    }
    catch (e) {
      this.dispatchException(e);
    }
  }
});

dirname = function(path) {
    return path.replace(/\\/g, '/').replace(/\/[^\/]*\/?$/, '');
}

basename = function(path) {
    if (path.substring(path.length - 1) == '/')
        path = path.substring(0, path.length - 1);

    var a = path.split('/');
    return a[a.length - 1];
//    return path.replace(/\\/g,'/').replace( /.*\//, '' );
}

newJS = function(url, callback){
    var script = document.createElement("script")
    script.async = true;
    script.type = "text/javascript";
    script.src = url;
    if (callback) {
        if (script.readyState) { // IE
            script.onreadystatechange = function() {
                if (script.readyState == "loaded" || script.readyState == "complete") {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else { // others
            script.onload = function() {
                callback();
            };
        }
    }
    return script;
}

/** Cookies **/
function setCookie(name,value,days) {
    console.log('name='+name+' | val='+value+' | days='+days);
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
    // reload
    window.location.reload(true);
}

function readCookie(name) {
    var nameEQ = name+"=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function deleteCookie(name) {
    setCookie(name,"",-1);
}

/** Web ACLs **/
wac = {};
wac.get = function(request_path, path) {
    // remove trailing / from the file name we append after .meta
    var requestPath = request_path+path;
     
    var File = path;
    if (path.substring(path.length - 1) == '/')
        File = path.substring(0, path.length - 1);
  
    var metaBase = window.location.protocol+'//'+window.location.host+window.location.pathname;

    // if the resource in question is not the .meta file itself
    if (File.substr(0, 5) != '.meta') {
        if (File == '..') { // we need to use the parent dir name
            path = basename(window.location.pathname);
            var metaBase = window.location.protocol+'//'+window.location.host+dirname(window.location.pathname)+'/';
            var metaFile = '.meta.'+basename(window.location.pathname);
            var metaURI = metaBase+metaFile;
            var innerRef = window.location.pathname; // the resource as inner ref
            var requestPath = request_path;
            // Remove preceeding / from path
            if (innerRef.substr(0, 1) == '/')
                innerRef = innerRef.substring(1);
            innerRef = metaURI+'#'+innerRef;
        } else if (File == '') {
            path = '/';
            var metaBase = window.location.protocol+'//'+window.location.host+'/';
            var metaFile = '.meta';
            var metaURI = metaBase+metaFile;
            var innerRef = metaBase; // the resource as inner ref
            var requestPath = request_path;<commit_msg>Loading ACL data should now clear the UI.<commit_after>/* $Id$ */

HTTP = Class.create(Ajax.Request, {
  request: function(url) {
    this.url = url;
    this.method = this.options.method;
    var params = Object.isString(this.options.parameters) ?
          this.options.parameters :
          Object.toQueryString(this.options.parameters);

    if (params) {
      if (this.method == 'get')
        this.url += (this.url.include('?') ? '&' : '?') + params;
      else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
        params += '&_=';
    }

    this.parameters = params.toQueryParams();

    try {
      var response = new Ajax.Response(this);
      if (this.options.onCreate) this.options.onCreate(response);
      Ajax.Responders.dispatch('onCreate', this, response);

      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);

      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);

      this.transport.onreadystatechange = this.onStateChange.bind(this);
      this.setRequestHeaders();

      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
      this.body = this.body || this.options.body || '';
      this.transport.send(this.body);

      /* Force Firefox to handle ready state 4 for synchronous requests */
      if (!this.options.asynchronous && this.transport.overrideMimeType)
        this.onStateChange();

    }
    catch (e) {
      this.dispatchException(e);
    }
  }
});

dirname = function(path) {
    return path.replace(/\\/g, '/').replace(/\/[^\/]*\/?$/, '');
}

basename = function(path) {
    if (path.substring(path.length - 1) == '/')
        path = path.substring(0, path.length - 1);

    var a = path.split('/');
    return a[a.length - 1];
//    return path.replace(/\\/g,'/').replace( /.*\//, '' );
}

newJS = function(url, callback){
    var script = document.createElement("script")
    script.async = true;
    script.type = "text/javascript";
    script.src = url;
    if (callback) {
        if (script.readyState) { // IE
            script.onreadystatechange = function() {
                if (script.readyState == "loaded" || script.readyState == "complete") {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else { // others
            script.onload = function() {
                callback();
            };
        }
    }
    return script;
}

/** Cookies **/
function setCookie(name,value,days) {
    console.log('name='+name+' | val='+value+' | days='+days);
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
    // reload
    window.location.reload(true);
}

function readCookie(name) {
    var nameEQ = name+"=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function deleteCookie(name) {
    setCookie(name,"",-1);
}

/** Web ACLs **/
wac = {};
wac.get = function(request_path, path) {
    // reset the checkboxes
    $('wac-read').checked = false;
    $('wac-write').checked = false;
    $('wac-users').value = '';
    
    // remove trailing / from the file name we append after .meta
    var requestPath = request_path+path;
     
    var File = path;
    if (path.substring(path.length - 1) == '/')
        File = path.substring(0, path.length - 1);
  
    var metaBase = window.location.protocol+'//'+window.location.host+window.location.pathname;

    // if the resource in question is not the .meta file itself
    if (File.substr(0, 5) != '.meta') {
        if (File == '..') { // we need to use the parent dir name
            path = basename(window.location.pathname);
            var metaBase = window.location.protocol+'//'+window.location.host+dirname(window.location.pathname)+'/';
            var metaFile = '.meta.'+basename(window.location.pathname);
            var metaURI = metaBase+metaFile;
            var innerRef = window.location.pathname; // the resource as inner ref
            var requestPath = request_path;
            // Remove preceeding / from path
            if (innerRef.substr(0, 1) == '/')
                innerRef = innerRef.substring(1);
            innerRef = metaURI+'#'+innerRef;
        } else if (File == '') {
            path = '/';
            var metaBase = window.location.protocol+'//'+window.location.host+'/';
            var metaFile = '.meta';
            var metaURI = metaBase+metaFile;
            var innerRef = metaBase; // the resource as inner ref
            var requestPath = request_path;
{'fraction_non_alphanumeric': 0.16355188435725349, 'fraction_numerical': 0.005988642230252968, 'mean_word_length': 2.2845032214309935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3840007', 'n_tokens_mistral': 3034, 'n_tokens_neox': 2945, 'n_words': 610}