T

  • Uploaded by: yhasa
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View T as PDF for free.

More details

  • Words: 1,845
  • Pages: 12
if (typeof Technorati == "undefined") { Technorati = { xhtmlNS: "http://www.w3.org/1999/xhtml", loadFunctions: [], domLoaded: false, init: function() { if (Technorati.domLoaded) return; for (var i = 0; i < Technorati.loadFunctions.length; i++) { Technorati.loadFunctions[i](); } Technorati.domLoaded = true; }, loadData: function (url) { var s = this.createElement("script"); s.setAttribute("charset", "UTF-8"); s.setAttribute("type", "text/javascript"); s.setAttribute("src", url); var head = document.getElementsByTagName("head")[0] || document.documentElement; head.appendChild(s); }, createElement: function (type) { if (document.createElementNS) { return document.createElementNS(this.xhtmlNS, type); } else if (document.createElement) { return document.createElement(type); } }, formatNumber: function (n) { var t = ""; if (typeof n == "string") { n = parseInt(n) } if (typeof n == "number") { s = n.toString(); for (var i = s.length - 3; i > 0; i -= 3) { s = s.substring(0, i) + "," + s.substring(i); } } return s; }, addElement: function (e) { /* if (document.write) { } else { var t = document.getElementsByTagName("*"); var n = t[t.length - 1].parentNode; n.appendChild(e); } */ },

addLoadFunction: function(f) { if (this.loadFunctions.length == 0) { if (document.addEventListener) { document.addEventListener("DOMContentLoaded", Technorati.init, false); } if (/WebKit/i.test(navigator.userAgent)) { var _trTimer = setInterval(function() { if (/loaded| complete/.test(document.readyState)) { clearInterval(_trTimer); Technorati.init(); } }, 10); } /*@cc_on @*/ /*@if (@_win32) document.write("<script id=__tr-ie defer src=javascript:void(0)><\/script>"); var s = document.getElementById("__tr-ie"); s.onreadystatechange = function() { if (this.readyState == "complete") { Technorati.init(); } }; /*@end @*/ } this.loadFunctions.push(f); } }

};

//////////////////////////////////////////////////////////// // GENERIC STATIC WIDGET //////////////////////////////////////////////////////////// if (typeof Technorati.GenericStaticWidget == "undefined") { Technorati.GenericStaticWidget = { initialized: false, elementURLs: {}, elementTargets: [], urlsToLoad: [], init: function() { if (Technorati.GenericStaticWidget.initialized == false) { Technorati.GenericStaticWidget.initialized = true; Technorati.addLoadFunction(this.loadFunction); } }, loadFunction: function () { Technorati.GenericStaticWidget.runWidgets(); }, runWidgets: function () { if(this.elementURLs.length <= 0) {

