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

📄 worklflowobject(9.0)_utils.js

📁 对web开发很有帮助的
💻 JS
📖 第 1 页 / 共 2 页
字号:
			result += ">";
		else
			result += txt.charAt(i);
		}

	return result;
	}

function FindForm(form, doc)
	{
	if ( g_theApp.isIE )
		return doc.forms[form];
	else if ( null != doc )
		{
		if ( null != doc.forms )
			{
			for ( i = 0 ; i < doc.forms.length ; i++ )
				{
				if ( form == doc.forms[i].name )
					return doc.forms[i];
				}
			}

		if ( null != doc.layers )
			{
			for ( i = 0 ; i < doc.layers.length ; i++ )
				{
				result = FindForm(form, doc.layers[i].document);

				if ( null != result )
					return result;
				}
			}
		}

	return null;
	}

function FindLayer(layer, doc)
	{
	var result = null;

	if ( g_theApp.isIE )
		return doc.all(layer);
	else if ( (null != doc) && (null != doc.layers) )
		{
		for ( i = 0 ; i < doc.layers.length ; i++ )
			{
			result = doc.layers[i];

			if ( layer == result.name )
				return result;

			result = FindLayer(layer, result.document);

			if ( null != result )
				return result;
			}
		}

	return null;
	}

function Unquote (str)
{
	var nStartIndex = 0;
	var nEndIndex = str.length;

	if (str.charAt (0) == '"')
	{
		nStartIndex = 1;
	}

	if (str.charAt (nEndIndex - 1) == '"')
	{
		nEndIndex -= 1;
	}

	return str.substring (nStartIndex, nEndIndex);
}

function ConvertXorYCoordinate(PosValue, OldMin, OldMax, NewMin, NewMax, MapBackwards)
{
//This is a simple conversion routine that changes from one system to another.
	var OldMid = (OldMax - OldMin) / 2;
	var NewMid = (NewMax - NewMin) / 2;
	var ConvertResult = 1 * PosValue;
	ConvertResult = ConvertResult - (OldMin + OldMid);
	ConvertResult = ConvertResult / OldMid;
	if(MapBackwards != 0)
	{
		ConvertResult = 0 - ConvertResult;
	}
	ConvertResult = ConvertResult * NewMid;
	ConvertResult = ConvertResult + (NewMin + NewMid);
	return ConvertResult;
}

function GoToURL (defURL)
{
	if ((g_theApp == null) || !SupportsXML () || (g_theApp.objParser == null))
	{
		if (defURL.indexOf ("javascript:") == 0)
		{
			// This is actually a function call, not a URL. 
			eval (defURL);
			return;
		}

		parent.location = defURL;
	}
}

var el;
function showMenu(pageID, shapeID) {

	if (SupportsXML ())
	{
		var shapeXML = FindShapeXML (pageID, shapeID);
		if (shapeXML != null)
		{
			CreateHLMenu (shapeXML);

			//ContextElement=window.event.srcElement;
			parent.frmPageView.menu1.style.leftPos += 10;
			parent.frmPageView.menu1.style.posLeft = event.clientX;
			parent.frmPageView.menu1.style.posTop = event.clientY;
			parent.frmPageView.menu1.style.display = "";

			var clientWidth = event.srcElement.document.body.clientWidth;
			var clientHeight = event.srcElement.document.body.clientHeight;

			var menuWidth = parseInt (parent.frmPageView.menu1.style.width);
			var margin = 10;

			// Figure out where to place the menu (X). 
			var menuX = event.clientX;
			if (event.clientX + parent.frmPageView.menu1.clientWidth > clientWidth)
			{
				menuX = clientWidth - parent.frmPageView.menu1.clientWidth - margin;
				if (menuX < margin)
				{
					menuX = margin;
				}
			}

			// Figure out where to place the menu (Y). 
			var menuY = event.clientY;
			if (event.clientY + parent.frmPageView.menu1.clientHeight > clientHeight)
			{
				menuY = clientHeight - parent.frmPageView.menu1.clientHeight - margin;
				if (menuY < margin)
				{
					menuY = margin;
				}
			}

			parent.frmPageView.menu1.style.posLeft = menuX;
			parent.frmPageView.menu1.style.posTop = menuY;

			parent.frmPageView.menu1.setCapture();

			event.cancelBubble = true;
		}
	}
}

function toggleMenu() {
	el=event.srcElement;
	if (el.className=="menuItem") {
	  el.className="highlightItem";
	} else if (el.className=="highlightItem") {
	  el.className="menuItem";
	}
}

function clickMenu()
{
	if (parent.frmPageView.menu1.style.display != "none")
	{
		parent.frmPageView.menu1.releaseCapture();
		parent.frmPageView.menu1.style.display="none";
		el=event.srcElement;
		if (el.doFunction != null) {
		 eval(el.doFunction);
		}
	}
}

