⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewnav.js

📁 关于网上汽车销售系统的详细编程项目实战实例
💻 JS
📖 第 1 页 / 共 4 页
字号:
/**
 * Actuate Corporation
 * Copyright (C) 2003 Actuate Corporation. All rights reserved.
 *
 * ViewNav.js - File contains code to display the Toolbar.
 */


///////////////////////////////////////////////////////////////////////////////
// Globals
///////////////////////////////////////////////////////////////////////////////

// URL REWRITE YOU MUST SET the following with <html:rewrite page="
var g_viewPageURL = '../servlet/ViewPage';
var g_printURL = 'print.jsp';
var g_downloadURL = 'saveas.jsp';

// cookie stuff
var g_cookieWritingEnabled = true;


// stuff
var ns4 = (document.layers)? true:false

var g_imageDir = "../images/viewer/";

var tb;

var theDownloadWindow = null;
var thePrintWindow = null;

var _top		= 0;
var _bottom		= 26;

var editValue = js_CurrentPage;   //js_CurrentPage from viewnav.achtml
var hiddenValue = editValue;

var g_cancelled = 0;

var g_tocScrollBarPositionX = 0;
var g_tocScrollBarPositionY = 0;

var g_tocCols		= "245,*";
var g_searchCols	= "350,*";
var g_reportCols	= "0,*";

var g_tocRows       = "*,0";// for IE only
var g_searchRows    = "0,*";// for IE only

var bDebugging		= false;

var currentButton	= -1;
var btnArray		= new Array();

var g_recycledReportLayersList;
var g_recycledSearchLayersList;

var g_areaIdList			= new Array();
var g_areaClassIdList		= new Array();
var g_hashIdList			= new Array();
var g_hashDisplayList		= new Array();
var g_hashClassIdList		= new Array();

var	g_searchIdList			= new Array();
var	g_searchDisplayList		= new Array();
var g_searchClassIdList		= new Array();
var	g_searchValueList		= new Array();
var	g_searchSelectedList	= new Array();

var g_balloonIdList			= new Array();

var g_scalingFactorValueList = new Array();

var g_searchPreviouslyOpen	= false;

var g_reportFrame;

var g_platform = navigator.platform;

var classLinkOff = "LinkOff";
var classLinkOver = "LinkOver";
var classLinkDisable = "LinkDisable";
var g_sessionID = "SessionID"

// Images used in the report frame during search. Needed here to preload before the search
// is conducted. Sometimes the image wouldn't be loaded in time when the mouse moves over
// an searchable item.
var imgHash		= g_imageDir + "img_hash8.gif";
var imgBlank	= g_imageDir + "img_blank.gif";

var noStyle1 = "Style sheets may be disabled in your browser.\n"
var noStyle2 = "Until style sheets are enabled, this report\n"
var noStyle3 = "may not be displayed as intended.\n"

// EXTERNALIZED RESOURCES USED IN JAVASCRIPT METHODS; INITIALLY DEFINED AS MISSING RESOURCES; UPDATED BY JSP
var ERRMSG_INVALID_PAGE_NUMBER = "Internal Error\nERRMSG_INVALID_PAGE_NUMBER: Missing Resource";

///////////////////////////////////////////////////////////////////////////////

function preLoadImage( imageNameStr )
{
	var imageObject = new Image();
	imageObject.src = imageNameStr;

	return imageObject;
}

///////////////////////////////////////////////////////////////////////////////

