| 226 | |
| 227 | // function(){loading the next set} |
| 228 | function loadNxt(clicked = img1, other = img2) { |
| 229 | let img1Index = -1; |
| 230 | let img2Index = -1; |
| 231 | let clickedIndex = getIndex(rnkList, img1.lastElementChild.innerText, category); |
| 232 | let otherIndex = getIndex(rnkList, img2.lastElementChild.innerText, category); |
| 233 | |
| 234 | // computing new indices |
| 235 | do { |
| 236 | img1Index = Math.floor(Math.random() * rnkLen[category]); |
| 237 | img2Index = Math.floor(Math.random() * rnkLen[category]); |
| 238 | } while (img1Index === img2Index || img1Index === clickedIndex || img1Index === otherIndex || img2Index === clickedIndex || img2Index === otherIndex); |
| 239 | |
| 240 | // loading images |
| 241 | img1.innerHTML = `<img src="${imgDictMixed[rnkList[img1Index][category]]}" alt=""><div>${rnkList[img1Index][category]}</div>`; |
| 242 | img2.innerHTML = `<img src="${imgDictMixed[rnkList[img2Index][category]]}" alt=""><div>${rnkList[img2Index][category]}</div>`; |
| 243 | } |
| 244 | |
| 245 | loadNxt(); // first set for new session |
| 246 | |