<commit_before>/*!
 * Comments for MunkiReport
 * requires bootstrap-markdown.js (http://github.com/toopay/bootstrap-markdown)
 */
$(document).on('appReady', function(e, lang) {

	try{
		if(serial_number){}
	}
	catch(e){
		alert('Error: comment.js - No serial_number');
		return;
	}

	var addComment = function(){

			var section = $(this).data('section'),
				commentdiv = $(this).prev(),
				editor = '',
				saveComment = function(){

					// add parsed text to hidden field
					var html = editor.parseContent();
					$('#myModal input[name="html"]').val(html);

					// Get formdata
					var formData = $('#myModal form').serializeArray();
					
					// Save comment
					var jqxhr = $.post( baseUrl + "index.php?/module/comment/save", formData);

					jqxhr.done(function(data){

						console.log(commentdiv)
						// Update comment in page
						commentdiv.html(html);

						// Dismiss modal
						$('#myModal').modal('hide');
					})

				}

			$('#myModal .modal-body')
				.empty()
				.append($('<form>')
					.submit(saveComment)
					.append($('<input>')
						.attr('type', 'submit')
						.addClass('invisible'))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'serial_number')
						.val(serial_number))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'section')
						.val(section))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'html'))
					.append($('<div>')
						.addClass('form-group')
						.append($('<label>')
							.text(i18n.t("dialog.comment.label")))
						.append($('<textarea>')
							.attr('name', 'text')
							.attr('rows', 10)
							.addClass('form-control'))));

			$.getJSON( baseUrl + 'index.php?/module/comment/retrieve/' + serial_number + '/' + section, function( data ) {
				data.text = data.text || ''
				$('textarea').text(data.text)
				$('textarea').markdown({
					autofocus:false,
					savable:false,
					iconlibrary: 'fa',
					fullscreen:{enable:true},
					onShow: function(e){
						// Store a reference to the editor
						editor = e;
					}
				});
			});


			$('#myModal button.ok')
				.text(i18n.t("dialog.save"))
				.off()
				.click(saveComment);
			$('#myModal .modal-title').text(i18n.t("dialog.comment.add"));
			$('#myModal').modal('show');
		}

	// Comment toggle
	$('.comment-toggle')
		.empty()
		.off()
		.addClass('btn btn-default btn-sm pull-right')
		.click(function(){
			$($(this).data('target')).toggleClass('hide');
		})
		.append($('<i>')
			.addClass('fa fa-comment'))

	// If comments on this page, get comment data
	$('div.comment')
		.empty()
		.append(function(){
			var me = $(this),
				section = $(this).data('section');
			$.getJSON( baseUrl + 'index.php?/module/comment/retrieve/' + serial_number + '/' + section, function( data ) {
				data.html = data.html || 'No comments'
				me.html(data.html)
					.after($('<button>')
						.addClass('btn btn-default hidden-print')
						.data('section', section)
						.click(addComment)
						.text('Edit'))
			});
			
		});

});<commit_msg>Change js var for serial<commit_after>/*!
 * Comments for MunkiReport
 * requires bootstrap-markdown.js (http://github.com/toopay/bootstrap-markdown)
 */
$(document).on('appReady', function(e, lang) {

	try{
		if(serialNumber){}
	}
	catch(e){
		alert('Error: comment.js - No serialNumber');
		return;
	}

	var addComment = function(){

			var section = $(this).data('section'),
				commentdiv = $(this).prev(),
				editor = '',
				saveComment = function(){

					// add parsed text to hidden field
					var html = editor.parseContent();
					$('#myModal input[name="html"]').val(html);

					// Get formdata
					var formData = $('#myModal form').serializeArray();
					
					// Save comment
					var jqxhr = $.post( baseUrl + "index.php?/module/comment/save", formData);

					jqxhr.done(function(data){

						console.log(commentdiv)
						// Update comment in page
						commentdiv.html(html);

						// Dismiss modal
						$('#myModal').modal('hide');
					})

				}

			$('#myModal .modal-body')
				.empty()
				.append($('<form>')
					.submit(saveComment)
					.append($('<input>')
						.attr('type', 'submit')
						.addClass('invisible'))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'serial_number')
						.val(serialNumber))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'section')
						.val(section))
					.append($('<input>')
						.attr('type', 'hidden')
						.attr('name', 'html'))
					.append($('<div>')
						.addClass('form-group')
						.append($('<label>')
							.text(i18n.t("dialog.comment.label")))
						.append($('<textarea>')
							.attr('name', 'text')
							.attr('rows', 10)
							.addClass('form-control'))));

			$.getJSON( baseUrl + 'index.php?/module/comment/retrieve/' + serialNumber + '/' + section, function( data ) {
				data.text = data.text || ''
				$('textarea').text(data.text)
				$('textarea').markdown({
					autofocus:false,
					savable:false,
					iconlibrary: 'fa',
					fullscreen:{enable:true},
					onShow: function(e){
						// Store a reference to the editor
						editor = e;
					}
				});
			});


			$('#myModal button.ok')
				.text(i18n.t("dialog.save"))
				.off()
				.click(saveComment);
			$('#myModal .modal-title').text(i18n.t("dialog.comment.add"));
			$('#myModal').modal('show');
		}

	// Comment toggle
	$('.comment-toggle')
		.empty()
		.off()
		.addClass('btn btn-default btn-sm pull-right')
		.click(function(){
			$($(this).data('target')).toggleClass('hide');
		})
		.append($('<i>')
			.addClass('fa fa-comment'))

	// If comments on this page, get comment data
	$('div.comment')
		.empty()
		.append(function(){
			var me = $(this),
				section = $(this).data('section');
			$.getJSON( baseUrl + 'index.php?/module/comment/retrieve/' + serialNumber + '/' + section, function( data ) {
				data.html = data.html || 'No comments'
				me.html(data.html)
					.after($('<button>')
						.addClass('btn btn-default hidden-print')
						.data('section', section)
						.click(addComment)
						.text('Edit'))
			});
			
		});

});
{'fraction_non_alphanumeric': 0.21505376344086022, 'fraction_numerical': 0.002606712284131639, 'mean_word_length': 2.722862340812614, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '1533968', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2015, 'n_words': 372}