Wait till I come! » Blog Archive » The great implementer swindle - making badge use easy doesn’t make it clever!
Wait till I come! » Blog Archive » The great implementer swindle - making badge use easy doesn’t make it clever!
<script src="badge.js" size="small" skin="blue">Brandname</script>
(badge = function(){
var s = document.getElementsByTagName('script');
for(var i=0;s[i];i++){
if(s[i].getAttribute('src') == 'badge.js'){
var div = document.createElement('div');
var content = s[i].firstChild.nodeValue;
div.innerHTML = 'Awesome badge!
';
div.appendChild(document.createTextNode(content));
var size = s[i].getAttribute('size');
var skin = s[i].getAttribute('skin');
var col,width;
switch(size){
case 'small':width = 100;break;
case 'large':width = 400;break;
default:width = 200;break;
}
switch(skin){
case 'blue':col = '#ccf';break;
case 'green':col = '#cfc';break;
default:col = '#ccc';break;
}
div.style.background = col;
div.style.width = width + 'px';
s[i].parentNode.replaceChild(div,s[i]);
}
}
})();
沒有留言:
張貼留言