<commit_before>wn.downloadify = function(data, roles, me) {
	if(roles && roles.length && !has_common(roles, user_roles)) {
		msgprint("Export not allowed. You need " + wn.utils.comma_or(roles)
			+ " Role to export.");
		return;
	}
	wn.require("lib/js/lib/downloadify/downloadify.min.js");
	wn.require("lib/js/lib/downloadify/swfobject.js");
	
	var id = wn.dom.set_unique_id();
	var msgobj = msgprint('<p id="'+ id +'">You must have Flash 10 installed to \
		download this file.</p>');
	
	Downloadify.create(id ,{
		filename: function(){
			return me.title + '.csv';
		},
		data: function(){ 
			return wn.to_csv(data);
		},
		swf: 'lib/js/lib/downloadify/downloadify.swf',
		downloadImage: 'lib/js/lib/downloadify/download.png',
		onComplete: function(){ msgobj.hide(); },
		onCancel: function(){ msgobj.hide(); },
		onError: function(){ msgobj.hide(); },
		width: 100,
		height: 30,
		transparent: true,
		append: false			
	});	
}

wn.to_csv = function(data) {
	var res = [];
	$.each(data, function(i, row) {
		row = $.map(row, function(col) {
			return typeof(col)==="string" ? ('"' + col.replace(/"/g, '\"') + '"') : col;
		});
		res.push(row.join(","));
	});
	return res.join("\n");
}

wn.slickgrid_tools = {
	get_view_data: function(columns, dataView, filter) {
		var col_row = $.map(columns, function(v) { return v.name; });
		var res = [];
		var col_map = $.map(columns, function(v) { return v.field; });

		for (var i=0, len=dataView.getLength(); i<len; i++) {
			var d = dataView.getItem(i);
			var row = [];<commit_msg>escape string while exporting to csv<commit_after>wn.downloadify = function(data, roles, me) {
	if(roles && roles.length && !has_common(roles, user_roles)) {
		msgprint("Export not allowed. You need " + wn.utils.comma_or(roles)
			+ " Role to export.");
		return;
	}
	wn.require("lib/js/lib/downloadify/downloadify.min.js");
	wn.require("lib/js/lib/downloadify/swfobject.js");
	
	var id = wn.dom.set_unique_id();
	var msgobj = msgprint('<p id="'+ id +'">You must have Flash 10 installed to \
		download this file.</p>');
	
	Downloadify.create(id ,{
		filename: function(){
			return me.title + '.csv';
		},
		data: function(){ 
			return wn.to_csv(data);
		},
		swf: 'lib/js/lib/downloadify/downloadify.swf',
		downloadImage: 'lib/js/lib/downloadify/download.png',
		onComplete: function(){ msgobj.hide(); },
		onCancel: function(){ msgobj.hide(); },
		onError: function(){ msgobj.hide(); },
		width: 100,
		height: 30,
		transparent: true,
		append: false			
	});	
}

wn.to_csv = function(data) {
	var res = [];
	$.each(data, function(i, row) {
		row = $.map(row, function(col) {
			return typeof(col)==="string" ? ('"' + col.replace(/"/g, '""') + '"') : col;
		});
		res.push(row.join(","));
	});
	return res.join("\n");
}

wn.slickgrid_tools = {
	get_view_data: function(columns, dataView, filter) {
		var col_row = $.map(columns, function(v) { return v.name; });
		var res = [];
		var col_map = $.map(columns, function(v) { return v.field; });

		for (var i=0, len=dataView.getLength(); i<len; i++) {
			var d = dataView.getItem(i);
			var row = [];
{'fraction_non_alphanumeric': 0.20434641582873825, 'fraction_numerical': 0.0051897502432695424, 'mean_word_length': 3.8262910798122065, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5739314', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1152, 'n_words': 237}