diff --git a/README.md b/README.md index e61d9f7..ed8a12b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Compiled on Raspbian Hardfloat. Instruction set: __armv6__ (compatible with all raspberry pi devices) -__Note__: Due to different versions of libraries for Rasbian prior to Stretch, you'll have to use the [master branch](https://github.com/piksel/phantomjs-raspberrypi/tree/master). +__Note__: Due to different versions of libraries for Rasbian prior to Stretch, you'll have to use the [jessie branch](https://github.com/piksel/phantomjs-raspberrypi/tree/jessie). __2017-09-09__: Compiled 2.1.1 for Raspbian Stretch __2017-06-26__: Compiled the first qt5 version: 2.1.1 @@ -15,4 +15,4 @@ __Dependencies__: `libicu57`, `libssl1.0.2`, `gstreamer0.10-base`, `fontconfig`, and `freetype2` To install them: -`sudo apt install libicu57 libssl1.0.2 gstreamer0.10-base fontconfig freetype2` +`sudo apt install libicu57 libssl1.0.2 gstreamer0.10-base fontconfig freetype2` \ No newline at end of file diff --git a/examples/arguments.coffee b/examples/arguments.coffee deleted file mode 100644 index 9502439..0000000 --- a/examples/arguments.coffee +++ /dev/null @@ -1,7 +0,0 @@ -system = require 'system' -if system.args.length is 1 - console.log 'Try to pass some args when invoking this script!' -else - for arg, i in system.args - console.log i + ': ' + arg -phantom.exit() diff --git a/examples/child_process-examples.coffee b/examples/child_process-examples.coffee deleted file mode 100644 index 47e9b50..0000000 --- a/examples/child_process-examples.coffee +++ /dev/null @@ -1,20 +0,0 @@ -{spawn, execFile} = require "child_process" - -child = spawn "ls", ["-lF", "/rooot"] - -child.stdout.on "data", (data) -> - console.log "spawnSTDOUT:", JSON.stringify data - -child.stderr.on "data", (data) -> - console.log "spawnSTDERR:", JSON.stringify data - -child.on "exit", (code) -> - console.log "spawnEXIT:", code - -#child.kill "SIGKILL" - -execFile "ls", ["-lF", "/usr"], null, (err, stdout, stderr) -> - console.log "execFileSTDOUT:", JSON.stringify stdout - console.log "execFileSTDERR:", JSON.stringify stderr - -setTimeout (-> phantom.exit 0), 2000 diff --git a/examples/colorwheel.coffee b/examples/colorwheel.coffee deleted file mode 100644 index 74866e1..0000000 --- a/examples/colorwheel.coffee +++ /dev/null @@ -1,46 +0,0 @@ -page = require('webpage').create() - -page.viewportSize = { width: 400, height : 400 } -page.content = '
' - -page.evaluate -> - el = document.getElementById 'surface' - context = el.getContext '2d' - width = window.innerWidth - height = window.innerHeight - cx = width / 2 - cy = height / 2 - radius = width / 2.3 - i = 0 - - el.width = width - el.height = height - imageData = context.createImageData(width, height) - pixels = imageData.data - - for y in [0...height] - for x in [0...width] - i = i + 4 - rx = x - cx - ry = y - cy - d = rx * rx + ry * ry - if d < radius * radius - hue = 6 * (Math.atan2(ry, rx) + Math.PI) / (2 * Math.PI) - sat = Math.sqrt(d) / radius - g = Math.floor(hue) - f = hue - g - u = 255 * (1 - sat) - v = 255 * (1 - sat * f) - w = 255 * (1 - sat * (1 - f)) - pixels[i] = [255, v, u, u, w, 255, 255][g] - pixels[i + 1] = [w, 255, 255, v, u, u, w][g] - pixels[i + 2] = [u, u, w, 255, 255, v, u][g] - pixels[i + 3] = 255 - - context.putImageData imageData, 0, 0 - document.body.style.backgroundColor = 'white' - document.body.style.margin = '0px' - -page.render('colorwheel.png') - -phantom.exit() diff --git a/examples/countdown.coffee b/examples/countdown.coffee deleted file mode 100644 index 821fc9f..0000000 --- a/examples/countdown.coffee +++ /dev/null @@ -1,8 +0,0 @@ -t = 10 -interval = setInterval -> - if t > 0 - console.log t-- - else - console.log 'BLAST OFF!' - phantom.exit() -, 1000 diff --git a/examples/detectsniff.coffee b/examples/detectsniff.coffee deleted file mode 100644 index b8d2719..0000000 --- a/examples/detectsniff.coffee +++ /dev/null @@ -1,42 +0,0 @@ -page = require('webpage').create() -system = require 'system' - -page.onInitialized = -> - page.evaluate -> - userAgent = window.navigator.userAgent - platform = window.navigator.platform - window.navigator = - appCodeName: 'Mozilla' - appName: 'Netscape' - cookieEnabled: false - sniffed: false - - window.navigator.__defineGetter__ 'userAgent', -> - window.navigator.sniffed = true - userAgent - - window.navigator.__defineGetter__ 'platform', -> - window.navigator.sniffed = true - platform - -if system.args.length is 1 - console.log 'Usage: detectsniff.coffeeasdfadsfycvx
- # - # - if page.evaluate(-> - typeof PhantomJSPrinting is "object" - ) - paperSize = page.paperSize - paperSize.header.height = page.evaluate(-> - PhantomJSPrinting.header.height - ) - paperSize.header.contents = phantom.callback((pageNum, numPages) -> - page.evaluate ((pageNum, numPages) -> - PhantomJSPrinting.header.contents pageNum, numPages - ), pageNum, numPages - ) - paperSize.footer.height = page.evaluate(-> - PhantomJSPrinting.footer.height - ) - paperSize.footer.contents = phantom.callback((pageNum, numPages) -> - page.evaluate ((pageNum, numPages) -> - PhantomJSPrinting.footer.contents pageNum, numPages - ), pageNum, numPages - ) - page.paperSize = paperSize - console.log page.paperSize.header.height - console.log page.paperSize.footer.height - window.setTimeout (-> - page.render output - phantom.exit() - ), 200 diff --git a/examples/printmargins.coffee b/examples/printmargins.coffee deleted file mode 100644 index 5be7ced..0000000 --- a/examples/printmargins.coffee +++ /dev/null @@ -1,33 +0,0 @@ -page = require("webpage").create() -system = require("system") -if system.args.length < 7 - console.log "Usage: printmargins.js URL filename LEFT TOP RIGHT BOTTOM" - console.log " margin examples: \"1cm\", \"10px\", \"7mm\", \"5in\"" - phantom.exit 1 -else - address = system.args[1] - output = system.args[2] - marginLeft = system.args[3] - marginTop = system.args[4] - marginRight = system.args[5] - marginBottom = system.args[6] - page.viewportSize = - width: 600 - height: 600 - - page.paperSize = - format: "A4" - margin: - left: marginLeft - top: marginTop - right: marginRight - bottom: marginBottom - - page.open address, (status) -> - if status isnt "success" - console.log "Unable to load the address!" - else - window.setTimeout (-> - page.render output - phantom.exit() - ), 200 diff --git a/examples/rasterize.coffee b/examples/rasterize.coffee deleted file mode 100644 index aa06dbd..0000000 --- a/examples/rasterize.coffee +++ /dev/null @@ -1,23 +0,0 @@ -page = require('webpage').create() -system = require 'system' - -if system.args.length < 3 or system.args.length > 4 - console.log 'Usage: rasterize.coffee URL filename [paperwidth*paperheight|paperformat]' - console.log ' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"' - phantom.exit 1 -else - address = system.args[1] - output = system.args[2] - page.viewportSize = { width: 600, height: 600 } - if system.args.length is 4 and system.args[2].substr(-4) is ".pdf" - size = system.args[3].split '*' - if size.length is 2 - page.paperSize = { width: size[0], height: size[1], border: '0px' } - else - page.paperSize = { format: system.args[3], orientation: 'portrait', border: '1cm' } - page.open address, (status) -> - if status isnt 'success' - console.log 'Unable to load the address!' - phantom.exit() - else - window.setTimeout (-> page.render output; phantom.exit()), 200 diff --git a/examples/render_multi_url.coffee b/examples/render_multi_url.coffee deleted file mode 100644 index 29afa48..0000000 --- a/examples/render_multi_url.coffee +++ /dev/null @@ -1,60 +0,0 @@ -# Render Multiple URLs to file - -system = require("system") - -# Render given urls -# @param array of URLs to render -# @param callbackPerUrl Function called after finishing each URL, including the last URL -# @param callbackFinal Function called after finishing everything -RenderUrlsToFile = (urls, callbackPerUrl, callbackFinal) -> - urlIndex = 0 # only for easy file naming - webpage = require("webpage") - page = null - getFilename = -> - "rendermulti-" + urlIndex + ".png" - - next = (status, url, file) -> - page.close() - callbackPerUrl status, url, file - retrieve() - - retrieve = -> - if urls.length > 0 - url = urls.shift() - urlIndex++ - page = webpage.create() - page.viewportSize = - width: 800 - height: 600 - - page.settings.userAgent = "Phantom.js bot" - page.open "http://" + url, (status) -> - file = getFilename() - if status is "success" - window.setTimeout (-> - page.render file - next status, url, file - ), 200 - else - next status, url, file - - else - callbackFinal() - - retrieve() -arrayOfUrls = null -if system.args.length > 1 - arrayOfUrls = Array::slice.call(system.args, 1) -else - # Default (no args passed) - console.log "Usage: phantomjs render_multi_url.js [domain.name1, domain.name2, ...]" - arrayOfUrls = ["www.google.com", "www.bbc.co.uk", "www.phantomjs.org"] - -RenderUrlsToFile arrayOfUrls, ((status, url, file) -> - if status isnt "success" - console.log "Unable to render '" + url + "'" - else - console.log "Rendered '" + url + "' at '" + file + "'" -), -> - phantom.exit() - diff --git a/examples/run-jasmine.coffee b/examples/run-jasmine.coffee deleted file mode 100644 index 22fb932..0000000 --- a/examples/run-jasmine.coffee +++ /dev/null @@ -1,61 +0,0 @@ -system = require 'system' - -## -# Wait until the test condition is true or a timeout occurs. Useful for waiting -# on a server response or for a ui change (fadeIn, etc.) to occur. -# -# @param testFx javascript condition that evaluates to a boolean, -# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or -# as a callback function. -# @param onReady what to do when testFx condition is fulfilled, -# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or -# as a callback function. -# @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used. -## -waitFor = (testFx, onReady, timeOutMillis=3000) -> - start = new Date().getTime() - condition = false - f = -> - if (new Date().getTime() - start < timeOutMillis) and not condition - # If not time-out yet and condition not yet fulfilled - condition = (if typeof testFx is 'string' then eval testFx else testFx()) #< defensive code - else - if not condition - # If condition still not fulfilled (timeout but condition is 'false') - console.log "'waitFor()' timeout" - phantom.exit 1 - else - # Condition fulfilled (timeout and/or condition is 'true') - console.log "'waitFor()' finished in #{new Date().getTime() - start}ms." - if typeof onReady is 'string' then eval onReady else onReady() #< Do what it's supposed to do once the condition is fulfilled - clearInterval interval #< Stop this interval - interval = setInterval f, 100 #< repeat check every 100ms - -if system.args.length isnt 2 - console.log 'Usage: run-jasmine.coffee URL' - phantom.exit 1 - -page = require('webpage').create() - -# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") -page.onConsoleMessage = (msg) -> - console.log msg - -page.open system.args[1], (status) -> - if status isnt 'success' - console.log 'Unable to access network' - phantom.exit() - else - waitFor -> - page.evaluate -> - if document.body.querySelector '.finished-at' - return true - return false - , -> - page.evaluate -> - console.log document.body.querySelector('.description').innerText - list = document.body.querySelectorAll('.failed > .description, .failed > .messages > .resultMessage') - for el in list - console.log el.innerText - - phantom.exit() diff --git a/examples/run-qunit.coffee b/examples/run-qunit.coffee deleted file mode 100644 index dcb24b9..0000000 --- a/examples/run-qunit.coffee +++ /dev/null @@ -1,64 +0,0 @@ -system = require 'system' - -## -# Wait until the test condition is true or a timeout occurs. Useful for waiting -# on a server response or for a ui change (fadeIn, etc.) to occur. -# -# @param testFx javascript condition that evaluates to a boolean, -# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or -# as a callback function. -# @param onReady what to do when testFx condition is fulfilled, -# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or -# as a callback function. -# @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used. -## -waitFor = (testFx, onReady, timeOutMillis=3000) -> - start = new Date().getTime() - condition = false - f = -> - if (new Date().getTime() - start < timeOutMillis) and not condition - # If not time-out yet and condition not yet fulfilled - condition = (if typeof testFx is 'string' then eval testFx else testFx()) #< defensive code - else - if not condition - # If condition still not fulfilled (timeout but condition is 'false') - console.log "'waitFor()' timeout" - phantom.exit 1 - else - # Condition fulfilled (timeout and/or condition is 'true') - console.log "'waitFor()' finished in #{new Date().getTime() - start}ms." - if typeof onReady is 'string' then eval onReady else onReady() #< Do what it's supposed to do once the condition is fulfilled - clearInterval interval #< Stop this interval - interval = setInterval f, 100 #< repeat check every 100ms - -if system.args.length isnt 2 - console.log 'Usage: run-qunit.coffee URL' - phantom.exit 1 - -page = require('webpage').create() - -# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") -page.onConsoleMessage = (msg) -> - console.log msg - -page.open system.args[1], (status) -> - if status isnt 'success' - console.log 'Unable to access network' - phantom.exit 1 - else - waitFor -> - page.evaluate -> - el = document.getElementById 'qunit-testresult' - if el and el.innerText.match 'completed' - return true - return false - , -> - failedNum = page.evaluate -> - el = document.getElementById 'qunit-testresult' - console.log el.innerText - try - return el.getElementsByClassName('failed')[0].innerHTML - catch e - return 10000 - - phantom.exit if parseInt(failedNum, 10) > 0 then 1 else 0 diff --git a/examples/scandir.coffee b/examples/scandir.coffee deleted file mode 100644 index 0ee4ffc..0000000 --- a/examples/scandir.coffee +++ /dev/null @@ -1,16 +0,0 @@ -# List all the files in a Tree of Directories -system = require 'system' - -if system.args.length != 2 - console.log "Usage: phantomjs scandir.coffee DIRECTORY_TO_SCAN" - phantom.exit 1 -scanDirectory = (path) -> - fs = require 'fs' - if fs.exists(path) and fs.isFile(path) - console.log path - else if fs.isDirectory(path) - fs.list(path).forEach (e) -> - scanDirectory path + "/" + e if e != "." and e != ".." - -scanDirectory system.args[1] -phantom.exit() diff --git a/examples/seasonfood.coffee b/examples/seasonfood.coffee deleted file mode 100644 index 5228c26..0000000 --- a/examples/seasonfood.coffee +++ /dev/null @@ -1,17 +0,0 @@ -# Show BBC seasonal food list. - -window.cbfunc = (data) -> - list = data.query.results.results.result - names = ['January', 'February', 'March', - 'April', 'May', 'June', - 'July', 'August', 'September', - 'October', 'November', 'December'] - for item in list - console.log [item.name.replace(/\s/ig, ' '), ':', - names[item.atItsBestUntil], 'to', - names[item.atItsBestFrom]].join(' ') - phantom.exit() - -el = document.createElement 'script' -el.src = 'http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20bbc.goodfood.seasonal%3B&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=window.cbfunc' -document.body.appendChild el diff --git a/examples/seasonfood.js b/examples/seasonfood.js deleted file mode 100644 index f827d46..0000000 --- a/examples/seasonfood.js +++ /dev/null @@ -1,19 +0,0 @@ -// Show BBC seasonal food list. - -var cbfunc = function (data) { - var list = data.query.results.results.result, - names = ['January', 'February', 'March', - 'April', 'May', 'June', - 'July', 'August', 'September', - 'October', 'November', 'December']; - list.forEach(function (item) { - console.log([item.name.replace(/\s/ig, ' '), ':', - names[item.atItsBestUntil], 'to', - names[item.atItsBestFrom]].join(' ')); - }); - phantom.exit(); -}; - -var el = document.createElement('script'); -el.src = 'http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20bbc.goodfood.seasonal%3B&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc'; -document.body.appendChild(el); diff --git a/examples/server.coffee b/examples/server.coffee deleted file mode 100644 index 96abdb9..0000000 --- a/examples/server.coffee +++ /dev/null @@ -1,45 +0,0 @@ -page = require("webpage").create() -server = require("webserver").create() -system = require("system") -host = undefined -port = undefined -if system.args.length isnt 2 - console.log "Usage: server.jspretty cool :)"
- response.close()
- )
- unless listening
- console.log "could not create web server listening on port " + port
- phantom.exit()
- url = "http://localhost:" + port + "/foo/bar.php?asdf=true"
- console.log "SENDING REQUEST TO:"
- console.log url
- page.open url, (status) ->
- if status isnt "success"
- console.log "FAIL to load the address"
- else
- console.log "GOT REPLY FROM SERVER:"
- console.log page.content
- phantom.exit()
diff --git a/examples/serverkeepalive.coffee b/examples/serverkeepalive.coffee
deleted file mode 100644
index ed33224..0000000
--- a/examples/serverkeepalive.coffee
+++ /dev/null
@@ -1,32 +0,0 @@
-port = undefined
-server = undefined
-service = undefined
-system = require("system")
-if system.args.length isnt 2
- console.log "Usage: serverkeepalive.js This is from PhantomJS web server. Request data:"
- response.write JSON.stringify(request, null, 4)
- response.write "
"
- response.write ""
- response.write ""
- response.close()
- )
- if service
- console.log "Web server running on port " + port
- else
- console.log "Error: Could not create web server listening on port " + port
- phantom.exit()
diff --git a/examples/sleepsort.coffee b/examples/sleepsort.coffee
deleted file mode 100644
index 863ad14..0000000
--- a/examples/sleepsort.coffee
+++ /dev/null
@@ -1,20 +0,0 @@
-###
-Sort integers from the command line in a very ridiculous way: leveraging timeouts :P
-###
-
-system = require 'system'
-
-if system.args.length < 2
- console.log "Usage: phantomjs sleepsort.coffee PUT YOUR INTEGERS HERE SEPARATED BY SPACES"
- phantom.exit 1
-else
- sortedCount = 0
- args = Array.prototype.slice.call(system.args, 1)
- for int in args
- setTimeout (do (int) ->
- ->
- console.log int
- ++sortedCount
- phantom.exit() if sortedCount is args.length),
- int
-
diff --git a/examples/stdin-stdout-stderr.coffee b/examples/stdin-stdout-stderr.coffee
deleted file mode 100644
index 60723e0..0000000
--- a/examples/stdin-stdout-stderr.coffee
+++ /dev/null
@@ -1,18 +0,0 @@
-system = require 'system'
-
-system.stdout.write 'Hello, system.stdout.write!'
-system.stdout.writeLine '\nHello, system.stdout.writeLine!'
-
-system.stderr.write 'Hello, system.stderr.write!'
-system.stderr.writeLine '\nHello, system.stderr.writeLine!'
-
-system.stdout.writeLine 'system.stdin.readLine(): '
-line = system.stdin.readLine()
-system.stdout.writeLine JSON.stringify line
-
-# This is essentially a `readAll`
-system.stdout.writeLine 'system.stdin.read(5): (ctrl+D to end)'
-input = system.stdin.read 5
-system.stdout.writeLine JSON.stringify input
-
-phantom.exit 0
diff --git a/examples/technews.coffee b/examples/technews.coffee
deleted file mode 100644
index 7a9807e..0000000
--- a/examples/technews.coffee
+++ /dev/null
@@ -1,17 +0,0 @@
-page = require('webpage').create()
-
-page.viewportSize = { width: 320, height: 480 }
-
-page.open 'http://news.google.com/news/i/section?&topic=t',
- (status) ->
- if status isnt 'success'
- console.log 'Unable to access the network!'
- else
- page.evaluate ->
- body = document.body
- body.style.backgroundColor = '#fff'
- body.querySelector('div#title-block').style.display = 'none'
- body.querySelector('form#edition-picker-form')
- .parentElement.parentElement.style.display = 'none'
- page.render 'technews.png'
- phantom.exit()
diff --git a/examples/technews.js b/examples/technews.js
deleted file mode 100644
index ba7cd94..0000000
--- a/examples/technews.js
+++ /dev/null
@@ -1,16 +0,0 @@
-var page = require('webpage').create();
-page.viewportSize = { width: 320, height: 480 };
-page.open('http://news.google.com/news/i/section?&topic=t', function (status) {
- if (status !== 'success') {
- console.log('Unable to access the network!');
- } else {
- page.evaluate(function () {
- var body = document.body;
- body.style.backgroundColor = '#fff';
- body.querySelector('div#title-block').style.display = 'none';
- body.querySelector('form#edition-picker-form').parentElement.parentElement.style.display = 'none';
- });
- page.render('technews.png');
- }
- phantom.exit();
-});
diff --git a/examples/tweets.coffee b/examples/tweets.coffee
deleted file mode 100644
index a6c064c..0000000
--- a/examples/tweets.coffee
+++ /dev/null
@@ -1,31 +0,0 @@
-# Get twitter status for given account (or for the default one, "PhantomJS")
-
-page = require('webpage').create()
-system = require 'system'
-twitterId = 'PhantomJS' #< default value
-
-# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
-page.onConsoleMessage = (msg) ->
- console.log msg
-
-# Print usage message, if no twitter ID is passed
-if system.args.length < 2
- console.log 'Usage: tweets.coffee [twitter ID]'
-else
- twitterId = system.args[1]
-
-# Heading
-console.log "*** Latest tweets from @#{twitterId} ***\n"
-
-# Open Twitter Mobile and, onPageLoad, do...
-page.open encodeURI("http://mobile.twitter.com/#{twitterId}"), (status) ->
- # Check for page load success
- if status isnt 'success'
- console.log 'Unable to access network'
- else
- # Execute some DOM inspection within the page context
- page.evaluate ->
- list = document.querySelectorAll 'div.tweet-text'
- for i, j in list
- console.log "#{j + 1}: #{i.innerText}"
- phantom.exit()
diff --git a/examples/tweets.js b/examples/tweets.js
deleted file mode 100644
index d3f18c5..0000000
--- a/examples/tweets.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Get twitter status for given account (or for the default one, "PhantomJS")
-
-var page = require('webpage').create(),
- system = require('system'),
- twitterId = "PhantomJS"; //< default value
-
-// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
-page.onConsoleMessage = function(msg) {
- console.log(msg);
-};
-
-// Print usage message, if no twitter ID is passed
-if (system.args.length < 2) {
- console.log("Usage: tweets.js [twitter ID]");
-} else {
- twitterId = system.args[1];
-}
-
-// Heading
-console.log("*** Latest tweets from @" + twitterId + " ***\n");
-
-// Open Twitter Mobile and, onPageLoad, do...
-page.open(encodeURI("http://mobile.twitter.com/" + twitterId), function (status) {
- // Check for page load success
- if (status !== "success") {
- console.log("Unable to access network");
- } else {
- // Execute some DOM inspection within the page context
- page.evaluate(function() {
- var list = document.querySelectorAll('div.tweet-text');
- for (var i = 0; i < list.length; ++i) {
- console.log((i + 1) + ": " + list[i].innerText);
- }
- });
- }
- phantom.exit();
-});
diff --git a/examples/unrandomize.coffee b/examples/unrandomize.coffee
deleted file mode 100644
index 841ffc7..0000000
--- a/examples/unrandomize.coffee
+++ /dev/null
@@ -1,18 +0,0 @@
-# Modify global object at the page initialization.
-# In this example, effectively Math.random() always returns 0.42.
-
-page = require('webpage').create()
-page.onInitialized = ->
- page.evaluate ->
- Math.random = ->
- 42 / 100
-
-page.open "http://ariya.github.com/js/random/", (status) ->
- if status != "success"
- console.log "Network error."
- else
- console.log page.evaluate(->
- document.getElementById("numbers").textContent
- )
- phantom.exit()
-
diff --git a/examples/useragent.coffee b/examples/useragent.coffee
deleted file mode 100644
index d401c7f..0000000
--- a/examples/useragent.coffee
+++ /dev/null
@@ -1,11 +0,0 @@
-page = require('webpage').create()
-
-console.log 'The default user agent is ' + page.settings.userAgent
-
-page.settings.userAgent = 'SpecialAgent'
-page.open 'http://www.httpuseragent.org', (status) ->
- if status isnt 'success'
- console.log 'Unable to access network'
- else
- console.log page.evaluate -> document.getElementById('myagent').innerText
- phantom.exit()
diff --git a/examples/version.coffee b/examples/version.coffee
deleted file mode 100644
index ce20269..0000000
--- a/examples/version.coffee
+++ /dev/null
@@ -1,5 +0,0 @@
-console.log 'using PhantomJS version ' +
- phantom.version.major + '.' +
- phantom.version.minor + '.' +
- phantom.version.patch
-phantom.exit()
diff --git a/examples/waitfor.coffee b/examples/waitfor.coffee
deleted file mode 100644
index 90773c6..0000000
--- a/examples/waitfor.coffee
+++ /dev/null
@@ -1,48 +0,0 @@
-##
-# Wait until the test condition is true or a timeout occurs. Useful for waiting
-# on a server response or for a ui change (fadeIn, etc.) to occur.
-#
-# @param testFx javascript condition that evaluates to a boolean,
-# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
-# as a callback function.
-# @param onReady what to do when testFx condition is fulfilled,
-# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
-# as a callback function.
-# @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
-##
-waitFor = (testFx, onReady, timeOutMillis=3000) ->
- start = new Date().getTime()
- condition = false
- f = ->
- if (new Date().getTime() - start < timeOutMillis) and not condition
- # If not time-out yet and condition not yet fulfilled
- condition = (if typeof testFx is 'string' then eval testFx else testFx()) #< defensive code
- else
- if not condition
- # If condition still not fulfilled (timeout but condition is 'false')
- console.log "'waitFor()' timeout"
- phantom.exit 1
- else
- # Condition fulfilled (timeout and/or condition is 'true')
- console.log "'waitFor()' finished in #{new Date().getTime() - start}ms."
- if typeof onReady is 'string' then eval onReady else onReady() #< Do what it's supposed to do once the condition is fulfilled
- clearInterval interval #< Stop this interval
- interval = setInterval f, 250 #< repeat check every 250ms
-
-
-page = require('webpage').create()
-
-# Open Twitter on 'sencha' profile and, onPageLoad, do...
-page.open 'http://twitter.com/#!/sencha', (status) ->
- # Check for page load success
- if status isnt 'success'
- console.log 'Unable to access network'
- else
- # Wait for 'signin-dropdown' to be visible
- waitFor ->
- # Check in the page if a specific element is now visible
- page.evaluate ->
- $('#signin-dropdown').is ':visible'
- , ->
- console.log 'The sign-in dialog should be visible now.'
- phantom.exit()
diff --git a/examples/walk_through_frames.coffee b/examples/walk_through_frames.coffee
deleted file mode 100644
index 1838fa2..0000000
--- a/examples/walk_through_frames.coffee
+++ /dev/null
@@ -1,66 +0,0 @@
-pageTitle = (page) ->
- page.evaluate ->
- window.document.title
-setPageTitle = (page, newTitle) ->
- page.evaluate ((newTitle) ->
- window.document.title = newTitle
- ), newTitle
-p = require("webpage").create()
-p.open "../test/webpage-spec-frames/index.html", (status) ->
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToChildFrame(\"frame1\"): " + p.switchToChildFrame("frame1")
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToChildFrame(\"frame1-2\"): " + p.switchToChildFrame("frame1-2")
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToParentFrame(): " + p.switchToParentFrame()
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToChildFrame(0): " + p.switchToChildFrame(0)
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToMainFrame()"
- p.switchToMainFrame()
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- console.log "p.switchToChildFrame(\"frame2\"): " + p.switchToChildFrame("frame2")
- console.log "pageTitle(): " + pageTitle(p)
- console.log "currentFrameName(): " + p.currentFrameName()
- console.log "childFramesCount(): " + p.childFramesCount()
- console.log "childFramesName(): " + p.childFramesName()
- console.log "setPageTitle(CURRENT TITLE+'-visited')"
- setPageTitle p, pageTitle(p) + "-visited"
- console.log ""
- phantom.exit()
diff --git a/examples/weather.coffee b/examples/weather.coffee
deleted file mode 100644
index d8da90d..0000000
--- a/examples/weather.coffee
+++ /dev/null
@@ -1,29 +0,0 @@
-page = require('webpage').create()
-system = require 'system'
-
-city = 'Mountain View, California'; # default
-if system.args.length > 1
- city = Array.prototype.slice.call(system.args, 1).join(' ')
-url = encodeURI 'http://api.openweathermap.org/data/2.1/find/name?q=' + city
-
-console.log 'Checking weather condition for', city, '...'
-
-page.open url, (status) ->
- if status isnt 'success'
- console.log 'Error: Unable to access network!'
- else
- result = page.evaluate ->
- return document.body.innerText
- try
- data = JSON.parse result
- data = data.list[0]
- console.log ''
- console.log 'City:', data.name
- console.log 'Condition:', data.weather.map (entry) ->
- return entry.main
- console.log 'Temperature:', Math.round(data.main.temp - 273.15), 'C'
- console.log 'Humidity:', Math.round(data.main.humidity), '%'
- catch e
- console.log 'Error:', e.toString()
-
- phantom.exit()
diff --git a/examples/weather.js b/examples/weather.js
deleted file mode 100644
index 2b4e611..0000000
--- a/examples/weather.js
+++ /dev/null
@@ -1,37 +0,0 @@
-var page = require('webpage').create(),
- system = require('system'),
- city,
- url;
-
-city = 'Mountain View, California'; // default
-if (system.args.length > 1) {
- city = Array.prototype.slice.call(system.args, 1).join(' ');
-}
-url = encodeURI('http://api.openweathermap.org/data/2.1/find/name?q=' + city);
-
-console.log('Checking weather condition for', city, '...');
-
-page.open(url, function(status) {
- var result, data;
- if (status !== 'success') {
- console.log('Error: Unable to access network!');
- } else {
- result = page.evaluate(function () {
- return document.body.innerText;
- });
- try {
- data = JSON.parse(result);
- data = data.list[0];
- console.log('');
- console.log('City:', data.name);
- console.log('Condition:', data.weather.map(function(entry) {
- return entry.main;
- }).join(', '));
- console.log('Temperature:', Math.round(data.main.temp - 273.15), 'C');
- console.log('Humidity:', Math.round(data.main.humidity), '%');
- } catch (e) {
- console.log('Error:', e.toString());
- }
- }
- phantom.exit();
-});