Clicking 'select all' in MyList [FIXED?]

already fixed bugs

Moderator: AniDB

Locked
Gambit
AniDB Staff
Posts: 555
Joined: Sun Oct 06, 2002 11:21 am

Clicking 'select all' in MyList [FIXED?]

Post by Gambit »

Whenever there is only 1 file of a certain title and you expand that list, you`ll see that there is 1 checkbox and a 'select all' box. If you click the 'select all' box, the browser stalls for about 5 seconds or longer, and then nothing happens.

You might disable that option - or fix that problem :)
exp
Site Admin
Posts: 2438
Joined: Tue Oct 01, 2002 9:42 pm
Location: Nowhere

Post by exp »

feel free to submit a fixed version of the javascript code :o)

BYe!
EXP
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

Kewl, I'll look at it later today. :oops:
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

Problem is this, this code will say length is 151951.
var anime202 = new Array(151951);
alert(anime202.length);

This code will say length is 1.
var anime202 = new Array('151951');
alert(anime202.length);

So umm EXP. you need to make the numbers into strings for when there's only 1 file (or everywhere if the extra bytes is np).
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

Or assign them differently:

Code: Select all

var anime202 = new Array();
anime202[0] = 151951;
Or assign the checkboxes a class and use DOM to locate them. I'll have to recheck my JaveScript docu tho as I don't use it so frequently.
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

Elberet, part of the reason the script is written as it is atm is to reduce the size of the code needed to find the stuff... ie, assigning the array by index = BAD.
There's probably some way to solve this better in DOM but then you'll have to write browser specific code to support the older browsers I believe. If there's some common way to do it in all browsers I don't know about it and I sure as hell wont take the time to figure it out when the current solution works just fine. 8O
Last edited by PetriW on Tue Aug 26, 2003 9:37 am, edited 1 time in total.
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

Ah, so a buggy script that freezes the browser works fine? :P

By the way, another workaround for the current script would be to always create the array with an additional value and subtract 1 from the loop. I.e.:

Code: Select all

var anime202 = new Array(151951, 0);
var len = anime202.length - 1;
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

The solution isn't buggy, only the array creation line in one case.
If you read the base code you'll see that the numbers are treated as strings, and that the bug is only the array creation line. Also, making changes in the base code by artificially adding one item to array is a really bad design habit and will only confuse other developers who might be using the code.
Better to do it properly and address the real issue, the fact that a string is treated as an array size number.

Edit: I should be nicer. :roll:
exp
Site Admin
Posts: 2438
Joined: Tue Oct 01, 2002 9:42 pm
Location: Nowhere

Post by exp »

this should be fixed now.

BYe!
EXP
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

PetriW wrote:Also, making changes in the base code by artificially adding one item to array is a really bad design habit and will only confuse other developers who might be using the code.
Yep, that's true. It's one of my vices to never care about JS code or HTML output that was generated by a PHP/Perl Script: as long as it runs and validates as proper HTML, anything goes... :P
PetriW wrote:Edit: I should be nicer. :roll:
Same goes for me. For some reason I've been quite cranky lately and must have stepped on some people's toes without even noticing... :oops: Gomenazai! :)
Locked