JS help
2 posters
Page 1 of 1
JS help
Hello,
I don't know how JavaScript works, I can only work on HTML and CSS, hence I require some help with this particular JS.
We have a table where we rank people according to their wins/loss + points. In this table, each win is +1 point and each loss is -1 point (i think).
I believe this is the part that handles math in this code:
I could be wrong tho.
Anyway, this is the page, if you want to take a look: http://www.duelacademy.net/h1-rankings
I'd like it to count each win as +3 points, and each loss as -1 point. There is Wins, Lose, Games Played, Points. I'm not sure how the code works exactly, but It uses your wins, loses and games played to do the math and distribute points.
I can't explain this any better lol
Thanks for your help
I don't know how JavaScript works, I can only work on HTML and CSS, hence I require some help with this particular JS.
We have a table where we rank people according to their wins/loss + points. In this table, each win is +1 point and each loss is -1 point (i think).
I believe this is the part that handles math in this code:
- Code:
function bubbleSort(a)
{
var swapped;
do {
swapped = false;
for (var i=0; i < a.length-1; i++) {
if (eval(a[i][5]) < eval(a[i+1][5])) {
var temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
swapped = true;
}
if (eval(a[i][5]) == eval(a[i+1][5])) {
if (eval(a[i][3]) > eval(a[i+1][3])) {
var temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
swapped = true;
}
}
}
} while (swapped);
}
I could be wrong tho.
Anyway, this is the page, if you want to take a look: http://www.duelacademy.net/h1-rankings
I'd like it to count each win as +3 points, and each loss as -1 point. There is Wins, Lose, Games Played, Points. I'm not sure how the code works exactly, but It uses your wins, loses and games played to do the math and distribute points.
I can't explain this any better lol
Thanks for your help
Re: JS help
the way its calculated you would have to add 3 wins for every 1 win
one of these should do the trick
or
one of these should do the trick
- Code:
function bubbleSort(a)
{
var swapped;
do {
swapped = false;
for (var i=0; i < a.length-1; i++) {
if (eval(a[i][5]) < eval(a[i+3][5])) {
var temp = a[i];
a[i] = a[i+3];
a[i+3] = temp;
swapped = true;
}
if (eval(a[i][5]) == eval(a[i+1][5])) {
if (eval(a[i][3]) > eval(a[i+1][3])) {
var temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
swapped = true;
}
}
}
} while (swapped);
}
or
- Code:
function bubbleSort(a)
{
var swapped;
do {
swapped = false;
for (var i=0; i < a.length-1; i++) {
if (eval(a[i][5]) < eval(a[i+1][5])) {
var temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
swapped = true;
}
if (eval(a[i][5]) == eval(a[i+1][5])) {
if (eval(a[i][3]) > eval(a[i+3][3])) {
var temp = a[i];
a[i] = a[i+3];
a[i+3] = temp;
swapped = true;
}
}
}
} while (swapped);
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum