DocumentObjectModel

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

TIP Sample Code

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")

Member Functions

Document:new

--------------------------------------------------------------------
 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,
}
; Map3DSystem.mcml.Document = Document;

constructor

syntax

function Document:new (o)

parameters

o  

Document:open

Opens a stream to collect the output from any document.write() or document.writeln() methods

syntax

function Document:open()

Document:close

Closes an output stream opened with the document.open() method, and displays the collected data

syntax

function Document:close()

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

function Document.write(self, code) 

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

function Document:flush() 

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

function Document.GetPageCtrl(self)

parameters

self  
Topic revision: r1 - 2008-02-29 - LiXizhi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback