diff --git a/galleryscript.js b/galleryscript.js
index 8978b35..de0646f 100644
--- a/galleryscript.js
+++ b/galleryscript.js
@@ -30,6 +30,8 @@ var fullscreen=false;
var preloader;
var slideshowtimer;
var slideshowinterval;
+var configupdatetimer;
+var sorttype="";
function setup() {
// Setup run at the load of page.
@@ -44,6 +46,7 @@ function setup() {
}
fullscreen=request('full')==1;
originals=request('orig')==1;
+ request('sort');
var req=request('p');
if (req==-1) { req=request('q'); }
if (req!=-1) {
@@ -153,11 +156,12 @@ function thumblist(n,curr) {
leftstr='← ('+ends.first+')
';
rightstr='→ ('+(imagelist.length-ends.last)+')
';
menustr='';
+ ' ';
+ //'Order: /'+
+ //'/'+
+ //''+
+ //'Original: '+
+ //'Fullscreen: ';
thumbstr='
Images '+menustr+'
'+leftstr;
for (i=ends.first; i
'+nicestring((imagelist[i]))+' ';
@@ -209,7 +213,7 @@ function subfoldersmalllist() {
// Shows a small subfolder list
ob=document.getElementById('pathcontainer');
pathstr='Subfolders: ';
- pathstr+='(text icon list ) ';
+ pathstr+='(text icon list ) ';
for (p=0; p'+nicestring(pathlist[p][0])+'('+String(pathlist[p][1])+')/ ';
}
@@ -282,7 +286,7 @@ function sortlist(property) {
imagetime[i]=templist[i].time;
imagedesc[i]=templist[i].desc;
if (imagelist[i] == tempcurrent) {
- currentimage=i;
+ currentimage=parseInt(i);
}
}
var markidx=0;
@@ -347,6 +351,17 @@ function request(type) {
return retval;
}
}
+ if (type=="sort") {
+ // Fetch ?sort=n|t|nr|nt
+ if ((query[0]=="sort") && query.length>1 && query[1].length>0) {
+ var order=query[1].substring(0,1);
+ var rev=query[1].substring(1,2)=="r"
+ if (order=="n") { sortlist('alpha'); }
+ if (order=="t") { sortlist('time'); }
+ if (rev) { sortlist('rev'); }
+ return 0;
+ }
+ }
}
if (type=="auto") { return 0; }
return -1;
@@ -398,8 +413,6 @@ function marklisteditor() {
''+
''+
' ';
-
-
mel.innerHTML=liststr;
return;
}
@@ -446,7 +459,14 @@ function marklistblur() {
var cel=document.getElementById('marktable');
cel.hasfocus=false;
}
-
+function ArrayToURL(array) {
+ var pairs = [];
+ for (var key in array) {
+ if (array.hasOwnProperty(key))
+ { pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(array[key])); }
+ }
+ return pairs.join('&');
+}
function nicestring(s) {
// Return a nice version of a string
s=String(s);
@@ -518,6 +538,18 @@ function slidenext() {
showimage(currentimage);
}
}
+function slidesetupfromconfig() {
+ var el=document.getElementById('configSlideInterval');
+ var newinterval=parseInt(el.value);
+ if (isNaN(newinterval)) { newinterval=0; }
+ el.value=newinterval;
+ slideshowinterval=newinterval;
+ if (slideshowtimer) { clearInterval(slideshowtimer); }
+ if (slideshowinterval!=0) {
+ slideshowtimer=setInterval('slidenext()',1000*Math.abs(slideshowinterval));
+ }
+ return;
+}
function keypressed(e) {
//if (currentimage==-1) { return; }
@@ -571,11 +603,7 @@ function keypressed(e) {
}
// s: setup
if (unicode==83) {
- if (document.getElementById('setupcontainer')) {
- usersetupclose();
- } else {
- usersetup();
- }
+ usersetupflip();
}
// x: mark image
if (unicode==88) {
@@ -590,11 +618,21 @@ function keypressed(e) {
return;
}
+function usersetupflip() {
+ if (document.getElementById('setupcontainer')) {
+ usersetupclose();
+ } else {
+ usersetup();
+ }
+ return
+}
function usersetup() {
if (!document.getElementById('setupcontainer')) {
el=getsetupwindow();
document.body.appendChild(el);
el.scrollIntoView(true);
+ document.getElementById('configSlideInterval').value=slideshowinterval;
+ configupdatetimer=setInterval('usersetupupdate()',500);
}
return
}
@@ -602,28 +640,46 @@ function usersetupclose() {
if (document.getElementById('setupcontainer')) {
var el=document.getElementById('setupcontainer')
el.parentNode.removeChild(el);
+ clearInterval(configupdatetimer);
}
return
}
+function usersetupupdate() {
+ var el=document.getElementById('configFullscreen');
+ if (fullscreen) { el.value='Fullscreen: True'; }
+ else { el.value='Fullscreen: False'; }
+ el=document.getElementById('configOriginals');
+ if (originals) { el.value='Originals: True'; }
+ else { el.value='Originals: False'; }
+ el=document.getElementById('configExample');
+ var optionArray=[];
+ if (fullscreen) { optionArray['full']=1; }
+ if (originals) { optionArray['orig']=1; }
+ if (slideshowinterval!=0) { optionArray['auto']=slideshowinterval; }
+ if (currentimage!=-1) { optionArray['p']=(parseInt(currentimage)+1); }
+ var optionstr=ArrayToURL(optionArray);
+ if (optionstr.length>0) { optionstr='?'+optionstr; }
+ var linkstr=top.location.origin+top.location.pathname+optionstr;
+ el.innerHTML='Link to this image and configuration ';
+ return
+}
function getsetupwindow() {
/* Returns an object containing the long help text */
var el = document.createElement('div');
el.setAttribute("id", 'setupcontainer');
//el.setAttribute("class", 'result-help');
- var str='Close ';
+ var str=' ';
/* Items to setup:
* var currentimage=-1; = offset
- * var originals=false;
- * var fullscreen=false;
- * var slideshowinterval;
- * sort name, time, namerev, timerev
*/
str+='Configuration
'+
- 'Your query will be searched in file names. ';
- if (location.protocol!='file:') {
- str+=' Example: '+
- top.location.origin+top.location.pathname+'?full=1 ';
- }
+ ' '+
+ '
'+
+ ' '+
+ ' '+
+ '
'+
+ 'Slideshow: seconds
';
+ str+='
';
el.innerHTML=str;
return el
}
diff --git a/gallerystyle.css b/gallerystyle.css
index 0108afe..1d86a7e 100644
--- a/gallerystyle.css
+++ b/gallerystyle.css
@@ -184,7 +184,7 @@ padding-right: 0px;
text-align: center;
}
input {
- width: 5px; height: 5px;
+ padding: 0px 0px 0px 0px;
}
.rounded {
border: 1px solid #000;