changeset 1186:7f7e31a4a71e

comments and fixes.
author robcast
date Sun, 14 Apr 2013 18:48:18 +0200
parents d39cdbbe21da
children 647e8676c8ac
files webapp/src/main/webapp/api/ImgInfo-json.jsp webapp/src/main/webapp/jquery/jquery.digilib.auth.js
diffstat 2 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/api/ImgInfo-json.jsp	Sun Apr 14 18:16:33 2013 +0200
+++ b/webapp/src/main/webapp/api/ImgInfo-json.jsp	Sun Apr 14 18:48:18 2013 +0200
@@ -58,6 +58,7 @@
 		ImageSize imgSize = img.getSize(); 
 		%>
   "filename" : "<%= imgFile.getName() %>",
+  "authentication_required" : <%= docBean.isAuthRequired(dlRequest) %>,
   "aspect" : <%= imgFile.getAspect() %>,
   "dpi_x" : <%= imgFile.getResX() %>,
   "dpi_y" : <%= imgFile.getResY() %><%
@@ -65,8 +66,7 @@
         if (imgSize != null) { 
             %>,
   "width" : <%= imgSize.getWidth() %>,
-  "height" : <%= imgSize.getHeight() %>,
-  "authentication_required" : <%= docBean.isAuthRequired(dlRequest) %>
+  "height" : <%= imgSize.getHeight() %>
 <% 		}
   	} 
 %>}
--- a/webapp/src/main/webapp/jquery/jquery.digilib.auth.js	Sun Apr 14 18:16:33 2013 +0200
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.auth.js	Sun Apr 14 18:48:18 2013 +0200
@@ -20,8 +20,12 @@
  * #L%
  * Authors: Robert Casties
  */
+
 /**
-digilib authentication plugin
+ * digilib authentication plugin.
+ * 
+ * Switches Scaler into error-code mode and listens for image load errors.
+ * When an error occurs, switches the Scaler URL to the authScalerBaseUrl.
  */
 
 (function($) {
@@ -35,16 +39,11 @@
             // URL of Scaler servlet that does not do authentication
             'unauthScalerBaseUrl' : null
     };
-
-    var actions = {
-            // action code goes here 
-            doStub : function (data, param) {
-                var settings = data.settings;
-                console.log("doStub");
-                // do some useful stuff ...
-            }
-    };
-
+    
+    /**
+     * Handle parameter unpacking event.
+     * Make sure the errcode flag is set.
+     */
     var handleUnpack = function (evt) {
         console.debug("auth: handleUnpack");
         var data = this;
@@ -59,6 +58,11 @@
         flags['errcode'] = 'errcode';
     };
 
+    /** 
+     * Handle image load error.
+     * Assume that it was an authentication error and try to use the authenticated Scaler url.
+     * @param {Object} evt
+     */
     var handleImgerror = function (evt) {
         console.debug("auth: handleImgerror");
         var data = this;
@@ -78,7 +82,7 @@
         console.debug('installing auth plugin. digilib:', digilib);
         // add defaults, actions, buttons
         $.extend(digilib.defaults, defaults);
-        $.extend(digilib.actions, actions);
+        //$.extend(digilib.actions, actions);
         //$.extend(digilib.buttons, buttons);
     };