<commit_before>/* set the proper URLs for the admin GUI */
var protocol= "file:";
if (document.location.protocol != null && document.location.protocol != "")
   protocol = document.location.protocol

var port    = "";
if (document.location.port != null && document.location.port != "")
   port = ":" + document.location.port

var href    = protocol + "//" + document.location.hostname + port; 
var mod     = "http://monetdb.cwi.nl/XQuery/admin/";
var modurl  = href + "/admin/admin.xq";
var posturl = href + "/xrpc/admin";

function myXRPC(method,arity,call,callback) {
    XRPC(posturl,mod,modurl,method,arity,call,callback);
}

/**********************************************************************
          Callback functions of the admin functions in admin.xq
***********************************************************************/

function doCollectionsCallback(response) {
    var cols = response.getElementsByTagName("collection");
    var cTable = top.content.document.getElementById("div1");
    var cTableBody = "";

    if(cols.length == 0){
        cTable.innerHTML = '<h3>No (documents) collections in the database</h3>\n';
        return;
    }

    var i;
    for(i = 0; i < cols.length; i++){
        var colName = cols[i].firstChild.nodeValue;
        var updatable = cols[i].getAttribute("updatable");
        var size = cols[i].getAttribute("size");
        var numDocs = cols[i].getAttribute("numDocs");

        if(updatable == null) updatable = "UNKNOWN";
        if(size == null) size = "UNKNOWN";
        if(numDocs == null) numDocs = "UNKNOWN";

        cTableBody += '<tr>\n';
        cTableBody += '<td>'+colName+'</td>\n';
        cTableBody += '<td>'+updatable+'</td>\n';
        cTableBody += '<td>'+size+'</td>\n';
        cTableBody += '<td>'+numDocs+'</td>\n';
        cTableBody +=
            '<td>'+
            '<input type="button" name="viewCol" value="view" onclick="top.doDocuments(\''+ colName + '\')" />'+
            '</td>\n';
        cTableBody +=
            '<td>'+
            '<input type="button" name="delCol" value="delete" onclick="top.doDelCol(\'' + colName+ '\')" />'+
            '</td>\n';
        cTableBody += '</tr>\n';
    }

    cTable.innerHTML = 
        '<h2>All collections in the database:</h2>\n' +
        '<table width="30%" border="1">\n' +
        '<tr>\n' +
        '<th>Name</th>\n' +
        '<th>Updatable</th>\n' +
        '<th>Size</th>\n' +
        '<th>#Docs</th>\n' +
        '<th>&nbsp;</th>\n' +
        '<th>&nbsp;</th>\n' +
        '</tr>\n' +
        cTableBody +
        '</table>\n';
}

