<commit_before>/*
posh 0.1
brought to you by http://vvvv.org
*/

var ws;
var sessionID = "session";
var ups;

window.onload = function() 
{
	hideConfig();

	// connect to WAMP server
	ab.connect("ws://LOCALIP:WEBSOCKETPORT",
	// WAMP session was established
	function (session) 
	{
		ws = session;
		sessionID = session.sessionid();
		$('#sessionID').text('Session ID: ' + sessionID);

		ws.subscribe("add", onAdd);
		ws.subscribe("updateattribute", onUpdateAttribute);
		ws.subscribe("updatecontent", onUpdateContent);
		ws.subscribe("remove", onRemove);
		ws.call("dump").then(dumpResult); 

		//load configs now that session is established
		var val = getCookie('ups');
		if (!val)
			val = parseInt($('#ups').val());
		setUpdatesPerSecond(val);
		ups = 1000 / val;

		var name = getCookie('sessionName');
		if (name)
			sendSessionName(name);
		else
			name = sessionID; 
		setSessionName(name);
		
		$('#config').css('color', 'black');
	},

	// WAMP session is gone
	function (code, reason) 
	{
		// things to do once the session fails
		log(reason);
		ws = null;
		
		$('#config').css('color', 'red');
	});
}

var editorTargetCall, overTargetCall;
$(document).ready(function()
{
	$(document).on("contextmenu", function(e){
		  return false;
	}); 
	
	//todo: svgterminal needs api to register shortcuts for which the default should be prevented
	//if simply preventing for all we cut ourselves out of default browser shortcuts
		
	$(document).on('keydown', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keydown', e.ctrlKey, e.shiftKey, e.altKey, e.which);
	});
	
	$(document).on('keyup', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keyup', e.ctrlKey, e.shiftKey, e.altKey, e.which);
	});
	
	//vvvv hosted IE does not send keydown/up, only keypress?
	$(document).on('keypress', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keypress', e.ctrlKey, e.shiftKey, e.altKey, String.fromCharCode(e.which));
		
		//don't scroll the page down on space
		if (e.keyCode == 32)
			e.originalEvent.preventDefault();
	});

	$('#svg').on('mousewheel', function(e)
	{
		if (overTargetCall)
		{
			ws.call(overTargetCall, e.originalEvent.wheelDelta / 120 + 100, sessionID);
			//prevent page fom scrolling
			return false;
		}
		
		return true;
	});
	
	$('#svg').on('mousedown', function(e)
	{
		hideConfig();
		$('#editor').blur();
	});
	
	$('#editor').on('keyup', function(e) 
	{  
		if (editorTargetCall)
		{
			if (e.keyCode == 13)
			{<commit_msg>removed hakc necessary for NWamp<commit_after>/*
posh 0.1
brought to you by http://vvvv.org
*/

var ws;
var sessionID = "session";
var ups;

window.onload = function() 
{
	hideConfig();

	// connect to WAMP server
	ab.connect("ws://LOCALIP:WEBSOCKETPORT",
	// WAMP session was established
	function (session) 
	{
		ws = session;
		sessionID = session.sessionid();
		$('#sessionID').text('Session ID: ' + sessionID);

		ws.subscribe("add", onAdd);
		ws.subscribe("updateattribute", onUpdateAttribute);
		ws.subscribe("updatecontent", onUpdateContent);
		ws.subscribe("remove", onRemove);
		ws.call("dump").then(dumpResult); 

		//load configs now that session is established
		var val = getCookie('ups');
		if (!val)
			val = parseInt($('#ups').val());
		setUpdatesPerSecond(val);
		ups = 1000 / val;

		var name = getCookie('sessionName');
		if (name)
			sendSessionName(name);
		else
			name = sessionID; 
		setSessionName(name);
		
		$('#config').css('color', 'black');
	},

	// WAMP session is gone
	function (code, reason) 
	{
		// things to do once the session fails
		log(reason);
		ws = null;
		
		$('#config').css('color', 'red');
	});
}

var editorTargetCall, overTargetCall;
$(document).ready(function()
{
	$(document).on("contextmenu", function(e){
		  return false;
	}); 
	
	//todo: svgterminal needs api to register shortcuts for which the default should be prevented
	//if simply preventing for all we cut ourselves out of default browser shortcuts
		
	$(document).on('keydown', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keydown', e.ctrlKey, e.shiftKey, e.altKey, e.which);
	});
	
	$(document).on('keyup', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keyup', e.ctrlKey, e.shiftKey, e.altKey, e.which);
	});
	
	//vvvv hosted IE does not send keydown/up, only keypress?
	$(document).on('keypress', function(e) 
	{
		//e.originalEvent.preventDefault();
		ws.call('keypress', e.ctrlKey, e.shiftKey, e.altKey, String.fromCharCode(e.which));
		
		//don't scroll the page down on space
		if (e.keyCode == 32)
			e.originalEvent.preventDefault();
	});

	$('#svg').on('mousewheel', function(e)
	{
		if (overTargetCall)
		{
			ws.call(overTargetCall, e.originalEvent.wheelDelta / 120, sessionID);
			//prevent page fom scrolling
			return false;
		}
		
		return true;
	});
	
	$('#svg').on('mousedown', function(e)
	{
		hideConfig();
		$('#editor').blur();
	});
	
	$('#editor').on('keyup', function(e) 
	{  
		if (editorTargetCall)
		{
			if (e.keyCode == 13)
			{
{'fraction_non_alphanumeric': 0.17515478330337528, 'fraction_numerical': 0.0057918913521070505, 'mean_word_length': 3.8107588856868397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2311390', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1705, 'n_words': 405}