/* 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(); /* V N L I S T D R O P D O W N */ var rstat = [ 'Unknown', 'Pending', 'Obtained', 'On loan', 'Deleted' ]; var vstat = [ 'Unknown', 'Playing', 'Finished', 'Stalled', 'Dropped' ]; function vlDropDown(e) { e = e || window.event; var tg = e.target || e.srcElement; while(tg && (tg.nodeType == 3 || tg.nodeName.toLowerCase() != 'a')) tg = tg.parentNode; var o = x('vldd'); if(!o && (!tg || tg.id.substr(0,6) != 'rlsel_')) return; if(o) { 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-5 || mouseX > ddx+o.offsetWidth+100 || mouseY < ddy-5 || mouseY > ddy+o.offsetHeight+5) || (tg && tg.id.substr(0,6) == 'rlsel_' && tg.id != 'rlsel_'+o.relId)) { document.body.removeChild(o); o = null; } } if(!o && tg) { o = tg; ddx = ddy = 0; do { ddx += o.offsetLeft; ddy += o.offsetTop; } while(o = o.offsetParent); ddx -= 185; var cu = tg.id.substr(6); var st = tg.innerHTML.split(' / '); if(st[0].indexOf('loading') >= 0) return; var r = '
  • Release status
  • '; for(var i=0;i= 0 ? '
  • '+rstat[i]+'
  • ' : '
  • '+rstat[i]+'
  • '; r += '
  • Play status
  • '; for(var i=0;i= 0 ? '
  • '+vstat[i]+'
  • ' : '
  • '+vstat[i]+'
  • '; r += '
'; if(tg.innerHTML != '--') r += ''; o = document.createElement('div'); o.id = 'vldd'; o.relId = tg.id.substr(6); o.style.left = ddx+'px'; o.style.top = ddy+'px'; o.innerHTML = r; document.body.appendChild(o); } } function vlMod(rid, act) { document.body.removeChild(x('vldd')); x('rlsel_'+rid).innerHTML = 'loading...'; ajax('/xml/rlist.xml?id='+rid+';e='+act, function(hr) { x('rlsel_'+rid).innerHTML = hr.responseXML.getElementsByTagName('rlist')[0].firstChild.nodeValue; }); return false; } /* J A V A S C R I P T T A B S */ function jtInit() { var sel = ''; var first = ''; var l = x('jt_select').getElementsByTagName('a'); for(var i=0;i= 0) { if(name != which) o.className = o.className.replace(/tabselected/, ''); } else if(name == which) o.className += ' tabselected'; } if(!nolink) location.href = '#'+which; return false; } /* Tag VN spoilers */ /* lvl = null to not change lvl, lim = null to not change limit */ function tvsSet(lvl, lim) { var l = x('tagops').getElementsByTagName('a'); for(var i=0;i= 0) lvl = i; } else { /* set level */ if(i == lvl && l[i].className.indexOf('tsel') < 0) l[i].className += ' tsel'; else if(i != lvl && l[i].className.indexOf('tsel') >= 0) l[i].className = l[i].className.replace(/tsel/, ''); } } else { if(lim == null) { /* determine limit */ if(l[i].className.indexOf('tsel') >= 0) lim = i == 3; } else { /* set limit */ if((i == 3) == lim && l[i].className.indexOf('tsel') < 0) l[i].className += ' tsel'; else if((i == 3) != lim && l[i].className.indexOf('tsel') >= 0) l[i].className = l[i].className.replace(/tsel/, ''); } } } l = x('vntags').getElementsByTagName('span'); lim = lim ? 15 : 999; var s=0; for(i=0;i=lim) && l[i].className.indexOf('hidden') < 0) l[i].className += ' hidden'; if(lvl >= l[i].className.substr(6, 1) && ++s<=lim && l[i].className.indexOf('hidden') >= 0) l[i].className = l[i].className.replace(/hidden/, ''); } return false; } /* date input */ var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; function dtLoad(obj) { var r = Math.floor(obj.value) || 0; var v = [ Math.floor(r/10000), Math.floor(r/100)%100, r%100 ]; var i; 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; }; // vnlist dropdown var l = document.getElementsByTagName('a'); for(var 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