/*
Copyright 2012 Ville Rantanen
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .
*/
var maxThumb=10;
var uagent = navigator.userAgent.toLowerCase();
var pathlist=[];
var pathimage=[];
var imagelist=[];
var filelist=[];
var imagedesc=[];
var imagetime=[];
var marklist=[]
var currentimage=-1;
var currentlist=-1;
var originals=false;
var fullscreen=false;
var preloader;
var slideshowtimer;
var slideshowinterval;
var configupdatetimer;
var sorttype="";
function setup() {
// Setup run at the load of page.
if (notsupported()) {
return;
}
//hidethumbs();
document.onkeydown=keypressed;
slideshowinterval=request('auto');
if (slideshowinterval!=0) {
slideshowtimer=setInterval('slidenext()',1000*Math.abs(slideshowinterval));
}
fullscreen=request('full')==1;
originals=request('orig')==1;
request('sort');
var req=request('p');
if (req==-1) { req=request('q'); }
if (req!=-1) {
showimage(req);
} else {
thumblist(0,-1);
subfolderbiglist();
}
return;
}
function showimage(i) {
// Main function to show a single image
if (i>imagelist.length-1 || i<0) { return; }
thumblist(i,i);
showbigimage(i);
preload(i);
subfoldersmalllist();
currentimage=i;
return;
}
function showbigimage(i) {
// The medium version of image in the big image container
if (i==-1) { return; }
ob=document.getElementById('imagecontainer');
width=document.body.clientWidth-30;
height=document.body.clientHeight-225;
if (fullscreen) { height=height+200; }
if (originals) { mediumstr=encodeURIComponent(imagelist[i]); }
else { mediumstr='_med/med_'+encodeURIComponent(imagelist[i])+'.jpg'; }
ob.innerHTML='

';
document.getElementById('imagesingle').style.maxWidth=width;
ob.style.height=height;
document.getElementById('imagesingle').style.maxHeight=height;
dc=document.getElementById('desccontainer');
dc.innerHTML=currentlink(i)+imagedesc[i];
dc.style.display='block';
return;
}
function currentlink(i) {
// gets the search term for this image
index = location.href.split("?");
s='['+String(i+1)+'] ';
return s;
}
function preload(i) {
// preloads left and right images
if (imagelist.length==0) { return; }
ob=document.getElementById('preloadcontainer');
right=Math.max(0,i+1);
right=Math.min(right,imagelist.length-1);
left=Math.max(0,i-1);
left=Math.min(left,imagelist.length-1);
if (originals) {
prestr='
';
prestr+='
';
} else {
prestr='
';
prestr+='
';
}
maxThumb=getmaxthumbs();
ends=getThumbStartEnd(i+maxThumb,maxThumb);
for (n=ends.first; n';
}
ends=getThumbStartEnd(i-maxThumb,maxThumb);
for (n=ends.first; n';
}
ob.innerHTML=prestr;
preloadcheck();
preloader=setInterval('preloadcheck()',100);
return;
}
function preloadcheck() {
var imgs=document.getElementById('preloadcontainer').childNodes;
var tob=document.getElementById('desccontainer');
var completed=preloadcheckcount();
var colorValue=32*completed/imgs.length + 223;
tob.style.backgroundColor="rgb("+colorValue+","+colorValue+","+colorValue+")";
if (imgs.length==completed) { clearInterval(preloader); tob.style.backgroundColor="rgb(255,255,255)"; }
return;
}
function preloadcheckcount() {
var imgs=document.getElementById('preloadcontainer').childNodes;
var completed=0;
for (i=0;i← ('+ends.first+')
';
rightstr='→ ('+(imagelist.length-ends.last)+')
';
menustr='