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

📄 pm.asp

📁 网上商城的设计与实现
💻 ASP
📖 第 1 页 / 共 3 页
字号:
	function _SOM_getState(strName)
	{
		if (this._objState == null)
			return null;
			
		if (this._objState[strName] == null)
			return null;

		return this._objState[strName];
	}

	//*****************************************************************
	// function _SOM_persistState(strName,objState)
	//	Persists the given object as state using the given name as key.
	//	Current implementation will persist state in a hidden field at
	//	the end of the file via the _generateHiddenFields method.
	//*****************************************************************
	function _SOM_persistState(strName,objState)
	{
		if (typeof(strName) == 'string' && typeof(objState) == 'object' &&
			strName != '' && objState != null)
		{
			if (this._objStateObjects == null)
				this._objStateObjects = new Object;

			this._objStateObjects[strName] = objState;
			return true;
		}
		return false;
	}

	//*****************************************************************
	// function _SOM_unpersistState(strName)
	//	Retrieves a state object using the given name as a key.
	//	Current implementation retrieves state from a hidden field.
	//*****************************************************************
	function _SOM_unpersistState(strName)
	{
		if (typeof(strName) == 'string' && strName != '')
		{
			var strState = Request.Form('_' + strName + '_state').Item;
			if (strState != '' && strState != null)
			{
				var state = new Object;
				var nEq, nAmp, name, value;
				while (strState.length > 0)
				{
					nEq = strState.indexOf('=');
					nAmp = strState.indexOf('&');
					if (nAmp == -1)
						nAmp = strState.length + 1;
					name = strState.substring(0,nEq);
					value = strState.substring(nEq+1,nAmp);
					state[name] = unescape(value);
					strState = strState.substring(nAmp+1,strState.length);
				}
				return state;
			}
		}
		return null;
	}

	//*****************************************************************
	// function _SOM_isStatePersisted(strName)
	//	Returns TRUE if there exists a state for the given key name.
	//*****************************************************************
	function _SOM_isStatePersisted(strName)
	{
		if (typeof(strName) == 'string' && strName != '')
		{
			var strState = Request.Form('_' + strName + '_state').Item;
			if (strState != '' && strState != null)
				return true;
		}
		return false;
	}

	//*****************************************************************
	// function _SOM_advise()
	//	Allows others to advise for MSPM events.
	//*****************************************************************
	function _SOM_advise(strEvent,funcToCall,nPriority)
	{
		return this._objEventManager.advise(strEvent,funcToCall,nPriority);
	}

	//*****************************************************************
	// function _SOM_unadvise()
	//	Allows others to unadvise for MSPM events.
	//*****************************************************************
	function _SOM_unadvise(strEvent,nAdviseID)
	{	
		return this._objEventManager.unadvise(strEvent,nAdviseID);	
	}

	//*****************************************************************
	// function _SOM_startPageContent(bFormType)
	//	Output client-side MSPM and thisForm if requested.
	//						0	:	NO FORM
	//		'undefined' or	1	:	FORM method=POST
	//						2	:	FORM
	//*****************************************************************
	function _SOM_startPageContent(bFormType)
	{	
		if (!this._bPageContentStarted)
		{
			this._bPageContentStarted = true;
			var secondSlash;
			var webRoot = String(this._location);
			if ((secondSlash = webRoot.indexOf('/',1)) != -1)
				webRoot = webRoot.substring(0,secondSlash);
			else
				webRoot = '';
			var strHTML = '<' + 'SCRIPT LANGUAGE=JavaScript SRC="' + webRoot + '/_ScriptLibrary/pm.js"><' + '/SCRIPT>\n';
			strHTML += '<' + 'SCRIPT LANGUAGE=JavaScript>thisPage._location = "' + this._location + '";<' + '/SCRIPT>\n';

			if (typeof(bFormType) == 'undefined' || bFormType == 1)
				strHTML += '<FORM name=thisForm method=POST>' + '\n';
				//strHTML += '<FORM name=thisForm method=POST language=JAVASCRIPT onsubmit="return thisPage.formIsValid;">' + '\n';
			else if (bFormType == 2)
				strHTML += '<FORM name=thisForm language=JAVASCRIPT onsubmit="return false;">' + '\n';
			Response.Write(strHTML);	
		}
	}
	
	//*****************************************************************
	// function _SOM_endPageContent()
	//	Provided for user methods to end page processing and
	//	cancel processing of the 'show' part of the page.
	//*****************************************************************
	function _SOM_endPageContent()
	{	this._bEndPageProcessing = true;	}

	//*****************************************************************
	// function _SOM_isDHTMLBrowser()
	//	Return TRUE for those browsers which support DHTML.
	//	Currently this method looks for MSIE 4.x and 5.x.
	//*****************************************************************
	function _SOM_isDHTMLBrowser()
	{	
		if (typeof(this._isDHTMLBrowser) == 'undefined')
		{
			this._isDHTMLBrowser = false;
			var userAgent = String(Request.ServerVariables('HTTP_USER_AGENT'));
			if (userAgent.indexOf('MSIE 4.') != -1 ||
				userAgent.indexOf('MSIE 5.') != -1)
				this._isDHTMLBrowser = true;
		}
		return this._isDHTMLBrowser;
	}

	//*****************************************************************
	// function _SOM__dispatchGET()
	//	Dispatches methods invoked via an HTTP GET request.
	//*****************************************************************
	function _SOM__dispatchGET()
	{
		var methodname = Request.QueryString('_method').Item;

		var methodtype = Request.QueryString('_mtype').Item;
		if (methodtype == PAGE_EXECUTE)
		{
			// return if methodname is not provided
			if (methodname == '' || methodname == null)
				return false;
			if (this._vtableExecute != null && typeof(RSDispatch) == 'function')
			{
				this._bExecuteMethodInvoked = RSDispatch(this._vtableExecute,methodname);
				this._bEndPageProcessing = this._bExecuteMethodInvoked;
				return this._bExecuteMethodInvoked;
			}
			return false;
		}
		// default to show if methodname is not provided
		if (methodname == '' || methodname == null)
			methodname = 'show';
		// default to navigate if methodtype is not provided	
		if (methodtype != '' && methodtype != null && methodtype != PAGE_NAVIGATE)
			return false;
		if (this._vtableNavigate != null && typeof(this._vtableNavigate[methodname]) == 'function')
		{	// validate that function is part of this._vtableNavigate description
			// extract parameters and dispatch to this._vtableNavigate.methodname
			var params = '';
			var pcount = Request.QueryString('pcount').Item;
			if (pcount == '' || pcount == null) pcount = 0;
			// extract parameter values
			for (var i=0; i < pcount; i++)
			{
				var param = Request.QueryString('p'+i).Item;
				if (param == null)
					params += 'null';
				else
					params += 'Request.QueryString("p' + i + '").Item';
				if (i < pcount-1)
					params += ',';
			}
			var dispatch = 'this._vtableNavigate.' + methodname + '(' + params + ')';
			// validated against this._vtableNavigate, safe to eval on the server
			eval(dispatch);
			return true;
		}
		if (methodname == 'show')
			return true;
		return false;
	}

	//*****************************************************************
	// function _SOM__dispatchPOST()
	//	Dispatches methods invoked via an HTTP POST request.
	//*****************************************************************
	function _SOM__dispatchPOST()
	{
		var queryString = Request.Form('_method').Item;
		if (queryString == '' || queryString == null)
			return false;

		if (queryString.indexOf(this._location) != 0)
		{	// redirect to another page
			this._redirect = queryString;
			this._bEndPageProcessing = true;
			return true;
		}

		queryString += '&';
		var methodname = this._extractValue(queryString,'?_method');
		if (methodname == null)
			methodname = 'show';
		if (this._vtableNavigate != null && typeof(this._vtableNavigate[methodname]) == 'function')
		{	// validate that function is part of this._vtableNavigate description
			// extract parameters and dispatch to thisPage.Navigate.methodname
			var params = '';
			var pcount = this._extractValue(queryString,'pcount');
			if (pcount == null) pcount = 0;
			// extract parameter values
			for (var i=0; i < pcount; i++)
			{
				var param = this._extractValue(queryString,'p'+i);
				if (param == null)
					params += 'null';
				else
					params += 'unescape(this._extractValue(queryString,"p' + i + '"))';
				if (i < pcount-1)
					params += ',';
			}

			var dispatch = 'this._vtableNavigate.' + methodname + '(' + params + ')';
			// validated against this._vtableNavigate, safe to eval on the server
			eval(dispatch);
			return true;
		}
		if (methodname == 'show')
			return true;
		return false;
	}

	//*****************************************************************
	// function _SOM__buildURL(url,method,args)
	//	PRIVATE HELPER FUNCTION
	//	Create URL which represents call to given method.
	//*****************************************************************
	function _SOM__buildURL(url,method,args)
	{
		if (typeof(method) == 'string')
		{
			url += '?_method=' + method
			var params = '&pcount=0';
			if (typeof(args) != 'undefined' && args.length)
			{	// add parameters
				params = '&pcount=' + args.length 
				for (var i = 0; i < args.length; i++) 
				{
					var arg = args[i];
					params += '&p' + i + '=' + escape(arg);
				}
			}
			url += params;
		}
		return url;
	}

	//*****************************************************************
	// function _SOM__extractValue(s,name)
	//	PRIVATE HELPER FUNCTION
	//	Extracts the value of a name/value pair from the given string,
	//	if it conforms to the following format :  'name=value&'
	//*****************************************************************
	function _SOM__extractValue(s,name)
	{
		var chStart = s.indexOf(name + '=');
		if (chStart != -1)
		{
			chStart += name.length + 1;
			var chEnd = s.indexOf('&',chStart);
			if (chEnd == -1)
				chEnd = s.length + 1;
			return s.substring(chStart,chEnd);
		}
		return null;
	}

	//*****************************************************************
	// function _SOM__generateHiddenFields()
	//	PRIVATE HELPER FUNCTION
	//	Generates hidden fields for _method and all state that needs
	//	to be round-tripped to/from the client.
	//*****************************************************************
	function _SOM__generateHiddenFields()
	{
		var strHTML = '\n<' + 'INPUT type=hidden name="_method">\n';			
		this.persistState('thisPage',this._objState);
		if (this._objStateObjects != null)

⌨️ 快捷键说明

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