return; } var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(this.elementURLs[anchor.className] && this.elementURLs[anchor.className]['url']) { var url = this.elementURLs[anchor.className]['url']; if(url) { this.elementTargets.push(anchor); } } } for (var i = 0; i < this.elementTargets.length; i++) { var target = this.elementTargets[i]; var url = this.elementURLs[target.className]["url"]; var type = this.elementURLs[target.className]["type"]; if(url && target) { if(type == "js") { Technorati.loadData(url); } else if(type == "iframe") { var width = this.elementURLs[target.className]["width"]; var height = this.elementURLs[target.className]["height"]; var frameborder = this.elementURLs[target.className]["frameborder"]; var scrolling = this.elementURLs[target.className]["scrolling"]; var frame = Technorati.createElement("iframe"); // Compatible with HTML & XHTML frame.setAttribute("width", width); frame.setAttribute("height", height); frame.setAttribute("scrolling", scrolling); frame.setAttribute("frameborder", frameborder); frame.setAttribute("src", url); target.parentNode.insertBefore(frame, target); target.parentNode.removeChild(target); } } } }, callback: var var for

function(klass, data) { anchors = document.getElementsByTagName("a"); todo = []; (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(anchor.className == klass && this.elementURLs[anchor.className] && this.elementURLs[anchor.className]['url']) { todo.push(anchor); } } for (var i = 0; i < todo.length; i++) { var target = todo[i]; var div = Technorati.createElement("div"); div.className = klass; div.innerHTML = data;

target.parentNode.insertBefore(div, target); target.parentNode.removeChild(target);

}

} }, addWidget: function (id, url, type) { this.elementURLs[id] = { 'url': url, 'type': type }; } }; // end generic static widget

//////////////////////////////////////////////////////////// // GENERIC DYNAMIC WIDGET //////////////////////////////////////////////////////////// if (typeof Technorati.GenericDynamicWidget == "undefined") { Technorati.GenericDynamicWidget = { initialized: false, elementURLs: {}, elementTargets: [], callbackObjects: [], urlsToLoad: [], _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", init: function() { if (Technorati.GenericDynamicWidget.initialized == false) { Technorati.GenericDynamicWidget.initialized = true; Technorati.addLoadFunction(this.loadFunction); } }, loadFunction: function () { Technorati.GenericDynamicWidget.runWidgets(); }, runWidgets: function () { if(this.elementURLs.length <= 0) { return; } var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(this.elementURLs[anchor.className] && this.elementURLs[anchor.className]['url']) { var url = this.elementURLs[anchor.className]['url']; if(url) { this.elementTargets.push(anchor); } } } for (var i = 0; i < this.elementTargets.length; i++) { var target = this.elementTargets[i]; var url = this.elementURLs[target.className]["url"]; var finalurl = this.getFinalUrl(target.getAttribute('href')); var enc = this.encode(finalurl); var d1 = enc.slice(0, 2); var d2 = enc.slice(2, 4); var d3 = enc.slice(4); url = url.replace("\[path\]", d1 + '/' + d2 + '/' + enc); var type = this.elementURLs[target.className]["type"];

if(url && target) { if(type == "js") { this.callbackObjects[target.className]["elements"].pus h({"element": target, "url": finalurl}); Technorati.loadData(url); } else if(type == "iframe") { var width = this.elementURLs[target.className]["width"]; var height = this.elementURLs[target.className]["height"]; var frameborder = this.elementURLs[target.className]["frameborder"]; var scrolling = this.elementURLs[target.className]["scrolling"]; var frame = Technorati.createElement("iframe"); frame.setAttribute("width", width); frame.setAttribute("height", height); frame.setAttribute("scrolling", scrolling); frame.setAttribute("frameborder", frameborder); frame.setAttribute("src", url); target.parentNode.insertBefore(frame, target); target.parentNode.removeChild(target); } } } }, getFinalUrl: function(href) { if(!href) { if(!location.protocol == 'http') { return false; } href = location.href; } href = this.trimSpaces(href); href = href.toLowerCase(); var str1 = "http://technorati.com/blogs/"; if (href.indexOf(str1) == 0) { href = href.slice(str1.length, href.length); } var str2 = "http://www.technorati.com/blogs/"; if (href.indexOf(str2) == 0) { href = href.slice(str2.length, href.length); } href = this.trimSpaces(href); var str3 = "http://technorati.com/search/"; if (href.indexOf(str3) == 0) { href = href.slice(str3.length, href.length); } var str4 = "http://www.technorati.com/search/"; if (href.indexOf(str4) == 0) { href = href.slice(str4.length, href.length); } href = this.trimSpaces(href); if (href.indexOf("{") == 0) { href = href.slice(1, href.length); } if (href.indexOf("%7b") == 0 || href.indexOf("%7B") == 0) {

href = href.slice(3, href.length); } var ind = href.lastIndexOf('?'); if (ind >= 0) { href = href.slice(0, ind); } if (href.lastIndexOf('%7d') == href.length-3 || href.lastIndexOf('%7D') == href.length-3) { href = href.slice(0, href.length-3); } if (href.lastIndexOf('}') == href.length-1) { href = href.slice(0, href.length-1); } href = this.trimSpaces(href); if (href.indexOf("http://") == 0) { href = href.slice(7, href.length); } if (href.indexOf("www.") == 0) { href = href.slice(4, href.length); } if (href.lastIndexOf('/') == href.length-1) { href = href.slice(0, href.length-1); } href = this.trimSpaces(href); return href; }, trimSpaces: function(str) { while(str.length > 0 && str.charAt(0) == ' ') { str = str.slice(1, str.length-1); } while(str.length > 0 && str.charAt(str.length-1) == ' ') { str = str.slice(0, str.length-1); } return str; }, callback: function(klass, data, url) { //var anchors = document.getElementsByTagName("a"); var todo = []; var refs = this.callbackObjects[klass]["elements"]; for (var i = 0; i < refs.length; i++) { var target = refs[i]["element"]; var aurl = refs[i]["url"]; if(target.parentNode && aurl == url) { var div = Technorati.createElement("div"); div.className = klass; div.innerHTML = data; target.parentNode.insertBefore(div, target); target.parentNode.removeChild(target); } } }, // Copied from http://www.webtoolkit.info/javascript-base64.html encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; //input = Base64._utf8_encode(input);

while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 enc2 enc3 enc4

= = = =

chr1 >> 2; ((chr1 & 3) << 4) | (chr2 >> 4); ((chr2 & 15) << 2) | (chr3 >> 6); chr3 & 63;

if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, addWidget: function (id, url, type) { this.elementURLs[id] = { 'url': url, 'type': type }; this.callbackObjects[id] = {"elements": [] }; } }; // end generic static widget } //////////////////////////////////////////////////////////// // GENERIC DYNAMIC BUWIDGET //////////////////////////////////////////////////////////// if (typeof Technorati.GenericDynamicBUWidget == "undefined") { Technorati.GenericDynamicBUWidget = { initialized: false, elementURLs: {}, elementTargets: [], callbackObjects: [], urlsToLoad: [], _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", init: function() { if (Technorati.GenericDynamicBUWidget.initialized == false) { Technorati.GenericDynamicBUWidget.initialized = true; Technorati.addLoadFunction(this.loadFunction); } }, loadFunction: function () { Technorati.GenericDynamicBUWidget.runWidgets(); }, runWidgets: function () { var divs = document.getElementsByTagName("div"); for (var i = 0; i < divs.length; i++) {

