define(function (require, exports, module) { var ep = require("../../platform/extensionPort.js"); var port = ep.port; var data = require("../../data.js"); var sessMgr = require("../../account/sessionMgr.js"); var ev = require("../../platform/EventObject.js"); var chat = require("../../platform/chat.js"); var uiLogin = require("./ui-login.js"); //frames var servernode = require("./servernode.js"); servernode.on("roomSelectHide", function () { hideChatFrameUI(); showChatFloatTip(); }); servernode.on("chatServerLoaded", function (e, serverList) { servers = serverList; if (servers) showChatFloatTip(); }); servernode.on("enterRoot", function (e, room) { //进入房间 sessMgr.ensureLogined(enterroom.bind(room)); }); //服务器 var servers; var showChatFloatTip = function () { if ($("#chat_frame.open").length) return; var totalcount = _.reduce(_.pluck(servers, "onlinecount"), function (i, m) { return i + m; }, 0); $("#chat_float_tip").find("span").html(totalcount).end().show(); }; var showChatFrameUI = function () { $("#chat_frame").height(); $("#chat_frame").addClass("open"); $("div.wrap").addClass("chat-on"); $("#chat_float_tip").hide(); }; var hideChatFrameUI = function () { $("div.wrap").removeClass("chat-on"); $("#chat_frame").removeClass("open"); }; var showServerList = function () { showChatFrameUI(); servernode.showRoomSelect(); }; //进入房间 var roomSession = require("./roomsession.js"); var enterroom = function () { showChatFrameUI(); roomSession.enterRoom(this); }; (function ui() { $("#chat_float_tip").click(showServerList); })(); servernode.loadServers(); return { }; });