<commit_before>var updating_text = "...updating...";
var UNKNOWN = 'unknown';
var NOT_APPLICABLE = "not applicable";


// function build_agg_table_on_slicepg() 
// {
//      var json_agg;
//      var name;
//      var output; 
//      var status_url, listres_url;

//      var s = all_ams;
//      var all_am_obj = JSON.parse(s);

//      status_url = 'sliverstatus.php?slice_id='+slice;
//      listres_url = 'listresources.php?slice_id='+slice;

//      // (2) create an HTML table with one row for each aggregate
//      json_agg = all_am_obj;
//      output = "<table id='status_table'>";
//      //  output +=  "<tr><th>Status</th><th colspan='2'>Slice</th><th>Creation</th><th>Expiration</th><th>Actions</th></tr>\n";
//      output +=  "<tr><th>Status</th><th colspan='6'>Slice</th></tr>\n";
//      /* Slice Info */
//      output +=  "<tr>";
//      output +=  "<td class='$slice_status'>"+slice_status+"</td>";
//      output +=  "<td colspan='5'>"+slice_name+"</td>";
//      output +=  "</tr>\n";
//      output += "<tr>";
//      output += "<th class='notapply'>";
//      output += "</th><th>";
//      output += "<button id='reload_all_button' type='button' onclick='refresh_all_agg_rows()'>Get All Status</button>";
//      output += "</th><th>Status</th><th>Aggregate</th>";
//      //      output += "<th>&nbsp;</th>";
//      output += "<th>Renew</th>";
//      output += "<th>Actions</th></tr>\n";
//      for (am_id in json_agg ) {
// 	    agg = json_agg[am_id];                    
// 	    name = agg.name;
//             output += "<tr id='"+am_id+"'>";
// 	    output += "<td class='notapply'></td>";
// 	    output += "<td><button id='reload_button_'"+am_id+" type='button' onclick='refresh_agg_row("+am_id+")'>Get Status</button>";
// 	    output += "</td><td id='status_"+am_id+"' class='notqueried'>";	
// 	    output += initial_text;
// 	    output += "</td><td>";	
// 	    output += name;
// 	    output += "</td>";	
// 	    // sliver expiration
// 	    if (renew_slice_privilege) {
//                 output += "<td><form  method='GET' action=\"do-renew.php\">";
// 		output += "<input type=\"hidden\" name=\"slice_id\" value=\""+slice+"\"/>\n";
// 		output += "<input type=\"hidden\" name=\"am_id\" value=\""+am_id+"\"/>\n";
// 		output += "<input id='renew_field_"+am_id+"' disabled='' class='date' type='text' name='sliver_expiration'";
// 		output += "value=\""+slice_expiration+"\"/>\n";
// 		output += "<input id='renew_button_"+am_id+"' disabled='' type='submit' name= 'Renew' value='Renew'/>\n";
// 		output += "</form></td>\n";
// 	    } else {
// 		output += "<td>"+sliver_expiration+"</td>"; 
// 	    }
// 	    // sliver actions
// 	    output += "<td>";
// 	    output += "<button id='status_button_"+am_id+"' disabled='' onClick=\"window.location='"+status_url+"&am_id="+am_id+"'\"><b>Resource Status</b></button>";
// 	    output += "<button  id='details_button_"+am_id+"' disabled='' title='Login info, etc' onClick=\"window.location='"+listres_url+"&am_id="+am_id+"'\"><b>Details</b></button>\n";
// 	    output += "<button  id='delete_button_"+am_id+"' disabled='' onClick=\"window.location='confirm-sliverdelete.php?slice_id=" + slice+ "&am_id="+am_id+"'\" "+ delete_slivers_disabled +"><b>Delete Resources</b></button>\n";
// 	    output += "</td></tr>";
//             // (3) Get the status for this slice at this aggregate
// //	    update_agg_row( am_id );
//      }	
//      output += "</table>";
//      $("#status_table_div").html(output);
// }


