?? pm.asp
字號:
<SCRIPT RUNAT=SERVER Language="JavaScript">
//*****************************************************************
// Microsoft Script Library
// Visual InterDev 6.0 Scripting Object Model framework for server.
//
// Copyright 1998 Microsoft Corporation. All Rights Reserved.
//*****************************************************************
//*****************************************************************
// function StartPageProcessing()
// This is the method which starts page processing.
// The following sequence of events will occur :
// 1. create thisPage object ( programming model object )
// 2. invoke all constructors on the page ( xxx_ctor functions )
// 3. fire 'oninit' events
// 4. fire 'onenter' events
// 5. dispatch to appropriate server method
// 6. return TRUE if processing is complete
// return FALSE to continue processing of page
//*****************************************************************
function StartPageProcessing()
{
if (typeof(thisPage) != 'object')
thisPage = new _SOMObject;
if (typeof(RuntimeObject) != 'undefined')
{
var ctors = RuntimeObject('*_ctor');
for (var name in ctors)
{ // invoke all constructor functions ( xxx_ctor functions )
if (typeof(ctors[name]) == 'function')
ctors[name]();
}
}
else
{ // display warning
var strWarning = '<br><hr><b>WARNING: Web server "' + Request.ServerVariables('SERVER_NAME') + '" requires an updated JSCRIPT.DLL.';
strWarning += '<br>The Visual InterDev 6.0 Scripting Object Model requires JSCRIPT.DLL Version 4.0.0.2405 or greater.';
Response.write(strWarning);
}
thisPage._objEventManager.fireEvent(PAGE_ONINIT);
thisPage._objEventManager.fireEvent(PAGE_ONENTER);
thisPage.dispatch();
if (!thisPage._bEndPageProcessing)
thisPage._objEventManager.fireEvent(PAGE_ONSHOW);
if (thisPage._bEndPageProcessing)
EndPageProcessing();
return thisPage._bEndPageProcessing;
}
//*****************************************************************
// function EndPageProcessing()
// This is the method which ends page processing.
// The following sequence of events will occur :
// 1. if execute method was invoked, do nothing
// 2. fire 'onexit' events
// 3. invoke all destructors on the page ( xxx_dtor methods )
// 4. if redirect defined, invoke redirect, otherwise
// 1. persist state in hidden field
//
//*****************************************************************
function EndPageProcessing()
{
if (typeof(thisPage) == 'object' && !thisPage._bExecuteMethodInvoked)
{
if (thisPage._objEventManager != null)
thisPage._objEventManager.fireEvent(PAGE_ONEXIT);
var dtors = RuntimeObject('*_dtor');
for (var name in dtors)
{ // invoke all destructor functions ( xxx_dtor functions )
if (typeof(dtors[name]) == 'function')
dtors[name]();
}
if (thisPage._redirect != '')
Response.redirect(thisPage._redirect);
thisPage._generateHiddenFields();
}
}
//*****************************************************************
// function _SOMObject()
// Constructor function for the 'thisPage' object.
// This object provides the programming model services for the
// page and is instantiated as the 'thisPage' object.
//
//*****************************************************************
function _SOMObject()
{
//events
PAGE_ONINIT = 'oninit';
PAGE_ONENTER = 'onenter';
PAGE_ONSHOW = 'onshow';
PAGE_ONEXIT = 'onexit';
//constants
PAGE_NAVIGATE = 'navigate';
PAGE_EXECUTE = 'execute';
//public members
this.createDE = _SOM_createDE;
this.dispatch = _SOM_dispatch;
this.invokeMethod = _SOM_invokeMethod;
this.navigateURL = _SOM_navigateURL;
this.registerMethod = _SOM_registerMethod;
this.registerVTable = _SOM_registerVTable;
this.setState = _SOM_setState;
this.getState = _SOM_getState;
this.persistState = _SOM_persistState;
this.unpersistState = _SOM_unpersistState;
this.isStatePersisted = _SOM_isStatePersisted;
this.advise = _SOM_advise;
this.unadvise = _SOM_unadvise;
this.startPageContent = _SOM_startPageContent;
this.endPageContent = _SOM_endPageContent;
this.isDHTMLBrowser = _SOM_isDHTMLBrowser;
this.firstEntered = (Request.Form('_method').Item == null);
//private members
this._dispatchGET = _SOM__dispatchGET;
this._dispatchPOST = _SOM__dispatchPOST;
this._buildURL = _SOM__buildURL;
this._extractValue = _SOM__extractValue;
this._generateHiddenFields = _SOM__generateHiddenFields;
this._bDECreated = false;
this._bPageContentStarted = false;
this._bEndPageProcessing = false;
this._bExecuteMethodInvoked = false;
this._vtableNavigate = null;
this._vtableExecute = null;
this._objState = this.unpersistState('thisPage');
if (this._objState == null)
this._objState = new Object;
this._objStateObjects = null;
this._location = escape(Request.ServerVariables('SCRIPT_NAME'));
this._redirect = '';
this._objEventManager = CreateEventManager();
this._objEventManager.adviseDefaultHandler('thisPage',PAGE_ONENTER);
this._objEventManager.adviseDefaultHandler('thisPage',PAGE_ONSHOW);
this._objEventManager.adviseDefaultHandler('thisPage',PAGE_ONEXIT);
this.registerMethod('_EM__onclientevent',_EM__onclientevent);
//scope implementation to _SOMObject constructor function
//*****************************************************************
// function _SOM_createDE()
// Create the data environment object as DE
//*****************************************************************
function _SOM_createDE()
{
if (!this._bDECreated)
{
DE = Server.CreateObject('DERuntime.DERuntime');
DE.Init(Application('DE'));
this._bDECreated = true;
}
}
//*****************************************************************
// function _SOM_dispatch()
// This function dispatches to the method indicated by the URL.
//*****************************************************************
function _SOM_dispatch()
{
var bDispatched = false;
var requestMethod = Request.ServerVariables('REQUEST_METHOD').Item;
if (requestMethod == 'GET')
bDispatched = this._dispatchGET();
else if (requestMethod == 'POST')
bDispatched = this._dispatchPOST();
// output client-side thisPage when navigating within this ASP
if (!this._bExecuteMethodInvoked && this._redirect == '')
this.startPageContent(0);
return bDispatched;
}
//*****************************************************************
// function _SOM_invokeMethod(url,method,args)
// This function navigates to the method indicated.
//*****************************************************************
function _SOM_invokeMethod(url,method,args)
{
this.navigateURL(this._buildURL(url,method,args));
}
//*****************************************************************
// function _SOM_navigateURL(url)
// This function navigates to the URL indicated.
//*****************************************************************
function _SOM_navigateURL(url)
{ // optimize to dispatch when URL is this file
this._redirect = url;
EndPageProcessing();
}
//*****************************************************************
// function _SOM_registerMethod(strName,fPtr,mType)
// Register the given name/function as an exported server method.
// The mType should indicate either PAGE_NAVIGATE or PAGE_EXECUTE
//*****************************************************************
function _SOM_registerMethod(strName,fPtr,mType)
{ // default mType = PAGE_NAVIGATE if not provided
if (typeof(strName) == 'string' && typeof(fPtr) == 'function')
{
if (mType == PAGE_EXECUTE)
{
if (this._vtableExecute == null)
this._vtableExecute = new Object;
this._vtableExecute[strName] = fPtr;
return true;
}
if (mType == PAGE_NAVIGATE || mType == null)
{
if (this._vtableNavigate == null)
this._vtableNavigate = new Object;
this._vtableNavigate[strName] = fPtr;
return true;
}
}
return false;
}
//*****************************************************************
// function _SOM_registerVTable(objVTable,mType)
// Register the given object of function ptrs as exported methods.
// The mType should indicate either PAGE_NAVIGATE or PAGE_EXECUTE
//*****************************************************************
function _SOM_registerVTable(objVTable,mType)
{ // default mType = PAGE_NAVIGATE if not provided
if (typeof(objVTable) == 'object')
{
if (mType == PAGE_EXECUTE)
{
if (this._vtableExecute == null)
this._vtableExecute = new Object;
for (var name in objVTable)
{
if (typeof(objVTable[name]) == 'function')
this._vtableExecute[name] = objVTable[name];
}
return true;
}
if (mType == PAGE_NAVIGATE || mType == null)
{
if (this._vtableNavigate == null)
this._vtableNavigate = new Object;
for (var name in objVTable)
{
if (typeof(objVTable[name]) == 'function')
this._vtableNavigate[name] = objVTable[name];
}
return true;
}
}
return false;
}
//*****************************************************************
// function _SOM_setState(strName,value)
// Stores the given value as state using the given name as a key.
//*****************************************************************
function _SOM_setState(strName,value)
{
if (this._objState == null)
this._objState = new Object;
this._objState[strName] = value;
}
//*****************************************************************
// function _SOM_getState(strName)
// Retrieves the given value for the state of given name.
//*****************************************************************
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.
//*****************************************************************
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -