MCPcopy Create free account
hub / github.com/codemistic/Web-Development / loadNxt

Function loadNxt

Facemash/js_fm.js:228–243  ·  view source on GitHub ↗
(clicked = img1, other = img2)

Source from the content-addressed store, hash-verified

226
227// function(){loading the next set}
228function 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
245loadNxt(); // first set for new session
246

Callers 1

js_fm.jsFile · 0.85

Calls 1

getIndexFunction · 0.85

Tested by

no test coverage detected