protected function getPhantomJsScript($targetFile)
{
return "\n var page = require('webpage').create();\n page.settings.javascriptEnabled = true;\n page.settings.resourceTimeout = " . $this->timeout . ';
page.viewportSize = { width: ' . $this->width . ', height: ' . ($this->height == 0 ? 1 : $this->height) . " };\n page.open('{$this->url}', function() {\n if (" . ($this->backgroundColor ? 'true' : 'false') . ") {\n page.evaluate(function() {\n var style = document.createElement('style'),\n text = document.createTextNode('body { background: {$this->backgroundColor} }');\n style.setAttribute('type', 'text/css');\n style.appendChild(text);\n document.head.insertBefore(style, document.head.firstChild);\n });\n }\n window.setTimeout(function(){\n page.render('{$targetFile}');\n phantom.exit();\n }, {$this->timeout});\n });\n ";
}