Location: PHPKode > projects > The Bug Genie > js/b2.js.php
<script type="text/javascript">

function buildContext(b_id, show_item)
{
	elem_ptr = document.getElementById('icon_release_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_addtoopen_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_retract_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_lock_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_unlock_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_default_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_edit_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_delete_text_' + b_id);
	elem_ptr.style.display = "none";
	elem_ptr = document.getElementById('icon_text_blank_' + b_id);
	elem_ptr.style.display = "none";

	elem_ptr = document.getElementById(show_item);
	elem_ptr.style.display = "";
}

function showBud(elem_id)
{
	elem_ptr = document.getElementById('bud_' + elem_id);
	elem_ptr_icon = document.getElementById('icon_' + elem_id);
	Effect.Appear('bud_' + elem_id, { duration: 0.5 });
	elem_ptr_icon.className = "imgtd_bud_hover";
}

function hideBud(elem_id)
{
	elem_ptr = document.getElementById('bud_' + elem_id);
	elem_ptr_icon = document.getElementById('icon_' + elem_id);
	Effect.Fade('bud_' + elem_id, { duration: 0.5 });
	elem_ptr_icon.className = "imgtd_bud";
}

function menuHover(elem_id)
{
	elem_ptr = document.getElementById('edit_issue_menu');
	elem_ptr.className == 'menu_item';
	elem_ptr = document.getElementById('progress_tracking_menu');
	elem_ptr.className == 'menu_item';
	elem_ptr = document.getElementById('workflow_actions_menu');
	elem_ptr.className == 'menu_item';
	elem_ptr = document.getElementById('log_menu');
	elem_ptr.className == 'menu_item';
	elem_ptr = document.getElementById('admin_actions_menu');
	elem_ptr.className == 'menu_item';
	elem_ptr = document.getElementById(elem_id);
	if (elem_ptr.className == 'menu_item')
	{
		elem_ptr.className = 'menu_item_hover';
	}
}

function menuUnhover(elem_id, force_unhover)
{
	if (elem_id == 'edit_issue_actions')
	{
		elem_ptr = document.getElementById('edit_issue_menu');
		if ((elem_ptr.className != 'menu_item_selected') || (force_unhover == 'yes'))
		{
			elem_ptr.className = 'menu_item';
		}
	}
	if (elem_id == 'progress_tracking_actions')
	{
		elem_ptr = document.getElementById('progress_tracking_menu');
		if ((elem_ptr.className != 'menu_item_selected') || (force_unhover == 'yes'))
		{
			elem_ptr.className = 'menu_item';
		}
	}
	if (elem_id == 'workflow_actions_actions')
	{
		elem_ptr = document.getElementById('workflow_actions_menu');
		if ((elem_ptr.className != 'menu_item_selected') || (force_unhover == 'yes'))
		{
			elem_ptr.className = 'menu_item';
		}
	}
	if (elem_id == 'log_actions')
	{
		elem_ptr = document.getElementById('log_menu');
		if ((elem_ptr.className != 'menu_item_selected') || (force_unhover == 'yes'))
		{
			elem_ptr.className = 'menu_item';
		}
	}
	if (elem_id == 'admin_actions_actions')
	{
		elem_ptr = document.getElementById('admin_actions_menu');
		if ((elem_ptr.className != 'menu_item_selected') || (force_unhover == 'yes'))
		{
			elem_ptr.className = 'menu_item';
		}
	}
}

function hideMenus(elem_id)
{
	if (elem_id != 'edit_issue_actions')
	{
		menuUnhover('edit_issue_actions', 'yes');
		elem_ptr = document.getElementById('edit_issue_actions');
		elem_ptr.style.display = "none";
	}
	if (elem_id != 'progress_tracking_actions')
	{
		menuUnhover('progress_tracking_actions', 'yes');
		elem_ptr = document.getElementById('progress_tracking_actions');
		elem_ptr.style.display = "none";
	}
	if (elem_id != 'workflow_actions_actions')
	{
		menuUnhover('workflow_actions_actions', 'yes');
		elem_ptr = document.getElementById('workflow_actions_actions');
		elem_ptr.style.display = "none";
	}
	if (elem_id != 'log_actions')
	{
		menuUnhover('log_actions', 'yes');
		elem_ptr = document.getElementById('log_actions');
		elem_ptr.style.display = "none";
	}
	if (elem_id != 'admin_actions_actions')
	{
		menuUnhover('admin_actions_actions', 'yes');
		elem_ptr = document.getElementById('admin_actions_actions');
		elem_ptr.style.display = "none";
	}
}

function showMenu(elem_id)
{
	elem_menu_item_id = elem_id + "_menu";
	elem_menu_item = document.getElementById(elem_menu_item_id);
	elem_menu = elem_id + "_actions";
	hideMenus(elem_menu);
	$(elem_menu).toggle();
	if (elem_menu_item.className == 'menu_item_hover')
	{
		elem_menu_item.className = 'menu_item_selected';
	}
	else
	{
		elem_menu_item.className = 'menu_item_hover';
	}
}

function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}

tinyMCE.init({
	theme : "advanced",
	mode : "none",
	plugins : "bbcode",
	theme_advanced_buttons1 : "bold,italic,underline,forecolor,|,bullist,numlist,blockquote,|,undo,redo,|,link,unlink",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "bottom",
	theme_advanced_toolbar_align : "left",
	theme_advanced_styles : "Code=bb_code;Quote=bb_quote",
	content_css : "<?php print BUGScontext::getB2path(); ?>themes/<?php print BUGSsettings::get('theme_name'); ?>/<?php print BUGSsettings::get('theme_name'); ?>.css",
	entity_encoding : "raw",
	add_unload_trigger : false,
	remove_linebreaks : false
});