var div = divs[i]; if(this.elementURLs[div.className] && this.elementURLs[div.className]['url']) { var url = this.elementURLs[div.className]['url']; if(url) { this.elementTargets.push(div); } } } for (var i = 0; i < this.elementTargets.length; i++) { var target = this.elementTargets[i]; var url = this.elementURLs[target.className]["url"]; var username = undefined; var blogurl = undefined; var anchors = target.getElementsByTagName("a"); for (var j=0; j 0) { username = tmp.substring(ind+profstr.length); ind = username.indexOf('?'); if(ind > 0) { username = username.substring(0, ind); } } } } if(blogurl != undefined && username != undefined) { var finalurl = this.getFinalUrl(blogurl); var enc = this.encode(finalurl); var d1 = enc.slice(0, 2); var d2 = enc.slice(2, 4); var d3 = enc.slice(4); url = url.replace("\[path\]", d1 + '/' + d2 + '/' + enc + '/' + this.encode(username)); var type = this.elementURLs[target.className]["type"]; if(url && target) { if(type == "js") { this.callbackObjects[target.className]["elements"] .push({"element": target, "url": finalurl, "username": username}); Technorati.loadData(url); } else if(type == "iframe") { var width = this.elementURLs[target.className]["width"]; var height = this.elementURLs[target.className]["height"]; var frameborder = this.elementURLs[target.className]["frameborder"]; var scrolling = this.elementURLs[target.className]["scrolling"]; var frame = Technorati.createElement("iframe"); frame.setAttribute("width", width); frame.setAttribute("height", height); frame.setAttribute("scrolling", scrolling);

} }

frame.setAttribute("frameborder", frameborder); frame.setAttribute("src", url); target.parentNode.insertBefore(frame, target); target.parentNode.removeChild(target);

}

} }, getFinalUrl: function(href) { if(!href) { if(!location.protocol == 'http') { return false; } href = location.href; } href = this.trimSpaces(href); href = href.toLowerCase(); var str1 = "http://technorati.com/blogs/"; if (href.indexOf(str1) == 0) { href = href.slice(str1.length, href.length); } var str2 = "http://www.technorati.com/blogs/"; if (href.indexOf(str2) == 0) { href = href.slice(str2.length, href.length); } href = this.trimSpaces(href); if (href.indexOf("{") == 0) { href = href.slice(1, href.length); } if (href.indexOf("%7b") == 0 || href.indexOf("%7B") == 0) { href = href.slice(3, href.length); } var ind = href.lastIndexOf('?'); if (ind >= 0) { href = href.slice(0, ind); } if (href.lastIndexOf('%7d') == href.length-3 || href.lastIndexOf('%7D') == href.length-3) { href = href.slice(0, href.length-3); } if (href.lastIndexOf('}') == href.length-1) { href = href.slice(0, href.length-1); } href = this.trimSpaces(href); if (href.indexOf("http://") == 0) { href = href.slice(7, href.length); } if (href.indexOf("www.") == 0) { href = href.slice(4, href.length); } if (href.lastIndexOf('/') == href.length-1) { href = href.slice(0, href.length-1); } href = this.trimSpaces(href); return href; },

