|
@@ -6,7 +6,7 @@ unit JOB_Web;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- Classes, SysUtils, JOB_Shared, JOB_WAsm;
|
|
|
|
|
|
+ Classes, SysUtils, JOB_Shared, JOB_WAsm, JOB_JS;
|
|
|
|
|
|
type
|
|
type
|
|
IJSEvent = interface;
|
|
IJSEvent = interface;
|
|
@@ -17,7 +17,7 @@ type
|
|
|
|
|
|
TJSEventHandler = function(Event: IJSEventListenerEvent): boolean of object;
|
|
TJSEventHandler = function(Event: IJSEventListenerEvent): boolean of object;
|
|
|
|
|
|
- IJSEventTarget = interface
|
|
|
|
|
|
+ IJSEventTarget = interface(IJSObject)
|
|
['{1883145B-C826-47D1-9C63-47546BA536BD}']
|
|
['{1883145B-C826-47D1-9C63-47546BA536BD}']
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
end;
|
|
end;
|
|
@@ -25,6 +25,7 @@ type
|
|
{ TJSEventTarget }
|
|
{ TJSEventTarget }
|
|
|
|
|
|
TJSEventTarget = class(TJSObject,IJSEventTarget)
|
|
TJSEventTarget = class(TJSObject,IJSEventTarget)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSEventTarget; overload;
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -40,6 +41,7 @@ type
|
|
{ TJSNode }
|
|
{ TJSNode }
|
|
|
|
|
|
TJSNode = class(TJSEventTarget,IJSNode)
|
|
TJSNode = class(TJSEventTarget,IJSNode)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSNode; overload;
|
|
function GetInnerText: UnicodeString;
|
|
function GetInnerText: UnicodeString;
|
|
procedure SetInnerText(const AValue: UnicodeString);
|
|
procedure SetInnerText(const AValue: UnicodeString);
|
|
end;
|
|
end;
|
|
@@ -50,28 +52,50 @@ type
|
|
['{A160069E-378F-4B76-BE64-1979A28B9EEA}']
|
|
['{A160069E-378F-4B76-BE64-1979A28B9EEA}']
|
|
function childElementCount : Integer;
|
|
function childElementCount : Integer;
|
|
function firstElementChild : IJSElement;
|
|
function firstElementChild : IJSElement;
|
|
|
|
+ function Getid: UnicodeString;
|
|
function GetInnerHTML: UnicodeString;
|
|
function GetInnerHTML: UnicodeString;
|
|
function GetName: UnicodeString;
|
|
function GetName: UnicodeString;
|
|
|
|
+ function GetOuterHTML: UnicodeString;
|
|
function Get_ClassName: UnicodeString;
|
|
function Get_ClassName: UnicodeString;
|
|
|
|
+ procedure append(const aNode : IJSElement); overload;
|
|
|
|
+ procedure append(const aText : UnicodeString); overload;
|
|
|
|
+ procedure Setid(const AValue: UnicodeString);
|
|
procedure SetInnerHTML(const AValue: UnicodeString);
|
|
procedure SetInnerHTML(const AValue: UnicodeString);
|
|
procedure SetName(const AValue: UnicodeString);
|
|
procedure SetName(const AValue: UnicodeString);
|
|
|
|
+ procedure SetOuterHTML(const AValue: UnicodeString);
|
|
procedure Set_ClassName(const AValue: UnicodeString);
|
|
procedure Set_ClassName(const AValue: UnicodeString);
|
|
property Name: UnicodeString read GetName write SetName;
|
|
property Name: UnicodeString read GetName write SetName;
|
|
property _ClassName: UnicodeString read Get_ClassName write Set_ClassName;
|
|
property _ClassName: UnicodeString read Get_ClassName write Set_ClassName;
|
|
|
|
+ property id : UnicodeString read Getid write Setid;
|
|
property InnerHTML: UnicodeString read GetInnerHTML write SetInnerHTML;
|
|
property InnerHTML: UnicodeString read GetInnerHTML write SetInnerHTML;
|
|
|
|
+ property OuterHTML : UnicodeString read GetOuterHTML write SetOuterHTML;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TJSElement }
|
|
{ TJSElement }
|
|
|
|
|
|
TJSElement = class(TJSNode,IJSElement)
|
|
TJSElement = class(TJSNode,IJSElement)
|
|
- function childElementCount : Integer;
|
|
|
|
- function firstElementChild : IJSElement;
|
|
|
|
|
|
+ private
|
|
|
|
+ function Getid: UnicodeString;
|
|
function GetInnerHTML: UnicodeString;
|
|
function GetInnerHTML: UnicodeString;
|
|
function GetName: UnicodeString;
|
|
function GetName: UnicodeString;
|
|
|
|
+ function GetOuterHTML: UnicodeString;
|
|
function Get_ClassName: UnicodeString;
|
|
function Get_ClassName: UnicodeString;
|
|
|
|
+ procedure Setid(const AValue: UnicodeString);
|
|
procedure SetInnerHTML(const AValue: UnicodeString);
|
|
procedure SetInnerHTML(const AValue: UnicodeString);
|
|
procedure SetName(const AValue: UnicodeString);
|
|
procedure SetName(const AValue: UnicodeString);
|
|
|
|
+ procedure SetOuterHTML(const AValue: UnicodeString);
|
|
procedure Set_ClassName(const AValue: UnicodeString);
|
|
procedure Set_ClassName(const AValue: UnicodeString);
|
|
|
|
+ public
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSElement; overload;
|
|
|
|
+ procedure append(const aText : UnicodeString); overload;
|
|
|
|
+ procedure append(const aNode : IJSElement); overload;
|
|
|
|
+ function childElementCount : Integer;
|
|
|
|
+ function firstElementChild : IJSElement;
|
|
|
|
+ property Name : UnicodeString read GetName write SetName;
|
|
|
|
+ property _className : UnicodeString read Get_ClassName write Set_ClassName;
|
|
|
|
+ property id : UnicodeString read Getid write Setid;
|
|
|
|
+ property InnerHTML : UnicodeString read GetInnerHTML write SetInnerHTML;
|
|
|
|
+ property OuterHTML : UnicodeString read GetOuterHTML write SetOuterHTML;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ IJSEvent }
|
|
{ IJSEvent }
|
|
@@ -85,20 +109,33 @@ type
|
|
{ TJSEvent }
|
|
{ TJSEvent }
|
|
|
|
|
|
TJSEvent = class(TJSObject,IJSEvent)
|
|
TJSEvent = class(TJSObject,IJSEvent)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSEvent; overload;
|
|
function CurrentTargetElement: IJSElement;
|
|
function CurrentTargetElement: IJSElement;
|
|
function TargetElement: IJSElement;
|
|
function TargetElement: IJSElement;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { IJSUIEvent }
|
|
|
|
+
|
|
IJSUIEvent = interface(IJSEvent)
|
|
IJSUIEvent = interface(IJSEvent)
|
|
['{A1234998-5180-4905-B820-10FAB9B2DD12}']
|
|
['{A1234998-5180-4905-B820-10FAB9B2DD12}']
|
|
end;
|
|
end;
|
|
|
|
+
|
|
|
|
+ { TJSUIEvent }
|
|
|
|
+
|
|
TJSUIEvent = class(TJSEvent,IJSUIEvent)
|
|
TJSUIEvent = class(TJSEvent,IJSUIEvent)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSUIEvent; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { IJSMouseEvent }
|
|
|
|
+
|
|
IJSMouseEvent = interface(IJSUIEvent)
|
|
IJSMouseEvent = interface(IJSUIEvent)
|
|
['{B91DC727-1164-43AE-8481-55421D3148C4}']
|
|
['{B91DC727-1164-43AE-8481-55421D3148C4}']
|
|
end;
|
|
end;
|
|
|
|
+
|
|
|
|
+ { TJSMouseEvent }
|
|
|
|
+
|
|
TJSMouseEvent = class(TJSUIEvent,IJSMouseEvent)
|
|
TJSMouseEvent = class(TJSUIEvent,IJSMouseEvent)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSMouseEvent; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
TJSHTMLClickEventHandler = function(aEvent: IJSMouseEvent) : boolean of object;
|
|
TJSHTMLClickEventHandler = function(aEvent: IJSMouseEvent) : boolean of object;
|
|
@@ -107,24 +144,62 @@ type
|
|
|
|
|
|
IJSHTMLElement = interface(IJSElement)
|
|
IJSHTMLElement = interface(IJSElement)
|
|
['{D50E53E1-5B3B-4DA4-ACB0-1FD0DE32B711}']
|
|
['{D50E53E1-5B3B-4DA4-ACB0-1FD0DE32B711}']
|
|
|
|
+ function Gettitle: UnicodeString;
|
|
|
|
+ procedure Settitle(const AValue: UnicodeString);
|
|
procedure set_onclick(const h: TJSHTMLClickEventHandler);
|
|
procedure set_onclick(const h: TJSHTMLClickEventHandler);
|
|
|
|
+ property title: UnicodeString read Gettitle write Settitle;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TJSHTMLElement }
|
|
{ TJSHTMLElement }
|
|
|
|
|
|
TJSHTMLElement = class(TJSElement,IJSHTMLElement)
|
|
TJSHTMLElement = class(TJSElement,IJSHTMLElement)
|
|
|
|
+ private
|
|
|
|
+ function Gettitle: UnicodeString;
|
|
|
|
+ procedure Settitle(const AValue: UnicodeString);
|
|
|
|
+ public
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSHTMLElement; overload;
|
|
procedure set_onclick(const h: TJSHTMLClickEventHandler);
|
|
procedure set_onclick(const h: TJSHTMLClickEventHandler);
|
|
|
|
+ property title: UnicodeString read Gettitle write Settitle;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { IJSHTMLButtonElement }
|
|
|
|
+
|
|
|
|
+ IJSHTMLButtonElement = interface(IJSHTMLElement)
|
|
|
|
+ ['{81DC2F80-FEF4-4705-A6DC-A04B2E32B72D}']
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { TJSHTMLButtonElement }
|
|
|
|
+
|
|
|
|
+ TJSHTMLButtonElement = class(TJSHTMLElement,IJSHTMLButtonElement)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSHTMLButtonElement; overload;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { IJSHTMLDivElement }
|
|
|
|
+
|
|
|
|
+ IJSHTMLDivElement = interface(IJSHTMLElement)
|
|
|
|
+ ['{A02A19B2-85B6-4C96-9281-AF90459E1CEC}']
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ { TJSHTMLDivElement }
|
|
|
|
+
|
|
|
|
+ TJSHTMLDivElement = class(TJSHTMLElement,IJSHTMLDivElement)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSHTMLDivElement; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { IJSDocument }
|
|
|
|
+
|
|
IJSDocument = interface(IJSNode)
|
|
IJSDocument = interface(IJSNode)
|
|
['{CC3FB7C1-C4ED-4BBC-80AB-7B6C2989E026}']
|
|
['{CC3FB7C1-C4ED-4BBC-80AB-7B6C2989E026}']
|
|
|
|
+ function createElement(const tagName : UnicodeString) : IJSElement; overload;
|
|
function getElementById(const aID : UnicodeString) : IJSElement;
|
|
function getElementById(const aID : UnicodeString) : IJSElement;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TJSDocument }
|
|
{ TJSDocument }
|
|
|
|
|
|
TJSDocument = class(TJSNode,IJSDocument)
|
|
TJSDocument = class(TJSNode,IJSDocument)
|
|
- function getElementById(const aID : UnicodeString) : IJSElement;
|
|
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSDocument; overload;
|
|
|
|
+ function createElement(const tagName : UnicodeString) : IJSElement; overload;
|
|
|
|
+ function getElementById(const aID : UnicodeString) : IJSElement; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ IJSWindow }
|
|
{ IJSWindow }
|
|
@@ -138,6 +213,7 @@ type
|
|
{ TJSWindow }
|
|
{ TJSWindow }
|
|
|
|
|
|
TJSWindow = class(TJSObject,IJSWindow)
|
|
TJSWindow = class(TJSObject,IJSWindow)
|
|
|
|
+ class function Cast(Intf: IJSObject): IJSWindow; overload;
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
procedure addEventListener(const aName: UnicodeString; const aListener: TJSEventHandler);
|
|
procedure Alert(Const Msg: UnicodeString);
|
|
procedure Alert(Const Msg: UnicodeString);
|
|
end;
|
|
end;
|
|
@@ -169,8 +245,41 @@ begin
|
|
Result:=H.AllocBool(TJSEventHandler(aMethod)(Event));
|
|
Result:=H.AllocBool(TJSEventHandler(aMethod)(Event));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ TJSHTMLDivElement }
|
|
|
|
+
|
|
|
|
+class function TJSHTMLDivElement.Cast(Intf: IJSObject): IJSHTMLDivElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSHTMLDivElement.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TJSHTMLButtonElement }
|
|
|
|
+
|
|
|
|
+class function TJSHTMLButtonElement.Cast(Intf: IJSObject): IJSHTMLButtonElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSHTMLButtonElement.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TJSMouseEvent }
|
|
|
|
+
|
|
|
|
+class function TJSMouseEvent.Cast(Intf: IJSObject): IJSMouseEvent;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSMouseEvent.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TJSUIEvent }
|
|
|
|
+
|
|
|
|
+class function TJSUIEvent.Cast(Intf: IJSObject): IJSUIEvent;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSUIEvent.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TJSEventTarget }
|
|
{ TJSEventTarget }
|
|
|
|
|
|
|
|
+class function TJSEventTarget.Cast(Intf: IJSObject): IJSEventTarget;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSEventTarget.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TJSEventTarget.addEventListener(const aName: UnicodeString;
|
|
procedure TJSEventTarget.addEventListener(const aName: UnicodeString;
|
|
const aListener: TJSEventHandler);
|
|
const aListener: TJSEventHandler);
|
|
var
|
|
var
|
|
@@ -186,6 +295,21 @@ end;
|
|
|
|
|
|
{ TJSHTMLElement }
|
|
{ TJSHTMLElement }
|
|
|
|
|
|
|
|
+function TJSHTMLElement.Gettitle: UnicodeString;
|
|
|
|
+begin
|
|
|
|
+ Result:=ReadJSPropertyUnicodeString('title');
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TJSHTMLElement.Settitle(const AValue: UnicodeString);
|
|
|
|
+begin
|
|
|
|
+ WriteJSPropertyUnicodeString('title',AValue);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class function TJSHTMLElement.Cast(Intf: IJSObject): IJSHTMLElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSHTMLElement.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TJSHTMLElement.set_onclick(const h: TJSHTMLClickEventHandler);
|
|
procedure TJSHTMLElement.set_onclick(const h: TJSHTMLClickEventHandler);
|
|
var
|
|
var
|
|
cb1: TJOB_Method;
|
|
cb1: TJOB_Method;
|
|
@@ -200,6 +324,11 @@ end;
|
|
|
|
|
|
{ TJSEvent }
|
|
{ TJSEvent }
|
|
|
|
|
|
|
|
+class function TJSEvent.Cast(Intf: IJSObject): IJSEvent;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSEvent.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TJSEvent.CurrentTargetElement: IJSElement;
|
|
function TJSEvent.CurrentTargetElement: IJSElement;
|
|
begin
|
|
begin
|
|
Result:=ReadJSPropertyObject('currentTargetElement',TJSElement) as IJSElement;
|
|
Result:=ReadJSPropertyObject('currentTargetElement',TJSElement) as IJSElement;
|
|
@@ -212,6 +341,11 @@ end;
|
|
|
|
|
|
{ TJSNode }
|
|
{ TJSNode }
|
|
|
|
|
|
|
|
+class function TJSNode.Cast(Intf: IJSObject): IJSNode;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSNode.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TJSNode.GetInnerText: UnicodeString;
|
|
function TJSNode.GetInnerText: UnicodeString;
|
|
begin
|
|
begin
|
|
Result:=ReadJSPropertyUnicodeString('innerText');
|
|
Result:=ReadJSPropertyUnicodeString('innerText');
|
|
@@ -224,6 +358,41 @@ end;
|
|
|
|
|
|
{ TJSElement }
|
|
{ TJSElement }
|
|
|
|
|
|
|
|
+function TJSElement.Getid: UnicodeString;
|
|
|
|
+begin
|
|
|
|
+ Result:=ReadJSPropertyUnicodeString('id');
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TJSElement.GetOuterHTML: UnicodeString;
|
|
|
|
+begin
|
|
|
|
+ Result:=ReadJSPropertyUnicodeString('outerHTML');
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TJSElement.Setid(const AValue: UnicodeString);
|
|
|
|
+begin
|
|
|
|
+ WriteJSPropertyUnicodeString('id',AValue);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TJSElement.SetOuterHTML(const AValue: UnicodeString);
|
|
|
|
+begin
|
|
|
|
+ WriteJSPropertyUnicodeString('outerHTML',AValue);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class function TJSElement.Cast(Intf: IJSObject): IJSElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSElement.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TJSElement.append(const aText: UnicodeString);
|
|
|
|
+begin
|
|
|
|
+ InvokeJSNoResult('append',[aText]);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TJSElement.append(const aNode: IJSElement);
|
|
|
|
+begin
|
|
|
|
+ InvokeJSNoResult('append',[aNode]);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TJSElement.childElementCount: Integer;
|
|
function TJSElement.childElementCount: Integer;
|
|
begin
|
|
begin
|
|
Result:=ReadJSPropertyLongInt('childElementCount');
|
|
Result:=ReadJSPropertyLongInt('childElementCount');
|
|
@@ -266,6 +435,16 @@ end;
|
|
|
|
|
|
{ TJSDocument }
|
|
{ TJSDocument }
|
|
|
|
|
|
|
|
+class function TJSDocument.Cast(Intf: IJSObject): IJSDocument;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSDocument.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TJSDocument.createElement(const tagName: UnicodeString): IJSElement;
|
|
|
|
+begin
|
|
|
|
+ Result:=InvokeJSObjectResult('createElement',[tagName],TJSElement) as IJSElement;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TJSDocument.getElementById(const aID: UnicodeString): IJSElement;
|
|
function TJSDocument.getElementById(const aID: UnicodeString): IJSElement;
|
|
begin
|
|
begin
|
|
Result:=InvokeJSObjectResult('getElementById',[aID],TJSElement) as IJSElement;
|
|
Result:=InvokeJSObjectResult('getElementById',[aID],TJSElement) as IJSElement;
|
|
@@ -273,6 +452,11 @@ end;
|
|
|
|
|
|
{ TJSWindow }
|
|
{ TJSWindow }
|
|
|
|
|
|
|
|
+class function TJSWindow.Cast(Intf: IJSObject): IJSWindow;
|
|
|
|
+begin
|
|
|
|
+ Result:=TJSWindow.JOBCast(Intf);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TJSWindow.addEventListener(const aName: UnicodeString;
|
|
procedure TJSWindow.addEventListener(const aName: UnicodeString;
|
|
const aListener: TJSEventHandler);
|
|
const aListener: TJSEventHandler);
|
|
var
|
|
var
|
|
@@ -292,8 +476,8 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
initialization
|
|
initialization
|
|
- JSDocument:=TJSDocument.CreateFromID(JOBObjIdDocument);
|
|
|
|
- JSWindow:=TJSWindow.CreateFromID(JOBObjIdWindow);
|
|
|
|
|
|
+ JSDocument:=TJSDocument.JOBCreateFromID(JOBObjIdDocument);
|
|
|
|
+ JSWindow:=TJSWindow.JOBCreateFromID(JOBObjIdWindow);
|
|
finalization
|
|
finalization
|
|
JSDocument.Free;
|
|
JSDocument.Free;
|
|
JSWindow.Free;
|
|
JSWindow.Free;
|