function build_agg_table() 
{
   // (1) query the server for all a list of aggregates
   $.getJSON("aggregates.php",function(responseTxt,statusTxt,xhr){
   if(statusTxt=="success") 
   {
     var json_agg;
     var name;
     var output; 
     // (2) create an HTML table with one row for each aggregate
     json_agg = responseTxt;
     output = "<table id='status_table'>";
     for (am_id in json_agg ) {
	    agg = json_agg[am_id];                    
	    name = agg.name;
            output += "<tr id='"+am_id+"'>";
	    output += "<td class='notapply'></td>";
	    output += "<td><button id='button_'"+am_id+" type='button' onclick='update_agg_row("+am_id+")'>Reload</button>";
	    output += "</td><td id='status_"+am_id+"' class='updating'>";	
	    output += "...updating...";
	    output += "</td><td>";	
	    output += name;
//	    output += "</td><td>";	
//	    output += agg.url;
	    output += "</td></tr>";
            // (3) Get the status for this slice at this aggregate
	    update_agg_row( am_id );
     }	
     output += "</table>";
     $("#status_table_div").html(output);
   }
   if(statusTxt=="error")
     alert("Error: "+xhr.status+": "+xhr.statusText);
   });
}



function refresh_all_agg_rows() {
    var s = all_ams;
    var all_am_obj = JSON.parse(s);
    for (var tmp_am_id in all_am_obj ) {
       refresh_agg_row(tmp_am_id);
    }
}

function refresh_agg_row(am_id) {
    geni_status = "updating"
    $("td#status_"+am_id).text( updating_text);
    $("td#status_"+am_id).attr( "class", geni_status );
    update_agg_row(am_id);
}



