minimal example of using [phantomjs] with [qunit]
$ phantomjs run-qunit.js file://`pwd`/test.html
'waitFor()' finished in 200ms.
Tests completed in 21 milliseconds.
5 tests of 5 passed, 0 failed.
/* | |
To avoid polluting the global namespace this uses an anonymous | |
function which is called with either the URL for an external | |
JavaScript file or a function. In either case jQuery will be loaded | |
from the Google CDN before your code is executed so it's free to | |
depend on jQuery without checking for it and can do things like | |
jQuery.getScript() to load other components (e.g. jQuery UI), | |
stylesheets, etc. | |
*/ | |
(function (target, msg) { |
# Add to ~/.bash_profile | |
function chrome() { | |
open $@ --args --allow-file-access-from-files | |
} | |
# Usage - chrome index.html | |
# now you don't have to worry about those pesky local XHR issues in Chrome. |
var json; | |
json = [ | |
{ | |
foo: { | |
bar: ['ka', 'boom'] | |
} | |
}, { | |
foo: { | |
bar: ['sna', 'fu'] |
<!-- | |
In an HTTP2 world, delivering multiple small individually cachable | |
and executable scripts can be more efficient than one big | |
concatenated script. Can we better prepare for this? Can it be | |
done in a way that works with existing JS files? | |
Imagine a page that had 4 interactive modules, all of which | |
depended on a couple of utility scripts. We could progressively | |
add behaviour to the page by executing the 'action' scripts | |
as soon as they download & the utilities have executed. |
(function($) { | |
$.fn.clippy = function(text, bgcolor) { | |
if (!bgcolor) { | |
var node = $(this); | |
while (node.css('background-color') == 'transparent' && node.length) { | |
node = node.parent(); | |
} | |
if (!node.length) { | |
bgcolor = '#ffffff'; | |
} else { |
# My Chrome developer profile is in the `Profile 1` directory, make sure to update with yours. | |
# Best on an ultra wide monitor. | |
function rwdurl() { | |
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(0,0);window.resizeTo(320,1395);window.location='$1';</script></body></html>" | |
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(330,0);window.resizeTo(480,1395);window.location='$1';</script></body></html>" | |
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(815,0);window.resizeTo(640,1395);window.location='$1';</script></body></html>" | |
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(1460,0);window.resizeTo(800,1395);window.location='$1';</script></body></html>" | |
open -n |
/** | |
* Polyfill for Object.keys | |
* | |
* @see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys | |
*/ | |
if (!Object.keys) { | |
Object.keys = (function () { | |
var hasOwnProperty = Object.prototype.hasOwnProperty, | |
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), | |
dontEnums = [ |
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |