<commit_before>"use strict";
/* global app, define, templates, socket */

define('admin/plugins/category-sections', ['settings'], function(settings) {
	var admin = {};

	admin.init = function() {
		activateUI();
		$('#new').on('click', newSection);
		$('#save').on('click', saveSections);
	};

	function newSection() {
		templates.parse('admin/plugins/category-sections', 'sections', {sections: [{name: "Untitled Section", categories: []}]}, function(li) {
			$('.sections').append($(li));
			activateUI();
		});
	}

	function activateUI() {
		$('.section-sortable')
			.sortable({
				connectWith: '.section-sortable'
			})
			.droppable({
				accept: $('.category-selector')
			});

		$('.category-selector')
			.draggable({
				connectToSortable: '.section-sortable',
				distance: 10,
				helper: function(ev, ui) {
					$(ev.target).removeAttr('style');
				}
			});
	}

	function saveSections() {
		var sections = [];

		$('.sections .section').each(function() {
			var cids = [];

			$(this).find('.category-selector').each(function() {
				cids.push($(this).find('[name="cid"]').val());
			});

			sections.push({
				name: $(this).find('[name="name"]').val(),
				cids: cids
			});
		});

		console.log(sections);

		socket.emit('plugins.category-sections.save', sections, function(err) {
			if (err) {
				app.alertError(err.message);
			} else {
				app.alertSuccess('Successfully saved category sections');
			}
		});
	}

	return admin;
});<commit_msg>console.log<commit_after>"use strict";
/* global app, define, templates, socket */

define('admin/plugins/category-sections', ['settings'], function(settings) {
	var admin = {};

	admin.init = function() {
		activateUI();
		$('#new').on('click', newSection);
		$('#save').on('click', saveSections);
	};

	function newSection() {
		templates.parse('admin/plugins/category-sections', 'sections', {sections: [{name: "Untitled Section", categories: []}]}, function(li) {
			$('.sections').append($(li));
			activateUI();
		});
	}

	function activateUI() {
		$('.section-sortable')
			.sortable({
				connectWith: '.section-sortable'
			})
			.droppable({
				accept: $('.category-selector')
			});

		$('.category-selector')
			.draggable({
				connectToSortable: '.section-sortable',
				distance: 10,
				helper: function(ev, ui) {
					$(ev.target).removeAttr('style');
				}
			});
	}

	function saveSections() {
		var sections = [];

		$('.sections .section').each(function() {
			var cids = [];

			$(this).find('.category-selector').each(function() {
				cids.push($(this).find('[name="cid"]').val());
			});

			sections.push({
				name: $(this).find('[name="name"]').val(),
				cids: cids
			});
		});

		socket.emit('plugins.category-sections.save', sections, function(err) {
			if (err) {
				app.alertError(err.message);
			} else {
				app.alertSuccess('Successfully saved category sections');
			}
		});
	}

	return admin;
});
{'fraction_non_alphanumeric': 0.2210344827586207, 'fraction_numerical': 0.001379310344827586, 'mean_word_length': 3.6865912762520194, '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': '4094872', 'n_tokens_mistral': 1123, 'n_tokens_neox': 938, 'n_words': 157}