function onResize()
{
	var l = tb.layer;
	var cLeft, cRight, cTop, cBottom;

	cLeft = 0;
	cTop  = 0;

	if ( ns4 )
		cRight = 5000;
	else
		cRight = document.body.clientWidth;

	cBottom = _bottom;

	if ( ns4 )
	{
		l.clip.left		= cLeft;
		l.clip.right	= cRight;
		l.clip.top		= cTop;
		l.clip.bottom	= cBottom + 4;
		var NSVersion = parseFloat(window.navigator.appVersion);
		// Only need to do this for NS4.7
		if (NSVersion >= 4.7)
		{
			var replacementUrl = "../viewer/viewnavigation.jsp" + replaceDuplicateParams(js_ObjURL , "page" , hiddenValue);
			document.location.replace (replacementUrl);
		}
	}
	else
	{
		l.style.pixelWidth	= cRight - cLeft;
		l.style.pixelHeight = cBottom - cTop;
		l.style.clip		= "rect("+cTop+","+cRight+","+cBottom+","+cLeft+")";
	}
}

///////////////////////////////////////////////////////////////////////////////

function setCurrentButton( newValue )
{
	currentButton = newValue;
}

///////////////////////////////////////////////////////////////////////////////

function getCurrentButton()
{
	return currentButton;
}

///////////////////////////////////////////////////////////////////////////////

// Button class
var BTN_HAS_ACTION = 0;
var BTN_HAS_NOACTION = 1;
var TXT_OF="of";

function Button()
{
	this.Id = "";
	this.bName = "";
	this.bDescription = "";
	this.fState = "";
	this.fTwoState = "";
	this.bClassOn = "";
	this.bClassOff = "";
	this.bClassDown = "";
	this.bClassOver = "";

	this.sAlign = "";
	this.aCaptions = "";
	this.sToolTip = "";
	this.sClassName = "";

	this.btnType = BTN_HAS_ACTION;
	
	//USED ONLY FOR RETRIEVING PART
	this.editValue = "";
	this.convertBtnToHtml = convertBtnToHtml;
	
	//FOR NS4
	this.left = 0;
}

function convertBtnToHtml()
{
	var str = "";
	if (ns4)
	{
		if (this.btnType == BTN_HAS_ACTION) // DEFINE EVENT HANDLING FOR ALL BUTTONS EXCEPT 'RETRIEVING' (WHICH IS A LABEL ONLY)
		{
			str += "<b>"
				+ "<a id='" + this.Id
				+ "' name='" + this.bName 
				+ "' class='" + this.sClassName+"' " 
				+ this.sToolTip +" "
				+ " href='javascript:myVoid()' "
				+ "onClick='swapLinkClass(this, event, " + this.Id + "); return false;' "
				+ "onDragStart='return false;' "
				+ "onMouseOver='swapLinkClass(this, event, " + this.Id + ")' "
				+ "onMouseOut='swapLinkClass(this, event, " + this.Id + ")' "
				+ "onMouseDown='swapLinkClass(this, event, " + this.Id + "); return false;' "
				+ "onMouseUp='swapLinkClass(this, event, " + this.Id + ")'> "
				+ this.aCaptions
				+ "</a></b>";
		}
		else 
		{
			str += "<form name='form1' onSubmit='handlePageEdit(event); return false' action='javascript:myVoid()'>"
				+ "<font class='"+ this.sClassName + "'>"
				+ "<a id='" + this.Id+ "' name='" + this.bName +"'></a>"
				+ this.aCaptions
				+ "</font>"
				+ "&nbsp;&nbsp;"
				+ "<input type=text name='editThis' size=5 value=\"" + this.editValue + "\">"
				+ "<font class='"+ this.sClassName + "'>"
				+ "&nbsp;" + TXT_OF +"&nbsp;"+ js_TotalPages
				+ "</font>";
			if (!js_IsReportCompleted) str += "+";
			str += "&nbsp;&nbsp;&nbsp;&nbsp;" + getScalingFactorMenu()
				+ "</form>";
		}
	}
	else
	{
		str += "<td nowrap" + this.sAlign + ">&nbsp;&nbsp;" + ((this.btnType == BTN_HAS_NOACTION) ? "" : "<b>") // NO <B> BOLD STYLE FOR LABEL
			+ "<a id='" + this.Id
			+ "' name='" + this.bName 
			+ "' class='" + this.sClassName 
			+ "' style='text-decoration: none'"
			+ " " + this.sToolTip;

		if (this.btnType == BTN_HAS_ACTION) // DEFINE EVENT HANDLING FOR ALL BUTTONS EXCEPT 'RETRIEVING' (WHICH IS A LABEL ONLY)
		{
			str += "href='javascript:myVoid()' "
				 + "onClick='swapLinkClass(this, event, " + this.Id + "); return false;' "
				 + "onDragStart='return false;' "
				 + "onMouseOver='swapLinkClass(this, event, " + this.Id + ")' "
				 + "onMouseOut='swapLinkClass(this, event, " + this.Id + ")' "
				 + "onMouseDown='swapLinkClass(this, event, " + this.Id + "); return false;' "
				 + "onMouseUp='swapLinkClass(this, event, " + this.Id + ")'>";
			str += this.aCaptions;
			str += "</a></b>&nbsp;&nbsp;</td>";
		}
		else 
		{
			str += ">"; // DONT FORGET TO CLOSE THE OPEN '<a' TAG
			str += this.aCaptions;
			str += "</a>&nbsp;&nbsp;</td>";

			str += "<td nowrap><input type=text name='editThis' size=5 value=\"" + editValue + "\"></td>";
			str += "<td nowrap valign='middle'><FONT color='white'>&nbsp;" + TXT_OF +"&nbsp;"+ js_TotalPages;
			if (!js_IsReportCompleted) str += "+";
			str += "&nbsp;&nbsp;</FONT></td><td nowrap valign='middle'>&nbsp;&nbsp;" + getScalingFactorMenu() + "</td>";
		}
	}
	return str;
}


