<commit_before>/**

pcep-grammar

Javascript PCEP grammar library

Supported RFCS:

RFC 5440, RFC 5520, RFC 5521, RFC 5886

<NAME>

*/

jPCEPGrammar = {};

(function (pcep,$,undefined) {

	// Version
	pcep.version = "0.3-dev"
	
	// List of PCEP Messages
	pcep.messages = [];

	// List of PCEP Objects
	pcep.objects = [];

	//List of PCEP Constructs
	pcep.constructs = [];

	//List of PCEP Elements lists
	pcep.lists = [];

	//List of PCEP choices
	pcep.choices = [];

	//FIXME: Add list of shown constructs to avoid repeating them

	pcep.pcep_element = function(){

		this.getHTML = function (RFCfilter, optional) {
			var newElem;
			//Check if the element's RFC is in the filter, otherwise, don't show it
			var found = $.inArray(this.rfc, RFCfilter) > -1;
			if (found) {
				if (this.type == "object"){
					//Check if the object is in the filter, otherwise, don't show it					
						newElem = $('<span />');
						newElem.addClass("object_"+this.rfc);
						if (optional == true){
							newElem.append('[&#60;'+ this.name+'&#62;]');
						}else {
							newElem.append('&#60;'+ this.name+'&#62;');
						}					
					
				} else if (this.type == "header") {
					// The element is the header of a message
					newElem = $('<span />');
					newElem.append('&#60;'+ this.name+'&#62;');
				} else if (this.type == "construct"){
					// The element is a construct
					newElem = $('<span />');
					newElem.addClass("construct_"+this.rfc);				
					if (optional == true){
						newElem.append('[&#60;'+ this.name+'&#62;]');
					}else {
						newElem.append('&#60;'+ this.name+'&#62;');
					}
					//FIXME: CHECK IF CONSTRhUCT HAS ALREADY BEEN DRAWN
					//A new element defintion is created to define the construct
					var elem_definition= $('<div />');
					$('#grammar_content').append(elem_definition);
					elem_definition.addClass("elem_definition");
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = '&#60;'+ this.name+'&#62;'+"::==";
					defined_element.append(displayText);
					elem_definition.append(defined_element);
					var definition = $('<div />');
					definition.addClass("definition");
					definition.append(definition);
					elem_definition.append(definition);
					//FIXME: HAY QUE PASAR EL PARRAFO PADRE
					console.log(this.name+ " tiene "+pcep.constructs[this.name].elems.length);
					for (var elem in pcep.constructs[this.name].elems) {
						console.log("vaaamos por "+elem+" de "+this.name);
						console.log("sale"+pcep.constructs[this.name].elems[elem].pcep_elem.name);
						definition.append(this.elems[elem].pcep_elem.getHTML(RFCfilter, pcep.constructs[this.name].elems[elem].optional));
					}
					
				} else if (this.type == "choice") {
					console.log("entering choice "+this.name);
					newElem = $('<span />');
					newElem.addClass("choice");				
					if (optional == true){
						newElem.append('[');
					}
					for (var elem in this.elems) {
						console.log("Choice: elem ["+elem+"]"+this.elems[elem].pcep_elem.name);

						newElem.append(this.elems[elem].pcep_elem.getHTML(RFCfilter, this.elems[elem].optional));
						if (elem < this.elems.length-1){
							newElem.append('|');	
						}						
					}
				} else if (this.type == "list"){
					console.log("entramos en lista de "+this.name);
					newElem = $('<span />');
					newElem.addClass("list."+this.rfc);				
					if (optional == true){
						newElem.append('[&#60;'+ this.name+'&#62;]');
					}else {
						newElem.append('&#60;'+ this.name+'&#62;');
					}
					//FIXME: CHECK IF LIST HAS ALREADY BEEN DRAWN
					var elem_definition= $('<div />');
					$('#grammar_content').append(elem_definition);
					elem_definition.addClass("elem_definition");
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = '&#60;'+ this.name+'&#62;'+"::==";
					defined_element.append(displayText);
					elem_definition.append(defined_element);
					var definition = $('<div />');
					definition.addClass("definition");
					definition.append(definition);
					definition.append(this.pcep_elem.getHTML(RFCfilter,false));
					var definition_text = '[&#60;'+ this.name+'&#62]';
					definition.append(definition_text);
					elem_definition.append(definition);
					
				}else {
					newElem = $('<div />');
					newElem.addClass("elem_definition");
					//Create a div for the defined element
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = this.name+":==";
					defined_element.append(displayText);
					newElem.append(defined_element);
					//Create another div for the defnition itself
					var definition = $('<div />');
					definition.addClass("definition");
					newElem.append(definition);
					for (var elem in this.elems) {
						console.log(this.elems[elem].pcep_elem.name);
						definition.append(this.elems[elem].pcep_elem.getHTML(RFCfilter));
					}
					
				}
			}
			return newElem;
		}

		
	}

	pcep.draw_message = function (message_name ) {
		console.log("Draw message: "+message_name);
		var newElem = $('<div />');
		newElem.attr('id', 'grammar_content');<commit_msg>logs removed<commit_after>/**

pcep-grammar

Javascript PCEP grammar library

Supported RFCS:

RFC 5440, RFC 5520, RFC 5521, RFC 5886

<NAME>

*/

jPCEPGrammar = {};

(function (pcep,$,undefined) {

	// Version
	pcep.version = "0.3-dev"
	
	// List of PCEP Messages
	pcep.messages = [];

	// List of PCEP Objects
	pcep.objects = [];

	//List of PCEP Constructs
	pcep.constructs = [];

	//List of PCEP Elements lists
	pcep.lists = [];

	//List of PCEP choices
	pcep.choices = [];

	//FIXME: Add list of shown constructs to avoid repeating them

	pcep.pcep_element = function(){

		this.getHTML = function (RFCfilter, optional) {
			var newElem;
			//Check if the element's RFC is in the filter, otherwise, don't show it
			var found = $.inArray(this.rfc, RFCfilter) > -1;
			if (found) {
				if (this.type == "object"){
					//Check if the object is in the filter, otherwise, don't show it					
						newElem = $('<span />');
						newElem.addClass("object_"+this.rfc);
						if (optional == true){
							newElem.append('[&#60;'+ this.name+'&#62;]');
						}else {
							newElem.append('&#60;'+ this.name+'&#62;');
						}					
					
				} else if (this.type == "header") {
					// The element is the header of a message
					newElem = $('<span />');
					newElem.append('&#60;'+ this.name+'&#62;');
				} else if (this.type == "construct"){
					// The element is a construct
					newElem = $('<span />');
					newElem.addClass("construct_"+this.rfc);				
					if (optional == true){
						newElem.append('[&#60;'+ this.name+'&#62;]');
					}else {
						newElem.append('&#60;'+ this.name+'&#62;');
					}
					//FIXME: CHECK IF CONSTRhUCT HAS ALREADY BEEN DRAWN
					//A new element defintion is created to define the construct
					var elem_definition= $('<div />');
					$('#grammar_content').append(elem_definition);
					elem_definition.addClass("elem_definition");
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = '&#60;'+ this.name+'&#62;'+"::==";
					defined_element.append(displayText);
					elem_definition.append(defined_element);
					var definition = $('<div />');
					definition.addClass("definition");
					definition.append(definition);
					elem_definition.append(definition);
					console.log(this.name+ " tiene "+pcep.constructs[this.name].elems.length);
					for (var elem in pcep.constructs[this.name].elems) {
						definition.append(this.elems[elem].pcep_elem.getHTML(RFCfilter, pcep.constructs[this.name].elems[elem].optional));
					}
					
				} else if (this.type == "choice") {
					newElem = $('<span />');
					newElem.addClass("choice");				
					if (optional == true){
						newElem.append('[');
					}
					for (var elem in this.elems) {
						newElem.append(this.elems[elem].pcep_elem.getHTML(RFCfilter, this.elems[elem].optional));
						if (elem < this.elems.length-1){
							newElem.append('|');	
						}						
					}
				} else if (this.type == "list"){
					newElem = $('<span />');
					newElem.addClass("list."+this.rfc);				
					if (optional == true){
						newElem.append('[&#60;'+ this.name+'&#62;]');
					}else {
						newElem.append('&#60;'+ this.name+'&#62;');
					}
					//FIXME: CHECK IF LIST HAS ALREADY BEEN DRAWN
					var elem_definition= $('<div />');
					$('#grammar_content').append(elem_definition);
					elem_definition.addClass("elem_definition");
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = '&#60;'+ this.name+'&#62;'+"::==";
					defined_element.append(displayText);
					elem_definition.append(defined_element);
					var definition = $('<div />');
					definition.addClass("definition");
					definition.append(definition);
					definition.append(this.pcep_elem.getHTML(RFCfilter,false));
					var definition_text = '[&#60;'+ this.name+'&#62]';
					definition.append(definition_text);
					elem_definition.append(definition);
		
				}else {
					newElem = $('<div />');
					newElem.addClass("elem_definition");
					//Create a div for the defined element
					var defined_element = $('<div />');
					defined_element.addClass("defined_element");
					var displayText = this.name+":==";
					defined_element.append(displayText);
					newElem.append(defined_element);
					//Create another div for the defnition itself
					var definition = $('<div />');
					definition.addClass("definition");
					newElem.append(definition);
					for (var elem in this.elems) {
						definition.append(this.elems[elem].pcep_elem.getHTML(RFCfilter));
					}
					
				}
			}
			return newElem;
		}

		
	}

	pcep.draw_message = function (message_name ) {
		console.log("Draw message: "+message_name);
		var newElem = $('<div />');
		newElem.attr('id', 'grammar_content');
{'fraction_non_alphanumeric': 0.17580758780315991, 'fraction_numerical': 0.0120760792995874, 'mean_word_length': 3.086348684210526, 'pattern_counts': {'":': 6, '<': 37, '<?xml version=': 0, '>': 37, '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': '2051441', 'n_tokens_mistral': 4256, 'n_tokens_neox': 3226, 'n_words': 667}