From e4c2d5790bac6a74037638fde049c374fc44cc7b Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sun, 17 Apr 2011 22:49:30 -0500 Subject: irrisponsibly massive commit --- source/javascripts/pinboard.js | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 source/javascripts/pinboard.js (limited to 'source/javascripts/pinboard.js') diff --git a/source/javascripts/pinboard.js b/source/javascripts/pinboard.js new file mode 100644 index 00000000..01d43621 --- /dev/null +++ b/source/javascripts/pinboard.js @@ -0,0 +1,52 @@ +var count = pinboard_count; +var linkroll = 'pinboard_linkroll'; +function pinboardNS_fetch_script(url) { + document.writeln(''); +} + +function pinboardNS_show_bmarks(r) { + var lr = new Pinboard_Linkroll(); + lr.set_items(r); + lr.show_bmarks(); +} + +var json_URL = "http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count=" + count; +pinboardNS_fetch_script(json_URL); + +function Pinboard_Linkroll() { + var items; + + this.set_items = function(i) { + this.items = i; + } + this.show_bmarks = function() { + var lines = []; + for (var i = 0; i < this.items.length; i++) { + var item = this.items[i]; + var str = this.format_item(item); + lines.push(str); + } + $(linkroll).set('html', lines.join("\n")); + } + this.cook = function(v) { + return v.replace('<', '<').replace('>', '>>'); + } + + this.format_item = function(it) { + var str = "
  • "; + if (!it.d) { return; } + str += "

    " + this.cook(it.d) + ""; + if (it.n) { + str += "" + this.cook(it.n) + "\n"; + } + if (it.t.length > 0) { + for (var i = 0; i < it.t.length; i++) { + var tag = it.t[i]; + str += " " + this.cook(tag) + " "; + } + } + str += "

  • \n"; + return str; + } +} +Pinboard_Linkroll.prototype = new Pinboard_Linkroll(); -- cgit v1.2.1