Skip to content

Instantly share code, notes, and snippets.

@jlewin
Last active December 10, 2015 20:28
Show Gist options
  • Save jlewin/4488897 to your computer and use it in GitHub Desktop.
Save jlewin/4488897 to your computer and use it in GitHub Desktop.
Console hijacking the W3C Microdata draft document http://www.w3.org/html/wg/drafts/microdata/master/ to provide parser results inline with the draft examples. Currently works by passing pre contents to a local http server that runs the data through the specified parser and returns the results as serialized JSON.
var halfWidth = { width: '45%', float: 'left', background: '#ccc', margin: '10px 0', padding: '5px', 'border-right': 'solid 1px #aaa' };
$('pre').css(halfWidth).each(function () {
var $pre = $(this);
$.ajax({
url: 'http://localhost:50231/api/hello',
data: { markup: $pre.text() , uri: window.location.href, impl: ''},
dataType: 'json',
success: function(result) {
$pre.after(
$('<pre>').text(result).addClass('jlewin').css(halfWidth).after($('<hr>').css({clear: 'both'}))
);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment