---++!! !DocumentObjectModel %TOC{title="Contents:"}% %STARTINCLUDE% ---++ a simple Document Object Model (DOM) in MCML | *Title* | a simple Document Object Model (DOM) in MCML | | *Author(s)* | LiXizhi | | *Date* | 2008/4/15 | | *File* | script/kids/3DMapSystemApp/MCML/DOM.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemApp/mcml/DOM.lua"); document = Map3DSystem.mcml.Document:new{}; -- common use examples local page = document:GetPageCtrl() page:SetNodeValue("username", "LiXizhi") local tmp = page:GetNodeValue("username") page:SetUIValue("company", "ParaEngine") local tmp = page:GetUIValue("company") </verbatim> ---+++ Member Functions ---++++ !Document:new <verbatim>-------------------------------------------------------------------- The Document object represents the entire MCML document and can be used to access all elements in a page. TODO: this is not used at moment -------------------------------------------------------------------- local Document = { -- Returns the domain name for the current document domain = nil, -- Returns the date and time a document was last modified lastModified = nil, -- Returns the title of the current document title = nil, -- Returns the URL of the current document URL = nil, -- gives direct access to the root mcml object, usually <pe:mcml> body = nil, -- text Buffer textbuffer_ = nil, }</verbatim>; Map3DSystem.mcml.Document = Document; constructor __syntax__ <verbatim>function Document:new (o)</verbatim> __parameters__ | *o* | | ---++++ !Document:open Opens a stream to collect the output from any document.write() or document.writeln() methods __syntax__ <verbatim>function Document:open()</verbatim> ---++++ !Document:close Closes an output stream opened with the document.open() method, and displays the collected data __syntax__ <verbatim>function Document:close()</verbatim> ---++++ !Document.write Writes HTML expressions or JavaScript code to a document tricky code: we can call document:write("hello") or document.write("hello"). they are the same. * _param_ __self__ : string or self. * _param_ __code__ : string __syntax__ <verbatim>function Document.write(self, code) </verbatim> __parameters__ | *self* | string or self. | | *code* | | ---++++ !Document:flush private: never call this function from MCML script yourself. This function is called automatically. flush all previous write operations to create a node * _return_ ____ : return nil or the root MCML node containing MCML node contents from previous write functions. The root node name is always "p" __syntax__ <verbatim>function Document:flush() </verbatim> __parameters__ | *return* | return nil or the root MCML node containing MCML node contents from previous write functions. The root node name is always "p" | ---++++ !Document.GetPageCtrl return the page control. document.GetPageCtrl() or document:GetPageCtrl() both works. __syntax__ <verbatim>function Document.GetPageCtrl(self)</verbatim> __parameters__ | *self* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback