vnext
Paul Schneider 5 years ago
parent a4c097dd0d
commit 25e2295d3d
1 changed files with 1 additions and 1 deletions

@ -6,4 +6,4 @@ $('<li></li>').append(tag+': '+targetid+': ').append(message).addClass(tag).appe
frontChanId=chanId;$('#sel_'+chanId).removeClass('btn-primary');$('#v'+chanId).removeClass('hidden');$('#inp_'+chanId).focus();};var chatbar=$('<div class="chatbar"></div>');var roomjoin=$('<div class="chatctl" class="form-control"></div>');var roomlist=$('<div class="roomlist"></div>');roomlist.appendTo(chatbar);$('<label for="channame">Join&nbsp;:</label>').appendTo(roomjoin);var chanName=$('<input id="channame" title="channel name" hint="yavsc" >');chanName.appendTo(roomjoin);roomjoin.appendTo(chatbar);chatbar.appendTo($view);var chatlist=$('<div class="chatlist" ></div>');chatlist.appendTo($view);var buildChan=function(chdp,chanType,chanName,sendCmd){var chanId=chanType+chanName;var roomTag=$('<a>'+chdp+chanName+'</a>').addClass('btn');roomTag.prop('id','sel_'+chanId).click(function(){setActiveChan(chanId);$(this).removeClass('btn-primary');});roomTag.appendTo(roomlist);var roomview=$('<div></div>').addClass('container');roomview.appendTo(chatlist);roomview.prop('id','v'+chanId);var msglist=$('<ul></ul>').addClass('mesglist');msglist.prop('id',chanId);msglist.appendTo(roomview);$('<input type="text">').prop('id','inp_'+chanId).prop('enable',false).prop('hint','hello').prop('title','send to '+chanName).addClass('form-control').keydown(function(ev){if(ev.which==13){if(this.value.length==0)return;sendCmd(chanName,this.value);this.value='';}}).appendTo(roomview);if(chanType=='r')chans.push(chanName);else if(chanType=='u'||chanType=='a')userlist.push(chanName);setActiveChan(chanId);};var buildRoom=function(roomName){if(chans.some(function(cname){return cname==roomName;}))setActiveChan('r'+roomName);else buildChan('#','r',roomName,chat.server.send);};var buildPv=function(userName){if(userlist.some(function(uname){return uname==userName;}))setActiveChan('u'+userName);else
if(userName[0]=='?')buildChan('@?','a',userName.slice(1),chat.server.sendPV);else buildChan('@','u',userName,chat.server.sendPV);};$view.data('chans').split(',').forEach(function(chan){buildRoom(chan);});function onCx(){setTimeout(function(){chans.forEach(function(room){chat.server.join(room).done(function(chatInfo){setActiveChan('r'+chatInfo.Name);});});},120);$view.removeClass('disabled');}
function onDisCx(){$view.addClass('disabled');}
$.connection.hub.start().done(function(){onCx();});$.connection.hub.disconnected(function(){onDisCx();setTimeout(function(){$.connection.hub.start().done(function(){onCx();});},30000);});chanName.keydown(function(event){if(event.which==13){if(this.value.length==0)return;buildRoom(this.value);chat.server.join(this.value).done(function(chatInfo){setActiveChan('r'+chatInfo.Name);});this.value='';}});var audio=new Audio('/sounds/bell.mp3');$('#command').keydown(function(event){if(event.which==13){}});var addChatUser=function(uname){$('#u'+uname).remove();$('<li class="user"><img src="/Avatars/'+uname+'.xs.png"> '+uname+'</li>').prop('id','u_'+uname).css('cursor','pointer').click(function(){buildPv(uname);}).appendTo(ulist);};function htmlEncode(value){var encodedValue=$('<div />').text(value).html();return encodedValue;}};$(document).ready(function($){ChatView($('#chatview'),true);});})(window.jQuery);
$.connection.hub.start().done(function(){onCx();});$.connection.hub.disconnected(function(){onDisCx();setTimeout(function(){$.connection.hub.start().done(function(){onCx();});},30000);});chanName.keydown(function(event){if(event.which==13){if(this.value.length==0)return;buildRoom(this.value);chat.server.join(this.value).done(function(chatInfo){setActiveChan('r'+chatInfo.Name);});this.value='';}});var audio=new Audio('/sounds/bell.mp3');$('#command').keydown(function(event){if(event.which==13){}});var addChatUser=function(uname){$('#u_'+uname).remove();$('<li class="user"><img src="/Avatars/'+uname+'.xs.png"> '+uname+'</li>').prop('id','u_'+uname).css('cursor','pointer').click(function(){buildPv(uname);}).appendTo(ulist);};function htmlEncode(value){var encodedValue=$('<div />').text(value).html();return encodedValue;}};$(document).ready(function($){ChatView($('#chatview'),true);});})(window.jQuery);
Loading…