From: konekoneko Date: Tue, 25 Sep 2012 18:00:41 +0000 (+0900) Subject: ルームごとにROMできるかどうかを設定できるようにした X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=0e0ed0bfc9ac1f936bdedd1cfe3a378185735b73;p=webchat%2FWebChat.git ルームごとにROMできるかどうかを設定できるようにした --- diff --git a/chatServer.js b/chatServer.js index 16ae00e..6cf9da8 100644 --- a/chatServer.js +++ b/chatServer.js @@ -200,6 +200,8 @@ for(var i = 0; i < $max_room_number; i++) var roomconfig = {}; if($rooms.IsFixedPassword(rno)) roomconfig.type = 2; + else if($rooms.IsHiddenLogFromRom(rno)) + roomconfig.type = 3; else if($rooms.IsContains(rno)) roomconfig.type = 1; else @@ -551,6 +553,11 @@ function RoomInfomationCollection() return name == collection[rno].owner || name in collection[rno].authed_list; }; + this.IsHiddenLogFromRom = function(rno){ + if(!this.IsContains(rno)) + return false; + return collection[rno].hiddenlog; + }; this.IsFixedPassword = function(rno){ if(!this.IsContains(rno)) return false; @@ -586,7 +593,8 @@ function RoomInfomationCollection() this.SetPassword = function(rno,owner,password){ if(this.IsContains(rno) && owner == collection[rno].owner && - !this.IsFixedPassword(rno)) + !this.IsFixedPassword(rno) && + !this.IsHiddenLogFromRom(rno)) { var date = new Date(); collection[rno].time = date.getTime(); @@ -604,7 +612,8 @@ function RoomInfomationCollection() var pass = collection[rno].password; if(pass == null) pass = ""; - retval += rno + ":" + pass + "\r\n"; + var hiddenlog = collection[rno].hiddenlog; + retval += rno + ":" + pass + ":" + hiddenlog + "\r\n"; } return retval; }; @@ -650,7 +659,7 @@ function RoomInfomationCollection() var token = line.toString().replace(/(\r|\n|\r\n)/gm, "").split(":"); if(token.length == 1) { - Add(token[0],null); + Add(token[0],null,false); } else if(token.length == 2) { @@ -658,7 +667,18 @@ function RoomInfomationCollection() var pass = token[1]; if(pass == "") pass = null; - Add(rno, pass); + Add(rno, pass,false); + } + else if(token.length == 3) + { + var rno = token[0]; + var pass = token[1]; + if(pass == "") + pass = null; + var hiddenlog = false; + if(token[2] == "true") + hiddenlog = true; + Add(rno, pass,hiddenlog); } }) .join(function(){ @@ -670,10 +690,11 @@ function RoomInfomationCollection() function Clear(){ collection = {}; }; - function Add(rno,pass){ + function Add(rno,pass,hiddenlogflag){ collection[rno] = {time : null, password : pass, owner : null, + hiddenlog : hiddenlogflag, authed_list : {}}; if(pass != null) collection[rno].owner = $system_name; diff --git a/public/scripts/chatclient.js b/public/scripts/chatclient.js index ab3a79e..67607c7 100644 --- a/public/scripts/chatclient.js +++ b/public/scripts/chatclient.js @@ -14,6 +14,7 @@ $invaild_name_message = "名前を空欄にすることはできません"; $free_password1 = "最初に入室する人が自由にパスワードを設定できます"; //自由パスワードメッセージ1 $free_password2 = "この部屋は使用されています。パスワードを入力してください"; //自由パスワードメッセージ2 $fixed_password = "この部屋にはパスワードが設定されています"; //固定パスワードルーム +$hidden_log_to_rom = "この部屋ではROMできないようになっています"; //ここから先は変更しないでください $prefix_filelist = "!"; @@ -79,6 +80,8 @@ function sendRoomInfoListerner(info) } }else if(info.type == 2){ $("#enter_message").append($fixed_password); + }else if(info.type == 3){ + $("#enter_message").append($hidden_log_to_rom); } } @@ -133,6 +136,8 @@ function openPastlogEventListener() function pastLogEventListerner(msg) { + if(IsRomMode() && $roominfo.type != 0) + return; for(var i = 0; i < msg.length; i++) ParseMessage(msg[i]); createNameList(); @@ -140,6 +145,8 @@ function pastLogEventListerner(msg) function getMessageEventListerner(msg) { + if(IsRomMode() && $roominfo.type != 0) + return; ParseMessage(msg); createNameList(); if( document.getElementById("bell").checked == true && msg.name != document.enter_form.name.value) @@ -223,12 +230,6 @@ function enterEventListener() return; } - if($roominfo.type != 0) //サーバー側からログが送られるので一旦クリアーする - { - $("#message").empty(); - $("#namelist").empty(); - } - $("#enter_frame").css("display","none"); $("#chat_frame").css("display","block"); @@ -243,9 +244,16 @@ function enterEventListener() function quitEventListener(){ $socket.json.emit("quit",{name:document.enter_form.name.value}); - $socket.json.emit("get pastLogList",{rno:document.chat_form.rno.value}); $("#enter_frame").css("display","block"); $("#chat_frame").css("display","none"); + + if($roominfo.type != 0) + { + $("#message").empty(); + $("#namelist").empty(); + } + else + $socket.json.emit("get pastLogList",{rno:document.chat_form.rno.value}); } function sidEventListener(){ @@ -275,6 +283,11 @@ function getErrorMessage(text) alert(text); } +function IsRomMode() +{ + return $("#chat_frame").css("display") == "none"; +} + //NameCollectionクラス function GetNameCollection(text) { diff --git a/readme.txt b/readme.txt index fd7a32e..affb531 100644 Binary files a/readme.txt and b/readme.txt differ