<commit_before>/**
 * @package     hubzero-cms
 * @file        components/com_resources/tagbrowser.js
 * @copyright   Copyright 2005-2011 Purdue University. All rights reserved.
 * @license     http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
 */

//----------------------------------------------------------
// Establish the namespace if it doesn't exist
//----------------------------------------------------------
if (!HUB) {
	var HUB = {};
}

//----------------------------------------------------------
// Tag Browser
//----------------------------------------------------------
if (!jq) {
	var jq = $;
}

HUB.TagBrowser = {
	
	jQuery: jq,

	settings: {
	},
	
	//isIE: false,
	col1active: '',
	col2active: '',
	baseURI: 'index.php?option=com_resources&task=browser&no_html=1',

	detect: function() {
		var $ = this.jQuery;
		
		// simplify things
		var agent 	= navigator.userAgent.toLowerCase();
				
		// detect platform
		this.isMac		= (agent.indexOf('mac') != -1);
		this.isWin		= (agent.indexOf('win') != -1);
		this.isWin2k	= (this.isWin && (
				agent.indexOf('nt 5') != -1));
		this.isWinSP2	= (this.isWin && (
				agent.indexOf('xp') != -1 || 
				agent.indexOf('sv1') != -1));
		this.isOther	= (
				agent.indexOf('unix') != -1 || 
				agent.indexOf('sunos') != -1 || 
				agent.indexOf('bsd') != -1 ||
				agent.indexOf('x11') != -1 || 
				agent.indexOf('linux') != -1);
				
		// detect browser
		this.isSafari	= (agent.indexOf('safari') != -1);
		this.isSafari2 = (this.isSafari && (parseFloat(agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).substring(0,agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).indexOf(' '))) >=  300));
		this.isOpera	= (agent.indexOf('opera') != -1);
		this.isNN		= (agent.indexOf('netscape') != -1);
		this.isIE		= (agent.indexOf('msie') != -1);
		this.isFirefox	= (agent.indexOf('firefox') != -1);
		this.isCamino	= (agent.indexOf('camino') != -1);
		this.isMozilla	= (agent.indexOf('mozilla') != -1);
	},

	incompatible: function() {
		var $ = this.jQuery;
		
		$('tagbrowser').parentNode.removeChild(div);
		$('tbh2').parentNode.removeChild(tbh2);
	},

	nextLevel: function(type, input, input2, level, id, rid) {
		var com = this,
			$ = this.jQuery;

		if (level == 2) {
			if (HUB.TagBrowser.col2active != '' && $(HUB.TagBrowser.col2active)) {
				$(HUB.TagBrowser.col2active).removeClass('open');
			}
			var curractive = $('#'+id);
			curractive.addClass('open');
			HUB.TagBrowser.col2active = '#'+id;
		} else {
			if (HUB.TagBrowser.col1active!='') {
				var prevactive = $(HUB.TagBrowser.col1active);
				if (prevactive) {
					prevactive.removeClass('open');
				}
			}
			var curractive = $('#'+id);
			curractive.addClass('open');
			HUB.TagBrowser.col1active = '#'+id;
		}
		var sortby = '';
		if ($('#sortby')) {
			sortby = $('#sortby').val();
		}
		var filterby = '';
		var frm = document.getElementById('tagBrowserForm');
		if (frm && frm.filter) {
			for (var i=0; i < frm.filter.length; i++){
				if (frm.filter[i].checked) {
					filterby += '&filter[]='+frm.filter[i].value;
				}
			}
		}
		var url = HUB.TagBrowser.baseURI+'&type='+type+'&level='+level+'&input='+input+'&input2='+input2+'&id='+rid+'&sortby='+sortby+filterby;
		/*if(browser.isFirefox ==false && browser.isCamino==false && browser.isMozilla) {
			var ev = false;
		} else {
			var ev = true;
		}
		var myAjax = new Ajax(url, {
			method: 'get',
			update: $('level-'+level), 
			onSuccess: function(){
				if ($('rid')) {
					var r = $('rid').value;
					if ($('col2_'+r)) {
						$('col2_'+r).addClass('open');
					}
				}
			}, 
			evalScripts: ev
		}).request();*/
		
		$.get(url, {}, function(data) {
			$('#level-'+level).html(data);
			if ($('#rid')) {
				var r = $('#rid').val();
				if ($('#col2_'+r)) {
					$('#col2_'+r).addClass('open');
				}
			}
		});
	},
	
	changeSort: function() {
		var com = this,
			$ = this.jQuery;
			
		var type = $('#pretype').val();
		var k = $('#preinput2').val();
		var p = null;
		$("#level-1 .open").each(function(el) {
			p = el.attr('id');
		});
		var i = p.replace('col1_', '');
		i = (i == 'all') ? '' : i;
		
		HUB.TagBrowser.nextLevel(type, i, k, 2, p, 0);
	},
	
	sc: 0,<commit_msg>Fixed issue with changing sort value<commit_after>/**
 * @package     hubzero-cms
 * @file        components/com_resources/tagbrowser.js
 * @copyright   Copyright 2005-2011 Purdue University. All rights reserved.
 * @license     http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
 */

//----------------------------------------------------------
// Establish the namespace if it doesn't exist
//----------------------------------------------------------
if (!HUB) {
	var HUB = {};
}

//----------------------------------------------------------
// Tag Browser
//----------------------------------------------------------
if (!jq) {
	var jq = $;
}

HUB.TagBrowser = {
	
	jQuery: jq,

	settings: {
	},
	
	//isIE: false,
	col1active: '',
	col2active: '',
	baseURI: 'index.php?option=com_resources&task=browser&no_html=1',

	detect: function() {
		var $ = this.jQuery;
		
		// simplify things
		var agent 	= navigator.userAgent.toLowerCase();
				
		// detect platform
		this.isMac		= (agent.indexOf('mac') != -1);
		this.isWin		= (agent.indexOf('win') != -1);
		this.isWin2k	= (this.isWin && (
				agent.indexOf('nt 5') != -1));
		this.isWinSP2	= (this.isWin && (
				agent.indexOf('xp') != -1 || 
				agent.indexOf('sv1') != -1));
		this.isOther	= (
				agent.indexOf('unix') != -1 || 
				agent.indexOf('sunos') != -1 || 
				agent.indexOf('bsd') != -1 ||
				agent.indexOf('x11') != -1 || 
				agent.indexOf('linux') != -1);
				
		// detect browser
		this.isSafari	= (agent.indexOf('safari') != -1);
		this.isSafari2 = (this.isSafari && (parseFloat(agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).substring(0,agent.substring(agent.indexOf("applewebkit/")+"applewebkit/".length,agent.length).indexOf(' '))) >=  300));
		this.isOpera	= (agent.indexOf('opera') != -1);
		this.isNN		= (agent.indexOf('netscape') != -1);
		this.isIE		= (agent.indexOf('msie') != -1);
		this.isFirefox	= (agent.indexOf('firefox') != -1);
		this.isCamino	= (agent.indexOf('camino') != -1);
		this.isMozilla	= (agent.indexOf('mozilla') != -1);
	},

	incompatible: function() {
		var $ = this.jQuery;
		
		$('tagbrowser').parentNode.removeChild(div);
		$('tbh2').parentNode.removeChild(tbh2);
	},

	nextLevel: function(type, input, input2, level, id, rid) {
		var com = this,
			$ = this.jQuery;

		if (level == 2) {
			if (HUB.TagBrowser.col2active != '' && $(HUB.TagBrowser.col2active)) {
				$(HUB.TagBrowser.col2active).removeClass('open');
			}
			var curractive = $('#'+id);
			curractive.addClass('open');
			HUB.TagBrowser.col2active = '#'+id;
		} else {
			if (HUB.TagBrowser.col1active!='') {
				var prevactive = $(HUB.TagBrowser.col1active);
				if (prevactive) {
					prevactive.removeClass('open');
				}
			}
			var curractive = $('#'+id);
			curractive.addClass('open');
			HUB.TagBrowser.col1active = '#'+id;
		}
		var sortby = '';
		if ($('#sortby')) {
			sortby = $('#sortby').val();
		}
		var filterby = '';
		var frm = document.getElementById('tagBrowserForm');
		if (frm && frm.filter) {
			for (var i=0; i < frm.filter.length; i++){
				if (frm.filter[i].checked) {
					filterby += '&filter[]='+frm.filter[i].value;
				}
			}
		}
		var url = HUB.TagBrowser.baseURI+'&type='+type+'&level='+level+'&input='+input+'&input2='+input2+'&id='+rid+'&sortby='+sortby+filterby;
		/*if(browser.isFirefox ==false && browser.isCamino==false && browser.isMozilla) {
			var ev = false;
		} else {
			var ev = true;
		}
		var myAjax = new Ajax(url, {
			method: 'get',
			update: $('level-'+level), 
			onSuccess: function(){
				if ($('rid')) {
					var r = $('rid').value;
					if ($('col2_'+r)) {
						$('col2_'+r).addClass('open');
					}
				}
			}, 
			evalScripts: ev
		}).request();*/
		
		$.get(url, {}, function(data) {
			$('#level-'+level).html(data);
			if ($('#rid')) {
				var r = $('#rid').val();
				if ($('#col2_'+r)) {
					$('#col2_'+r).addClass('open');
				}
			}
		});
	},
	
	changeSort: function() {
		var com = this,
			$ = this.jQuery;
			
		var type = $('#pretype').val();
		var k = $('#preinput2').val();
		var p = null;
		$("#level-1 .open").each(function(i, el) {
			p = $(el).attr('id');
		});
		var i = p.replace('col1_', '');
		i = (i == 'all') ? '' : i;
		
		HUB.TagBrowser.nextLevel(type, i, k, 2, p, 0);
	},
	
	sc: 0,
{'fraction_non_alphanumeric': 0.2709434849018917, 'fraction_numerical': 0.015509340853013746, 'mean_word_length': 2.5363523057748236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6812282', 'n_tokens_mistral': 3571, 'n_tokens_neox': 3088, 'n_words': 521}