///////////////////////////////////////////////////////////////////////////////

function findButtonId( description )
{
	for ( var index = 0; index < btnArray.length; index++ )
	{
		if ( description == btnArray[index].bDescription )
		{
			return btnArray[index].Id;
		}
	}
	return -1;
}


function findButton (name)
{
	for ( var index = 0; index < btnArray.length; index++ )
	{
		if (name == btnArray[index].bName)
		{
			return btnArray[index];
		}
	}
	return false;
}

///////////////////////////////////////////////////////////////////////////////

function getCommonEvent( eventObject , thisObj)
{
	// Get event data
	commonEvent = new Object();

	// Get event type
	commonEvent.type = eventObject.type;

	// Get event source
	if ( ns4 )
	{
		commonEvent.source = eventObject.target;
		commonEvent.source.id = -1;
	}
	else
	{
		//commonEvent.source = getEventTarget(eventObject);
		commonEvent.source = thisObj;
	}

	// Get event button
	if ( ns4 )
	{
		commonEvent.button = eventObject.which;
	}
	else
	{
		commonEvent.button = eventObject.button;
	}

	// Get event altKey
	if ( ns4 )
	{
		commonEvent.altKey = eventObject.modifiers || Event.ALT_MASK;
	}
	else
	{
		commonEvent.altKey = eventObject.altKey;
	}

	// Get event ctrlKey
	if ( ns4 )
	{
		commonEvent.ctrlKey = eventObject.modifiers || Event.CONTROL_MASK;
	}
	else
	{
		commonEvent.ctrlKey = eventObject.ctrlKey;
	}

	// Get event shiftKey
	if ( ns4 )
	{
		commonEvent.shiftKey = eventObject.modifiers || Event.SHIFT_MASK;
	}
	else
	{
		commonEvent.shiftKey = eventObject.shiftKey;
	}

	// Get event mouse position
	if ( ns4 )
	{
		commonEvent.pageX	= eventObject.pageX;
		commonEvent.pageY	= eventObject.pageY;
		commonEvent.screenX = eventObject.screenX;
		commonEvent.screenY = eventObject.screenY;
	}
	else
	{
		commonEvent.pageX	= eventObject.clientX;
		commonEvent.pageY	= eventObject.clientY;
		commonEvent.screenX = eventObject.screenX;
		commonEvent.screenY = eventObject.screenY;
	}
	return commonEvent;
}

