2009/dap/docs/lrest gallery-lrest.html,1.1,1.2 gallery-lrest.js,1.1,1.2

Update of /sources/public/2009/dap/docs/lrest
In directory hutz:/tmp/cvs-serv14475

Modified Files:
	gallery-lrest.html gallery-lrest.js 
Log Message:
with infauxbox

Index: gallery-lrest.html
===================================================================
RCS file: /sources/public/2009/dap/docs/lrest/gallery-lrest.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gallery-lrest.html	11 Feb 2010 15:03:17 -0000	1.1
+++ gallery-lrest.html	11 Feb 2010 16:15:52 -0000	1.2
@@ -29,7 +29,18 @@
     <div id='big' style='text-align: center'><img/></div>
     <hr/>
     <pre id='log'></pre>
-    
+    <div id='infauxbox' style='display: none; position: fixed; top: 0; left: 0; width: 100%; background: #000; color: #fff; font-size: 0.8em;'>
+      <p style='float: left; padding: 0; margin: 10px 0 10px 10px'>
+        This application wants to access <span id='access' style='font-weight: bold;'></span>.
+        <span style='font-style: italic; text-decoration: underline'>Dude, I'm lost. WTF?</span>
+      </p>
+      <div style='float: right; padding: 0; margin: 5px 10px 5px 0'>
+        <button id='share'>Share Gallery</button>
+        <button id='no-share'>Don't Share</button>
+        <label for='remember'>Remember for this site</label>
+        <input type='checkbox' id='remember'/>
+      </div>
+    </div>
     <script type='text/javascript'>
       $("#gal").hide();
       $("#big").hide();
@@ -58,7 +69,7 @@
       }
       // show gallery
       function showGal (gal) {
-          log("showGal", gal.uri);
+          // log("showGal", gal.uri);
           try { $.getJSON(gal.uri, function (data) { displayGal(gal.name, data); }); }
           catch (e) { log("ERROR:", e); }
       }

Index: gallery-lrest.js
===================================================================
RCS file: /sources/public/2009/dap/docs/lrest/gallery-lrest.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gallery-lrest.js	11 Feb 2010 15:03:17 -0000	1.1
+++ gallery-lrest.js	11 Feb 2010 16:15:52 -0000	1.2
@@ -23,6 +23,40 @@
         ],
     };
 
+    // silly InfauxBox
+    var InfauxBox = {
+        rememberYes: {},
+        rememberNo: {},
+        auth:   function (uri, cb, ctx, prm) {
+            if (this.rememberNo[uri]) return;
+            if (this.rememberYes[uri]) return cb.apply(ctx, prm);
+            
+            var name;
+            for (var i = 0; i < navigator.services.galleries.length; i++) {
+                if (navigator.services.galleries[i].uri == uri) name = navigator.services.galleries[i].name;
+            }
+            // show the infauxbox
+            var $ifb = $("#infauxbox");
+            var r = $("#remember")[0];
+            $("#access").text("your super-personal gallery: " + name);
+            var obj = this;
+            $("#share").click(function () {
+                $("#share, #no-share").unbind("click");
+                if (r.checked) obj.rememberYes[uri] = true;
+                cb.apply(ctx, prm);
+                $ifb.hide();
+            });
+            $("#no-share").click(function () {
+                $("#share, #no-share").unbind("click");
+                if (r.checked) obj.rememberNo[uri] = true;
+                ctx.abort();
+                $ifb.hide();
+            });
+            r.checked = false;
+            $ifb.show();
+        },
+    };
+
     // wrap the XHR
     var XHR = function () {
         // log("XHR constructed");
@@ -34,6 +68,7 @@
             // log("open called with", meth, uri);
             if (/^unicorn:/.test(uri)) {
                 this.isMagic = true;
+                this.uri = uri;
                 uri = uri.replace(/^unicorn:/, "");
                 var tmp = uri.split(/\//);
                 this.service = tmp[0];
@@ -51,9 +86,9 @@
             // log("xhr, magic:", this.xhr, this.isMagic);
         },
         send:   function (data) {
-            try {
-                // log("send called with", data, this.isMagic);
-                if (!this.isMagic) return this.xhr.send.apply(this.xhr, arguments);
+            // log("send called with", data, this.isMagic);
+            if (!this.isMagic) return this.xhr.send.apply(this.xhr, arguments);
+            InfauxBox.auth(this.uri, function (data) {
                 var obj = this;
                 GLOBAL.jsonFlickrFeed = function (o) {
                     if (!obj.cb) return;
@@ -84,8 +119,7 @@
                 src += this.param + "&lang=en-us&format=json";
                 // log("req uri", src);
                 $.getScript(src, function () {});
-            }
-            catch (e) { log("boom", e); }
+            }, this, data);
         },
         abort:  function () {
             // log("send called with", data);
@@ -144,7 +178,5 @@
         },
     };
     GLOBAL.XMLHttpRequest = XHR;
-    
-    // XXX create the Infauxbox!
 })(this);
 

Received on Thursday, 11 February 2010 16:15:55 UTC