Created
March 7, 2011 05:08
-
-
Save jpablobr/858103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dickbar = function() { | |
var opts = { | |
"symbol" : "✪", | |
"font-size": "64px", | |
"color": "#eee", | |
"time": 3000 | |
}; | |
if(window.dickbar && window.dickbarOptions) { | |
var d = window.dickbarOptions; | |
if(d["font-size"]) opts["font-size"] = d["font-size"]; | |
if(d.color) opts.color = d.color; | |
if(d.time) opts.time = d.time; | |
if(d.symbol) opts.symbol = d.symbol; | |
} | |
$.getJSON("http://api.twitter.com/1/trends/current.json?callback=?", function(data) { | |
var trending; | |
$.each(data.trends, function(key, value) { | |
trending = value; | |
}); | |
var html = "<div id=\"dickbar\" style=\"position:absolute;left:0px;top:0px;width:100%;"+ | |
"background-color:rgba(0,0,0,0.7);font-size:"+opts["font-size"]+";font-family:helvetica,arial,sans-serif;color:"+opts.color+";"+ | |
"text-shadow:0 2px 1px rgba(0,0,0,0.7);\"><div id=\"dickbar-symbol\" style=\"padding:15px 0;float:left;width:80px;text-align:center;margin-right:5px;border-right:solid 1px rgba(0,0,0,0.3);\">"+ | |
opts.symbol+"</div><div id=\"dickbar-trend\" style=\"margin-left:81px;border-left:solid 1px rgba(255,255,255,0.2);font-weight:bold;padding:15px 20px;\">"+ | |
"<a id=\"dickbar-link\" style=\"color:"+opts.color+";text-decoration:none;\" href=\"http://twitter.com/search/"+encodeURIComponent(trending[0].query)+"\">"+trending[0].name+"</a>"+ | |
"</div><div style=\"clear:both;height:1px;font-size:1px;\"> </div></div>"; | |
$("body").append(html); | |
var height = $("#dickbar").height(); | |
var half = height/2; | |
$("#dickbar").append("<div style=\"position:absolute;left:0px;top:"+half+"px;width:100%;height:1px;font-size:1px;background-color:rgba(0,0,0,0.3);\"> </div>"); | |
$("#dickbar").append("<div style=\"position:absolute;left:0px;top:"+(half+1)+"px;width:100%;height:1px;font-size:1px;background-color:rgba(255,255,255,0.2);\"> </div>"); | |
$("#dickbar").append("<div id=\"dickbar-frame\" style=\"display:none;position:absolute;left:0px;top:0px;width:100%;height:1px;font-size:1px;background-color:rgba(0,0,0,0.5);\"> </div>"); | |
setTimeout(function() { dickbarUpdate(trending, 1, opts.time); }, opts.time); | |
}); | |
}; | |
var dickbarUpdate = function(trending, i, time) { | |
$("#dickbar-frame").show().animate({"height":$("#dickbar").height()},100, function() { | |
$("#dickbar-frame").hide().css({"height":1}); | |
$("#dickbar-link").attr("href", "http://twitter.com/search/"+encodeURIComponent(trending[i].query)).html(trending[i].name); | |
}); | |
var next = i+1; if(next >= trending.length) next = 0; | |
setTimeout(function() { dickbarUpdate(trending, next, time); }, time); | |
}; | |
if(window.jQuery) { | |
dickbar(); | |
} else { | |
var dickbar_head = document.getElementsByTagName("HEAD")[0]; | |
var dickbar_script = document.createElement("script"); | |
dickbar_script.type = "text/javascript"; | |
dickbar_script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"; | |
dickbar_script.onreadystatechange= function () { | |
if (this.readyState == 'complete') dickbar(); | |
} | |
dickbar_script.onload = dickbar; | |
dickbar_head.appendChild(dickbar_script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment