From 53f6db27b926a7696e0976698236875e4fc632c5 Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Thu, 8 Sep 2011 17:02:21 -0700
Subject: [PATCH] We can now show all email addresses, including certs

---
 browserid/static/js/browserid.js | 124 ++++++++++++++++---------------
 1 file changed, 65 insertions(+), 59 deletions(-)

diff --git a/browserid/static/js/browserid.js b/browserid/static/js/browserid.js
index e3e9f1fa9..dafc6ac8e 100644
--- a/browserid/static/js/browserid.js
+++ b/browserid/static/js/browserid.js
@@ -1,4 +1,4 @@
-/*globals: BrowserIDNetwork: true */
+/*globals BrowserIDNetwork: true, BrowserIDIdentities: true, _: true, confirm: true, getEmails: true, display_saved_ids: true, displayEmails: true*/
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
@@ -33,72 +33,78 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
+(function() {
+  "use strict";
 
-$(function() {
-  BrowserIDNetwork.checkAuth(function(authenticated) {
-    if (authenticated) {
-      $("body").addClass("authenticated");
-      if ($('#emailList').length) {
-        display_saved_ids();
+  $(function() {
+    BrowserIDNetwork.checkAuth(function(authenticated) {
+      if (authenticated) {
+        $("body").addClass("authenticated");
+        if ($('#emailList').length) {
+          display_saved_ids();
+        }
       }
-    }
+    });
   });
-});
 
-function display_saved_ids()
-{
-  var emails = {};
-  BrowserIDIdentities.syncIdentities(function() {
-    emails = getEmails();
-    displayEmails();
-  });
+  function display_saved_ids()
+  {
+    var emails = {};
+    BrowserIDIdentities.syncIdentities(function() {
+      emails = getEmails();
+      displayEmails();
+    });
 
 
-  function displayEmails() {
-    $('#cancellink').click(function() {
-      if (confirm('Are you sure you want to cancel your account?')) {
-        BrowserIDNetwork.cancelUser(function() {
-          document.location="/";
-        });
-      }
-    });
+    function displayEmails() {
+      $('#cancellink').click(function() {
+        if (confirm('Are you sure you want to cancel your account?')) {
+          BrowserIDNetwork.cancelUser(function() {
+            document.location="/";
+          });
+        }
+      });
 
-    $("#emailList").empty();
-      _(emails).each(function(data, e) {
-        var block = $("<div>").addClass("emailblock");
-        var label = $("<div>").addClass("email").text(e);
-        var meta = $("<div>").addClass("meta");
+      $("#emailList").empty();
+        _(emails).each(function(data, e) {
+          var block = $("<div>").addClass("emailblock");
+          var label = $("<div>").addClass("email").text(e);
+          var meta = $("<div>").addClass("meta");
 
-        var pub = $("<div class='keyblock'>").text(data.pub);
-        pub.hide();
-        var linkblock = $("<div>");
-        var puba = $("<a>").text("[show public key]");
-        // var priva = $("<a>").text("[show private key]");
-        puba.click(function() {pub.show()});
-        // priva.click(function() {priv.show()});
-        linkblock.append(puba);
-        // linkblock.append(" / ");
-        // linkblock.append(priva);
-        
-        var deauth = $("<button>").text("Forget this Email");
-        meta.append(deauth);
-        deauth.click(function() {
-          // remove email from server
-          BrowserIDNetwork.removeEmail(e, display_saved_ids);
-        });
-      
-        var d = new Date(data.created);
-        var datestamp = $("<div class='date'>").text("Signed in at " + d.toLocaleString());
+          var pub = $("<div class='keyblock'>").hide();
+          
+          var keyText = data.pub.value;
+          pub.text(keyText);
 
-        meta.append(datestamp);
-        meta.append(linkblock);
-                    
-        block.append(label);
-        block.append(meta);
-        // block.append(priv);
-        block.append(pub);
+          var linkblock = $("<div>");
+          var puba = $("<a>").text("[show public key]");
+          // var priva = $("<a>").text("[show private key]");
+          puba.click(function() {pub.show();});
+          // priva.click(function() {priv.show()});
+          linkblock.append(puba);
+          // linkblock.append(" / ");
+          // linkblock.append(priva);
+          
+          var deauth = $("<button>").text("Forget this Email");
+          meta.append(deauth);
+          deauth.click(function() {
+            // remove email from server
+            BrowserIDNetwork.removeEmail(e, display_saved_ids);
+          });
         
-        $("#emailList").append(block);
-    });
+          var d = new Date(data.created);
+          var datestamp = $("<div class='date'>").text("Signed in at " + d.toLocaleString());
+
+          meta.append(datestamp);
+          meta.append(linkblock);
+                      
+          block.append(label);
+          block.append(meta);
+          // block.append(priv);
+          block.append(pub);
+          
+          $("#emailList").append(block);
+      });
+    }
   }
-}
+}());
-- 
GitLab