Mercurial > summit-idp
changeset 30:f56852d2076f
Simplified logic for saving/restoring profile info fields
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sat, 26 Jun 2010 09:00:46 -0700 |
parents | 818e16d3f262 |
children | b92bb0974500 |
files | static-files/index.html static-files/index.js |
diffstat | 2 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/static-files/index.html Fri Jun 25 20:11:24 2010 -0700 +++ b/static-files/index.html Sat Jun 26 09:00:46 2010 -0700 @@ -96,20 +96,23 @@ <fieldset> <div class="ctrlHolder"> <label for="">Your Name</label> - <input id="name" name="" value="" size="35" class="textInput" type="text"> + <input id="usr_name" name="" value="" size="35" + class="usr textInput" type="text"> <p class="formHint">What should people call you?</p> </div> <div class="ctrlHolder"> <label for="">Profile Image URL</label> - <input id="profile-image" name="" value="" size="35" class="textInput" type="text"> + <input id="usr_profileImage" name="" value="" size="35" + class="usr textInput" type="text"> <p class="formHint">If you have a picture of yourself somewhere, paste in its URL here. It's expected to have square dimensions.</p> </div> <div class="ctrlHolder"> <label for="">Bugzilla Email</label> - <input id="bugzilla-email" name="" value="" size="35" class="textInput" type="text"> + <input id="usr_bugzillaEmail" name="" value="" size="35" + class="usr textInput" type="text"> <p class="formHint">If you use Bugzilla, enter your email here.</p> </div>
--- a/static-files/index.js Fri Jun 25 20:11:24 2010 -0700 +++ b/static-files/index.js Sat Jun 26 09:00:46 2010 -0700 @@ -123,9 +123,11 @@ var userInfo = Attendees.value[Config.value.userID]; if (!userInfo) userInfo = {}; - $("#name").val(userInfo.name || ""); - $("#profile-image").val(userInfo.profileImage || ""); - $("#bugzilla-email").val(userInfo.bugzillaEmail || ""); + $(".usr").each( + function() { + var prop = this.id.match(/usr_(.+)/)[1]; + $(this).val(userInfo[prop] || ""); + }); } Attendees.observers.push(fillUserInfo); @@ -180,11 +182,13 @@ $("#logged-in .success").hide(); $("#logged-in .error").hide(); - var contents = { - name: $("#name").val(), - profileImage: $("#profile-image").val(), - bugzillaEmail: $("#bugzilla-email").val() - }; + var contents = {}; + + $(".usr").each( + function() { + var prop = this.id.match(/usr_(.+)/)[1]; + contents[prop] = this.value; + }); jQuery.postJSON( "api/profile",