forked from mozilla/persona
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing this from layout.ejs to prepare for minification.
- Loading branch information
Shane Tomlinson
committed
Jul 19, 2011
1 parent
f806ac9
commit 27f18ae
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
$(function() { | ||
if ($('#emailList')) { | ||
display_saved_ids(); | ||
} | ||
}); | ||
|
||
function display_saved_ids() | ||
{ | ||
var emails = {}; | ||
if (window.localStorage.emails) { | ||
emails = JSON.parse(window.localStorage.emails); | ||
} | ||
|
||
$('#cancellink').click(function() { | ||
if (confirm('Are you sure you want to cancel your account?')) { | ||
$.post("/wsapi/account_cancel", {}, function(result) { | ||
window.localStorage.emails = null; | ||
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"); | ||
|
||
/* | ||
var priv = $("<div class='keyblock'>").text(data.priv); | ||
priv.hide(); | ||
*/ | ||
|
||
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() { | ||
var t = JSON.parse(window.localStorage.emails); | ||
// remove email from server | ||
$.post("/wsapi/remove_email", {"email" : e}, function(response) { | ||
// we delete from store only once we got response | ||
delete t[e]; | ||
window.localStorage.emails = JSON.stringify(t); | ||
display_saved_ids(); | ||
}); | ||
}); | ||
|
||
var d = new Date(data.created); | ||
var datestamp = $("<div class='date'>").text("Signed in at " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ", " + d.getMonth() + "/" + d.getDay() + "/" + d.getUTCFullYear()); | ||
|
||
meta.append(datestamp); | ||
meta.append(linkblock); | ||
|
||
block.append(label); | ||
block.append(meta); | ||
// block.append(priv); | ||
block.append(pub); | ||
|
||
$("#emailList").append(block); | ||
}); | ||
} |