aboutsummaryrefslogtreecommitdiff
path: root/source/javascripts/pinboard.js
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-04-17 22:49:30 -0500
committerBrandon Mathis <brandon@imathis.com>2011-04-17 22:49:30 -0500
commite4c2d5790bac6a74037638fde049c374fc44cc7b (patch)
tree83f5e5b7324fcb5951d755442e2e601a3eaed35a /source/javascripts/pinboard.js
parent4db81a9e51e452495a06ad8c57ac4ac689a9ff34 (diff)
downloadmy_new_personal_website-e4c2d5790bac6a74037638fde049c374fc44cc7b.tar.xz
my_new_personal_website-e4c2d5790bac6a74037638fde049c374fc44cc7b.zip
irrisponsibly massive commit
Diffstat (limited to 'source/javascripts/pinboard.js')
-rw-r--r--source/javascripts/pinboard.js52
1 files changed, 52 insertions, 0 deletions
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('<s'+'cript type="text/javascript" src="' + url + '"></s'+'cript>');
+}
+
+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('<', '&lt;').replace('>', '&gt>');
+ }
+
+ this.format_item = function(it) {
+ var str = "<li class=\"pin-item\">";
+ if (!it.d) { return; }
+ str += "<p><a class=\"pin-title\" href=\"" + this.cook(it.u) + "\">" + this.cook(it.d) + "</a>";
+ if (it.n) {
+ str += "<span class=\"pin-description\">" + this.cook(it.n) + "</span>\n";
+ }
+ if (it.t.length > 0) {
+ for (var i = 0; i < it.t.length; i++) {
+ var tag = it.t[i];
+ str += " <a class=\"pin-tag\" href=\"http://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag) + "</a> ";
+ }
+ }
+ str += "</p></li>\n";
+ return str;
+ }
+}
+Pinboard_Linkroll.prototype = new Pinboard_Linkroll();