protected void Page_Load(object sender, EventArgs e) { // Get information about chat room this window has been opened for. int roomId = QueryHelper.GetInteger("windowroomid", 0); try { ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomId); } catch (ChatServiceException) { DisplayError(); return; } ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomId); if (room == null) { DisplayError(); return; } // Script references insertion ScriptHelper.RegisterJQuery(Page); ChatScriptHelper.RegisterChatManager(Page); ChatScriptHelper.RegisterChatNotificationManager(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/Pages/Scripts/ChatRoomWindow.js"); SetWebpartsUp(room.ChatRoomIsSupport); lblTitle.Text = HTMLHelper.HTMLEncode(room.ChatRoomDisplayName) + " – " + GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation"); string json = JsonConvert.SerializeObject( new { roomId, pnlChatRoomWindowClientId = pnlChatRoomWindow.ClientID, pnlTopClientId = pnlTop.ClientID, pnlBottomClientId = pnlBottom.ClientID, ChatRoomMessagesClientId = ChatRoomMessagesElem.ClientID, btnCloseClientId = btnCloseWindow.ClientID, isSupport = room.ChatRoomIsSupport, notificationManagerOptions = new { eventName = "newmessage", soundFile = ChatSettingsProvider.EnableSoundSupportChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty, notifyTitle = GetString("chat.general.newmessages") }, title = lblTitle.Text }, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml } ); string startupScript = String.Format("ChatSupportWindow({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatSupportWindow", startupScript, true); }
protected void Page_Load(object sender, EventArgs e) { PageTitle title = PageTitle; passwordPromptElem.TitleText = ResHelper.GetString("chat.password"); // Script references insertion ScriptHelper.RegisterJQuery(Page); ChatScriptHelper.RegisterChatNotificationManager(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ChatRoomWindow.js"); // Get information about chat room this window has been opened for. int roomID = QueryHelper.GetInteger("windowroomid", 0); try { ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomID); } catch (ChatServiceException) { DisplayError(); return; } ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID); if (room == null) { DisplayError(); return; } string pnlChatRoomWindowCssClass = " ChatPopupWindow"; // Disable irrelevant controls if (room.ChatRoomIsOneToOne) { ChatMessageSendElem.HideUserPicker(); pnlChatRoomWindowCssClass += " IsOneToOne"; // Set appropriate window title string pageTitle = ResHelper.GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation"); Page.Header.Title = title.TitleText = pageTitle; } else { Page.Header.Title = title.TitleText = room.ChatRoomDisplayName; } SetWebpartsUp(); if (room.ChatRoomIsSupport) { pnlChatRoomWindowCssClass += " IsSupport"; if (ChatSettingsProvider.IsSupportMailEnabledAndValid) { pnlSupportSendMail.Visible = true; hplSupportSendMail.NavigateUrl = ChatSettingsProvider.SupportMailDialogURL + "?roomid=" + roomID; hplSupportSendMail.Target = "_blank"; } } pnlChatRoomWindow.CssClass += pnlChatRoomWindowCssClass; JavaScriptSerializer sr = new JavaScriptSerializer(); string json = sr.Serialize( new { roomID = roomID, password = room.HasPassword, pnlChatRoomPasswordPrompt = '#' + pnlChatRoomPasswordPrompt.ClientID, txtChatRoomPasswordPromptInput = '#' + txtChatRoomPasswordPromptInput.ClientID, btnChatRoomPasswordPromptSubmit = '#' + btnChatRoomPasswordPromptSubmit.ClientID, isOneToOne = room.IsWhisperRoom, isCustomerSupport = room.ChatRoomIsSupport, hplSupportSendMailClientID = room.ChatRoomIsSupport ? '#' + hplSupportSendMail.ClientID : "", pnlPasswordPromptError = '#' + pnlChatRoomsPromptPasswordError.ClientID, pnlChatRoomWindow = '#' + pnlChatRoomWindow.ClientID, ChatRoomMessagesClientID = ChatRoomMessagesElem.ClientID, btnClose = "#" + btnCloseWindow.ClientID, notificationManagerOptions = new { eventName = "newmessage", soundFile = ChatSettingsProvider.EnableSoundLiveChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty, notifyTitle = ResHelper.GetString("chat.general.newmessages") } } ); string startupScript = String.Format("ChatRoomWindow({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomWindow_" + ClientID, startupScript, true); }