RE: Help me with my new website!
January 8, 2018 at 5:40 pm
(This post was last modified: January 8, 2018 at 6:26 pm by bennyboy.)
No, he said IE6 tho.
IE6 was dead about 10 years ago. Get a proper browser. In my experience, you have to try VERY hard to get JQuery to crash a site. (Like. . . it's almost impossible to do)
Don't try to fix this. Redo it.
I'd give the divs a class name, and use JQuery collection to add a handler for the click of that class, instead of trying to make an individual on-click routine for each individual div. You will need to do something like:
1) figure out which div has been clicked (this is exposed in the click handler automatically)
2) swap the divs directly-- don't reference your array at all after your divs are built.
3) I often cheat by using meaningful css class names to carry data. For example, I might add class names like "R1 C1" for row 1 column 1. Then if I want to swap with say "R1 C2," I can easily grab the right div by making a JQuery collection with those class names. $(".R1.C2") or whatever.
If you need to retrieve the order of the cells at some point, you can just cycle through all the cells in order and rebuild a new array.
IE6 was dead about 10 years ago. Get a proper browser. In my experience, you have to try VERY hard to get JQuery to crash a site. (Like. . . it's almost impossible to do)
(January 8, 2018 at 10:29 am)FlatAssembler Wrote: I really like the way Internet Explorer 6 renders my website. No gradients, no background image, no SVGs, no columns… That would be excellent for small devices, right?
Anyway, in one part of the game, you should click on a row in a "table" (tablica) made out of divs (tablica[i][j]) to swap the cells in that row (to put the content of the cell in the correct column). Here is the relevant piece of code:
When the user clicks on a row in that table, the cells in that row are swapped, and the content of the table is correctly tracked in the string arrays "odgovor1" and "odgovor2". However, they are swapped without any animation, they are swapped immediately. When I try to apply JQuery animations to the cells (divs) "tablica[1][j]" and "tablica[2][j]" (by inserting them into the "eval"), the program crashes. Do you know how to do that properly?Code:for (var j=0; j<odgovor1.length; j++)
for (var i=1; i<3; i++)
{
tablica[i][j]=document.createElement("div");
tablica[i][j].setAttribute("class","rijecUDrugomDijelu");
if (i===1) tablica[i][j].appendChild(document.createTextNode(odgovor1[j]));
else if (i===2) tablica[i][j].appendChild(document.createTextNode(odgovor2[j]));
tablica[i][j].style.top=228+27*j;
tablica[i][j].style.left=-153+110+153*i;
tablica[i][j].onclick=eval(
"(function()"+
"{"+
"var tmp=tablica[1]["+j+"].style.left;"+
"tablica[1]["+j+"].style.left=tablica[2]["+j+"].style.left;"+
"tablica[2]["+j+"].style.left=tmp;"+
"tmp=odgovor1["+j+"];"+
"odgovor1["+j+"]=odgovor2["+j+"];"+
"odgovor2["+j+"]=tmp;"+
"})"
);
pozadina.appendChild(tablica[i][j]);
}
Here is a screenshot if it helps: https://postimg.org/image/t6cofk4f1/
If you have some ideas for the interfaces of the Part #2 and Part #3 of the game that are easy to program, please tell me about them.
Don't try to fix this. Redo it.
I'd give the divs a class name, and use JQuery collection to add a handler for the click of that class, instead of trying to make an individual on-click routine for each individual div. You will need to do something like:
1) figure out which div has been clicked (this is exposed in the click handler automatically)
2) swap the divs directly-- don't reference your array at all after your divs are built.
3) I often cheat by using meaningful css class names to carry data. For example, I might add class names like "R1 C1" for row 1 column 1. Then if I want to swap with say "R1 C2," I can easily grab the right div by making a JQuery collection with those class names. $(".R1.C2") or whatever.
If you need to retrieve the order of the cells at some point, you can just cycle through all the cells in order and rebuild a new array.