<commit_before>/*
 * Jappix Me - Your public profile, anywhere
 * Profile privacy page
 * 
 * License: AGPL
 * Author: <NAME>
 */


// XMPP connected handler
function handleConnected() {
	// Change status
	if(con && con.connected()) {
		// Stop waiter
		$('#content .step:not(.disabled) .stepped .status').removeClass('network').text('Connected.');

		// Disconnect from XMPP (not needed then)
		con.disconnect();
	}
	
	// Back button link
	$('#content .step .stepped a.button.back').attr('href', '/' + (con.username).htmlEnc() + '@' + (con.domain).htmlEnc());
	
	// Switch to next 2 steps!
	$('#content .step').eq(0).find('input').attr('disabled', true);
	$('#content .step').eq(0).addClass('disabled');
	$('#content .step').eq(1).removeClass('disabled');
	$('#content .step').eq(1).find('input').removeAttr('disabled');
	
	$('#content .step').eq(2).removeClass('disabled');
	$('#content .step').eq(2).find('button').removeAttr('disabled');
	
	if($('#content .step').eq(1).find('.saveit').is(':hidden'))
		$('#content .step').eq(1).find('.saveit').fadeIn('slow');
	
	window.location.hash = 'step2';
}

// XMPP error handler
function handleError() {
	$('#content .step:not(.disabled) .stepped .status').removeClass('network').text('Wrong credentials.');
	$('#content .step').eq(0).find('input').removeAttr('disabled');
}

// XMPP node public access
function rightsAccessNode(node, value, handler) {
	var iq = new JSJaCIQ();
	iq.setType('set');
	
	// Main elements
	var pubsub = iq.appendNode('pubsub', {'xmlns': NS_PUBSUB_OWNER});
	var configure = pubsub.appendChild(iq.buildNode('configure', {'node': node, 'xmlns': NS_PUBSUB}));
	var x = configure.appendChild(iq.buildNode('x', {'xmlns': NS_XDATA, 'type': 'submit'}));
	
	// Form type
	var field1 = x.appendChild(iq.buildNode('field', {'var': 'FORM_TYPE', 'type': 'hidden', 'xmlns': NS_XDATA}));
	field1.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, NS_PUBSUB_NC));
	
	// Access rights
	var field2 = x.appendChild(iq.buildNode('field', {'var': 'pubsub#access_model', 'xmlns': NS_XDATA}));
	field2.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, value));
	
	if(handler)
		con.send(iq, handler);
	else
		con.send(iq);
}

