OSDN Git Service

管理画面表示時に落ちるバグ&部屋情報が正しく表示されないバグを修正した
authorgdkhd812 <jbh03215@hotmail.co.jp>
Fri, 30 May 2014 17:52:37 +0000 (02:52 +0900)
committergdkhd812 <jbh03215@hotmail.co.jp>
Fri, 30 May 2014 17:52:37 +0000 (02:52 +0900)
room.js

diff --git a/room.js b/room.js
index b64a059..a5ff81c 100644 (file)
--- a/room.js
+++ b/room.js
@@ -1,6 +1,7 @@
 //RoomInfomationCollecion\83N\83\89\83X
 module.exports = function()
 {
+       var _this = this;
        var config = require("./configure.js");
        var MySQLPool = new require("./mysql_pool.js");
        var pool = new MySQLPool({
@@ -22,7 +23,7 @@ module.exports = function()
                for(var rno in collection)
                {
                        item={};
-                       item.applyflag = !$rooms.Get(rno).IsVolatile();
+                       item.applyflag = !_this.Get(rno).IsVolatile();
                        item.password = collection[rno].password;
                        if(item.password == null)
                                item.password = "";
@@ -104,7 +105,7 @@ module.exports = function()
                        collection[rno].owner = $system_name;
        };
        var $gc_interval_id = setInterval(function(){
-               for(var rno in this.rom_list)
+               for(var rno in _this.rom_list)
                        collection[rno].GCRomList();
        },$gc_time_interval);
        GetRoomList();
@@ -113,6 +114,7 @@ module.exports = function()
 //RoomInfomation\83N\83\89\83X
 function RoomInfomation(pass,hiddenlogflag)
 {
+       var _this = this;
        this.password = pass;
        this.rom_list = {};
        this.authed_list = {};
@@ -121,90 +123,90 @@ function RoomInfomation(pass,hiddenlogflag)
        this.hiddenlog = hiddenlogflag;
        this.GetConfig = function(){
                var roomconfig = {};
-               if(this.IsVolatile() == false)
+               if(_this.IsVolatile() == false)
                {
-                       if(this.IsFixedPassword())
+                       if(_this.IsFixedPassword())
                                roomconfig.type = 2;
-                       else if(this.IsHiddenLogFromRom())
+                       else if(_this.IsHiddenLogFromRom())
                                roomconfig.type = 3;
                        else
                                roomconfig.type = 1;
-                       roomconfig.IsOwned = !this.IsFirstAuth();
+                       roomconfig.IsOwned = !_this.IsFirstAuth();
                }else{
                        roomconfig.type = 0;
                }
                return roomconfig;
        }
        this.IsVolatile = function(){
-               return this.owner == null &&
-                       this.password == null &&
-                       this.time == null &&
-                       this.hiddenlog == null;
+               return _this.owner == null &&
+                       _this.password == null &&
+                       _this.time == null &&
+                       _this.hiddenlog == null;
        }
        this.GetRomCount = function(){
                var count = 0;
-               for(var key in this.rom_list)
+               for(var key in _this.rom_list)
                        count++;
                return count;
        };
        this.AddRom = function(ip){
                var date = new Date();
-               this.rom_list[ip] = {time:date.getTime()};
+               _this.rom_list[ip] = {time:date.getTime()};
        };
        this.RemoveRom = function(ip){
-               delete this.rom_list[ip];
+               delete _this.rom_list[ip];
        };
        this.Reset = function(owner){
                var date = new Date();
                var time = date.getTime();
-               this.password = null;
-               this.authed_list = {};
-               this.owner = owner;
-               this.time = time;
+               _this.password = null;
+               _this.authed_list = {};
+               _this.owner = owner;
+               _this.time = time;
        };
        this.IsFirstAuth = function(){
-               return this.owner == null;
+               return _this.owner == null;
        };
        this.IsAuthed = function(name){
-               return name == this.owner ||
-                       name in this.authed_list;
+               return name == _this.owner ||
+                       name in _this.authed_list;
        };
        this.IsHiddenLogFromRom = function(){
-               return this.hiddenlog;
+               return _this.hiddenlog;
        };
        this.IsFixedPassword = function(){
-               return this.owner == $system_name;
+               return _this.owner == $system_name;
        };
        this.IsOwner = function(name){
-               return this.owner == name;
+               return _this.owner == name;
        };
        this.IsTimeout = function(){
                var date = new Date();
                var current_time = date.getTime();
-               return !this.IsFixedPassword() &&
-                       current_time - this.time >= $reset_password_diff;
+               return !_this.IsFixedPassword() &&
+                       current_time - _this.time >= $reset_password_diff;
        };
        this.RemoveAuth = function(name)
        {
-               delete this.authed_list[name];
+               delete _this.authed_list[name];
        };
        this.Auth = function(name,password){
-               if(this.password != password)
+               if(_this.password != password)
                        return false;
                var date = new Date();
                var time = date.getTime();
-               this.time = time;
-               this.authed_list[name] = "";
+               _this.time = time;
+               _this.authed_list[name] = "";
                return true;
        };
        this.SetPassword = function(owner,password){
-               if(owner == this.owner &&
-                       !this.IsFixedPassword() &&
-                       !this.IsHiddenLogFromRom())
+               if(owner == _this.owner &&
+                       !_this.IsFixedPassword() &&
+                       !_this.IsHiddenLogFromRom())
                {
                        var date = new Date();
-                       this.time = date.getTime();
-                       this.password = password;
+                       _this.time = date.getTime();
+                       _this.password = password;
                        return true;
                }
                return false;
@@ -212,10 +214,10 @@ function RoomInfomation(pass,hiddenlogflag)
        this.GCRomList = function(){
                var date = new Date();
                var current_time = date.getTime();
-               for(var ip in this.rom_list)
+               for(var ip in _this.rom_list)
                {
-                       if(current_time - this.rom_list[ip].time >= $gc_time_interval)
-                               delete this.rom_list[ip];
+                       if(current_time - _this.rom_list[ip].time >= $gc_time_interval)
+                               delete _this.rom_list[ip];
                }
        };
 }