aboutsummaryrefslogtreecommitdiff
path: root/themes/classic/source/javascripts/pinboard.js
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-06-07 16:12:46 -0400
committerBrandon Mathis <brandon@imathis.com>2011-06-07 16:12:46 -0400
commitaa230616241321ca9c4b8f4202d045c829527618 (patch)
treea3421f7253257f8644ff9adb956af3575a4eec9d /themes/classic/source/javascripts/pinboard.js
parent6cba2145136309d2ac5202853b554f0471a67bf0 (diff)
downloadmy_new_personal_website-aa230616241321ca9c4b8f4202d045c829527618.tar.xz
my_new_personal_website-aa230616241321ca9c4b8f4202d045c829527618.zip
Added themes directory, improved javascript load and minification.
Diffstat (limited to 'themes/classic/source/javascripts/pinboard.js')
-rw-r--r--themes/classic/source/javascripts/pinboard.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/themes/classic/source/javascripts/pinboard.js b/themes/classic/source/javascripts/pinboard.js
new file mode 100644
index 00000000..52577e2c
--- /dev/null
+++ b/themes/classic/source/javascripts/pinboard.js
@@ -0,0 +1,56 @@
+function pinboardNS_fetch_script(url) {
+ //document.writeln('<s'+'cript type="text/javascript" src="' + url + '"></s'+'cript>');
+ (function(){
+ var pinboardLinkroll = document.createElement('script');
+ pinboardLinkroll.type = 'text/javascript';
+ pinboardLinkroll.async = true;
+ pinboardLinkroll.src = url;
+ document.getElementsByTagName('head')[0].appendChild(pinboardLinkroll);
+ })();
+}
+
+function pinboardNS_show_bmarks(r) {
+ var lr = new Pinboard_Linkroll();
+ lr.set_items(r);
+ lr.show_bmarks();
+}
+
+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);
+ }
+ document.getElementById(linkroll).innerHTML = 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).replace(/^\s+|\s+$/g, '') + "</a> ";
+ }
+ }
+ str += "</p></li>\n";
+ return str;
+ }
+}
+Pinboard_Linkroll.prototype = new Pinboard_Linkroll();
+pinboardNS_fetch_script("http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);
+