-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zjednodušení načítání pomocí angular helperu
- Loading branch information
Ondřej Dušek
committed
Nov 11, 2015
1 parent
0620a3a
commit 98e3790
Showing
4 changed files
with
42 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1 @@ | ||
var system = require('system'), | ||
url = system.args[1], | ||
page = require('webpage').create(), | ||
log = require('./logger').create(), | ||
resourceManager = require('./resource-manager').create(page), | ||
loadWait = 50, | ||
loadHandle; | ||
|
||
setTimeout(function () { | ||
log.error('script timeout'); | ||
phantom.exit(1); | ||
}, 180e3); | ||
|
||
phantom.onError = function(msg) { | ||
log.error(msg); | ||
}; | ||
|
||
page.settings.loadImages = false; | ||
page.settings.resourceTimeout = 120e3; | ||
page.viewportSize = { | ||
width: 1024, | ||
height: 768 | ||
}; | ||
|
||
page.onError = function (msg) { | ||
log.error(msg); | ||
}; | ||
|
||
page.onConsoleMessage = function (msg) { | ||
log.warn('[console]', msg); | ||
}; | ||
|
||
page.onLoadStarted = function() { | ||
clearTimeout(loadHandle); | ||
}; | ||
|
||
page.onLoadFinished = function(status) { | ||
// redirect may start another loading | ||
loadHandle = setTimeout(function () { | ||
if (status !== 'success') { | ||
log.error('page loading failed'); | ||
log.error(page.url, url); | ||
phantom.exit(1); | ||
return; | ||
} | ||
log.info('waiting for resources...'); | ||
resourceManager.load(function () { | ||
log.info('loading finished'); | ||
system.stdout.write(page.content); | ||
phantom.exit(); | ||
}); | ||
}, loadWait); | ||
}; | ||
|
||
log.info('requesting', url); | ||
page.open(url); | ||
require('./script.js'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
var system = require('system'), | ||
page = require('webpage').create(), | ||
url = system.args[1]; | ||
|
||
phantom.addCookie({ | ||
name: 'cookieconsent_dismissed', | ||
value: 'yes', | ||
domain: '.chcipraci.cz' | ||
}); | ||
|
||
page.onError = function(msg) { | ||
system.stderr.write('error: '); | ||
system.stderr.writeLine(msg); | ||
}; | ||
|
||
page.onConsoleMessage = function (msg) { | ||
system.stderr.write('console: '); | ||
system.stderr.writeLine(msg); | ||
}; | ||
|
||
page.onCallback = function() { | ||
system.stdout.write(page.content); | ||
phantom.exit(); | ||
}; | ||
|
||
page.open(url, function(status) { | ||
if (status === 'fail') { | ||
phantom.exit(1); | ||
} | ||
|
||
page.evaluateAsync(function() { | ||
var element = document.querySelector('body'); | ||
if (window.angular) { | ||
angular.getTestability(element).whenStable(window.callPhantom); | ||
} else { | ||
window.callPhantom(); | ||
} | ||
}); | ||
}); |