///////////////////////////////////////////////////////////////////////////////
function swapLinkClass(thisObj, event, id)
{
	if(id == -1)
		return;

	var targetLink;
	var newLink;

	//Get the common event data
	commonEvent = getCommonEvent(event, thisObj);
	targetLink = getLinkById(id);

	//Get the new image
	newLink = btnArray[id-1];


	//If the button is disabled, we don't need to do anything else.
	if (newLink && newLink.fState == "dis")
	{
		return;
	}

	//Get the new currentButton which is being clicked
	if (event.type == "mousedown")
	{
		currentButton = commonEvent.source.id.toString();
	}
	if (ns4 && (event.type == "click" || event.type == "mousedown"))
	{
		currentButton = id;
	}

	if ( bDebugging )
	{
		if ( id == 1 || id == 2 )
		{
			var element = new Option;
			element.text = "";
			element.text += " id = ";
			element.text += commonEvent.source.id.toString();
			element.text += " type = ";
			element.text += commonEvent.type;
			element.text += " button = ";
			element.text += commonEvent.button;
			element.text += " currentButton = ";
			element.text += currentButton;

			var cItems = parent.frames.toolbarframe.document.forms[0].elements[0].options.length;
			parent.frames.toolbarframe.document.forms[0].elements[0].options[cItems] = element;
		}
	}
	
	for ( var index = 0; index < btnArray.length; index++ )
	{
		if ((ns4) ? (id == btnArray[index].Id) : (commonEvent.source.id == btnArray[index].Id))
		{
			if (commonEvent.type == "mouseover")
			{
				if (currentButton == commonEvent.source.id)
				{
					if (newLink.fState != "on")
					{
						setClassName(targetLink, newLink.bClassDown);
					}
				}
				else if (currentButton == -1 && newLink.fState != "on")
				{
					setClassName(targetLink, newLink.bClassOver);
				}
			}
			else if (commonEvent.type == "mouseout")
			{
				if (newLink.fState != "on")
				{
					setClassName(targetLink, newLink.bClassOff);
				}

				if (!ns4)
					currentButton = -1;
			}
			else if ( commonEvent.type == "mousedown" )
			{
				if (newLink.fState != "on")
					setClassName(targetLink, newLink.bClassDown);
			}
			else if (commonEvent.type == "mouseup" || commonEvent.type == "click")
			{
				if ( currentButton != -1 && ((ns4) ? (currentButton == id) : (currentButton == commonEvent.source.id)))
				{
					if (newLink.fState == "on")
					{
						setClassName(targetLink, newLink.bClassOver);
						newLink.fState = "off";
					}
					else
					{
						if ( newLink.fTwoState )
						{
							setClassName(targetLink, newLink.bClassOn);
							newLink.fState = "on";
						}
						else
						{
							setClassName(targetLink, newLink.bClassOver);
						}
					}
					
					// Take the action.
					buttonClick( (ns4 ? id : commonEvent.source.id));
				}
			}
			else
			{
				setClassName(targetLink, newLink.bClassOff);
			}

			break;
		}
	}

	if ( event.type == "mouseup" || event.type == "click" )
	{
		currentButton = -1;
	}
}


///////////////////////////////////////////////////////////////////////////////


function disableToolBarButtons()
{
	//Disable the "Previous Page" and "First Page" buttons
	changeClass( findButtonId( "firstpage" ),    "disable" );
	changeClass( findButtonId( "previouspage" ), "disable" );

	//Disable the "Next Page" and "Last Page" buttons
	changeClass( findButtonId( "lastpage" ),     "disable" );
	changeClass( findButtonId( "nextpage" ),     "disable" );

	changeClass( findButtonId( "goto" ),         "disable" );
	changeClass( findButtonId( "search" ),       "disable" );
	changeClass( findButtonId( "download" ),     "disable" );
	changeClass( findButtonId( "print" ),        "disable" );

	if (!js_IsReportCompleted)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -