<commit_before>/*

transitd web UI main js file

@license The MIT License (MIT)
@author Alex <<EMAIL>>
@author Serg <<EMAIL>>
@copyright 2016 Alex
@copyright 2016 Serg

*/

var service = new rpc.ServiceProxy("/jsonrpc", {methods: ['nodeInfo','connectTo','disconnect','listGateways','pollCallStatus','listSessions','startScan','getGraphSince','status']});

function logAppendMessage(type, msg)
{
	if($("#log div").length >= 5)
		$("#log").children().first().remove();
	var div = $("<div class='alert alert-"+type+" fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><span class='logmsg'/></div>");
	div.find(".logmsg").text(msg);
	div.fadeIn(500).delay(10000).fadeOut(1000);
	$("#log").append(div);
}

function nonBlockingCallWrapper(result, callback)
{
	if(result.callId)
	{
		var id = result.callId;
		setTimeout(function(){
			service.pollCallStatus({
				params: [id],
				onSuccess: function(result) {
					nonBlockingCallWrapper(result, callback);
				},
				onException: function(e) {
					logAppendMessage('danger', e);
					return true;
				}
			});
		},1000);
	}
	else
		callback(result);
}

function bootstrap()
{
	if($("#gateways").length>0)
		reloadGateways();
	if($("#sessions").length>0)
		reloadSessions();
	if($("#status").length>0)
		reloadStatus();
	if($("#startScan").length>0)
		$("#startScan").click(startScan);
	if($("#network").length>0)
		startNetworkGraph();
}

var nodeInfo;
$(document).ready(function(){
	$("#gateways").hide();
	$("#sessions").hide();
	
	$("li.title").click(function(event) {
		event.preventDefault();
		$("#pageone-about").hide();
		$("#pageone-home").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.home").addClass("active");
	});
	
	$(".navbar li.home").click(function(event) {
		event.preventDefault();
		$("#pageone-about").hide();
		$("#pageone-home").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.home").addClass("active");
	});

	$(".navbar li.about").click(function(event) {
		event.preventDefault();
		$("#pageone-home").hide();
		$("#pageone-about").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.about").addClass("active");
	});
	
	service.nodeInfo({
		params: [],
		onSuccess: function(result) {
			nonBlockingCallWrapper(result, function(result) {
				if(result.success==true)<commit_msg>minor change<commit_after>/*

transitd web UI main js file

@license The MIT License (MIT)
@author Alex <<EMAIL>>
@author Serg <<EMAIL>>
@copyright 2016 Alex
@copyright 2016 Serg

*/

var service = new rpc.ServiceProxy("/jsonrpc", {methods: ['nodeInfo','connectTo','disconnect','listGateways','pollCallStatus','listSessions','startScan','getGraphSince','status']});

function logAppendMessage(type, msg)
{
	if($("#log div").length >= 5)
		$("#log").children().first().remove();
	var div = $("<div class='alert alert-"+type+" fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><span class='logmsg'/></div>");
	div.find(".logmsg").text(msg);
	div.fadeIn(500).delay(10000).fadeOut(1000);
	$("#log").append(div);
}

function nonBlockingCallWrapper(result, callback)
{
	if(result.callId)
	{
		var id = result.callId;
		setTimeout(function(){
			service.pollCallStatus({
				params: [id],
				onSuccess: function(result) {
					nonBlockingCallWrapper(result, callback);
				},
				onException: function(e) {
					logAppendMessage('danger', e);
					return true;
				}
			});
		},1000);
	}
	else
		callback(result);
}

function bootstrap()
{
	if($("#gateways").length>0)
		reloadGateways();
	if($("#sessions").length>0)
		reloadSessions();
	if($("#status").length>0)
		reloadStatus();
	if($("#startScan").length>0)
		$("#startScan").click(startScan);
	if($("#network").length>0)
		startNetworkGraph();
}

var nodeInfo;
$(document).ready(function(){
	$("#gateways").hide();
	$("#sessions").hide();
	
	$(".navbar li.title").click(function(event) {
		event.preventDefault();
		$("#pageone-about").hide();
		$("#pageone-home").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.home").addClass("active");
	});
	
	$(".navbar li.home").click(function(event) {
		event.preventDefault();
		$("#pageone-about").hide();
		$("#pageone-home").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.home").addClass("active");
	});

	$(".navbar li.about").click(function(event) {
		event.preventDefault();
		$("#pageone-home").hide();
		$("#pageone-about").show();
		$(".navbar li.active").removeClass("active");
		$(".navbar li.about").addClass("active");
	});
	
	service.nodeInfo({
		params: [],
		onSuccess: function(result) {
			nonBlockingCallWrapper(result, function(result) {
				if(result.success==true)
{'fraction_non_alphanumeric': 0.23500741682559864, 'fraction_numerical': 0.012714558169103624, 'mean_word_length': 5.378378378378378, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 33, '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': '4075541', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1569, 'n_words': 253}