1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-11-28 09:08:36 +02:00
dockerfiles/webkit/frame.js

33 lines
790 B
JavaScript
Raw Normal View History

2015-01-19 16:08:57 +02:00
function frameData(page, data) {
data.url = page.frameUrl;
data.name = page.frameName;
data.content = page.frameContent;
data.childCount = page.framesCount;
data.childFrames = [];
var posList = page.evaluate(framePosition);
for(var i=0; i<data.childCount; i++) {
var node = {};
node.position = posList[i];
data.childFrames.push(node);
page.switchToFrame(i);
frameData(page, node);
page.switchToParentFrame();
}
}
function framePosition() {
var nodes = document.getElementsByTagName('iframe');
var results = [];
for(var i=0; i<nodes.length; i++) {
var pos = nodes[i].getBoundingClientRect();
results.push(pos);
}
return results;
}
module.exports.frameData = frameData;