var author = [];
var mesaj = [];
var author_url = [];
var published = [];
var author_photo = [];
var url = [];
var generator = [];
var colors = ['ff0000', '00ff00', '0000ff', 'FF9900', 'CC00CC', '00CCCC', '33FF00', '990000', '000066', '555555', '999900', '009999', '990099', '0099ff', 'ff0099', '9900ff'];
var i = 0;
var perpage = 3;
var message_limit = 140;
var height = 167;
var d = new Date();
var updated = 0;
var count = 0;
var rotatorInit = 0;
var generators_width = parseInt(300)-6-90;
var reaction_content_width = parseInt(300)-20-28;
var animation_index = 0;
var chart_color = 'FFFFFF'
function plural(i) {
if (parseInt(i) != 1) {
return 's';
}
return '';
}
function StripTags(strMod){
if(arguments.length<3) strMod=strMod.replace(/<\/?(?!\!)[^>]*>/gi, '');
else{
var IsAllowed=arguments[1];
var Specified=eval("["+arguments[2]+"]");
if(IsAllowed){
var strRegExp='?(?!(' + Specified.join('|') + '))\b[^>]*>';
strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
}else{
var strRegExp='?(' + Specified.join('|') + ')\b[^>]*>';
strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
}
}
return strMod;
}
function decode(utftext) {
// This function was added to decode utf-encoded text
// Now I skip it due to errors in displaing chinese characters.
//return utftext;
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
document.write ('')
function writeDiv() {
document.getElementById("ubervu_widget_div").innerHTML = '
';
}
function get_passed_time(time) {
d = new Date();
now = d.getTime() / 1000;
dif = now - time;
if (dif < 60) {
return 'seconds ago';
} else if (dif < 3600) {
return parseInt(dif / 60) + ' minute' + plural(dif / 60) + ' ago';
} else if (dif < 86400) {
return parseInt(dif / 3600) +' hour' + plural(dif / 3600) + ' ago';
} else if (dif < 604800) {
return parseInt(dif / 86400) + ' day' + plural(dif / 86400) + ' ago';
} else if (dif < 2592000) {
return parseInt(dif / 604800) + ' week' + plural(dif / 604800) + ' ago';
} else {
return parseInt(dif / 2592000) + ' month' + plural(dif / 2592000) + ' ago';
}
}
function showCharts(count, date_start, date_stop, generators, total) {
var content = '';
var linechartlink = 'http://chart.apis.google.com/chart?chs=90x90&cht=p&chd=t:';
for (i = 0; i < generators.length; i ++) {
content += '
' + generators[i].generator + ' ' + generators[i].count + '%
';
linechartlink += generators[i].count + ',';
}
linechartlink = linechartlink.substring(0, linechartlink.length - 1);
linechartlink += '&chco=';
for (j = 0; j < generators.length - 1; j++) {
linechartlink += colors[j] + ',';
}
linechartlink += colors[generators.length - 1];
linechartlink += '&chf=bg,s,' + chart_color
content += '
';
content += '';
document.getElementById('ubervu_pie_container').innerHTML = content;
var content = '';
content += '
';
document.getElementById('ubervu_chart').innerHTML = content;
}
function stop() {
rotatorInit = window.clearInterval(rotatorInit);
}
function start() {
rotatorInit = window.clearInterval(rotatorInit);
rotatorInit = setInterval("loadAnim()", 2000);
}
function reactionCode(i) {
code = '';
return code;
}
function write_reactions(i) {
content = '';
var start = Math.max(i - 5, 0);
for (j = start; j < i + author.length; j ++) {
content = reactionCode(j) + content;
}
content = 'Recent activity
' + decode(content) + '
'
document.getElementById('ubervu_recent_activity').innerHTML = content;
document.getElementById('ubervu_widget').scrollTop = 0;
count += author.length;
for (j = start; j < i; j ++) {
$("div#id" + j).show(0);
}
}
function loadAnim() {
if (animation_index + 3 >= count) {
write_reactions(animation_index);
}
$("div#id"+animation_index).show(1000);
animation_index += 1;
rotatorInit = window.clearInterval(rotatorInit);
rotatorInit = setInterval("loadAnim()", 3000);
}
function loadData(data){
showCharts(data.count, data.date_start, data.date_stop, data.generators, data.total);
updated = d.getTime() / 1000;
jQuery.each(data.reactions, function(i,item){
author[i] = item.author.name;
mesaj[i] = StripTags(item.content);
if (mesaj[i].length > message_limit) {
mesaj[i] = mesaj[i].substring(0, message_limit) + '...';
}
author_url[i] = item.author.url;
author_photo[i] = item.author.image;
if (!author_photo[i]) {
author_photo[i] = 'http://d284gtceqi4kf4.cloudfront.net/user_icon_unknown.jpg';
}
published[i] = item.published;
url[i] = item.url;
generator[i] = item.generator;
});
document.getElementById('ubervu_reactions_no').innerHTML = '' + data.total + ' reactions this month';
if (author.length > 0) {
write_reactions(0);
$("div#id0").show(0);
$("div#id1").show(0);
animation_index = 2;
rotatorInit = setInterval("loadAnim()", 3000);
} else {
document.getElementById('ubervu_recent_activity').innerHTML = 'No reactions found.
';
}
}
function queryAPI() {
call = 'http://www.ubervu.com/chart_data_widget/?keyword=thiamteck.blogspot.com/&callback=?'
$.getJSON(call, loadData);
}
function initialize() {
writeDiv();
queryAPI();
}
function insertScript(link) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = link;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if (!this.readyState ||
this.readyState == "loaded" || this.readyState == "complete") {
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
head.removeChild( script );
initialize();
}
};
head.appendChild(script);
}
function loadjQuery() {
present = false;
try {
if (jQuery) present = true;
}
catch (e) { }
// Try to load jQuery, if not already present.
if (!present) {
insertScript('http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js');
} else {
$ = jQuery;
initialize();
}
}
document.write('');
loadjQuery();