Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/aimogen-pro/res/phantomjs/phantom-screenshot.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + "use strict";
2 + var page = require("webpage").create();
3 +
4 + var system = require("system");
5 + var args = system.args;
6 + var fs = require("fs");
7 + var timeout = 2000; // you can set default timeout
8 +
9 + var path = args[1];
10 + var url = args[2];
11 + var imageName = args[3];
12 + var w = parseInt(args[4]);
13 + var h = parseInt(args[5]);
14 + fs.changeWorkingDirectory("" + path);
15 + var height = 1080;
16 +
17 + if (isNaN(w)) {
18 + w = 1920; // you can set default width
19 + }
20 +
21 + if (h > 0) {
22 + height = h; // you can set default width
23 + }
24 + if(args[6] != 'default')
25 + {
26 + page.settings.userAgent = args[6];
27 + }
28 + if(args[7] != 'default')
29 + {
30 + document.cookie = args[7];
31 + }
32 + if(args[8] != 'default')
33 + {
34 + var xres = args[8].split(":");
35 + if(xres[1] != undefined)
36 + {
37 + page.settings.userName = xres[0];
38 + page.settings.password = xres[1];
39 + }
40 + }
41 + page.viewportSize = {
42 + width: w,
43 + height: height
44 + };
45 +
46 + if(system.args[10] != undefined && system.args[10] != 'default' && system.args[10] != '' && system.args[10] != null)
47 + {
48 + page.setContent("", encodeURI(url));
49 + var localStorageVar = system.args[10];
50 + localStorageVar = localStorageVar.replace(/\\/g, '');
51 + page.evaluate(function(localStorageVar) {
52 + localStorageVarx = localStorageVar.split(";");
53 + var k;
54 + for (k = 0; k < localStorageVarx.length; k++)
55 + {
56 + localx = localStorageVarx[k].split("=");
57 + if(localx[1] != undefined && localx[1] != '' && localx[1] != null)
58 + {
59 + localStorage.setItem(localx[0], localx[1]);
60 + }
61 + else
62 + {
63 + if(localx[0] != '')
64 + {
65 + localStorage.setItem(localx[0], '');
66 + }
67 + }
68 + }
69 + }, localStorageVar);
70 + }
71 + page.open(encodeURI(url), function() {
72 + if (h == 0) {
73 + h = page.evaluate(function(){
74 + return document.body.scrollHeight;
75 + });
76 + }
77 +
78 + page.viewportSize = {
79 + width: w,
80 + height: h
81 + };
82 +
83 + page.clipRect = {top: 0, left: 0, width: w, height: h};
84 + var system = require('system');
85 + if(system.args[9] !== undefined && system.args[9] != 'default')
86 + {
87 + var evalVar = system.args[9];
88 + evalVar = String(evalVar);
89 + evalVar = evalVar.replace(/\\/g, '');
90 + page.evaluate(function(evalVar) {
91 + eval(evalVar);
92 + }, evalVar);
93 + }
94 + window.setTimeout(function () {
95 + page.render(imageName+".jpg");
96 + console.log('OK!');
97 + phantom.exit();
98 + }, timeout);
99 +
100 + });
101 +
102 +