diff --git a/index.js b/index.js index 7a858ba..2d34359 100644 --- a/index.js +++ b/index.js @@ -18,8 +18,10 @@ function makeSpaceWord(word){ $("#imagesky").html(""); let length = word.length; for (var i = 0; i < length; i++) { - $("#lettersky").append('
'); - $("#imagesky").append('
'); + $("#lettersky").append('
'); + ranid++; + $("#imagesky").append('
'); + ranid++; } $("#lettersky").append('
'); $("#imagesky").append('
'); @@ -126,6 +128,28 @@ function randomize(inarray){ return tmp; } +function getEmptyIndex(element) { + var emptyPlaces = []; + var idcka = []; + var finalindex = -1; + var idcko = ""; + element.each(function (){ + let thiselement = $(this); + if (thiselement.html() == ""){ + emptyPlaces.push(thiselement.attr("finalplaceindex")); + idcka.push(thiselement.attr("id")); + } + }); + + emptyPlaces.forEach(function (value, index) { + if (value < finalindex || finalindex < 0){ + finalindex = value; + idcko = idcka[index]; + } + }); + return [finalindex, idcko]; +} + function showImages() { var images = []; var letters = []; @@ -137,7 +161,7 @@ function showImages() { let audiopath = prefix + "audio/" + data_tabl[i] + ".ogg"; images.push( - "
" + + "
" + "" + "