PIMShell預定義並初始化了一些全域變數,這些變數可以直接在javascript代碼中訪問。其中,“page”是第一個全域變數,其他全域變數都直接或間接來自於它。這些變數的初始化類似於如下的代碼:
- /*
- enum
- */
- //behavior notify code
- var enum_behaviorNotify=
- {addprofile:9,addmarkup:10,addinit:11,addready:12,dispose:13};
- //cuteEvent eventClass id
- var enum_eventClassId=
- {delay:0,async:1,simple:2,asyncScript:3,data:4,catalog:5};
- //tray message
- var enum_trayMessageType={info:0,warning:1,error:2};
- var enum_trayMessageContentType={string:0,iframe:1,behavior:2};
- //plugins guid
- var enum_plugins_guid={
- empty:"{00000000-0000-0000-0000-000000000000}",
- theme:"{00000000-0000-0000-0000-000000000001}",
- system:"{00000000-0000-0000-0001-000000000000}",
- general:"{00000000-0000-0000-0001-000000000001}",
- safe:"{00000000-0000-0000-0001-000000000002}",
- help:"{00000000-0000-0000-0001-000000000003}"};
- /*
- variables
- */
- var clientContext=page.clientContext;
- var plugin=clientContext.plugin;
- var system=clientContext.plugin(enum_plugins_guid.system);
- var general=clientContext.plugin(enum_plugins_guid.general);
- var options=clientContext.options;
- var config=clientContext.config;
- var language=clientContext.language;
- var cuteEvent=clientContext.event;
- var dataManager=clientContext.dataManager;
- var trayMessage=clientContext.trayMessage;
- var remoteObject=clientContext.remoteObject;
- var profileManager=clientContext.profileManager;
- var profile=page.profile;
- //
- var root=page.root;
- //
- var Ajax=page.Ajax;
- var Sys=Ajax.Sys;
- var UI=Ajax.UI;
- var Net=Ajax.Net;
- var DomElement=UI.DomElement;
- var Timer=Sys.Timer;
- var String2=Sys.String;
- var XMLHttpManager=Net.XMLHttpManager;
- var PIMTools=page.PIMTools;
- var Tools=page.Tools;
- var Trace=null;
- if(root)
- Trace=root.trace;
- /*
- function
- */
- //
- function $(element)
- {
- return Sys.getElementById(element);
- }
- function $object(element)
- {
- return page.findControl(element);
- }
- function $F(element)
- {
- return Sys.getElementValue(element);
- }
- function $list(str,delimiter)
- {
- var __oList=Sys.List;
-
- if(typeof(delimiter)=="undefined")
- __oList.Split(str,",");
- else
- __oList.Split(str,delimiter);
-
- return __oList;
- }
關於如何通過VC++設定javascript中的全域變數,請參考文章: 走進PIMShell(2)--不再使用external擴充瀏覽器,兼談三種方案