set the preferred size specifically on user click
authorgc <gc>
Wed, 26 Apr 2006 20:22:38 +0000 (20:22 +0000)
committergc <gc>
Wed, 26 Apr 2006 20:22:38 +0000 (20:22 +0000)
bin/booh-backend
lib/booh/html-merges.rb

index 23b615b..e9fdf3f 100755 (executable)
@@ -517,14 +517,16 @@ def substitute_html_sizes(html, sizeobj, type, suffix)
     sizestrings = []
     if $images_size.length > 1 || (type == 'image' && $limit_sizes =~ /original/)
         for sizeobj2 in $images_size
+            sizejs = size2js(sizeobj2['name'])
+            sizen = sizename(sizeobj2['name'])
             if sizeobj != sizeobj2
                 if type == 'thumbnails'
-                    sizestrings << '<a href="thumbnails-' + size2js(sizeobj2['name']) + suffix + '.html">' + sizename(sizeobj2['name']) + '</a>'
+                    sizestrings << '<a href="thumbnails-' + sizejs + suffix + '.html" onclick="set_preferred_size(\'' + sizejs + '\')">' + sizen + '</a>'
                 else
-                    sizestrings << '<a id="link' + size2js(sizeobj2['name']) + '">' + sizename(sizeobj2['name']) + '</a>'
+                    sizestrings << '<a id="link' + sizejs + '" onclick="set_preferred_size(\'' + sizejs + '\')">' + sizen + '</a>'
                 end
             else
-                sizestrings << sizename(sizeobj2['name'])
+                sizestrings << sizen
             end
         end
         if type == 'image' && $limit_sizes =~ /original/
index d17353d..3bfcd68 100644 (file)
@@ -418,6 +418,14 @@ function run_slideshow() {
         toggle_slideshow(true);
     }
 }
+
+function set_preferred_size(val) {
+    var expires = new Date(new Date().getTime() + (30 * 86400000));  // 30 days
+    document.cookie = 'booh-preferred-size-~~theme~~='
+                      + val
+                      + '; expires=' + expires.toGMTString()
+                      + '; path=/';
+}
 </script>
 EOF
 
@@ -482,10 +490,13 @@ $thumbnails_head_code = '<meta name="generator" content="Booh-' + $VERSION + <<'
  http://zarb.org/~gc/html/booh.html"/>
 
 <script language="JavaScript1.1" type="text/JavaScript">
+function set_preferred_size(val) {
     var expires = new Date(new Date().getTime() + (30 * 86400000));  // 30 days
-    document.cookie = 'booh-preferred-size-~~theme~~=~~current_size_js~~'
+    document.cookie = 'booh-preferred-size-~~theme~~='
+                      + val
                       + '; expires=' + expires.toGMTString()
                       + '; path=/';
+}
 </script>
 EOF