Add front-end password changing bits
username: <input type="text" id="login.username" size="10">
password: <input type="password" id="login.password" size="10">
<input type="submit" value="login">
- <p style="font-size: large"><a href="#" onclick="$('welcome').hide(); $('items').hide(); $('post').hide(); $('signup').show(); return false;">I want to blërg!</a></p>
+ <p style="font-size: large"><a href="#" onclick="$('welcome').hide(); $('items').hide(); $('post').hide(); $('signup').show(); return false">I want to blërg!</a></p>
</form>
<div id="logout" style="display: none">
- Hello, <a href="#" id="userlink" onclick="return qlink()"></a>. <a href="#" onclick="loginStatus.logout(); return false">logout</a><br>
+ Hello, <a href="#" id="userlink" onclick="return qlink()"></a>. <a href="#" onclick="$('welcome').hide(); $('items').hide(); $('post').hide(); $('navigation').hide(); $('passwd').show(); return false">change password</a> <a href="#" onclick="loginStatus.logout(); return false">logout</a><br>
<a href="#" onclick="postPopup(); return false">Write new entry</a><br>
<a href="#" id="reflink" onclick="return qlink()">Chatter about me</a><br>
<a href="#/feed" onclick="return qlink()">Stalk your victims <span id="newFeedMessages"></span></a>
<div id="signup" style="display:none">
<h2>Sign Up</h2>
<table>
- <tr><td>Username:</td><td><input type="text" id="signup.username" width="40"></td>
- <tr><td>Password:</td><td><input type="password" id="signup.password" width="40"></td>
+ <tr><td>Username:</td><td><input type="text" id="signup.username" width="40"></td></tr>
+ <tr><td>Password:</td><td><input type="password" id="signup.password" width="40"></td></tr>
</table>
<button onclick="signup()">Signup</button> <button onclick="signup_cancel()">Cancel</button>
</div>
+
+ <div id="passwd" style="display:none">
+ <h2>Change Your Password</h2>
+ <table>
+ <tr><td>Old Password:</td><td><input type="text" id="passwd.old_password" width="40"></td></tr>
+ <tr><td>New Password:</td><td><input type="text" id="passwd.new_password" width="40"></td></tr>
+ </table>
+ <button onclick="passwd()">Change</button> <button onclick="passwd_cancel()">Cancel</button>
+ </div>
+
</div>
</body>
urlSwitch();
}
+function passwd() {
+ var old_password = $('passwd.old_password').value;
+ var new_password = $('passwd.new_password').value;
+
+ new Ajax.Request(baseURL + '/passwd', {
+ parameters: {
+ username: loginStatus.username,
+ password: old_password,
+ new_password: new_password
+ },
+ onSuccess: function(r) {
+ if (r.responseJSON.status == 'success') {
+ alert('Password changed');
+ passwd_cancel();
+ } else {
+ alert('Password change failed. Your password has NOT been changed.');
+ }
+ },
+ onFailure: function(r) {
+ alert('Password change error');
+ }
+ });
+}
+
+function passwd_cancel() {
+ $('passwd').hide();
+ $('navigation').show();
+ urlSwitch();
+}
+
function subscribe() {
new Ajax.Request(baseURL + '/subscribe/' + currentPager.username, {
method: 'post',
$('welcome').hide();
}
+Welcome.prototype.updateState = function() {
+ this.show();
+}
+
function ExternalURLPost(m) {
this.title = decodeURIComponent(m[1]).replace(']','').replace('[','');
this.url = decodeURIComponent(m[2]);