mirror of
https://github.com/Mibew/i18n.git
synced 2025-01-22 13:30:29 +03:00
Prevent user from setting an empty name (see Issue #3)
This commit is contained in:
parent
338d5a9976
commit
239e62d979
@ -18,7 +18,7 @@ c)},showTyping:function(a){$("typingdiv")&&($("typingdiv").style.display=a?"inli
|
||||
"typing"))&&this.showTyping("1"==d);(d=NodeUtils.getAttrValue(a,"canpost"))&&("1"==d&&!this.ownThread||this.ownThread&&"1"!=d)&&(window.location.href=window.location.href);for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];"message"==e.tagName?(b=!0,this.processMessage(c,e)):"avatar"==e.tagName&&this.setupAvatar(e)}0<=window.location.search.indexOf("trace=on")?(a="updated",0<this.lastupdate&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",10<c&&alert(a)),this.lastupdate=(new Date).getTime(),
|
||||
this.setStatus(a)):this.clearStatus();b&&(FrameUtils.scrollDown(this._options.container),this.skipNextsound||(b=$("soundimg"),(null==b||b.className.match(/\bisound\b/))&&playSound(Chat.mibewRoot+"/sounds/new_message.wav")),this.focused||window.focus())},isSendkey:function(a,b){return 13==b&&(a||this._options.ignorectrl)||10==b},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);return this._options.message&&this.isSendkey(ctrl,a)?(a=this._options.message.value,
|
||||
this._options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1):!0},handleError:function(a,b,c){b&&"error"==b.tagName?this.setStatus(NodeUtils.getNodeValue(b,"descr")):this.setStatus("reconnecting")},showStatusDiv:function(a){$("engineinfo")&&($("engineinfo").style.display="inline",$("engineinfo").innerHTML=a)},setStatus:function(a){this.statusTimeout&&clearTimeout(this.statusTimeout);this.showStatusDiv(a);this.statusTimeout=setTimeout(this.clearStatus.bind(this),4E3)},clearStatus:function(){$("engineinfo").style.display=
|
||||
"none"}});var Chat={threadUpdater:{},applyName:function(){Chat.threadUpdater.changeName($("uname").value);$("changename1").style.display="none";$("changename2").style.display="inline";$("unamelink").innerHTML=htmlescape($("uname").value)},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"}};
|
||||
"none"}});var Chat={threadUpdater:{},applyName:function(){$("uname").value.match(/^\s*$/)||(Chat.threadUpdater.changeName($("uname").value),$("changename1").style.display="none",$("changename2").style.display="inline",$("unamelink").innerHTML=htmlescape($("uname").value))},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"}};
|
||||
Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&Chat.threadUpdater.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){var a=$("msgwnd");0!=this.selectedIndex&&(a.value=this.options[this.selectedIndex].innerText||this.options[this.selectedIndex].innerHTML);this.selectedIndex=0;a.focus()}},"div#changename2 a":function(a){a.onclick=function(){Chat.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){Chat.applyName();
|
||||
return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){13==(a||event).keyCode&&Chat.applyName()}},"a#refresh":function(a){a.onclick=function(){Chat.threadUpdater.stopUpdate();Chat.threadUpdater.update()}},"a#togglesound":function(a){a.onclick=function(){var a=$("soundimg");a&&(a.className.match(/\bisound\b/)?a.className="tplimage inosound":a.className="tplimage isound",(a=$("msgwnd"))&&a.focus())}},"a.closethread":function(a){a.onclick=function(){Chat.threadUpdater.closeThread()}}});
|
||||
EventHelper.register(window,"onload",function(){Chat.mibewRoot=threadParams.wroot;Chat.cssfile=threadParams.cssfile;Chat.threadUpdater=new Ajax.ChatThreadUpdater({ignorectrl:-1,container:"safari"==myRealAgent?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}.extend(threadParams||{}))});
|
||||
|
@ -165,6 +165,7 @@ Class.inherit( Ajax.ChatThreadUpdater, Ajax.Base, {
|
||||
this.skipNextsound = true;
|
||||
new Ajax.Request(this._options.servl, {parameters:'act=rename&thread=' + (this._options.threadid || 0) +
|
||||
'&token=' + (this._options.token || 0) + '&name=' + encodeURIComponent(newname)});
|
||||
|
||||
},
|
||||
|
||||
onThreadClosed: function(_response) {
|
||||
@ -311,10 +312,12 @@ var Chat = {
|
||||
threadUpdater : {},
|
||||
|
||||
applyName: function() {
|
||||
Chat.threadUpdater.changeName($('uname').value);
|
||||
$('changename1').style.display='none';
|
||||
$('changename2').style.display='inline';
|
||||
$('unamelink').innerHTML = htmlescape($('uname').value);
|
||||
if ( !$('uname').value.match(/^\s*$/) ) {
|
||||
Chat.threadUpdater.changeName($('uname').value);
|
||||
$('changename1').style.display='none';
|
||||
$('changename2').style.display='inline';
|
||||
$('unamelink').innerHTML = htmlescape($('uname').value);
|
||||
}
|
||||
},
|
||||
|
||||
showNameField: function() {
|
||||
|
@ -91,10 +91,12 @@ if( $act == "refresh" ) {
|
||||
|
||||
$newname = getrawparam('name');
|
||||
|
||||
rename_user($thread, $newname);
|
||||
$data = strtr(base64_encode(myiconv($mibew_encoding,"utf-8",$newname)), '+/=', '-_,');
|
||||
setcookie($namecookie, $data, time()+60*60*24*365);
|
||||
show_ok_result("rename");
|
||||
if (!preg_match('/^\s*$/', $newname)) {
|
||||
rename_user($thread, $newname);
|
||||
$data = strtr(base64_encode(myiconv($mibew_encoding,"utf-8",$newname)), '+/=', '-_,');
|
||||
setcookie($namecookie, $data, time()+60*60*24*365);
|
||||
show_ok_result("rename");
|
||||
}
|
||||
|
||||
} else if( $act == "ping" ) {
|
||||
show_ok_result("ping");
|
||||
|
Loading…
Reference in New Issue
Block a user