function starname(star) { if (typeof(star) == "null") return "unknown"; if (typeof(star) == "undefined") return "unknown"; if (star<2) return "easy"; if (star<2.7) return "normal"; if (star<4) return "hard"; if (star<5.3) return "insane"; if (star<6.5) return "expert"; return "expert-plus"; } // star: number; numerical representation of star rating // returns an html element used in difficulty selection menu function createStarRow(star) { let row = document.createElement("div"); row.className = "star-row"; for (let i=0; i<10; ++i) { let container = document.createElement("div"); container.className = "imgcontainer"; let img = document.createElement("img"); container.appendChild(img); row.appendChild(container); img.src = "img/star.png"; let value = Math.min(Math.max(star-i,0),1); let size = 8 + value*10; let pad = (1-value) * 5; let style = "width:" + size + "px;"; style += "bottom:" + pad + "px;"; style += "left:" + pad + "px;"; if (value == 0) { style += "opacity:0.4;"; } img.setAttribute("style", style); } return row; } // creates a difficulty selection menu function createDifficultyList(boxclicked, event) { // check if a list of this kind is already there if (window.currentDifficultyList) { window.removeEventListener("click", window.currentDifficultyList.clicklistener); window.currentDifficultyList.parentElement.removeChild(window.currentDifficultyList); window.currentDifficultyList = null; } // window.showingDifficultyList = true; event.stopPropagation(); // calculate list position on page let rect = boxclicked.getBoundingClientRect(); let x = event.clientX - rect.left; let y = event.clientY - rect.top; // create list let difficultyBox = document.createElement("div"); window.currentDifficultyList = difficultyBox; difficultyBox.className = "difficulty-box"; difficultyBox.style.left = x + "px"; difficultyBox.style.top = y + "px"; boxclicked.appendChild(difficultyBox); // close list if clicked outside var closeDifficultyList = function() { boxclicked.removeChild(difficultyBox); window.currentDifficultyList = null; window.removeEventListener('click', closeDifficultyList, false); }; window.addEventListener("click", closeDifficultyList, false); difficultyBox.clicklistener = closeDifficultyList; // fill list for (let i=0; i0) difficultyRing.classList.add(s); row.appendChild(difficultyRing); } } // show only highest star and count otherwise else { let difficultyRing = document.createElement("div"); difficultyRing.className = "difficulty-ring"; let s = starname(stars[stars.length-1]); if (s.length>0) difficultyRing.classList.add(s); row.appendChild(difficultyRing); let cnt = document.createElement("span"); cnt.className = "difficulty-count"; cnt.innerText = stars.length; row.appendChild(cnt); } if (data.length == 0) { let cnt = document.createElement("span"); cnt.className = "difficulty-count"; cnt.innerText = "no std map"; row.appendChild(cnt); } }, addLength: function(box, data) { // show length & bpm let length = 0; let bpm = 0; for (let i=0; i