window.thumbsup = function(dom,parent){ var parent = parent || dom.getParentNodeByTagName('FORM'); if(!parent){ parent = document.body; } const thumbs = Array.from(parent.getElementsByClassName('thumbsup')); const value = parseInt(dom.getAttribute('value')); const span = dom.getElementsByTagName('SPAN')[0]; const name = dom.getAttribute('name'); window.criteria = window.criteria ?? {}; window.criteria.rerank = window.criteria.rerank ?? '[]'; let json = JSON.parse(window.criteria.rerank); const index = json.indexOf(value); if(index != -1){ json.splice(index, 1); dom.classList.remove('selected'); span.innerText = ''; thumbs.forEach(item =>{ let v = parseInt(item.getAttribute('value')); let i = json.indexOf(v); if(i != -1){ let s = item.getElementsByTagName('SPAN')[0]; s.innerText = i+1; } }); }else{ json.push(value); dom.classList.add('selected'); span.innerText = json.length; } window.criteria.rerank = JSON.stringify(json); const button = document.getElementById('thumbsupbutton'); if(button){ button.style.display = (json.length>0) ? 'block' : 'none'; } }