July 06, 2008, 00:10:37 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Add your links to our directory. Click here to add your links.
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Add your links to our directory. Click here to add your links.
Pages: [1]
  Print  
Author Topic:

Code?

 (Read 1023 times)
0 Members and 1 Guest are viewing this topic.
rockinaway
Jr. Member
**

Points: 0
Offline Offline

Posts: 50


« on: June 20, 2006, 21:55:30 »

what code did you use for the karma images?
« Last Edit: June 20, 2006, 22:19:18 by TheGodFather » Logged


TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #1 on: June 20, 2006, 22:22:41 »

is a javascript what is modifing the dom of the browser. The code is not made by me. It is just modified to can work with "thousands"

just add the flowing code before </body> tag in your html

Code:
<script type="text/javascript">
<!--


var noKarma = "No Karma";

var crossOver = 10; //Cross Over Point from small to large icons
var bbbInt = 100;
var bigInt = 10; //Number of Karma for Big Icon
var smallInt = 2; //Number of Karma for Small Icon

var positive = [
['http://www.webmasterstalks.com/images/reputation_balance.gif'], // Small Karma Icon
['http://www.webmasterstalks.com/images/reputation_green.gif'], // Big Karma Icon
['http://www.webmasterstalks.com/images/reputation_greenh.gif'], // Big Karma Icon
];


var negative = [
['http://www.webmasterstalks.com/images/reputation_neg.gif'], // Small Karma Icon
['http://www.webmasterstalks.com/images/reputation_neg.gif'], // Big Karma Icon
['http://www.webmasterstalks.com/images/reputation_neg.gif'], // Small Karma Icon
];

var noKarma="No Karma";

var td=document.getElementsByTagName('div');
for(i=0; i<td.length; i++) {

if(td.item(i).parentNode.innerHTML.match(/(Points: (-)?(.+?))</i)) {

var iTemp = RegExp.$1;
var iHolder = 'Points: ';
if(RegExp.$3 == '0')
iHolder += noKarma;
else {
var base = (RegExp.$2 == '-')? negative : positive;
var kar = parseInt(RegExp.$3)

var small = Math.round(((kar % bbbInt)%bigInt) / smallInt);
var big = Math.round(((kar-small) % bbbInt) / bigInt);
var bbb = Math.round((kar - (kar % bbbInt)) / bbbInt);


for(bb=0; bb<bbb; bb++)
{
iHolder += '<img src="'+ base[2] +'" alt="'+ bbbInt +' Karma" />';
}

for(b=0; b<big; b++)
{
iHolder += '<img src="'+ base[0] +'" alt="'+ bigInt +' Karma" />';
}

for(s=0; s<small; s++)
{
iHolder += '<img src="'+ base[1] +'" alt="'+ smallInt +' Karma" />';
}


td.item(i).innerHTML = td.item(i).innerHTML.replace(iTemp,iHolder)
}
}
}
//-->
</script>

« Last Edit: June 20, 2006, 22:48:09 by TheGodFather » Logged

xulescu
Full Member
***

Points: 8
Offline Offline

Posts: 245


WWW
« Reply #2 on: June 22, 2006, 19:39:26 »

I think the script originaly is from vbulletin

Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!