Web component API example: adding a native template to the DOM
A Pen by Mike North on CodePen.
/** | |
* A function to check heroku status, and return results to a callback | |
*/ | |
function heroku_status(callback) { | |
//YQL is necessary becasue heroku status JSON data is not padded | |
$.getJSON("http://query.yahooapis.com/v1/public/yql", | |
{ | |
q:"select * from json where url=" + | |
"\"https://status.heroku.com/api/v3/current-status.json\"", |
// An array of data to operate on | |
var dat = ['a', 'b', 'c', 'd', null, 'e']; | |
/** | |
* A long running task to run for each element of the array. | |
* It must return a promise | |
*/ | |
function doThing(arg) { | |
return new Promise( | |
function (resolve, reject) { |
Web component API example: adding a native template to the DOM
A Pen by Mike North on CodePen.
--- | |
language: node_js | |
node_js: | |
- "0.12" | |
- "iojs" | |
sudo: false | |
cache: | |
directories: |
/** | |
* Poll for presence of DOM elements until they | |
* are found (or until timeout is reached), and then | |
* call a function as soon as a non-empty result is found | |
* | |
* @param {string} selector CSS selector to check for | |
* @param {Function} fn callback function(jqSelector, elapsedTimeInMs) {} | |
* @param {int} timeout timeout in ms (optional) | |
* @param {int} interval polling interval in ms (optional) | |
*/ |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<!-- jQuery 1.11.1 --> | |
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> | |
<!-- Latest compiled and minified CSS --> |
var emberParsingRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:(?:\-(alpha|beta)\.([0-9]+)(?:\.([0-9]+))?)?)?(?:\+(canary))?(?:\.([0-9abcdef]+))?$/; |