function getUserStateList()
{
	new Ajax.Updater('user_statelist', '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?getuserstatelist=true', {
	asynchronous:true,
	method: "post"
	});
}

function setUserState(sid)
{
	new Ajax.Request('<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?getuserstatelist=true', {
	asynchronous:true,
	method: "post",
	parameters: {setuserstate: sid}
	});
}

function setEmailPrivacy(priv)
{
	new Ajax.Updater('account_email', '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?setemailprivacy=true', {
	asynchronous:true,
	method: "post",
	parameters: {setting: priv}
	});
}

function showFollowUps(priv)
{
	new Ajax.Updater('account_followups', '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?showfollowups=true', {
	asynchronous:true,
	method: "post",
	parameters: {setting: priv}
	});
}

function showAssigned(priv)
{
	new Ajax.Updater('account_showassigned', '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?showassigned=true', {
	asynchronous:true,
	method: "post",
	parameters: {setting: priv}
	});
}

function submitNewPassword()
{
	var params = Form.serialize('changepassword_form');
	new Ajax.Updater('password_changed_span', '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?change_password=true', {
	asynchronous:true,
	method: "post",
	parameters: params,
	evalScripts: true
	});
	Element.show('password_changed_span');
}

function addFriend(uname, rndno, u_id)
{
	new Ajax.Updater('friends_message_' + uname + '_' + rndno, '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?addfriend=true', {
	asynchronous:true,
	method: "post",
	parameters: {uid: u_id},
	onSuccess: function (addFriendSuccess) {
		new Ajax.Updater('friends_link_' + uname + '_' + rndno, '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?getfriendlink=true', {
		asynchronous:true,
		method: "get",
		parameters: {uid: u_id, rnd_no: rndno}
		});
	}
	});
}

function removeFriend(uname, rndno, u_id)
{
	new Ajax.Updater('friends_message_' + uname + '_' + rndno, '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?removefriend=true', {
	asynchronous:true,
	method: "post",
	parameters: {uid: u_id},
	onSuccess: function (addFriendSuccess) {
		new Ajax.Updater('friends_link_' + uname + '_' + rndno, '<?php echo BUGScontext::getB2path(); ?>ajax_handler.php?getfriendlink=true', {
		asynchronous:true,
		method: "get",
		parameters: {uid: u_id, rnd_no: rndno}
		});
	}
	});
}
function addComment(modl, t_type, t_id)
{
	tinyMCE.triggerSave();
	var params = Form.serialize('new_comment_form_' + modl + '_' + t_type + '_' + t_id);
	new Ajax.Request('ajax_handler.php', {
	asynchronous: true,
	method: "post",
	parameters: params,
	onLoading: function (something) {
		$('add_comment_indicator_' + modl + '_' + t_type + '_' + t_id).show();
	},
	onSuccess: function (something) {
		getComments(modl, t_type, t_id);
		Form.reset('new_comment_form_' + modl + '_' + t_type + '_' + t_id);
		Element.hide('addComment_' + modl + '_' + t_type + '_' + t_id);
		Element.show('addCommentLink_' + modl + '_' + t_type + '_' + t_id);
		$('add_comment_indicator_' + modl + '_' + t_type + '_' + t_id).hide();
	},
	onFailure: function (somethingelse) {
		alert('Your comment could not be added. Please try again.');
		$('add_comment_indicator_' + modl + '_' + t_type + '_' + t_id).hide();
	}
	});
}
function getComments(modl, t_type, t_id)
{
	new Ajax.Updater('comments_span_' + modl + '_' + t_type + '_' + t_id, 'ajax_handler.php?getcomments=true', {
	asynchronous:true,
	method: "post",
	evalScripts: true,
	parameters: { target_id: t_id, target_type: t_type, module: modl },
	insertion: Insertion.Top
	});
}

function editComment(cid, modl, t_type, t_id)
{
	new Ajax.Updater('comment_' + cid, 'ajax_handler.php?edit_comment=true', {
	asynchronous:true,
	method: "post",
	evalScripts: true,
	parameters: { comment_id: cid, target_id: t_id, target_type: t_type, module: modl } });
}

function getComment(cid, modl, t_type, t_id)
{
	new Ajax.Updater('comment_' + cid, 'ajax_handler.php?get_comment=true', {
	asynchronous:true,
	method: "post",
	evalScripts: true,
	parameters: { comment_id: cid, target_id: t_id, target_type: t_type, module: modl } });
}

function updateComment(cid, modl, t_type, t_id)
{
	tinyMCE.triggerSave();
	var params = Form.serialize('edit_comment_form_' + modl + '_' + t_type + '_' + t_id);
	new Ajax.Updater('comment_' + cid, 'ajax_handler.php?update_comment=true&comment_id=' + cid + '&target_id=' + t_id + '&target_type=' + t_type + '&module=' + modl, {
	asynchronous:true,
	method: "post",
	evalScripts: true,
	parameters: params,
	onSuccess: function (something) {
		tinyMCE.execCommand('mceRemoveControl', false, 'new_comment_comment_' + modl + '_' + t_type + '_' + t_id);
	},
	onFailure: function (somethingelse) {
		alert('Your comment could not be updated. Please try again.');
	}	
	});
}

function deleteComment(cid, modl, t_type, t_id, hash)
{
	new Ajax.Request('ajax_handler.php?delete_comment=true&pagehash=' + hash, {
	asynchronous:true,
	method: "post",
	evalScripts: true,
	parameters: { comment_id: cid, target_id: t_id, target_type: t_type, module: modl } });
	Element.hide('commentheader_' + cid);
	Element.hide('commentbody_' + cid);
	Element.show('deletedcomment_' + cid);
}

</script>
Return current item: The Bug Genie