/* STANDARD JAVASCRIPT FUNCTIONS */ $(window).unload(function() { $.fn.stats_pageVisits_send(); }); /* window.onbeforeunload = confirmExit; function confirmExit() { $.fn.stats_pageVisits_send(); return "0"; }*/ function setPositions(onload) { if(onload==true) { //There is no position array to use here. We have to build one and create positions from "pagesOnScreen". for(i=1;i<=pagesOnScreen;i++) { //Settings width ------------------------------------------------------------------------------------ $('#pageArea'+i+'_div').width(getPageWidth()+'px').height(getPageWidth('height')+'px'); //Setting start-positions --------------------------------------------------------------------------- if(i1) { $('#pageArea'+i+'_div').hide(); //Hiding the forst inivisble one if not single view. } //Insert this img into positions-array -------------------------------------------------------------- positionsOnScreen[i]='pageArea'+i; } _d.getElementById('choosePage').value=activePage; } else { //We use our position-array for(var i in positionsOnScreen) { if(i0) { $.fn.slidePage(direction,(loop-1),speed); //Run animation } //If thumbnail creation is needed, cache two ahead if(loop==0 && scaleImages==0) { var i=0; var imageSrcs = []; for (i=0;i<(pagesOnScreen-1);i++) { imageSrcs.push('https://unifiler.b-cdn.net/image.php?maxHeight='+getPageWidth('height')+'&src=images/87c7e/'+imgPrefix+(activePage+2+i)+'.jpg&rand=20240427161'); } preloadImages(imageSrcs); } } } function enableButtons() { $('#LArrow').show(); $('#RArrow').show(); if(activePage>=totalPages) { $('#RArrow').hide(); } if(activePage<=1) { $('#LArrow').hide(); } } function insertBlankImage(id) { //Inserts blank images instead of the real one. This function is used by function loadNewPage. _d.getElementById(id).src='https://unifiler.b-cdn.net/image.php?blank=1'; } function loadNewPage(loadWhat,id) { //Loading images. if(loadWhat=='everything') { //(Re)load all images. loadImage = activePage; if(pagesOnScreen>2) { loadImage--; } for(i=pagesOnScreen;i>0;i--) { if(loadImage>totalPages) { insertBlankImage(positionsOnScreen[i]); //Insert blank image } else if(loadImage<1) { insertBlankImage(positionsOnScreen[i]); //Insert blank image } else { //If browser can handle scaled images in animations, print image directly, else create thumbnail with PHP. if(scaleImages==1) { imageSrc='images/87c7e/'+imgPrefix+loadImage+'.jpg?rand=20240427161'; } else { imageSrc='https://unifiler.b-cdn.net/image.php?maxHeight='+getPageWidth('height')+'&src=images/87c7e/'+imgPrefix+loadImage+'.jpg&rand=20240427161'; } //Print result if the source has changed if(_d.getElementById(positionsOnScreen[i]).src.indexOf('/'+imgPrefix+loadImage+'.jpg') < 0) { $('#'+positionsOnScreen[i]+'_loading').show(); $('#'+positionsOnScreen[i]).hide().attr('src',imageSrc).load(function(){ $('#'+$(this).attr('id')+'_loading').hide(); $(this).delay(0).fadeIn(200); }); } } loadImage++; } } else { //(Re)load single specific image loadImage = loadWhat; if(pagesOnScreen>2) { loadImage--; } //If browser can handle scaled images in animations, print image directly, else create thumbnail with PHP. if(scaleImages==1) { imageSrc='images/87c7e/'+imgPrefix+loadImage+'.jpg?rand=20240427161'; } else { imageSrc='https://unifiler.b-cdn.net/image.php?maxHeight='+getPageWidth('height')+'&src=images/87c7e/'+imgPrefix+loadImage+'.jpg&rand=20240427161'; } //Print result if the source has changed if(_d.getElementById(id).src.indexOf(('/'+imgPrefix+loadImage+'.jpg')) < 0) { $('#'+id+'_loading').show(); $('#'+id).hide().attr('src',imageSrc).load(function(){ $('#'+$(this).attr('id')+'_loading').hide(); $(this).delay(0).fadeIn(200); }); } } } function updatePositionArray(direction) { //The animation is complete. Updating the positions-array. var temporary_positionsOnScreen = new Array(); //Working with temporary array... if(direction=='prev') { for(var i in positionsOnScreen) { if(i==1) { temporary_positionsOnScreen[pagesOnScreen]=positionsOnScreen[i]; } else { temporary_positionsOnScreen[(parseInt(i)-1)]=positionsOnScreen[i]; } } } else { for(var i in positionsOnScreen) { if(i==pagesOnScreen) { temporary_positionsOnScreen[1]=positionsOnScreen[i]; } else { temporary_positionsOnScreen[(parseInt(i)+1)]=positionsOnScreen[i]; } } } positionsOnScreen=temporary_positionsOnScreen; //..then replacing the old one. } function GetElementPosition(id) { //Gettings pixel coordinates from img. var position=new Array(); position["x"] = _d.getElementById(id).offsetLeft; position["y"] = _d.getElementById(id).offsetTop; return(position); } function GetZoomFactor () { //Gettings browser zoom-level (for use in jquery-plugin, slidePage) var factor = 1; if (_d.body.getBoundingClientRect) { var rect = _d.body.getBoundingClientRect (); var physicalW = rect.right - rect.left; var logicalW = _d.body.offsetWidth; factor = Math.round ((physicalW / logicalW) * 100) / 100; } return factor; } function GetWindowSize () { //Gettings user resolution (for use in jquery-plugin, slidePage) var zoomFactor = GetZoomFactor(); var size=new Array(); size["w"] = Math.round (_d.documentElement.clientWidth / zoomFactor); size["h"] = Math.round (_d.documentElement.clientHeight / zoomFactor); return(size); } function startUp() { //if(pagesOnScreen>2 && pagesOnScreen>2) { activePage--; } setPositions(true); //Settings startup-styles. loadNewPage('everything',0); //Loading startup-images. enableButtons(); //Disable so you cannot go forw/prev if no images exists there. } function getPageWidth(WidthOrHeight) { if(pagesOnScreen<3) { var divide=1; //It this is a single layout, use the whole screen. } else { var divide=2; //If this is a multiple-page-layout, use half screen. } if(mode=='adapted') { var preferedHeight=document.documentElement.clientHeight-marginTop-marginBottom; //Getting the perfect height. if((((preferedHeight*0.706713780919)*divide)+marginSides) > document.documentElement.clientWidth) //Is it too large for the screen? { var preferedHeight=(((document.documentElement.clientWidth-marginSides)/divide)/0.706713780919); } if(WidthOrHeight=='height') { return Math.round(preferedHeight); //Round and return width } else { return Math.round(preferedHeight*0.706713780919); //Round and return width return(2000); } } else { if(WidthOrHeight=='height') { return Math.round((((document.documentElement.clientWidth-marginSides)/divide)/0.706713780919)); //Round and return height } else { return Math.round((document.documentElement.clientWidth-marginSides)/divide); //Round and return width } } } /* STANDARD JAVASCRIPT FUNCTIONS */ function playSound(whatSound) { if(playFlipSound==1) { if (navigator.geolocation) { //Check for HTML5 support var snd = new Audio('sound/'+whatSound); snd.play(); } } } function preloadImages(srcs) { if (!preloadImages.cache) { preloadImages.cache = []; } var img; for (var i = 0; i < srcs.length; i++) { img = new Image(); img.src = srcs[i]; preloadImages.cache.push(img); } } /* CUSTOM JQUERY PLUGINS */ $.fn.jumpToPage = function(mode) { if((mode==0 && _d.getElementById('choosePage').value!='') || mode!=0) { var runStartUp=1; if(_d.getElementById('choosePage').value>totalPages) { var choosePage=totalPages; _d.getElementById('choosePage').value=totalPages; } else if(_d.getElementById('choosePage').value<1) { var choosePage=1; _d.getElementById('choosePage').value=1; } else { var choosePage=_d.getElementById('choosePage').value; } for(i=1;i<=pagesOnScreen;i++) { $('#pageArea'+i+'_div').fadeOut(100, function() { if(mode=='first') { activePage=1; } else if(mode=='last') { activePage=totalPages+1; } else { activePage=parseInt(_d.getElementById('choosePage').value); } //Update overview slide if(overviewLoaded==1) { $.fn.selectOverview(activePage,1); //Scroll to active page with animation } startUp(); //Start the application again. }).fadeIn(0); } } } $.fn.loadOverview = function() { if(overviewLoaded==0) { //Create content of overview DIV var overviewData = '
'; overviewData += '
'; for(i=1;i<=totalPages;i++) { overviewData += '
'+i+'
'; } overviewData += '
'; //Load into div $("#overviewArea").html(overviewData); //Loop all thumbnails and load them var loadedImages=0; for(i=1;i<=totalPages;i++) { //Load the image $('#ovPImg-'+i).one('load', function() { loadedImages++; if(loadedImages==totalPages) { overviewLoaded=1; //All images of overview have been properly loaded. $.fn.selectOverview(activePage,0); //Scroll to active page without animation $('#overviewContent').jScrollPane(); //Apply a nice scrollbar $('.jspHorizontalBar').css({ width:(_d.documentElement.clientWidth-20)+'px' }); //Change size of that nice scrollbar $('.jspTrack').css({ width:(_d.documentElement.clientWidth-20)+'px' }); //Change size of that nice scrollbar if(badBrowsersScroll==1) { $('.jspHorizontalBar').css({ bottom:19 }); } //Change position on scrollbar for some users } }).attr('src', 'https://unifiler.b-cdn.net/images/87c7e/thumb-'+i+'.jpg?rand=20240427161'); } } else { //Already been loaded. Just open it. $.fn.selectOverview(activePage,0); if($(".jspHorizontalBar").width()==null) { $('#overviewArea').toggleClass("oaOpenNoScroll", 500); } else { $('#overviewArea').toggleClass("oaOpen", 500); } } } $.fn.selectOverview = function(selectPage,animation) { if(selectPage>totalPages) { selectPage=totalPages; } //Make sure value arent to big - that will cause crash if(selectPage<1) { selectPage=1; } //Make sure value arent to small - that will cause crash var jScrollPaneAPI = $('#overviewContent').data('jsp'); //Initialize API for scrollbar $(".overviewImages").removeClass("selectedOverviewImage"); //Remove hightlight for previous selected image... $(".overviewPageNo").removeClass("overviewPageNoSelected"); //and its pagenumer $("#ovPImg-"+selectPage).addClass("selectedOverviewImage"); //Highlight the new one... $("#ovPNo-"+selectPage).addClass("overviewPageNoSelected"); //..and its pagenumer var pagePosition = GetElementPosition('ovP-'+selectPage); if(animation==1) { jScrollPaneAPI.scrollTo(pagePosition["x"]-(_d.documentElement.clientWidth/2)+($("#ovPImg-"+selectPage).width()/2),0,true); } else { $('#overviewContent').scrollLeft(pagePosition["x"]-(_d.documentElement.clientWidth/2)+($("#ovPImg-"+selectPage).width()/2)); } } $.fn.changeOverview = function(imgId) { //Get the pagenumber var page = imgId.replace('ovPImg-',''); //Change choosePage-field and flip _d.getElementById('choosePage').value=page; $.fn.jumpToPage(0); //Animate overview $.fn.selectOverview(activePage,1); } $.fn.slidePage = function(direction,loop,speed) { //Make the animations. if(slideLock==pagesOnScreen) { //Check if animation already in progress. slideLock=0; //Locking application while running slide. if(direction=='prev') { //Update overview slide if(overviewLoaded==1) { $.fn.selectOverview((activePage-1),1); //Scroll to active page without animation } for(var i in positionsOnScreen) { $('#'+positionsOnScreen[i]+'_div').show(); //Make sure its visible if(i==1) { //The first image is hidden behind the second one. Animate from left side of screen and change z-index. loadNewPage((activePage-1),positionsOnScreen[i]); //Loading new image before slide in. _d.getElementById(positionsOnScreen[i]+'_div').style.left="-"+Math.round(((_d.documentElement.clientWidth-(getPageWidth()*2))/2)+($('#'+positionsOnScreen[i]+'_div').width()+marginBetween))+"px"; //Move to the side of screen. _d.getElementById(positionsOnScreen[i]+'_div').style.zIndex="20"; //Set right z-index. $('#'+positionsOnScreen[i]+'_div').show(); //Make sure its visible $('#'+positionsOnScreen[i]+'_div').animate({ left: '0px' }, speed,'linear', function() { slideLock++; slideCompleted(direction,loop,speed); }); } else if(i==pagesOnScreen) { //This is the last image. Animate in, change z-index and move to first position. _d.getElementById(positionsOnScreen[i]+'_div').style.zIndex="20"; //Set right z-index. $('#'+positionsOnScreen[i]+'_div').show(); //Make sure its visible $('#'+positionsOnScreen[i]+'_div').animate({ left: '+='+($('#pageArea'+(i-1)+'_div').width()+marginBetween) }, speed,'linear', function() { slideLock++; slideCompleted(direction,loop,speed); }); } else { //The second image that overlays the first. Just change z-index. _d.getElementById(positionsOnScreen[i]+'_div').style.zIndex="10"; //Set right z-index. slideLock++; slideCompleted(direction,loop,speed); } } } else { //Update overview slide if(overviewLoaded==1) { $.fn.selectOverview((activePage+1),1); //Scroll to active page without animation } for(var i in positionsOnScreen) { if(i==1 && pagesOnScreen>2) { //The first image is hidden behind the second one. Just change z-index and display. //The z-index is changed just before the last image is placed first (in the last "else if"). $('#'+positionsOnScreen[i]+'_div').show(); //Make sure its visible slideLock++; slideCompleted(direction,loop,speed); } else if(i==pagesOnScreen) { //This is the last image. Animate out, change z-index and move to first position. $('#'+positionsOnScreen[i]+'_div').animate({ left: '-='+Math.round(((_d.documentElement.clientWidth-(getPageWidth()*2))/2)+($('#'+positionsOnScreen[i]+'_div').width()+marginBetween)) }, speed,'linear', function() { $('#'+positionsOnScreen[i]+'_div').hide(); //Make sure its invisible _d.getElementById(positionsOnScreen[i]+'_div').style.left=($('#'+positionsOnScreen[i]+'_div').width()+marginBetween)+"px"; //Move below top slideLock++; slideCompleted(direction,loop,speed); }); } else { //This is an image somewhere in the middle. $('#'+positionsOnScreen[i]+'_div').show(); //Make sure its in visible var position=GetElementPosition(positionsOnScreen[(parseInt(i)+1)]+'_div'); $('#'+positionsOnScreen[i]+'_div').animate({ left: (position["x"]) }, speed,'linear', function() { slideLock++; slideCompleted(direction,loop,speed); }); } } } } } $.fn.runSlide = function(direction) { //How many loops? var loops = (pagesOnScreen-2); //What animation-speed? if(loops>0) { var speed=300; } else { var speed=500; } //Running animation on users call. $.fn.slidePage(direction,loops,speed); //Run animation enableButtons(); //Disable so you cannot go forw/prev if no images exists there. } $.fn.stats_pageVisits = function() { //Current time var currentTime = Math.round(new Date().getTime() / 1000); //Calculate time var diffTime = (currentTime-visitingTime); if(diffTime>180) { diffTime=180; } //Add to global array for (var i=0;i<(pagesOnScreen-1);i++) { pageNo = activePage-i; if(pageNo>0 && pageNo<=totalPages) { if(isNaN(visitingTime_page_time[pageNo])) { visitingTime_page_time[pageNo]=diffTime; } else { visitingTime_page_time[pageNo]=visitingTime_page_time[pageNo]+diffTime; } } } //Reset timer visitingTime=Math.round(new Date().getTime() / 1000); } $.fn.stats_pageVisits_send = function() { $.fn.stats_pageVisits(); //Creating URL & send ajax request url = '../data/stats.pageVisits.php?dId='; for (key in visitingTime_page_time) url = url + '&pageNo['+key+']='+visitingTime_page_time[key]; /* Inactivate to save capacity $.ajax({ url:url,async:false }); */ //Empty array visitingTime_page_time=[]; } $(document).ready(function() { /* ON BOOT */ startUp(); $("[rel^='prettyPhoto']").prettyPhoto({ social_tools: '' }); /* ON USER ACTION */ $('#firstPage').click(function() { $.fn.stats_pageVisits(); $.fn.jumpToPage('first'); }); $('#lastPage').click(function() { $.fn.stats_pageVisits(); $.fn.jumpToPage('last'); }); $('#download').click(function() { $("#downloadWindow").load("data/window.downloadWindow.php?dKey=87c7e", function() { $.prettyPhoto.open("#downloadWindow"); }); }); $('#printer').click(function() { window.open("/data/print.printIframe.php?dKey=87c7e"); }); $('#overview').click(function() { $.fn.loadOverview(); }); $('#choosePage').bind('keyup', function() { $.fn.stats_pageVisits(); $.fn.jumpToPage(0); }); $('#LArrow').click(function() { $.fn.stats_pageVisits(); playSound('click.wav');$.fn.runSlide('prev'); }); $('#LArrow').mouseover(function() { this.style.cursor='pointer';$(this).css({ opacity: 0.5 }); }); $('#LArrow').mouseout(function() { $(this).css({ opacity: 1 }); }); $('#RArrow').click(function() { $.fn.stats_pageVisits(); playSound('click.wav');$.fn.runSlide('next'); }); $('#RArrow').mouseover(function() { this.style.cursor='pointer';$(this).css({ opacity: 0.5 }); }); $('#RArrow').mouseout(function() { $(this).css({ opacity: 1 }); }); $('.overviewImages').live('click', function () { $.fn.stats_pageVisits(); $.fn.changeOverview($(this).attr('id')); }); $('.overviewImages').live('mouseenter mouseleave', function (e) { if (e.type == 'mouseenter') { this.style.cursor='pointer'; } else { this.style.cursor='pointer'; } }); $('#overviewMin').live('click', function () { $.fn.loadOverview(); }); $('#overviewMin').live('mouseenter mouseleave', function (e) { if (e.type == 'mouseenter') { this.style.cursor='pointer'; } else { this.style.cursor='pointer'; } }); if(getMode=='adapted') { $('#viewMode').click(function() { document.location='/?dKey=87c7e&mode=&aP='+activePage; }); } else { $('#viewMode').click(function() { document.location='/?dKey=87c7e&mode=adapted&aP='+activePage; }); } if(zoom==1) { $('#zoom').click(function() { document.location='/?dKey=87c7e&mode='+getMode+'&aP='+activePage; }); } else { $('#zoom').click(function() { document.location='/?dKey=87c7e&mode='+getMode+'&zoom=1&aP='+activePage; }); } }); /* CUSTOM JQUERY PLUGINS */