Yahoo Pipes example

This example shows how to use Yahoo Pipes to connect to Trove People and Organisations query

by AnnaGerber

HTML

<div id="input">
    <span>Name</span>
    <input id="pname" type="text" />
    <button id="getDetails">Get Details</button>
</div>
<ul id="output"></ul>

CSS

#input { padding-bottom: 10px; }
#output { 
    padding-top: 5px; 
    border-top: solid 1px black; 
    line-height: 2em;
    list-style-type: disc;
    padding-left: 15px;
}

JavaScript

// action that occurs when the 'Get Details' button is pressed
$("#getDetails").bind( "click", function() {
    // Get the value of the Name field
    var pName = $("#pname").val();
    // Construct the URL for the Yahoo Pipe for Trove People query
    var url = "http://pipes.yahoo.com/pipes/pipe.run?_id=eed133e99c38a68d20d279e46cee66e6&_render=json&name=" + pName;

    // Get the JSON result
    $.getJSON( url, function( data ) {
        var outputHTML = "";
        
        $.each(data.value.items[0].records.record, function( index, item ) {
          // Use console.log to print to browser console (e.g. in  Chrome)
          //console.log(item)
          var record=item.recordData.entry;
          outputHTML += "<li><a target='_blank' href='" 
              + record.link[0].href 
              +"'>" 
              + record.title 
              + "</a></li>";
        });
        $('#output').html(outputHTML); 
    });
});