iviewWedataItemTest.js

function x1 ( xpath, context ) {
    var n = $X(xpath, context);
    if ( !n )
        return n;
    if ( n instanceof Array )
        n = n[0];
    if ( n instanceof Attr )
       n = n.nodeValue;
    else if ( n.textContent )
        n = n.textContent.replace(/^\s*|\s*$/g, ''); 
    return n;
}
function me(wedataRecord) {
try {
    console.log("raw", wedataRecord);
    var siteinfo = wedataRecord.data;


    var cols = keys(siteinfo).filter( function (k){return !k.match(/^(url|paragraph|[|\w+\.\w+)$/i)} );
    var r = $x( siteinfo.paragraph ).map ( function (paragraph)  {
                var stash = {};
		cols.map( function ( k ) {
			stash[k] = x1(siteinfo[k], paragraph);
                } );
                return stash;
            } )
    var nextLink = $x(siteinfo.nextLink);
    if ( nextLink ) {
        nextLink = nextLink.shift();
        if ( nextLink.nodeType == nextLink.ATTRIBUTE_NODE )
            nextLink = nextLink.ownerElement;
        nextLink = nextLink.href;
    }
    var result = {
        paragraph: r,
        nextLink: nextLink
    }
    console.log(result, siteinfo)
}catch(e){console.log(e)}
}

if ( 0 ) {
    
} else {
  var _injectscript = function (src) {
  var s = document.createElement('script');
  s.src = src;
  s.type = 'text/javascript';
  document.body.appendChild(s);
  }
if ( !window.$X )
 _injectscript('http://gist.github.com/raw/3238/0b1c093e30415be1109f9a36664ebd56e0e7300b');
  
 _injectscript('http://wedata.net/items/2229.json?callback=me&.rand=' + btoa(Math.random()));

}