Read default values out of bookreader-defaults in meta.xml
authorMichael Ang <mang@archive.org>
Mon, 18 Apr 2011 21:38:45 +0000 (21:38 +0000)
committerMichael Ang <mang@archive.org>
Mon, 18 Apr 2011 21:38:45 +0000 (21:38 +0000)
BookReader/BookReader.js
BookReaderIA/datanode/BookReaderJSIA.php

index 5bd7692..a8d77ec 100644 (file)
@@ -152,7 +152,16 @@ BookReader.prototype.init = function() {
     this.pageScale = this.reduce; // preserve current reduce
     
     // Find start index and mode if set in location hash
-    var params = this.paramsFromFragment(window.location.hash);
+    var params = {};
+    if (window.location.hash) {
+        // params explicitly set in URL
+        params = this.paramsFromFragment(window.location.hash);
+    } else {
+        // params not explicitly set, use defaults if we have them
+        if ('defaults' in this) {
+            params = this.paramsFromFragment(this.defaults);
+        }
+    }
     
     // Sanitize/process parameters
 
index f02a92e..e4da14a 100644 (file)
@@ -539,8 +539,8 @@ foreach ($metaData->xpath('//collection') as $collection) {
     }
 }
 
-echo "br.olHost = 'http://openlibrary.org'\n";
-#echo "br.olHost = 'http://ol-mang:8080'\n";
+echo "br.olHost = 'http://openlibrary.org';\n";
+#echo "br.olHost = 'http://mang-dev.us.archive.org:8080';\n";
 
 if ($useOLAuth) {
     echo "br.olAuth = true;\n";
@@ -552,10 +552,9 @@ if ($protected) {
     echo "br.protected = true;\n";
 }
 
-# Special cases
-if ('bandersnatchhsye00scarrich' == $id) {
-    echo "br.mode     = 2;\n";
-    echo "br.auto     = true;\n";
+# Default options for BookReader
+if ('' != $metaData->{'bookreader-defaults'}) {
+    echo "br.defaults = '" . $metaData->{'bookreader-defaults'} . "';\n";
 }
 
 ?>