html = $html_thumbnails.collect { |l| l.clone }
iterations = {}
for i in html
- i.sub!(/~~run_slideshow~~/, images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html?run_slideshow">' + utf8(_('Run slideshow!'))+'</a>')
+ i.sub!(/~~run_slideshow~~/, images.size <= 1 ? '' : '<a href="image-' + size2js(sizeobj['name']) + '.html#run_slideshow=1">' + utf8(_('Run slideshow!'))+'</a>')
i.sub!(/~~title~~/, xmldir.attributes['thumbnails-caption'] || utf8(File.basename(dir)))
substitute_html_sizes(i, sizeobj, 'thumbnails')
discover_iterations(iterations, i)
if type == 'image'
index = images.index(file)
html_thumbnails.gsub!(/~~image_iteration~~/,
- '<a href="image-' + size2js(sizeobj['name']) + '.html?current=' + fullscreen_images[sizeobj['name']][index] +
+ '<a href="image-' + size2js(sizeobj['name']) + '.html#current=' + fullscreen_images[sizeobj['name']][index] +
'" name="' + fullscreen_images[sizeobj['name']][index] + '">' +
img_element("#{dest_dir}/#{thumbnail_images[sizeobj['name']][index]}") + '</a>')
html_thumbnails.gsub!(/~~caption_iteration~~/,
return 1;
}
+function getparam(key) {
+ all_params = location.href.split("#")
+ if (all_params.length > 1) {
+ params = all_params[1].split("&");
+ for (i = 0; i < params.length; i++) {
+ keyvalue = params[i].split("=");
+ if (keyvalue[0] == key) {
+ return keyvalue[1];
+ }
+ }
+ }
+ return null;
+}
+
+function loadcurrent(img) {
+ for (i = 0; i < images.length; i++) {
+ if (images[i] == img) {
+ current = i;
+ display_current();
+ return;
+ }
+ }
+ current = 0;
+ display_current();
+}
+
+/* check URL for changes; allows the URL to reflect currently showed image */
+var currentURL = '';
+function checkURL() {
+ if (window.location.href != currentURL) {
+ currentURL = window.location.href;
+ img = getparam('current');
+ loadcurrent(img);
+ }
+ setTimeout("checkURL()", 100);
+}
+
function preload() {
/* favor current image, if user clicked on `last' or something */
* but rather load them one by one, in order to get
* next ones faster, beginning with next to current
*/
- for (i = current + 1; i < images.length && i <= current + 5; i++) {
+ if (current + 1 < images.length && load(current + 1) == 0) {
+ setTimeout("preload()", 500);
+ return;
+ }
+ if (current - 1 >= 0 && load(current - 1) == 0) {
+ setTimeout("preload()", 500);
+ return;
+ }
+
+ for (i = current + 2; i < images.length && i <= current + 5; i++) {
if (load(i) == 0) {
setTimeout("preload()", 500);
return;
}
}
- for (i = current - 1; i >= current - 3; i--) {
+ for (i = current - 2; i >= current - 3; i--) {
if (i >= 0) {
if (load(i) == 0) {
setTimeout("preload()", 500);
add_cookie('booh-preferred-size-~~theme~~=~~current_size~~')
- /* retrieve GET parameters */
- all_params = location.href.split("?")
- if (all_params.length > 1) {
- params = all_params[1].split("&");
- for (i = 0; i < params.length; i++) {
- keyvalue = params[i].split("=");
- if (keyvalue[0] == "run_slideshow") {
- toggle_slideshow();
- }
- if (keyvalue[0] == "current") {
- for (i = 0; i < images.length; i++) {
- if (images[i] == keyvalue[1]) {
- current = i;
- break;
- }
- }
- }
- }
+ if (getparam('run_slideshow')) {
+ toggle_slideshow();
}
+ checkURL();
+
preload();
- display_current();
if (images.length == 1) {
document.getElementById("b_slideshow").disabled = true;
}
function set_cursor(value) {
set_cursor_(value, document.getElementById('body'));
+ set_cursor_(value, document.getElementById('b_first'));
+ set_cursor_(value, document.getElementById('b_previous'));
+ set_cursor_(value, document.getElementById('b_next'));
+ set_cursor_(value, document.getElementById('b_last'));
}
function show_current_text() {
if (other_sizes[i] == "original") {
document.getElementById('link' + other_sizes[i]).href = eval("images_" + other_sizes[i] + "[current]");
} else {
- document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + '.html?current=' + eval("images_" + other_sizes[i] + "[current]");
+ document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + '.html#current=' + eval("images_" + other_sizes[i] + "[current]");
}
}
document.getElementById('thumbnails').href = 'thumbnails-~~current_size~~.html#' + images[current];
}
function display_current() {
- eval("document.main_img.src = images[" + current + "]");
+ document.main_img.src = images[current];
+ window.location.href = 'image-~~current_size~~.html#current=' + images[current];
show_current_text();
update_sensibilities();
}