function doAllDocumentsCallback(response) {
    var docs = response.getElementsByTagName("document");
    var dTableBody = "";

    var i;
    for(i = 0; i < docs.length; i++){
        var docName   = docs[i].firstChild.nodeValue;
        var cName     = docs[i].getAttribute("collection");
        var updatable = docs[i].getAttribute("updatable");
        var url       = docs[i].getAttribute("url");

        if(cName == null) cName = "UNKNOWN";
        if(updatable == null) updatable = "UNKNOWN";
        if(url == null) url = "UNKNOWN";

        dTableBody += '<tr>\n';
        dTableBody += '<td>'+docName+'</td>\n';
        dTableBody += '<td>'+cName+'</td>\n';
        dTableBody += '<td>'+updatable+'</td>\n';
        dTableBody += '<td>'+url+'</td>\n';
        dTableBody +=
            '<td>'+
            '<input type="button" name="viewDoc" value="view" onclick="open(\'/xrpc/doc/'+docName+'\',\'_blank\',\'scrollbars=yes,resizable=yes,directories=no,location=no,titlebar=no,toolbar=no\')"/>'+
            '</td>\n';
        dTableBody +=
            '<td>'+
            '<input type="button" name="delDoc" value="delete" onclick="top.doDelDoc(\''+docName+'\')" />'+
            '</td>\n';
        dTableBody += '</tr>\n';
    }

    var dTable = top.content.document.getElementById("div1");
    dTable.innerHTML = 
        '<h2>All documents in the database:</h2>\n' +
        '<table width="30%" border="1">\n' +
        '<tr>\n' +
        '<th>Name</th>\n' +
        '<th>Collection</th>\n' +
        '<th>Updatable</th>\n' +
        '<th>URL</th>\n' +
        /*
        '<th>&nbsp;</th>\n' +
        */
        '<th>&nbsp;</th>\n' +
        '</tr>\n' +<commit_msg>In an XRPC response message, an empty collection (as the result of document deletion) does not have a "numDocs" attribute.  Using "UNKNOWN" to indicate an empty collection is very confusing, hence, we now filter out those empty collection tuples.<commit_after>/* set the proper URLs for the admin GUI */
var protocol= "file:";
if (document.location.protocol != null && document.location.protocol != "")
   protocol = document.location.protocol

var port    = "";
if (document.location.port != null && document.location.port != "")
   port = ":" + document.location.port

var href    = protocol + "//" + document.location.hostname + port; 
var mod     = "http://monetdb.cwi.nl/XQuery/admin/";
var modurl  = href + "/admin/admin.xq";
var posturl = href + "/xrpc/admin";

function myXRPC(method,arity,call,callback) {
    XRPC(posturl,mod,modurl,method,arity,call,callback);
}

/**********************************************************************
          Callback functions of the admin functions in admin.xq
***********************************************************************/

function doCollectionsCallback(response) {
    var cols = response.getElementsByTagName("collection");
    var cTable = top.content.document.getElementById("div1");
    var cTableBody = "";

    if(cols.length == 0){
        cTable.innerHTML = '<h3>No (documents) collections in the database</h3>\n';
        return;
    } else if( (cols.length == 1) &&
               (cols[0].getAttribute("numDocs") == null) ){
        cTable.innerHTML = '<h3>No (documents) collections in the database</h3>\n';
        return;
    }

    var i;
    for(i = 0; i < cols.length; i++){
        var colName = cols[i].firstChild.nodeValue;
        var updatable = cols[i].getAttribute("updatable");
        var size = cols[i].getAttribute("size");
        var numDocs = cols[i].getAttribute("numDocs");

        if(numDocs != null) {
            if(updatable == null) updatable = "UNKNOWN";
            if(size == null) size = "UNKNOWN";

            cTableBody += '<tr>\n';
            cTableBody += '<td>'+colName+'</td>\n';
            cTableBody += '<td>'+updatable+'</td>\n';
            cTableBody += '<td>'+size+'</td>\n';
            cTableBody += '<td>'+numDocs+'</td>\n';
            cTableBody +=
                '<td>'+
                '<input type="button" name="viewCol" value="view" onclick="top.doDocuments(\''+ colName + '\')" />'+
                '</td>\n';
            cTableBody +=
                '<td>'+
                '<input type="button" name="delCol" value="delete" onclick="top.doDelCol(\'' + colName+ '\')" />'+
                '</td>\n';
            cTableBody += '</tr>\n';
        }
    }

    cTable.innerHTML = 
        '<h2>All collections in the database:</h2>\n' +
        '<table width="30%" border="1">\n' +
        '<tr>\n' +
        '<th>Name</th>\n' +
        '<th>Updatable</th>\n' +
        '<th>Size</th>\n' +
        '<th>#Docs</th>\n' +
        '<th>&nbsp;</th>\n' +
        '<th>&nbsp;</th>\n' +
        '</tr>\n' +
        cTableBody +
        '</table>\n';
}

function doAllDocumentsCallback(response) {
    var docs = response.getElementsByTagName("document");
    var dTable = top.content.document.getElementById("div1");
    var dTableBody = "";

    if(docs == null || docs.length == 0){
        dTable.innerHTML = '<h3>No documents in the database</h3>\n';
        return;
    }

    var i;
    for(i = 0; i < docs.length; i++){
        var docName   = docs[i].firstChild.nodeValue;
        var cName     = docs[i].getAttribute("collection");
        var updatable = docs[i].getAttribute("updatable");
        var url       = docs[i].getAttribute("url");

        if(cName == null) cName = "UNKNOWN";
        if(updatable == null) updatable = "UNKNOWN";
        if(url == null) url = "UNKNOWN";

        dTableBody += '<tr>\n';
        dTableBody += '<td>'+docName+'</td>\n';
        dTableBody += '<td>'+cName+'</td>\n';
        dTableBody += '<td>'+updatable+'</td>\n';
        dTableBody += '<td>'+url+'</td>\n';
        dTableBody +=
            '<td>'+
            '<input type="button" name="viewDoc" value="view" onclick="open(\'/xrpc/doc/'+docName+'\',\'_blank\',\'scrollbars=yes,resizable=yes,directories=no,location=no,titlebar=no,toolbar=no\')"/>'+
            '</td>\n';
        dTableBody +=
            '<td>'+
            '<input type="button" name="delDoc" value="delete" onclick="top.doDelDoc(\''+docName+'\')" />'+
            '</td>\n';
        dTableBody += '</tr>\n';
    }

    dTable.innerHTML = 
        '<h2>All documents in the database:</h2>\n' +
        '<table width="30%" border="1">\n' +
        '<tr>\n' +
        '<th>Name</th>\n' +
        '<th>Collection</th>\n' +
        '<th>Updatable</th>\n' +
        '<th>URL</th>\n' +
        /*
        '<th>&nbsp;</th>\n' +
        */
        '<th>&nbsp;</th>\n' +
        '</tr>\n' +
{'fraction_non_alphanumeric': 0.22873387273124862, 'fraction_numerical': 0.00448283402580363, 'mean_word_length': 2.4335585585585586, 'pattern_counts': {'":': 2, '<': 149, '<?xml version=': 0, '>': 145, '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': '352584', 'n_tokens_mistral': 2966, 'n_tokens_neox': 2980, 'n_words': 539}