changeset 754:ce5a0e6b5ee9 jquery

reading image info asynchronously works now. has just no use yet.
author robcast
date Sun, 06 Feb 2011 00:12:47 +0100
parents 39bd5128811c
children 4c0cc97a6399
files client/digitallibrary/ImgInfo-json.jsp client/digitallibrary/jquery/jquery.digilib.js
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/ImgInfo-json.jsp	Sat Feb 05 22:50:15 2011 +0100
+++ b/client/digitallibrary/ImgInfo-json.jsp	Sun Feb 06 00:12:47 2011 +0100
@@ -25,8 +25,7 @@
 FileOps.FileClass fc = FileOps.FileClass.IMAGE;
 ImageFileset imgFile = (ImageFileset) dirCache.getFile(dlRequest.getFilePath(), dlRequest.getAsInt("pn"), fc);
 
-%>// JSON format metadata about an image
-{ <% 
+%>{ <% 
     if (imgFile != null) {
 		ImageFile img = imgFile.getBiggest();
 		if (!img.isChecked()) {
--- a/client/digitallibrary/jquery/jquery.digilib.js	Sat Feb 05 22:50:15 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Sun Feb 06 00:12:47 2011 +0100
@@ -148,8 +148,8 @@
             img : "size.png"
             },
         calibrationx : {
-            onclick : "javascript:calibrate('x')",
-            tooltip : "calibrate screen x-ratio",
+            onclick : "calibrate",
+            tooltip : "calibrate screen resolution",
             img : "calibration-x.png"
             },
         scale : {
@@ -584,6 +584,11 @@
                 setQuality(data, qual);
                 redisplay(data);
             }
+        },
+        
+        // calibrate (only faking)
+        calibrate : function (data) {
+            getImageInfo(data);
         }
     };
 
@@ -680,6 +685,21 @@
         return settings.digilibBaseUrl + '?' + queryString;
     };
 
+    // gets image information from digilib server via HTTP and calls complete
+    var getImageInfo = function (data, complete) {
+        var settings = data.settings;
+        var p = settings.scalerBaseUrl.indexOf('/servlet/Scaler');
+        var url = settings.scalerBaseUrl.substring(0, p) + '/ImgInfo-json.jsp';
+        url += '?' + getParamString(settings, ['fn', 'pn'], defaults);
+        jQuery.getJSON(url, function (json) {
+            console.debug("got json data=", json);
+            data.imgInfo = json;
+            if (complete != null) {
+                complete.call(this, data, json);
+            }
+        });
+    };
+    
     // processes some parameters into objects and stuff
     var unpackParams = function (data) {
         var settings = data.settings;