fix cookie
[booh] / lib / booh / html-merges.rb
index 26489505e5cbfcdcdb2ad5932aa8b915383f453b..23b1d4fc4e097d1a54ff3a57e05a87649607fb46 100644 (file)
@@ -26,7 +26,7 @@ bindtextdomain("booh")
 require 'booh/booh-lib'
 include Booh
 
-$head_code = <<'EOF'
+$image_head_code = <<'EOF'
 <meta name="generator" content="Generated by Booh! http://zarb.org/~gc/html/booh.html">
 
 <script language="JavaScript1.1" type="text/JavaScript">
@@ -98,7 +98,12 @@ function preload() {
 }
 
 function init() {
-  
+
+    var expires = new Date(new Date().getTime() + (30 * 86400000));  // 30 days
+    document.cookie = 'booh-preferred-size-~~theme~~=~~current_size~~'
+                      + '; expires=' + expires.toGMTString()
+                      + '; path=/';
+
     /* retrieve GET parameters */
     all_params = location.href.split("?")
     if (all_params.length > 1) {
@@ -269,8 +274,8 @@ function run_slideshow() {
 </script>
 EOF
 
-$head_code.sub!('~~run_slideshow~~', utf8(_('Run slideshow!')))
-$head_code.sub!('~~stop_slideshow~~', utf8(_('Stop slideshow')))
+$image_head_code.sub!('~~run_slideshow~~', utf8(_('Run slideshow!')))
+$image_head_code.sub!('~~stop_slideshow~~', utf8(_('Stop slideshow')))
 
 $body_additions = <<'EOF'
 onload="init()" id="body"
@@ -322,3 +327,40 @@ EOF
 $body_code = <<'EOF'
 EOF
 
+
+$thumbnails_head_code = <<'EOF'
+<script language="JavaScript1.1" type="text/JavaScript">
+    var expires = new Date(new Date().getTime() + (30 * 86400000));  // 30 days
+    document.cookie = 'booh-preferred-size-~~theme~~=~~current_size~~'
+                      + '; expires=' + expires.toGMTString()
+                      + '; path=/';
+</script>
+EOF
+
+
+$preferred_size_reloader = <<'EOF'
+<html>
+    <head>
+        <script language="JavaScript1.1" type="text/JavaScript">
+
+function getPreferredSize() {
+    if (document.cookie) {
+        var index = document.cookie.indexOf('booh-preferred-size-~~theme~~');
+        if (index != -1) {
+            var oleft = (document.cookie.indexOf('=', index) + 1);
+            var oright = document.cookie.indexOf(';', index);
+            if (oright == -1) {
+                oright = document.cookie.length;
+            }
+            return 'thumbnails-' + document.cookie.substring(oleft, oright) + '.html';
+        }
+    }
+    return 'thumbnails-~~default_size~~.html';
+}
+
+window.location.href = getPreferredSize();
+
+        </script>
+    </head>
+</html>
+EOF