Skip to content

Commit 373f734

Browse files
committed
Feature: Change username
We have added the ability to change your username.
1 parent 2790a7b commit 373f734

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

client/pfc-init.js

+31
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,43 @@ var phpFreeChat = (function (pfc, $, window, undefined) {
481481
menu += '<li><a href="#">Remove operator rights</a></li>';
482482
menu += '<li><a href="#">Kick</a></li>';
483483
menu += '<li><a href="#">Ban</a></li>';
484+
if( $(this).parent().attr("id") == "user_"+pfc.uid )
485+
{
486+
//User's Menu
487+
//Display change username menu
488+
menu += '<li><a id="changeNickname" href="#">Change Username</a></li>';
489+
}else{
490+
//Other User's Menu
491+
//Don't display change username menu
492+
}
484493
menu += '</ul></div>';
485494
$(this).append(menu);
495+
496+
$('#changeNickname').click(function (evt) {
497+
498+
var newName = prompt("Please enter your new nickname", "");
499+
500+
if(newName=='')
501+
{
502+
alert('Your nickname may not be blank.');
503+
}
504+
else{
505+
pfc.renameUser(newName);
506+
}
507+
});
508+
486509
}).live("mouseleave", function () {
487510
$(".actions-menu").remove();
488511
});
489512
};
513+
514+
pfc.renameUser = function (newName) {
515+
//1. Send GET Request
516+
$.get( "../server/users/"+pfc.uid+"/rename/"+newName+"", function( data ) {
517+
//2. Refresh Browser
518+
location.reload();
519+
});
520+
}
490521

491522
/**
492523
* Load specific javascript defined by the theme

0 commit comments

Comments
 (0)