<commit_before>/**
 * Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

//-----------------------------------------------------------
//  Ensure we have our namespace
//-----------------------------------------------------------
if (!HUB) {
	var HUB = {};
}

//----------------------------------------------------------
// Project Component JS
//----------------------------------------------------------
if (!jq) {
	var jq = $;
}

HUB.Projects = {
	jQuery: jq,
		
	initialize: function() 
	{											
		// Fix up users with no JS
		HUB.Projects.fixJS();
		
		// Activate boxed content
		HUB.Projects.launchBox();
		
		// Add confirms
		HUB.Projects.addConfirms();
		
		// Reviewers
		HUB.Projects.addFiltering();
		
		// Fade-out status message
		HUB.Projects.addMessageFade();
	},
	
	addFiltering: function()
	{
		var $ = this.jQuery;
		// Browse projects - filtering
		$(".filterby").each(function(i, item) {
			$(item).on('change', function(e) {
				if ($('#browseForm')) {
					$('#browseForm').submit();
				}
			});
		});
	},

	addMessageFade: function()
	{
		var $ = this.jQuery;
		
		if ($("#status-msg").length > 0)
		{
			var keyupTimer = setTimeout((function() 
			{  
				if (!$("#status-msg").hasClass('ajax-loading') && $('#status-msg').html().trim() != '')
				{
					$("#status-msg").animate({opacity:0.0}, 2000, function() {
					    $('#status-msg').html('');
					});	
				}
			}), 4000);
		}		
	},
	
	addConfirms: function()
	{
		var $ = this.jQuery;

		// Confirm project delete delete
		if ($('#delproject').length)
		{
			$('#delproject').on('click', function(e) 
			{
				e.preventDefault();			
				HUB.Projects.addConfirm($('#delproject'), 
				'Are you sure you want to delete this project? <br />This is a permanent action and cannot be undone.', 
				'Yes, delete', 'No, do not delete');
			});
		}

		// Confirm revert
		if ($('#confirm-revert').length)
		{
			$('#confirm-revert').on('click', function(e) 
				{
					e.preventDefault();			
					HUB.Projects.addConfirm($('#confirm-revert'), 
					'Are you sure you want to revert this publication to draft mode?', 
					'Yes, revert', 'No, keep as pending');
			});
		}	
	},

	// Launch SqueezeBox with Ajax actions	
	launchBox: function() 
	{
		var $ = this.jQuery;
		var bWidth 	= 600;
		var bHeight = 500;
		var css 	= 'sbp-window';
		var cBtn	= 1;
		
		$('.showinbox').each(function(i, item) {
			// Clean up
			$(item).off('click');
			
			var href = $(item).attr('href');
			if (href.search('&no_html=1') == -1) {
				href = href + '&no_html=1';
			}
			if (href.search('&ajax=1') == -1) {
				href = href + '&ajax=1';
			}
			$(item).attr('href', href);	
			
			// TEX compiler view
			if ($(item).hasClass('tex-menu') || $(item).hasClass('box-expanded'))
			{
				bWidth = 800;
			}
						
			// Open box on click
			$(item).on('click', function(e) {
				e.preventDefault();
				
				// New publication process: fileselector
				if ($(this).hasClass('item-add'))
				{
					bWidth = 700;				
				}
				if ($(this).hasClass('nox'))
				{
					cBtn = 0;
				}		<commit_msg>[COM_PROJECTS] correct href in js<commit_after>/**
 * Copyright 2005-2009 by Purdue Research Foundation, West Lafayette, IN 47906.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

//-----------------------------------------------------------
//  Ensure we have our namespace
//-----------------------------------------------------------
if (!HUB) {
	var HUB = {};
}

//----------------------------------------------------------
// Project Component JS
//----------------------------------------------------------
if (!jq) {
	var jq = $;
}

HUB.Projects = {
	jQuery: jq,
		
	initialize: function() 
	{											
		// Fix up users with no JS
		HUB.Projects.fixJS();
		
		// Activate boxed content
		HUB.Projects.launchBox();
		
		// Add confirms
		HUB.Projects.addConfirms();
		
		// Reviewers
		HUB.Projects.addFiltering();
		
		// Fade-out status message
		HUB.Projects.addMessageFade();
	},
	
	addFiltering: function()
	{
		var $ = this.jQuery;
		// Browse projects - filtering
		$(".filterby").each(function(i, item) {
			$(item).on('change', function(e) {
				if ($('#browseForm')) {
					$('#browseForm').submit();
				}
			});
		});
	},

	addMessageFade: function()
	{
		var $ = this.jQuery;
		
		if ($("#status-msg").length > 0)
		{
			var keyupTimer = setTimeout((function() 
			{  
				if (!$("#status-msg").hasClass('ajax-loading') && $('#status-msg').html().trim() != '')
				{
					$("#status-msg").animate({opacity:0.0}, 2000, function() {
					    $('#status-msg').html('');
					});	
				}
			}), 4000);
		}		
	},
	
	addConfirms: function()
	{
		var $ = this.jQuery;

		// Confirm project delete delete
		if ($('#delproject').length)
		{
			$('#delproject').on('click', function(e) 
			{
				e.preventDefault();			
				HUB.Projects.addConfirm($('#delproject'), 
				'Are you sure you want to delete this project? <br />This is a permanent action and cannot be undone.', 
				'Yes, delete', 'No, do not delete');
			});
		}

		// Confirm revert
		if ($('#confirm-revert').length)
		{
			$('#confirm-revert').on('click', function(e) 
				{
					e.preventDefault();			
					HUB.Projects.addConfirm($('#confirm-revert'), 
					'Are you sure you want to revert this publication to draft mode?', 
					'Yes, revert', 'No, keep as pending');
			});
		}	
	},

	// Launch SqueezeBox with Ajax actions	
	launchBox: function() 
	{
		var $ = this.jQuery;
		var bWidth 	= 600;
		var bHeight = 500;
		var css 	= 'sbp-window';
		var cBtn	= 1;
		
		$('.showinbox').each(function(i, item) {
			// Clean up
			$(item).off('click');
			
			var href = $(item).attr('href');
			if (href.search('no_html=1') == -1)
			{
				if (href.indexOf('?') == -1)
				{
					href = href + '?no_html=1';
				}
				else
				{
					href = href + '&no_html=1';
				}
			}
			if (href.search('&ajax=1') == -1) {
				href = href + '&ajax=1';
			}
			$(item).attr('href', href);	
			
			// TEX compiler view
			if ($(item).hasClass('tex-menu') || $(item).hasClass('box-expanded'))
			{
				bWidth = 800;
			}
						
			// Open box on click
			$(item).on('click', function(e) {
				e.preventDefault();
				
				// New publication process: fileselector
				if ($(this).hasClass('item-add'))
				{
					bWidth = 700;				
				}
				if ($(this).hasClass('nox'))
				{
					cBtn = 0;
				}		
{'fraction_non_alphanumeric': 0.22139692468074015, 'fraction_numerical': 0.014855355746677092, 'mean_word_length': 2.1300978792822187, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1367701', 'n_tokens_mistral': 3044, 'n_tokens_neox': 2412, 'n_words': 661}