Code: Select all
procedure SimpleDOMIteration3(const aDocument: ICefDomDocument;
var x, y, w, h: Integer; var t: String);
var
TempNode: ICefDomNode;
procedure ProcessNode(ANode: ICefDomNode);
var
Node: ICefDomNode;
begin
if ANode <> nil then
begin
Node := ANode.FirstChild;
while Node <> nil do
begin
if Node.HasElementAttribute('href') then
begin
t := Node.ElementInnerText;
x := Node.ElementBounds.x;
y := Node.ElementBounds.y;
w := Node.ElementBounds.width;
h := Node.ElementBounds.height;
if t = CourseTeeName then
Exit;
end;
ProcessNode(Node);
Node := Node.NextSibling;
end;
end;
end;
begin
try
if (aDocument <> nil) then
begin
TempNode := aDocument.GetElementById('gvCourses');
ProcessNode(TempNode);
end;
except
on e: exception do
if CustomExceptionHandler('SimpleDOMIteration3', e) then
raise;
end;
end;
procedure DOMVisitor_OnDocAvailable3(const browser: ICefBrowser;
const frame: ICefFrame; const document: ICefDomDocument);
var
x, y, w, h: Integer;
t: String;
TempMessage: ICefProcessMessage;
begin
x := 0;
y := 0;
w := 0;
h := 0;
t := '';
SimpleDOMIteration3(document, x, y, w, h, t);
try
TempMessage := TCefProcessMessageRef.New(MSGNAME_SEND_TEELIST_COORDINATES);
TempMessage.ArgumentList.SetString(0, IntToStr(x));
TempMessage.ArgumentList.SetString(1, IntToStr(y));
TempMessage.ArgumentList.SetString(2, IntToStr(w));
TempMessage.ArgumentList.SetString(3, IntToStr(h));
TempMessage.ArgumentList.SetString(4, t);
if (frame <> nil) and frame.IsValid then
frame.SendProcessMessage(PID_BROWSER, TempMessage);
finally
TempMessage := nil;
end;
end;
Code: Select all
procedure SimpleDOMIteration1(const aDocument: ICefDomDocument;
const searchclass: String; var x, y, w, h: Integer; var t: String);
var
TempNode: ICefDomNode;
procedure ProcessNode(ANode: ICefDomNode);
var
Node: ICefDomNode;
nodeclass, nodecourse: String;
begin
if ANode <> nil then
begin
Node := ANode.FirstChild;
while Node <> nil do
begin
nodeclass := Node.GetElementAttribute('class');
if nodeclass = searchclass then
begin
nodecourse := Node.ElementInnerText;
if nodecourse = CourseTeeName then
begin
t := nodecourse;
x := Node.ElementBounds.x;
y := Node.ElementBounds.y;
w := Node.ElementBounds.width;
h := Node.ElementBounds.height;
Exit;
end;
end;
ProcessNode(Node);
Node := Node.NextSibling;
end;
end;
end;
procedure DOMVisitor_OnDocAvailable1(const browser: ICefBrowser;
const frame: ICefFrame; const document: ICefDomDocument);
var
x, y, w, h: Integer;
t: String;
TempMessage: ICefProcessMessage;
begin
x := 0;
y := 0;
w := 0;
h := 0;
t := '';
SimpleDOMIteration1(document, 'item__name', x, y, w, h, t);
try
TempMessage := TCefProcessMessageRef.New(MSGNAME_SEND_COORDINATES);
TempMessage.ArgumentList.SetString(0, IntToStr(x));
TempMessage.ArgumentList.SetString(1, IntToStr(y));
TempMessage.ArgumentList.SetString(2, IntToStr(w));
TempMessage.ArgumentList.SetString(3, IntToStr(h));
TempMessage.ArgumentList.SetString(4, t);
if (frame <> nil) and frame.IsValid then
frame.SendProcessMessage(PID_BROWSER, TempMessage);
finally
TempMessage := nil;
end;
end;