trimSpaces: function(str) { while(str.length > 0 && str.charAt(0) == ' ') { str = str.slice(1, str.length-1); } while(str.length > 0 && str.charAt(str.length-1) == ' ') { str = str.slice(0, str.length-1); } return str; }, callback: function(klass, data, url, username) { //var anchors = document.getElementsByTagName("a"); var todo = []; var refs = this.callbackObjects[klass]["elements"]; /*for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(anchor.className == klass && this.elementURLs[anchor.className] && this.elementURLs[anchor.className]['url']) { todo.push(anchor); } }*/ for (var i = 0; i < refs.length; i++) { var target = refs[i]["element"]; var aurl = refs[i]["url"]; var ausername = refs[i]["username"]; if(aurl == url && ausername == username) { var div = Technorati.createElement("div"); div.className = klass; div.innerHTML = data; target.parentNode.insertBefore(div, target); target.parentNode.removeChild(target); } } }, // Copied from http://www.webtoolkit.info/javascript-base64.html encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; //input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 enc2 enc3 enc4

= = = =

chr1 >> 2; ((chr1 & 3) << 4) | (chr2 >> 4); ((chr2 & 15) << 2) | (chr3 >> 6); chr3 & 63;

if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; }

output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, addWidget: function (id, url, type) { this.elementURLs[id] = { 'url': url, 'type': type }; this.callbackObjects[id] = {"elements": [] }; } }; // end generic static widget } // Static widgets Technorati.GenericStaticWidget.addWidget('tr_global-tagcloud_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_global-tagcloud_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_top-searches_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_top-searches_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_wtf-hot-topics_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_wtf-hot-topics_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_top-news_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_top-news_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_searches-vertical-ticker_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_searches-vertical-ticker_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_searches-horizontal-ticker_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/general/tr_searches-horizontal-ticker_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_searches-small-vertical-ticker_t_js', 'http://widgets.technorati.com/syndication /embed/data/general/tr_searches-small-vertical-ticker_t_js.js', 'js'); Technorati.GenericStaticWidget.addWidget('tr_searches-small-horizontalticker_t_js', 'http://widgets.technorati.com/syndication /embed/data/general/tr_searches-small-horizontal-ticker_t_js.js', 'js'); // Dynamic widgets Technorati.GenericDynamicWidget.addWidget('tr_authority_t_js', 'http://widgets.technorati.com/syndicatio n/embed/data/blogs/[path]/tr_authority_t_js.js', 'js'); Technorati.GenericDynamicWidget.addWidget('tr_tagcloud_t_js', 'http://widgets.technorati.com/syndicatio

n/embed/data/blogs/[path]/tr_tagcloud_t_js.js', 'js'); // Dynamic Blog/User Technorati.GenericDynamicBUWidget.addWidget('tr_embed_t_js', 'http://widgets.technorati.com/syndica tion/embed/data/blogs/[path]/tr_embed_t_js.js', 'js');

Technorati.GenericStaticWidget.init(); Technorati.GenericDynamicWidget.init(); Technorati.GenericDynamicBUWidget.init(); // vim: set filetype=javascript :

Related Documents

T & T
June 2020 18
T
December 2019 23
T
November 2019 31
T
November 2019 29
T
November 2019 29
T
November 2019 29

More Documents from ""

T
November 2019 29