mirror of
https://github.com/vimagick/dockerfiles.git
synced 2024-12-23 01:39:27 +02:00
add position to frameData
This commit is contained in:
parent
e6ba069f84
commit
42de7f208c
@ -1,5 +1,6 @@
|
||||
|
||||
var webpage = require('webpage');
|
||||
var frame = require('./frame');
|
||||
|
||||
|
||||
function setCookies(page, cookies) {
|
||||
@ -40,22 +41,6 @@ function execScripts(page, scripts, arr) {
|
||||
}
|
||||
|
||||
|
||||
function frameData(page, data) {
|
||||
data.url = page.frameUrl;
|
||||
data.name = page.frameName;
|
||||
data.content = page.frameContent;
|
||||
data.childCount = page.framesCount;
|
||||
data.childFrames = [];
|
||||
for(var i=0; i<data.childCount; i++) {
|
||||
var node = {};
|
||||
data.childFrames.push(node);
|
||||
page.switchToFrame(i);
|
||||
frameData(page, node);
|
||||
page.switchToParentFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function urlopen(req, callback) {
|
||||
|
||||
var page = webpage.create();
|
||||
@ -201,7 +186,7 @@ function urlopen(req, callback) {
|
||||
execScripts(page, req.execScripts.postInjected, result.execScriptsOutput.postInjected);
|
||||
|
||||
var fdata = {};
|
||||
frameData(page, fdata);
|
||||
frame.frameData(page, fdata);
|
||||
fdata.content = null;
|
||||
result.frameData = fdata;
|
||||
page.switchToMainFrame();
|
||||
|
32
webkit/frame.js
Normal file
32
webkit/frame.js
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user