function update_agg_row(am_id) {
  // This queries for the json file at (for example):
  // https://sergyar.gpolab.bbn.com/secure/amstatus.php?am_id=9&slice_id=b18cb314-c4dd-4f28-a6fd-b355190e1b61
  $("button#reload_button_"+am_id).prop( "disabled", true ); 
  $.getJSON("amstatus.php", { am_id:am_id, slice_id:slice },function(responseTxt,statusTxt,xhr){
     if(statusTxt=="success") 
     {
        var json_am;
        var am;
        var geni_status;
        var output=""; 
        json_am = responseTxt;

	if (Object.keys(json_am).length > 0) {
            am = json_am[am_id];	   
            geni_status = am['geni_status'];
            status_code = am['status_code'];
            sliver_expiration = am['geni_expires'];
    	    output += geni_status;
	} else {
	    status_code = GENI_NO_STATUS;
	    output += GENI_NO_STATUS_STR;
            sliver_expiration = UNKNOWN;
	}
        $("td#status_"+am_id).text( output );
        $("td#status_"+am_id).attr( "class", GENI_CLASSES[ status_code ] );
        $("span#renew_sliver_"+am_id).text( sliver_expiration );

	$("button#reload_button_"+am_id).prop( "disabled", false ); 
	if ((status_code == GENI_NO_RESOURCES) || (status_code == GENI_NO_STATUS)){
// could hide rows for AMs with no resources	    $("tr#"+am_id).hide(); 
	    $("button#status_button_"+am_id).prop( "disabled", true ); 
	    $("button#details_button_"+am_id).prop( "disabled", true ); 
	    $("button#delete_button_"+am_id).prop( "disabled", true );
	    $("span#renew_sliver_"+am_id).text( NOT_APPLICABLE);  
	    $("input#renew_button_"+am_id).prop( "disabled", true ); 
	    $("input#renew_field_"+am_id).prop( "disabled", true ); 
	} else {
	    $("button#status_button_"+am_id).removeProp( "disabled"); 
	    $("button#details_button_"+am_id).removeProp( "disabled"); 
	    $("button#delete_button_"+am_id).removeProp( "disabled");
	    $("input#renew_button_"+am_id).removeProp( "disabled");
	    $("input#renew_field_"+am_id).removeProp( "disabled");<commit_msg>Format dates in consistent format.<commit_after>var updating_text = "...updating...";
var UNKNOWN = 'unknown';
var NOT_APPLICABLE = "not applicable";
var NOT_RETRIEVED = "not retrieved";

// function build_agg_table_on_slicepg() 
// {
//      var json_agg;
//      var name;
//      var output; 
//      var status_url, listres_url;

//      var s = all_ams;
//      var all_am_obj = JSON.parse(s);

//      status_url = 'sliverstatus.php?slice_id='+slice;
//      listres_url = 'listresources.php?slice_id='+slice;

//      // (2) create an HTML table with one row for each aggregate
//      json_agg = all_am_obj;
//      output = "<table id='status_table'>";
//      //  output +=  "<tr><th>Status</th><th colspan='2'>Slice</th><th>Creation</th><th>Expiration</th><th>Actions</th></tr>\n";
//      output +=  "<tr><th>Status</th><th colspan='6'>Slice</th></tr>\n";
//      /* Slice Info */
//      output +=  "<tr>";
//      output +=  "<td class='$slice_status'>"+slice_status+"</td>";
//      output +=  "<td colspan='5'>"+slice_name+"</td>";
//      output +=  "</tr>\n";
//      output += "<tr>";
//      output += "<th class='notapply'>";
//      output += "</th><th>";
//      output += "<button id='reload_all_button' type='button' onclick='refresh_all_agg_rows()'>Get All Status</button>";
//      output += "</th><th>Status</th><th>Aggregate</th>";
//      //      output += "<th>&nbsp;</th>";
//      output += "<th>Renew</th>";
//      output += "<th>Actions</th></tr>\n";
//      for (am_id in json_agg ) {
// 	    agg = json_agg[am_id];                    
// 	    name = agg.name;
//             output += "<tr id='"+am_id+"'>";
// 	    output += "<td class='notapply'></td>";
// 	    output += "<td><button id='reload_button_'"+am_id+" type='button' onclick='refresh_agg_row("+am_id+")'>Get Status</button>";
// 	    output += "</td><td id='status_"+am_id+"' class='notqueried'>";	
// 	    output += initial_text;
// 	    output += "</td><td>";	
// 	    output += name;
// 	    output += "</td>";	
// 	    // sliver expiration
// 	    if (renew_slice_privilege) {
//                 output += "<td><form  method='GET' action=\"do-renew.php\">";
// 		output += "<input type=\"hidden\" name=\"slice_id\" value=\""+slice+"\"/>\n";
// 		output += "<input type=\"hidden\" name=\"am_id\" value=\""+am_id+"\"/>\n";
// 		output += "<input id='renew_field_"+am_id+"' disabled='' class='date' type='text' name='sliver_expiration'";
// 		output += "value=\""+slice_expiration+"\"/>\n";
// 		output += "<input id='renew_button_"+am_id+"' disabled='' type='submit' name= 'Renew' value='Renew'/>\n";
// 		output += "</form></td>\n";
// 	    } else {
// 		output += "<td>"+sliver_expiration+"</td>"; 
// 	    }
// 	    // sliver actions
// 	    output += "<td>";
// 	    output += "<button id='status_button_"+am_id+"' disabled='' onClick=\"window.location='"+status_url+"&am_id="+am_id+"'\"><b>Resource Status</b></button>";
// 	    output += "<button  id='details_button_"+am_id+"' disabled='' title='Login info, etc' onClick=\"window.location='"+listres_url+"&am_id="+am_id+"'\"><b>Details</b></button>\n";
// 	    output += "<button  id='delete_button_"+am_id+"' disabled='' onClick=\"window.location='confirm-sliverdelete.php?slice_id=" + slice+ "&am_id="+am_id+"'\" "+ delete_slivers_disabled +"><b>Delete Resources</b></button>\n";
// 	    output += "</td></tr>";
//             // (3) Get the status for this slice at this aggregate
// //	    update_agg_row( am_id );
//      }	
//      output += "</table>";
//      $("#status_table_div").html(output);
// }


function build_agg_table() 
{
   // (1) query the server for all a list of aggregates
   $.getJSON("aggregates.php",function(responseTxt,statusTxt,xhr){
   if(statusTxt=="success") 
   {
     var json_agg;
     var name;
     var output; 
     // (2) create an HTML table with one row for each aggregate
     json_agg = responseTxt;
     output = "<table id='status_table'>";
     for (am_id in json_agg ) {
	    agg = json_agg[am_id];                    
	    name = agg.name;
            output += "<tr id='"+am_id+"'>";
	    output += "<td class='notapply'></td>";
	    output += "<td><button id='button_'"+am_id+" type='button' onclick='update_agg_row("+am_id+")'>Reload</button>";
	    output += "</td><td id='status_"+am_id+"' class='updating'>";	
	    output += "...updating...";
	    output += "</td><td>";	
	    output += name;
//	    output += "</td><td>";	
//	    output += agg.url;
	    output += "</td></tr>";
            // (3) Get the status for this slice at this aggregate
	    update_agg_row( am_id );
     }	
     output += "</table>";
     $("#status_table_div").html(output);
   }
   if(statusTxt=="error")
     alert("Error: "+xhr.status+": "+xhr.statusText);
   });
}



function refresh_all_agg_rows() {
    var s = all_ams;
    var all_am_obj = JSON.parse(s);
    for (var tmp_am_id in all_am_obj ) {
       refresh_agg_row(tmp_am_id);
    }
}

function refresh_agg_row(am_id) {
    geni_status = "updating"
    $("td#status_"+am_id).text( updating_text);
    $("td#status_"+am_id).attr( "class", geni_status );
    update_agg_row(am_id);
}

function twodigits( input ) {
    var in_str = "";
    in_str = input + "";
    if (in_str.length == 1) {
	 in_str = "0"+in_str;
    }
    return in_str;
}

function update_agg_row(am_id) {
  // This queries for the json file at (for example):
  // https://sergyar.gpolab.bbn.com/secure/amstatus.php?am_id=9&slice_id=b18cb314-c4dd-4f28-a6fd-b355190e1b61
  $("button#reload_button_"+am_id).prop( "disabled", true ); 
  $.getJSON("amstatus.php", { am_id:am_id, slice_id:slice },function(responseTxt,statusTxt,xhr){
     if(statusTxt=="success") 
     {
        var json_am;
        var am;
        var geni_status;
        var output=""; 
	var geni_expires;
        json_am = responseTxt;

	if (Object.keys(json_am).length > 0) {
            am = json_am[am_id];	   
            geni_status = am['geni_status'];
            status_code = am['status_code'];
            geni_expires = am['geni_expires'];
	    var exp = new Date( geni_expires );
	    if (isNaN(exp.getUTCFullYear())) { 
		sliver_expiration = NOT_RETRIEVED;
	    } else {
		sliver_expiration = exp.getUTCFullYear() + "-" + twodigits(exp.getUTCMonth()) + "-" + twodigits(exp.getUTCDate()) + " " + twodigits(exp.getUTCHours()) + ":" + twodigits(exp.getUTCMinutes()) + ":" + twodigits(exp.getUTCSeconds()) + " UTC";
	    }
    	    output += geni_status;
	} else {
	    status_code = GENI_NO_STATUS;
	    output += GENI_NO_STATUS_STR;
            sliver_expiration = UNKNOWN;
	}
        $("td#status_"+am_id).text( output );
        $("td#status_"+am_id).attr( "class", GENI_CLASSES[ status_code ] );
        $("span#renew_sliver_"+am_id).text( sliver_expiration );

	$("button#reload_button_"+am_id).prop( "disabled", false ); 
	if ((status_code == GENI_NO_RESOURCES) || (status_code == GENI_NO_STATUS)){
// could hide rows for AMs with no resources	    $("tr#"+am_id).hide(); 
	    $("button#status_button_"+am_id).prop( "disabled", true ); 
	    $("button#details_button_"+am_id).prop( "disabled", true ); 
	    $("button#delete_button_"+am_id).prop( "disabled", true );
	    $("span#renew_sliver_"+am_id).text( NOT_APPLICABLE);  
	    $("input#renew_button_"+am_id).prop( "disabled", true ); 
	    $("input#renew_field_"+am_id).prop( "disabled", true ); 
	} else {
	    $("button#status_button_"+am_id).removeProp( "disabled"); 
	    $("button#details_button_"+am_id).removeProp( "disabled"); 
	    $("button#delete_button_"+am_id).removeProp( "disabled");
	    $("input#renew_button_"+am_id).removeProp( "disabled");
	    $("input#renew_field_"+am_id).removeProp( "disabled");
{'fraction_non_alphanumeric': 0.21541381413949706, 'fraction_numerical': 0.004066969429946452, 'mean_word_length': 3.0256480218281037, 'pattern_counts': {'":': 4, '<': 195, '<?xml version=': 0, '>': 197, 'https://': 2, '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': '1658645', 'n_tokens_mistral': 5443, 'n_tokens_neox': 5229, 'n_words': 883}