| |
Line 1: | Line 1: |
| jQuery; | | jQuery; |
| + | |
| + | jQuery.fn.getPipe = function () { |
| + | alert("Your book is overdue."); |
| + | var pipeFeed = new microbubble.PipeFeed(this); |
| + | pipeFeed.parse(); |
| + | }; |
| | | |
| var microbubble = window.microbubble || {}; // namepsace | | var microbubble = window.microbubble || {}; // namepsace |
Line 12: | Line 18: |
| | | |
| | | |
− | jQuery.fn.getPipe = function () { | + | |
− | alert("Your book is overdue."); | |
− | var pipeFeed = new microbubble.PipeFeed(this); | |
− | pipeFeed.parse(); | |
− | }; | |
| | | |
| /** | | /** |
jQuery; jQuery.fn.getPipe = function () { alert("Your book is overdue."); var pipeFeed = new microbubble.PipeFeed(this); pipeFeed.parse(); }; var microbubble = window.microbubble || {}; // namepsace $('body').append('<div id="ssinterwikis">interwikis</div>'); // $("#ssinterwikis").html("<em>loading interwikis...</em>"); alert(wgTitle); pipeFeed.parse('sloth'); //wgTitle $("#ssinterwikis").getPipe('sloth'); /** * PipeFeed Class * Returns an ordered interwikis */ microbubble.PipeFeed = function (htmlElement) { htmlElement.html('<ol id="feed-results"></ol>'); var listElement = $("#feed-results"); return { parse: function (word) { $.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=eb450438ffa82162ff9a4be13c6e27e9&word=" + 'sloth' + "&_render=json&_callback=?", function (json) { parseFeed(json); }); } }; function parseFeed(json) { var seen = {}; /* preventing double interwikis */ if (json.count > 0) { $(json.value.items).each(function () { var itemDetail = createInterwiki(this); if (seen[itemDetail]) $(this).remove(); else { seen[itemDetail] = true; $(listElement).append('<li>' + itemDetail + '</li>'); } }); } else { -htmlElement.html("<i>No interwikis found</i>"); } } function createInterwiki(item) { return '<h4>[[' + item.content + ':' + 'word' + ']]</h4>'; } };