<commit_before>var topicExplorer = new Object();
topicExplorer.pluginModel;
var jsonObject;
//This would be the default script
topicExplorer.PluginModel = function (defaultPlugins) {
	var self = this;
	self.plugins = ko.observableArray();
	
	//method to register your plugins
	self.registerPlugin = function(pluginName) {
		//check if the plugin is already registered
		var isLoaded = ko.utils.arrayFirst(self.plugins(), function(item) {			
			if(item.name === pluginName) {
				return item;
			}
		});
		if(!isLoaded) {
			$( "#ajaxLoader" ).show();
			//Initialize a plugin object
			plugin = new Object();
			//loadScript from plugin folder
			$.ajaxSetup({
				async: false
				});
			$.getScript('scripts/plugins/'+pluginName+'.js').success(function(data) {
				start = new Date().getTime();
				plugin.init();
				//delete init function after init
				delete plugin.init;
				plugin.name = pluginName;
				self.plugins.push(plugin);
				if(plugin.setTab) {
					gui.drawTab(plugin.tabName, plugin.tabCanClose, plugin.setActive, plugin.content);
				}
				delete plugin;
				console.log("Zeit KO Plugin"+pluginName+": " + (new Date().getTime() - start));
			}).complete(function(){
				$( "#ajaxLoader" ).hide();				
			});
			//avoid overwrite
			//push plugin into KO array
			//self.plugins.push(plugin);
			//delete reference to object
			//delete plugin;
		}
	};
	
	$.each(defaultPlugins,function(key, value){		
		self.registerPlugin(value);
	});
}
$(document).ajaxStart(function() {
	$( "#ajaxLoader" ).show();
}).ajaxSuccess(function(event, request, settings) {
	//$( "#ajaxLoader" ).hide();
}).ajaxComplete(function(){
	$( "#ajaxLoader" ).hide();
});
$(document).ready(function() {
	var start = new Date().getTime();
	$.getJSON('getRandomDocs', {art:'random', id:null, limit:20})
	.done(function(json) {
		console.log("Zeit JSON holen: " + (new Date().getTime() - start));
		start = new Date().getTime();
		
		jsonModel = ko.mapping.fromJS(json.JSON);
		console.log("Zeit JSON mit KO mappen: " + (new Date().getTime() - start));
		start = new Date().getTime();
		jsonObject = json.JSON;
		console.log(json.FRONTEND_VIEWS);
		pluginModel = new PluginModel(json.FRONTEND_VIEWS);// ["search", "slider", "topic", "text"]
		console.log("Zeit KO Plugins initialisieren: " + (new Date().getTime() - start));
		
	}).fail(console.log("error"));
		
	ko.bindingHandlers.topicTest = {
		update: function(elem,valueAccessor) {
			if(valueAccessor().length > 0) {
				console.log(valueAccessor());
				$(elem).append($('<div class="small">').append(valueAccessor()[0].name));
			}
		}
	};
	ko.bindingHandlers.topicTest = {
			update: function(elem,valueAccessor, allBindingsAccessor, viewModel, bindingContext) {			
				$(elem).append($('<div class="">').append('<input data-bind="value: $data.name">'));<commit_msg>Bug behoben, dass PluginModel nicht generiert werden konnte<commit_after>var topicExplorer = new Object();
topicExplorer.pluginModel;
var jsonObject;
//This would be the default script
topicExplorer.PluginModel = function (defaultPlugins) {
	var self = this;
	self.plugins = ko.observableArray();
	
	//method to register your plugins
	self.registerPlugin = function(pluginName) {
		//check if the plugin is already registered
		var isLoaded = ko.utils.arrayFirst(self.plugins(), function(item) {			
			if(item.name === pluginName) {
				return item;
			}
		});
		if(!isLoaded) {
			$( "#ajaxLoader" ).show();
			//Initialize a plugin object
			plugin = new Object();
			//loadScript from plugin folder
			$.ajaxSetup({
				async: false
				});
			$.getScript('scripts/plugins/'+pluginName+'.js').success(function(data) {
				start = new Date().getTime();
				plugin.init();
				//delete init function after init
				delete plugin.init;
				plugin.name = pluginName;
				self.plugins.push(plugin);
				if(plugin.setTab) {
					gui.drawTab(plugin.tabName, plugin.tabCanClose, plugin.setActive, plugin.content);
				}
				delete plugin;
				console.log("Zeit KO Plugin"+pluginName+": " + (new Date().getTime() - start));
			}).complete(function(){
				$( "#ajaxLoader" ).hide();				
			});
			//avoid overwrite
			//push plugin into KO array
			//self.plugins.push(plugin);
			//delete reference to object
			//delete plugin;
		}
	};
	
	$.each(defaultPlugins,function(key, value){		
		self.registerPlugin(value);
	});
}
$(document).ajaxStart(function() {
	$( "#ajaxLoader" ).show();
}).ajaxSuccess(function(event, request, settings) {
	//$( "#ajaxLoader" ).hide();
}).ajaxComplete(function(){
	$( "#ajaxLoader" ).hide();
});
$(document).ready(function() {
	var start = new Date().getTime();
	$.getJSON('getRandomDocs', {art:'random', id:null, limit:20})
	.done(function(json) {
		console.log("Zeit JSON holen: " + (new Date().getTime() - start));
		start = new Date().getTime();
		
		jsonModel = ko.mapping.fromJS(json.JSON);
		console.log("Zeit JSON mit KO mappen: " + (new Date().getTime() - start));
		start = new Date().getTime();
		jsonObject = json.JSON;
		console.log(json.FRONTEND_VIEWS);
		pluginModel = new topicExplorer.PluginModel(json.FRONTEND_VIEWS);// ["search", "slider", "topic", "text"]
		console.log("Zeit KO Plugins initialisieren: " + (new Date().getTime() - start));
		
	}).fail(console.log("error"));
		
	ko.bindingHandlers.topicTest = {
		update: function(elem,valueAccessor) {
			if(valueAccessor().length > 0) {
				console.log(valueAccessor());
				$(elem).append($('<div class="small">').append(valueAccessor()[0].name));
			}
		}
	};
	ko.bindingHandlers.topicTest = {
			update: function(elem,valueAccessor, allBindingsAccessor, viewModel, bindingContext) {			
				$(elem).append($('<div class="">').append('<input data-bind="value: $data.name">'));
{'fraction_non_alphanumeric': 0.18207381370826012, 'fraction_numerical': 0.00140597539543058, 'mean_word_length': 4.04074402125775, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 11, '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': '5434846', 'n_tokens_mistral': 2075, 'n_tokens_neox': 1788, 'n_words': 380}