/* M I N I M A L J A V A S C R I P T L I B R A R Y */ var http_request = false; function ajax(url, func) { if(http_request) http_request.abort(); http_request = (window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); if(http_request == null) return alert("Your browser does not support the functionality this website requires."); http_request.onreadystatechange = function() { if(!http_request || http_request.readyState != 4 || !http_request.responseText) return; if(http_request.status != 200) return alert('Whoops, error! :('); func(http_request); }; url += (url.indexOf('?')>=0 ? ';' : '?')+(Math.floor(Math.random()*999)+1); http_request.open('GET', url, true); http_request.send(null); } function setCookie(n,v) { var date = new Date(); date.setTime(date.getTime()+(365*24*60*60*1000)); document.cookie = n+'='+v+'; expires='+date.toGMTString()+'; path=/'; } function getCookie(n) { var l = document.cookie.split(';'); for(var i=0; i createTextNode * tag('tagname', tag(), 'string', ..) -> createElement(), appendChild(), .. * tag('tagname', { class: 'meh', title: 'Title' }) -> createElement(), setAttribute().. * tag('tagname', { }, ) -> create, setattr, append */ function tag() { if(arguments.length == 1) return typeof arguments[0] != 'object' ? document.createTextNode(arguments[0]) : arguments[0]; var el = typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', arguments[0]) : document.createElement(arguments[0]); for(var i=1; i 4 && ol[i].className.indexOf('hidden') < 0 && ol[i].id != 'ivprev' && ol[i].id != 'ivnext') l[l.length] = ol[i]; for(i=0;i ww || h+70 > wh) { full.href = u; setText(full, w+'x'+h); full.style.visibility = 'visible'; if(w/h > ww/wh) { // width++ h *= (ww-100)/w; w = ww-100; } else { // height++ w *= (wh-70)/h; h = wh-70; } } else full.style.visibility = 'hidden'; var dw = w; var dh = h+20; dw = dw < 200 ? 200 : dw; // update document view.style.display = 'block'; setContent(x('ivimg'), tag('img', {src:u, onclick:ivClose, onload: function() { byId('ivimgload').style.top='-400px'; }, style: 'width: '+w+'px; height: '+h+'px' })); view.style.width = dw+'px'; view.style.height = dh+'px'; view.style.left = ((ww - dw) / 2 - 10)+'px'; view.style.top = ((wh - dh) / 2 + st - 20)+'px'; byId('ivimgload').style.left = ((ww - 100) / 2 - 10)+'px'; byId('ivimgload').style.top = ((wh - 20) / 2 + st)+'px'; return false; } function ivClose() { byId('iv_view').style.display = 'none'; byId('iv_view').style.top = '-5000px'; byId('ivimgload').style.top = '-400px'; setText(byId('ivimg'), ''); return false; } ivInit(); /* D R O P D O W N */ function ddInit(obj, align, contents) { obj.dd_align = align; // only 'left' and 'bottom' supported at the moment obj.dd_contents = contents; document.onmousemove = ddMouseMove; if(!byId('dd_box')) addBody(tag('div', {id:'dd_box', dd_used: false})); } function ddHide() { var box = byId('dd_box'); setText(box, ''); box.style.left = '-500px'; box.dd_used = false; } function ddMouseMove(e) { e = e || window.event; var lnk = e.target || e.srcElement; while(lnk && (lnk.nodeType == 3 || !lnk.dd_align)) lnk = lnk.parentNode; var box = byId('dd_box'); if(!box.dd_used && !lnk) return; if(box.dd_used) { var mouseX = e.pageX || (e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft); var mouseY = e.pageY || (e.clientY + document.body.scrollTop + document.documentElement.scrollTop); if((mouseX < ddx-10 || mouseX > ddx+box.offsetWidth+10 || mouseY < ddy-10 || mouseY > ddy+box.offsetHeight+10) || (lnk && lnk.id == box.dd_id)) ddHide(); } if(!box.dd_used && lnk) { var content = lnk.dd_contents(lnk, box); if(content == null) return; setContent(box, content); box.dd_id = lnk.id; box.dd_used = true; var o = lnk; ddx = ddy = 0; do { ddx += o.offsetLeft; ddy += o.offsetTop; } while(o = o.offsetParent); if(lnk.dd_align == 'left') ddx -= box.offsetWidth; if(lnk.dd_align == 'bottom') ddy += lnk.offsetHeight; box.style.left = ddx+'px'; box.style.top = ddy+'px'; } } // release list dropdown on VN pages var rstat = [ 'Unknown', 'Pending', 'Obtained', 'On loan', 'Deleted' ]; var vstat = [ 'Unknown', 'Playing', 'Finished', 'Stalled', 'Dropped' ]; function rlDropDown(lnk) { var relid = lnk.id.substr(6); var st = getText(lnk).split(' / '); if(st[0].indexOf('loading') >= 0) return null; var rs = tag('ul', tag('li', tag('b', 'Release status'))); var vs = tag('ul', tag('li', tag('b', 'Play status'))); for(var i=0;i= 0) rs.appendChild(tag('li', tag('i', rstat[i]))); else rs.appendChild(tag('li', tag('a', {href:'#', rl_rid:relid, rl_act:'r'+i, onclick:rlMod}, rstat[i]))); } for(var i=0;i= 0) vs.appendChild(tag('li', tag('i', vstat[i]))); else vs.appendChild(tag('li', tag('a', {href:'#', rl_rid:relid, rl_act:'v'+i, onclick:rlMod}, vstat[i]))); } return tag('div', {class:'vrdd'}, rs, vs, st[0] == '--' ? null : tag('ul', {class:'full'}, tag('li', tag('a', {href:'#', rl_rid: relid, rl_act:'del', onclick:rlMod}, 'Remove from VN List'))) ); } function rlMod() { var lnk = byId('rlsel_'+this.rl_rid); ddHide(); setContent(lnk, tag('b', {class: 'patch'}, 'loading...')); ajax('/xml/rlist.xml?id='+this.rl_rid+';e='+this.rl_act, function(hr) { // TODO: get rid of innerHTML here... lnk.innerHTML = hr.responseXML.getElementsByTagName('rlist')[0].firstChild.nodeValue; }); return false; } { var l = byClass('a', 'vnrlsel'); for(var i=0;i'+i+''; r += ''; r += ''; v = document.createElement('div'); v.obj = obj; v.innerHTML = r; obj.parentNode.insertBefore(v, obj); } function dtSerialize(obj) { obj = obj.parentNode; var l = obj.getElementsByTagName('select'); var v = [ l[0].options[l[0].selectedIndex].value*1, l[1].options[l[1].selectedIndex].value*1, l[2].options[l[2].selectedIndex].value*1 ]; obj = obj.obj; if(v[0] == 0) obj.value = 0; else if(v[0] == 9999) obj.value = 99999999; else obj.value = v[0]*10000 + v[1]*100 + (v[1]==99?99:v[2]); } // search box var i = x('sq'); i.onfocus = function () { if(this.value == 'search') { this.value = ''; this.style.fontStyle = 'normal' } }; i.onblur = function () { if(this.value.length < 1) { this.value = 'search'; this.style.fontStyle = 'italic' } }; // VN Voting i = x('votesel'); if(i) i.onchange = function() { var s = this.options[this.selectedIndex].value; if(s == 1 && !confirm( "You are about to give this visual novel a 1 out of 10. This is a rather extreme rating, " +"meaning this game has absolutely nothing to offer, and that it's the worst game you have ever played.\n" +"Are you really sure this visual novel matches that description?")) return; if(s == 10 && !confirm( "You are about to give this visual novel a 10 out of 10. This is a rather extreme rating, " +"meaning this is one of the best visual novels you've ever played and it's unlikely " +"that any other game could ever be better than this one.\n" +"It is generally a bad idea to have more than three games in your vote list with this rating, choose carefully!")) return; if(s) location.href = location.href.replace(/\.[0-9]+/, '')+'/vote?v='+s; }; // VN Wishlist editing i = x('wishsel'); if(i) i.onchange = function() { if(this.selectedIndex != 0) location.href = location.href.replace(/\.[0-9]+/, '')+'/wish?s='+this.options[this.selectedIndex].value; }; // Batch Wishlist editing i = x('batchedit'); if(i) i.onchange = function() { var frm = this; while(frm.nodeName.toLowerCase() != 'form') frm = frm.parentNode; if(this.selectedIndex != 0) frm.submit(); }; // Release list editing i = x('listsel'); if(i) i.onchange = function() { if(this.selectedIndex != 0) location.href = location.href.replace(/\.[0-9]+/, '')+'/list?e='+this.options[this.selectedIndex].value; }; // User VN list // (might want to make this a bit more generic, as it's now also used for the user tag list) i = x('relhidall'); if(i) { var l = document.getElementsByTagName('tr'); for(var i=0;i= 0) l[i].style.display = 'none'; var l = document.getElementsByTagName('td'); for(var i=0;i= 0) l[i].onclick = function() { var l = document.getElementsByTagName('tr'); for(var i=0;i= 0) { l[i].style.display = allhid ? 'none' : ''; x(l[i].className.substr(7)).getElementsByTagName('i')[0].innerHTML = allhid ? '▸' : '▾'; } this.getElementsByTagName('i')[0].innerHTML = allhid ? '▸' : '▾'; }; } // Advanced search if(x('advselect')) x('advselect').onload = function() { var e = x('advoptions'); e.className = e.className.indexOf('hidden')>=0 ? '' : 'hidden'; this.getElementsByTagName('i')[0].innerHTML = e.className.indexOf('hidden')>=0 ? '▸' : '▾'; return false; }; // auto-complete tag search if(x('advselect') && x('ti')) { var fields=['ti','te']; for(var field=0;field= 0) { if(l[i].className.indexOf('hidden') >= 0) { s++; l[i].className = 'nsfw'; l[i].getElementsByTagName('a')[0].className = ''; } else { l[i].className += ' hidden'; l[i].getElementsByTagName('a')[0].className = 'hidden'; } } else s++; } x('nsfwshown').innerHTML = s; return false; }; // spoiler tags l = document.getElementsByTagName('b'); for(i=0;i= 0) { if(!e && l[i].className.indexOf('hidden') < 0) l[i].className += ' hidden'; if(e && l[i].className.indexOf('hidden') >= 0) l[i].className = l[i].className.replace(/hidden/, ''); } }; setcomment(); x('history_comments').onclick = function () { setCookie('histexpand', getCookie('histexpand') == 1 ? 0 : 1); setcomment(); return false; }; } // Are we really vndb? if(location.hostname != 'vndb.org') { var d = document.createElement('div'); d.setAttribute('id', 'debug'); d.innerHTML = '

This is not VNDB!

The real VNDB is here.'; document.body.appendChild(d); } // date selector l = document.getElementsByTagName('input'); for(i=0;i= 1) for(i=0; i