<commit_before>var app = angular.module("fgis");
var map, drawnItems, drawControl, fachkarten, basemap;
var lines,
	linesArray = new Array();
var commentsMap = new Map();
var options; 
var drawControl;

app.controller("MapController", function($scope, $http, $sce, $location){

	//url of the db-server:
	$scope.dbServerAddress = $location.absUrl().split(":")[0] + ":" + $location.absUrl().split(":")[1] + ":3000/";

	$scope.sideContent = {};
	$scope.sideContent.template = "";
	$scope.sideContent.textvar = "";
	$scope.sideContent.close = function(){
		$scope.sideContent.template = "";
	}
	$scope.sideContent.change = function(template){
		$scope.sideContent.template = template;
	}

	/********************************
	************ Fields *************
	********************************/

	$scope.fields = {};
	$scope.fields.fieldOrder = fieldOrder;
	$scope.fields.symbols = symbolProperties;
	$scope.fields.symbolsFilter = "";
	$scope.fields.currentField = {};
	$scope.fields.currentField.image = "images/symbols/_universal.svg";
	$scope.fields.currentField.topText = "";
	$scope.fields.currentField.bottomText = "";
	$scope.fields.currentField.commentField = "";
	$scope.fields.currentField.active = false;
	$scope.fields.currentField.id = undefined;
	$scope.fields.currentField.fieldTextTop = "";
	$scope.fields.currentField.fieldTextBottom = "";
	$scope.fields.currentField.fieldComment = "";
	
	
	/**
	* @desc activates a tz slot, shows the field-properties in the side-content
	*/
	$scope.fields.register = function(field){
		$('#' + $scope.fields.currentField.id).removeClass("activated");
		$scope.fields.deleteLastLine($scope.fields.currentField.id);

		// when the clicked field is already the active/current one: deselect it
		if ($scope.fields.currentField.id == field) {
			$scope.fields.currentField.id = undefined;
			$scope.fields.cancel();			
			return;
		}

		var _template = "/app/templates/fgis/_fieldContent.html";
		try{$scope.map.editCancel();}catch(e){}
		var thisImage = document.getElementById(field).getElementsByTagName('img');
		$scope.fields.currentField.id = field;
		$scope.fields.currentField.active = true;		
		$('#' + $scope.fields.currentField.id).addClass("activated"); //highlight		
		
		drawnItems.eachLayer(function(layer) {				
			setClickable(layer, false);			
		});		
		
		if(thisImage.length == 0){
			if ($scope.map.lastClick !=null){
				$scope.fields.addLine();
			}
			$scope.fields.currentField.image = "images/symbols/_universal.svg";
			$scope.fields.currentField.topText = "";
			$scope.fields.currentField.bottomText = "";
			$scope.fields.currentField.commentField = "";
			$scope.fields.currentField.fieldTextTop = "";
			$scope.fields.currentField.fieldTextBottom = "";
			$scope.fields.currentField.fieldComment = "";
		}
		else {
			$scope.fields.currentField.image = thisImage[0].src;
			console.log(thisImage);
			$scope.fields.currentField.topText = "";
			$scope.fields.currentField.bottomText = "";
			$scope.fields.currentField.commentField = "";
			$scope.fields.currentField.fieldTextTop = document.getElementById('fieldTextTop'+field).innerHTML;
			$scope.fields.currentField.fieldTextBottom = document.getElementById('fieldTextBottom'+field).innerHTML;
			$scope.fields.currentField.fieldComment = document.getElementById('fieldComment'+field).innerHTML;
		}
		$scope.sideContent.change(_template);
	}

	//submit the field ('bestaetigen')
	$scope.fields.submit = function(){
		$scope.fields.currentField.active = false;		
		$scope.map.lastClick = null;		
		if(linesArray[$scope.fields.currentField.id] != null){
			$('#' + $scope.fields.currentField.id).removeClass("activated");
		}
		var _textTop, _textBottom, _comment, _image;
		_textTop = '<div id="fieldTextTop'
					+ $scope.fields.currentField.id
					+ '" class="fieldText fieldTextTop" style="overflow:hidden" title="' +$scope.fields.currentField.fieldTextTop + '" data-toggle="tooltip">'
					+ $scope.fields.currentField.fieldTextTop
					+ '</div>';

		_textBottom = '<div id="fieldTextBottom'
					+ $scope.fields.currentField.id
					+ '" class="fieldText fieldTextBottom" style="overflow:hidden" title="' +$scope.fields.currentField.fieldTextBottom + '" data-toggle="tooltip">'
					+ $scope.fields.currentField.fieldTextBottom
					+ '</div>';
		_comment = '<div id="fieldComment'
					+ $scope.fields.currentField.id
					+ '" class="fieldComment">'
					+ $scope.fields.currentField.fieldComment
					+ '</div>';

		//insert the image:
		_image = '<img id="image'
					+ $scope.fields.currentField.id
					+ '" draggable="true" ondragstart="drag(event)" src="'
					+ $scope.fields.currentField.image
					+ '" style="height:'
					+ fieldOrder.size
					+ '; width:'
					+ fieldOrder.size
					+ '; background-color: white; text-align: center;" />';
		var _htmlString = _textTop + _textBottom + _comment + _image;
		document.getElementById($scope.fields.currentField.id).innerHTML = _htmlString;
		$scope.sideContent.close();
	}

	$scope.fields.cancel = function(){
		$scope.sideContent.close();		
		$scope.fields.currentField.active = false;
		$('#' + $scope.fields.currentField.id).removeClass("activated");		
		$scope.fields.deleteLastLine($scope.fields.currentField.id);	
	}

	$scope.fields.delete = function(){
		$scope.fields.deleteLine();
		var htmlString = '<div id="fieldTextTop'
						+ $scope.fields.currentField.id
						+ '" class="fieldText fieldTextTop"></div>'
						+ '<div id="fieldTextBottom'
						+ $scope.fields.currentField.id
						+ '" class="fieldText fieldTextBottom"></div>'
						+ '<div id="fieldComment'
						+ $scope.fields.currentField.id
						+ '" class="fieldComment"></div>'
						+ '<svg id="image'
						+ $scope.fields.currentField.id
						+ '" style="height:'
						+ fieldOrder.size
						+ '; width:'
						+ fieldOrder.size
						+ ';"><polygon points="2,2 88,2 88,88 2,88 2,2 2,22.5 88,22.5 88,67.5 2,67.5"/></svg>';
		document.getElementById($scope.fields.currentField.id).innerHTML = htmlString;
		$scope.sideContent.close();
		$scope.fields.currentField.active = false;
		$('#' + $scope.fields.currentField.id).removeClass("activated");
	}

	//filter the list of fields
	$scope.fields.fiterSymbols = function(string){
		console.log("filter: " + string);
		$scope.fields.symbolsFilter = string;
	}

	$scope.fields.addSymbol = function(string){
		$scope.fields.currentField.image = "images/symbols/" + string + ".svg";
	}<commit_msg>addSymbol function updated<commit_after>var app = angular.module("fgis");
var map, drawnItems, drawControl, fachkarten, basemap;
var lines,
	linesArray = new Array();
var commentsMap = new Map();
var options; 
var drawControl;

app.controller("MapController", function($scope, $http, $sce, $location){

	//url of the db-server:
	$scope.dbServerAddress = $location.absUrl().split(":")[0] + ":" + $location.absUrl().split(":")[1] + ":3000/";

	$scope.sideContent = {};
	$scope.sideContent.template = "";
	$scope.sideContent.textvar = "";
	$scope.sideContent.close = function(){
		$scope.sideContent.template = "";
	}
	$scope.sideContent.change = function(template){
		$scope.sideContent.template = template;
	}

	/********************************
	************ Fields *************
	********************************/

	$scope.fields = {};
	$scope.fields.fieldOrder = fieldOrder;
	$scope.fields.symbols = symbolProperties;
	$scope.fields.symbolsFilter = "";
	$scope.fields.currentField = {};
	$scope.fields.currentField.image = "images/symbols/_universal.svg";
	$scope.fields.currentField.topText = "";
	$scope.fields.currentField.bottomText = "";
	$scope.fields.currentField.commentField = "";
	$scope.fields.currentField.active = false;
	$scope.fields.currentField.id = undefined;
	$scope.fields.currentField.fieldTextTop = "";
	$scope.fields.currentField.fieldTextBottom = "";
	$scope.fields.currentField.fieldComment = "";
	
	
	/**
	* @desc activates a tz slot, shows the field-properties in the side-content
	*/
	$scope.fields.register = function(field){
		$('#' + $scope.fields.currentField.id).removeClass("activated");
		$scope.fields.deleteLastLine($scope.fields.currentField.id);

		// when the clicked field is already the active/current one: deselect it
		if ($scope.fields.currentField.id == field) {
			$scope.fields.currentField.id = undefined;
			$scope.fields.cancel();			
			return;
		}

		var _template = "/app/templates/fgis/_fieldContent.html";
		try{$scope.map.editCancel();}catch(e){}
		var thisImage = document.getElementById(field).getElementsByTagName('img');
		$scope.fields.currentField.id = field;
		$scope.fields.currentField.active = true;		
		$('#' + $scope.fields.currentField.id).addClass("activated"); //highlight		
		
		drawnItems.eachLayer(function(layer) {				
			setClickable(layer, false);			
		});		
		
		if(thisImage.length == 0){
			if ($scope.map.lastClick !=null){
				$scope.fields.addLine();
			}
			$scope.fields.currentField.image = "images/symbols/_universal.svg";
			$scope.fields.currentField.topText = "";
			$scope.fields.currentField.bottomText = "";
			$scope.fields.currentField.commentField = "";
			$scope.fields.currentField.fieldTextTop = "";
			$scope.fields.currentField.fieldTextBottom = "";
			$scope.fields.currentField.fieldComment = "";
		}
		else {
			$scope.fields.currentField.image = thisImage[0].src;
			console.log(thisImage);
			$scope.fields.currentField.topText = "";
			$scope.fields.currentField.bottomText = "";
			$scope.fields.currentField.commentField = "";
			$scope.fields.currentField.fieldTextTop = document.getElementById('fieldTextTop'+field).innerHTML;
			$scope.fields.currentField.fieldTextBottom = document.getElementById('fieldTextBottom'+field).innerHTML;
			$scope.fields.currentField.fieldComment = document.getElementById('fieldComment'+field).innerHTML;
		}
		$scope.sideContent.change(_template);
	}

	//submit the field ('bestaetigen')
	$scope.fields.submit = function(){
		$scope.fields.currentField.active = false;		
		$scope.map.lastClick = null;		
		if(linesArray[$scope.fields.currentField.id] != null){
			$('#' + $scope.fields.currentField.id).removeClass("activated");
		}
		var _textTop, _textBottom, _comment, _image;
		_textTop = '<div id="fieldTextTop'
					+ $scope.fields.currentField.id
					+ '" class="fieldText fieldTextTop" style="overflow:hidden" title="' +$scope.fields.currentField.fieldTextTop + '" data-toggle="tooltip">'
					+ $scope.fields.currentField.fieldTextTop
					+ '</div>';

		_textBottom = '<div id="fieldTextBottom'
					+ $scope.fields.currentField.id
					+ '" class="fieldText fieldTextBottom" style="overflow:hidden" title="' +$scope.fields.currentField.fieldTextBottom + '" data-toggle="tooltip">'
					+ $scope.fields.currentField.fieldTextBottom
					+ '</div>';
		_comment = '<div id="fieldComment'
					+ $scope.fields.currentField.id
					+ '" class="fieldComment">'
					+ $scope.fields.currentField.fieldComment
					+ '</div>';

		//insert the image:
		_image = '<img id="image'
					+ $scope.fields.currentField.id
					+ '" draggable="true" ondragstart="drag(event)" src="'
					+ $scope.fields.currentField.image
					+ '" style="height:'
					+ fieldOrder.size
					+ '; width:'
					+ fieldOrder.size
					+ '; background-color: white; text-align: center;" />';
		var _htmlString = _textTop + _textBottom + _comment + _image;
		document.getElementById($scope.fields.currentField.id).innerHTML = _htmlString;
		$scope.sideContent.close();
	}

	$scope.fields.cancel = function(){
		$scope.sideContent.close();		
		$scope.fields.currentField.active = false;
		$('#' + $scope.fields.currentField.id).removeClass("activated");		
		$scope.fields.deleteLastLine($scope.fields.currentField.id);	
	}

	$scope.fields.delete = function(){
		$scope.fields.deleteLine();
		var htmlString = '<div id="fieldTextTop'
						+ $scope.fields.currentField.id
						+ '" class="fieldText fieldTextTop"></div>'
						+ '<div id="fieldTextBottom'
						+ $scope.fields.currentField.id
						+ '" class="fieldText fieldTextBottom"></div>'
						+ '<div id="fieldComment'
						+ $scope.fields.currentField.id
						+ '" class="fieldComment"></div>'
						+ '<svg id="image'
						+ $scope.fields.currentField.id
						+ '" style="height:'
						+ fieldOrder.size
						+ '; width:'
						+ fieldOrder.size
						+ ';"><polygon points="2,2 88,2 88,88 2,88 2,2 2,22.5 88,22.5 88,67.5 2,67.5"/></svg>';
		document.getElementById($scope.fields.currentField.id).innerHTML = htmlString;
		$scope.sideContent.close();
		$scope.fields.currentField.active = false;
		$('#' + $scope.fields.currentField.id).removeClass("activated");
	}

	//filter the list of fields
	$scope.fields.fiterSymbols = function(string){
		console.log("filter: " + string);
		$scope.fields.symbolsFilter = string;
	}
	/**
	* @desc changes symbol in tz 
	* @param string: string for new symbol location 
	**/
	$scope.fields.addSymbol = function(string){
		$scope.fields.currentField.image = "images/symbols/" + string + ".svg";
		document.getElementById('image'+ $scope.fields.currentField.id).src = $scope.fields.currentField.image;
	}
{'fraction_non_alphanumeric': 0.1821803416839041, 'fraction_numerical': 0.006128859266069103, 'mean_word_length': 4.234161988773056, 'pattern_counts': {'":': 8, '<': 35, '<?xml version=': 0, '>': 35, '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': '7651618', 'n_tokens_mistral': 4720, 'n_tokens_neox': 4088, 'n_words': 587}