Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Strict ordering algorithm for the periodical display of elements.

This patch applies a strict ordering algorithm based on a few
Javascript Math library functions to enhance the proper ordering
of images during a slideshow. In order to use the enhanced algorithm
you can press an undocumented key. I'm not documenting the key since
the algorithm has some consistency issues and I'm having trouble
reproducing my test results. However, this could perhaps be
of use to folks already while I debug the problems.
  • Loading branch information...
commit 06a63e07cc63e7b99b3e66011e373b2aa73dfcee 1 parent 43e7b3d
@sofar authored
Showing with 20 additions and 9 deletions.
  1. +20 −9 album.js
View
29 album.js
@@ -25,6 +25,7 @@ var last_index_section = 0;
var last_album_section = 0;
var fullscreen = false;
var slideshow = false;
+var slideshowrandom = false;
var slideshowinterval;
var slideshowspeed = 5;
var help = false;
@@ -394,12 +395,18 @@ function select(a, i) {
}
function run_slideshow() {
- var x = last_album;
- var y = last_image;
- if (y < albums[x].images.length - 1)
- select(x, y+1);
- else
- select(x, 0);
+ if (slideshowrandom) {
+ var x = Math.floor(Math.random() * albums.length);
+ var y = Math.floor(Math.random() * albums[x].images.length);
+ select(x, y);
+ } else {
+ var x = last_album;
+ var y = last_image;
+ if (y < albums[x].images.length - 1)
+ select(x, y+1);
+ else
+ select(x, 0);
+ }
}
function repaint() {
@@ -424,7 +431,8 @@ function load_settings() {
}
}
-function do_slideshow() {
+function do_slideshow(random) {
+ slideshowrandom = random;
if (slideshow) {
slideshow = false;
window.clearInterval(slideshowinterval);
@@ -484,7 +492,7 @@ function do_help() {
c += "Backspace Go to the previous page or photo\n";
c += "Up Go back to the album or index\n\n";
- c += "s Start or stop the <u><a title=\"slideshow\" href=\"#\" onclick=\"do_slideshow();\">slideshow</a></u>\n";
+ c += "s Start or stop the <u><a title=\"slideshow\" href=\"#\" onclick=\"do_slideshow(false);\">slideshow</a></u>\n";
c += "f Toggle <u><a title=\"fullscreen\" href=\"#\" onclick=\"do_fullscreen();\">fullscreen</a></u> display\n";
c += "h Show or leave this help screen\n\n";
@@ -651,8 +659,11 @@ function keypressed(e) {
select(last_album, last_image);
}
break;
+ case 82: // r
+ do_slideshow(true);
+ break;
case 83: // s
- do_slideshow();
+ do_slideshow(false);
break;
case 70: // f
do_fullscreen();
Please sign in to comment.
Something went wrong with that request. Please try again.