// Server bot creation request
function submitBot() {
	var app_url = $('#config input[name="app-url"]').val();

	// Send the bot a request
	$('#content .step:not(.disabled) .stepped .status').addClass('network').text('Sending to our bot…').show();
	
	// Read data
	var d_search = $('#content .step .stepped input[name=robots]:checked').val();
	var d_flagged = $('#content .step .stepped input[name=flagged]:checked').val();
	var d_microblog = $('#content .step .stepped input[name=microblog]:checked').val();
	var d_geoloc = $('#content .step .stepped input[name=geoloc]:checked').val();
	var d_update = $('#content .step .stepped input[name=update]').is(':checked') ? '1' : '0';
	var d_remove = $('#content .step .stepped input[name=remove]').is(':checked') ? '1' : '0';

	$.post('/privacy/bot', {usr: con.username, srv: con.domain, pwd: <PASSWORD>, search: d_search, flagged: d_flagged, microblog: d_microblog, geoloc: d_geoloc, update: d_update, remove: d_remove}, function(data) {
		// Any error?
		if(data != 'OK') {
			$('#content .step:not(.disabled) .stepped .status').removeClass('network').text(data);
			
			return;
		}
		<commit_msg>Job done notification on privacy<commit_after>/*
 * Jappix Me - Your public profile, anywhere
 * Profile privacy page
 * 
 * License: AGPL
 * Author: <NAME>
 */


// XMPP connected handler
function handleConnected() {
	// Change status
	if(con && con.connected()) {
		// Stop waiter
		$('#content .step:not(.disabled) .stepped .status').removeClass('network').text('Connected.');

		// Disconnect from XMPP (not needed then)
		con.disconnect();
	}
	
	// Back button link
	$('#content .step .stepped a.button.back').attr('href', '/' + (con.username).htmlEnc() + '@' + (con.domain).htmlEnc());
	
	// Switch to next 2 steps!
	$('#content .step').eq(0).find('input').attr('disabled', true);
	$('#content .step').eq(0).addClass('disabled');
	$('#content .step').eq(1).removeClass('disabled');
	$('#content .step').eq(1).find('input').removeAttr('disabled');
	
	$('#content .step').eq(2).removeClass('disabled');
	$('#content .step').eq(2).find('button').removeAttr('disabled');
	
	if($('#content .step').eq(1).find('.saveit').is(':hidden'))
		$('#content .step').eq(1).find('.saveit').fadeIn('slow');
	
	window.location.hash = 'step2';
}

// XMPP error handler
function handleError() {
	$('#content .step:not(.disabled) .stepped .status').removeClass('network').text('Wrong credentials.');
	$('#content .step').eq(0).find('input').removeAttr('disabled');
}

// XMPP node public access
function rightsAccessNode(node, value, handler) {
	var iq = new JSJaCIQ();
	iq.setType('set');
	
	// Main elements
	var pubsub = iq.appendNode('pubsub', {'xmlns': NS_PUBSUB_OWNER});
	var configure = pubsub.appendChild(iq.buildNode('configure', {'node': node, 'xmlns': NS_PUBSUB}));
	var x = configure.appendChild(iq.buildNode('x', {'xmlns': NS_XDATA, 'type': 'submit'}));
	
	// Form type
	var field1 = x.appendChild(iq.buildNode('field', {'var': 'FORM_TYPE', 'type': 'hidden', 'xmlns': NS_XDATA}));
	field1.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, NS_PUBSUB_NC));
	
	// Access rights
	var field2 = x.appendChild(iq.buildNode('field', {'var': 'pubsub#access_model', 'xmlns': NS_XDATA}));
	field2.appendChild(iq.buildNode('value', {'xmlns': NS_XDATA}, value));
	
	if(handler)
		con.send(iq, handler);
	else
		con.send(iq);
}

// Server bot creation request
function submitBot() {
	var app_url = $('#config input[name="app-url"]').val();

	// Send the bot a request
	$('#content .step:not(.disabled) .stepped .status').addClass('network').text('Sending to our bot…').show();
	
	// Read data
	var d_search = $('#content .step .stepped input[name=robots]:checked').val();
	var d_flagged = $('#content .step .stepped input[name=flagged]:checked').val();
	var d_microblog = $('#content .step .stepped input[name=microblog]:checked').val();
	var d_geoloc = $('#content .step .stepped input[name=geoloc]:checked').val();
	var d_update = $('#content .step .stepped input[name=update]').is(':checked') ? '1' : '0';
	var d_remove = $('#content .step .stepped input[name=remove]').is(':checked') ? '1' : '0';

	$.post('/privacy/bot', {usr: con.username, srv: con.domain, pwd: <PASSWORD>, search: d_search, flagged: d_flagged, microblog: d_microblog, geoloc: d_geoloc, update: d_update, remove: d_remove}, function(data) {
		// Any error?
		if(data != 'OK') {
			$('#content .step:not(.disabled) .stepped .status').removeClass('network').text(data);
			
			return;
		}
		
		// Job done!
		$('#content .step:not(.disabled) .stepped .status').removeClass('network').text('Done.');
		
{'fraction_non_alphanumeric': 0.22287649050493155, 'fraction_numerical': 0.0055939938171647285, 'mean_word_length': 4.938811188811189, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, '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': '5164798', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2299, 'n_words': 492}