function CreateHLMenu (shapeNode)
{
	// Create the HTML string. 
	var strHLMenuHTML = "";

	if (shapeNode != null)
	{
		// Look up all the Hyperlink nodes. 
		var hlColl = shapeNode.selectNodes ("Scratch/B/SolutionXML/HLURL:Hyperlinks/HLURL:Hyperlink");

		// Walk the list of Hyperlink nodes to generate the menu.
		var hlCount = hlColl.length;
		for (var count = 0; count < hlCount; count++)
		{
			var strDoFunction = "";
			var strDesc = "";
			var strAddress = "";

			var hlAddress = hlColl.item(count).selectSingleNode("HLURL:Address/textnode()");
			if (hlAddress != null && hlAddress.text.length > 0 && IsValidAddress (hlAddress.text))
			{
				strDoFunction = "'parent.location.href=";

				// Get the absolute URL. 
				var absoluteURL = hlColl.item(count).selectSingleNode("HLURL:AbsoluteURL/textnode()");
				if (g_theApp.DocHasBaseHL && absoluteURL != null && absoluteURL.text.length > 0)
				{
					// Use the absolute URL for our hyperlink. 
					strAddress = absoluteURL.text;
				}
				else
				{
					// Just use the address field. 
					strAddress = hlAddress.text;
				}

				strDoFunction += '"' + EscapePath (strAddress) + '"' + ";'";

				// Now try to get the description field. If empty, use the address as the description. 
				hlDesc = hlColl.item(count).selectSingleNode("HLURL:Description/textnode()");
				if (hlDesc != null && hlDesc.text.length > 0)
				{
					strDesc = hlDesc.text;
				}
				else
				{
					strDesc = strAddress;
				}
			}
			else // Address is not present, assume it's a link into a different page in this document. 
			{
				hlAddress = hlColl.item(count).selectSingleNode("HLURL:SubAddress/textnode()");
				if (hlAddress != null && hlAddress.text.length > 0)
				{
					strAddress = hlAddress.text;

					// Strip off the shape id (if present). 
					var pageShapeSep = strAddress.lastIndexOf ('/');
					if (pageShapeSep > 0)
					{
						strAddress = strAddress.substring (0, pageShapeSep);
					}

					strAddress = unescape(strAddress);

					var pageIndex = PageIndexFromName (strAddress);

					strDoFunction = "'GoToPage (" + pageIndex + ");'";

					// Just set the description to the page name as well. 
					strDesc = strAddress;
				}
			}

			if (strDoFunction.length > 0 && strDesc.length > 0)
			{
				strHLMenuHTML += "<div class='menuItem' doFunction=" + strDoFunction + ">";
				strHLMenuHTML += strDesc + "</div>";
			}
		}
	}

	parent.frmPageView.menu1.innerHTML = strHLMenuHTML;
}

function IsValidAddress (strAddress)
{
	var ret = false;

	if (strAddress != null && strAddress.length > 0)
	{
		var strFullPath = g_theApp.VisDocPath + g_theApp.VisDocName;

		if (strAddress != strFullPath &&
			strAddress != g_theApp.VisDocName)
		{
			// Points to something other than this file, go ahead 
			// and consider it valid. 
			ret = true;
		}
	}

	return ret;
}

function FindShapeXML (pageID, shapeID)
{
	var shapeObj = null;

	if (g_theApp != null && g_theApp.objParser != null)
	{
		// Get the Pages collection. 
		var pagesObj = g_theApp.objParser.selectSingleNode("VisioDocument/Pages");
		if(!pagesObj)
		{
			return null;
		}
		
		// Get the correct page. 
		var pageQuerryString = './/Page[@ID = "' + pageID + '"]';
		var pageObj = pagesObj.selectSingleNode(pageQuerryString);
		if(!pageObj)
		{
			return null;
		}

		// Get the correct shape.
		var shapeQuerryString = './/Shape[@ID = "' + shapeID + '"]';
		shapeObj = pageObj.selectSingleNode(shapeQuerryString);
	}

	return shapeObj;
}

function UpdateProps(pageID, shapeID)
{
	// Check to see if we should ignore this event. 
	if (window.event != null &&
		window.event.ctrlKey)
	{
		// If the control key is down, do nothing!
		return;
	}

	if (SupportsXML ())
	{
		var shape = FindShapeXML (pageID, shapeID);

		if (g_theApp.custPropEntryPoint != null)
			g_theApp.custPropEntryPoint (shape);
	}
}

function SupportsXML ()
{
	return (g_theApp != null && g_theApp.isIE && g_theApp.verIE >= 5.0);
}

function SupportsPriOutputType ()
{
	if (g_theApp.isIE)	// IE
	{
		return ((g_theApp.verIE >= g_theApp.PriFormatMinIE) && (g_theApp.PriFormatMinIE > 0.0));
	}
	else if (g_theApp.isNav)	// Nav
	{
		return ((g_theApp.verNav >= g_theApp.PriFormatMinNav) && (g_theApp.PriFormatMinNav > 0.0));
	}

	// Unsupported browser. 
	return false;
}

function EscapePath (strPath)
{
	var strResult = "";

	for ( var i = 0 ; i < strPath.length ; i++ )
	{
		if ( strPath.charAt(i) == '\\' )
		{
			strResult += "\\\\";
		}
		else
		{
			strResult += strPath.charAt(i);
		}
	}

	return strResult;
}

⌨️ 快捷键说明

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