<commit_before><?

// This tab can act as a standalone page or be included from a containter
//
// If included from a container the header and footer are not repeated


// $headerLoaded is imported from the containter
// determines whether we were called standalone or included
if ( $headerLoaded != true ) {
	include('head.php'); 
	include('header.php'); 
	$headerLoaded = false;
}


// Authenticate
require_once('lib/libAuthentication.php');

// init
$friends = 2;

// Have we found a webid?
$webid = $_REQUEST['webid'];
$webidbase = preg_replace('/#.*/', '', $webid);
if (!empty($webid)) {

	// get webid details
	$auth = get_agent($webid);
	$friends = count($auth['agent']['knows']);

} 
?>


<script type="text/javascript">
<!--
// function to add a friend
function addf(el) {

	// empty list 
	// @TODO more robust detection
	if ($("#friendstable tr:last td:last input").attr("name") == "friend1") {

		var about = $("#friendstable tr:last").attr("about");
		var lastFriend = about != undefined? about.replace(/.*friend/, "") : -1;
		lastFriend++;
		//alert (lastFriend)

		var clone = $("#friendstable tr:last").clone();
		clone.attr({about : '#friend' + lastFriend });

		clone.appendTo("#friendstable");
		return;
	}

	// edit in place
	var last = $("#friendstable tr:last");
	if (last == null) {
	} else {
		var about = $("#friendstable tr:last").attr("about");
		var lastFriend = about != undefined? about.replace(/.*friend/, "") : -1;
		lastFriend++;
		//alert (lastFriend)
		$("#friendstable tr:last").after("<tr about='<?= $webidbase ?>#friend"+lastFriend+"' typeof='foaf:Person' ><td>Friend</td><td><span property='foaf:name'></span></td><td><a rel='refs:seeAlso'></a></td><td about='<?= $webid ?>' rel='foaf:knows' href='<?= $webidbase ?>#friend"+lastFriend+"' ><a>x</a></td></tr>");

		sparul();
	}


}
// -->
</script>

	<table id="friendstable" about="<?= $webid ?>">
	<tr>
		<td></td>
		<td>Name</td><td>URL</td>
	</tr>

	<? for ($i=0; $i<$friends; $i++) { ?>


		<? if (empty($webid)) {  ?>

		<tr typeof="foaf:Person" id="friend<?= $i ?>" about="<?= $webidbase ?>friend<?= $i ?>" >
			<td>Friend: </td>
			<td><input size="12" property="foaf:name" onchange="makeTags()" type="text" name="friend<?= $i ?>name" /></td>
			<td><input size="12" rel="rdfs:seeAlso" onchange="makeTags()" type="text" name="friend<?= $i ?>" /></td>

		<? } else { $v = $auth['agent']['knows'][$i]; $about =  $v['about']?$v['about']  : $webidbase . "#friend" . $i ; ?>

		<tr typeof="foaf:Person" id="friend<?= $i ?>" about="<?= $about ?>" >
			<td><a href="?webid=<?= $v['webid'] ?>">Friend</a>: </td>
			<td><span property="foaf:name"><?= $v['name'] ?></span></td>
			<td><span href="<?= $v['webid'] ?>" rel="rdfs:seeAlso" ><?= $v['webid'] ?></span></td>
			<td about="<?= $webid ?>" rel="foaf:knows" href="<?= $webidbase ?>#friend<?= $i ?>"><a  id="delfriend<?= $i ?>" href="javascript:del('delfriend<?= $i ?>')" >x</a></td>
		<? } ?>

	</tr><commit_msg>cleanup<commit_after><?

// This tab can act as a standalone page or be included from a containter
//
// If included from a container the header and footer are not repeated


// $headerLoaded is imported from the containter
// determines whether we were called standalone or included
if ( $headerLoaded != true ) {
	include('head.php'); 
	include('header.php'); 
	$headerLoaded = false;
}


// Authenticate
require_once('lib/libAuthentication.php');

// init
$friends = 2;

// Have we found a webid?
$webid = $_REQUEST['webid'];
$webidbase = preg_replace('/#.*/', '', $webid);
if (!empty($webid)) {

	// get webid details
	$auth = get_agent($webid);
	$friends = count($auth['agent']['knows']);

} 
?>


<script type="text/javascript">
<!--
// function to add a friend
function addf(el) {

	// empty list 
	// clone it
	// replace numbers
	// make sure fields are blank
	if ($(el).prevAll().find("tr:last input").attr("type") === 'text' ) {

		var about = $(el).prevAll().find(" tr:last").attr("about");
		var lastFriend = (about != undefined) ? about.replace(/[^0-9]*/, "") : -1;

		lastFriend++;
		var clone = $("#friendstable tr:last").clone();

		clone.attr({about : 'friend' + lastFriend });
		clone.appendTo("#friendstable");

		return;
	}

	// edit in place
	var last = $("#friendstable tr:last");
	if (last == null) {
	} else {
		var about = $("#friendstable tr:last").attr("about");
		var lastFriend = about != undefined? about.replace(/.*friend/, "") : -1;
		lastFriend++;
		//alert (lastFriend)
		$("#friendstable tr:last").after("<tr about='<?= $webidbase ?>#friend"+lastFriend+"' typeof='foaf:Person' ><td>Friend</td><td><span property='foaf:name'></span></td><td><a rel='refs:seeAlso'></a></td><td about='<?= $webid ?>' rel='foaf:knows' href='<?= $webidbase ?>#friend"+lastFriend+"' ><a>x</a></td></tr>");

		sparul();
	}


}
// -->
</script>

	<table id="friendstable" about="<?= $webid ?>">
	<tr>
		<td></td>
		<td>Name</td><td>URL</td>
	</tr>

	<? for ($i=0; $i<$friends; $i++) { ?>


		<? if (empty($webid)) {  ?>

		<tr typeof="foaf:Person" about="<?= $webidbase ?>friend<?= $i ?>" >
			<td>Friend: </td>
			<td><input size="12" property="foaf:name" onchange="makeTags()" type="text" /></td>
			<td><input size="12" rel="rdfs:seeAlso" onchange="makeTags()" type="text" /></td>

		<? } else { $v = $auth['agent']['knows'][$i]; $about =  $v['about']?$v['about']  : $webidbase . "friend" . $i ; ?>

		<tr typeof="foaf:Person" id="friend<?= $i ?>" about="<?= $about ?>" >
			<td><a href="?webid=<?= $v['webid'] ?>">Friend</a>: </td>
			<td><span property="foaf:name"><?= $v['name'] ?></span></td>
			<td><span href="<?= $v['webid'] ?>" rel="rdfs:seeAlso" ><?= $v['webid'] ?></span></td>
			<td about="<?= $webid ?>" rel="foaf:knows" href="<?= $webidbase ?>#friend<?= $i ?>"><a  id="delfriend<?= $i ?>" href="javascript:del('delfriend<?= $i ?>')" >x</a></td>
		<? } ?>

	</tr>
{'fraction_non_alphanumeric': 0.26510354270066744, 'fraction_numerical': 0.0032517542358377546, 'mean_word_length': 4.411111111111111, 'pattern_counts': {'":': 0, '<': 162, '<?xml version=': 0, '>': 160, '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': '5166626', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2130, 'n_words': 477}