protected void Page_Load(object sender, EventArgs e) { if (StopProcessing || !ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview)) { return; } // Registration to chat webservice AbstractCMSPage cmsPage = Page as AbstractCMSPage; if (cmsPage != null) { ChatScriptHelper.RegisterChatAJAXProxy(cmsPage); } // Script references insertion ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterJQueryCookie(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx"); ScriptHelper.RegisterJQueryTemplates(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/AutoInitiatedChat_files/AutoInitiatedChat.js"); int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName); // Run script string json = JsonConvert.SerializeObject( new { wpGUID = InstanceGUID, clientID = pnlInitiatedChat.ClientID, contentID = pnlContent.ClientID, pnlErrorID = pnlError.ClientID, lblErrorID = lblError.ClientID, windowURL = ChatUIHelper.GetChatRoomWindowURL(), trans = ChatUIHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"), guid = optID, delay = Delay * 1000, initiatorName = InitiatorName, messages = MacroResolver.Resolve(Messages).Split('\n') }, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml } ); string startupScript = string.Format("InitAutoInitiatedChat({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatAutoInitiatedChat_" + ClientID, startupScript, true); }
protected void Page_Load(object sender, EventArgs e) { if (!ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview)) { return; } // Registration to chat webservice AbstractCMSPage cmsPage = Page as AbstractCMSPage; if (cmsPage != null) { ChatHelper.RegisterChatAJAXProxy(cmsPage); } // Script references insertion ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx"); ScriptHelper.RegisterJQueryTemplates(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/InitiatedChat_files/InitiatedChat.js"); int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName); // Run script JavaScriptSerializer sr = new JavaScriptSerializer(); string json = sr.Serialize( new { clientID = pnlInitiatedChat.ClientID, contentID = pnlContent.ClientID, pnlErrorID = pnlError.ClientID, lblErrorID = lblError.ClientID, windowURL = ChatHelper.GetChatRoomWindowURL(), trans = ChatHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"), guid = optID, pingTick = ChatHelper.GlobalPingIntervalSetting * 1000 } ); string startupScript = string.Format("InitInitiatedChatManager({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatInitiatedChat_" + ClientID, startupScript, true); }
/// <summary> /// Builds startup script. /// </summary> private string BuildStartupScript() { // Set all the transformation settings for chat room window int roomSettingsId = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName); bool isLiveSite = ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview); string json = JsonConvert.SerializeObject( new { template = ChatUIHelper.GetWebpartTransformation(NotificationTransformation, "chat.error.transformation.notification"), clientID = ClientID, chatRoomGUID = roomSettingsId, pnlChatNotificationEmpty = GetString(pnlChatNotificationEmpty), pnlChatNotificationFull = GetString(pnlChatNotificationFull), btnChatNotificationFullLink = GetString(btnChatNotificationFullLink), lblChatNotificationFullTextNumber = GetString(lblChatNotificationFullTextNumber), pnlChatNotificationNotifications = GetString(pnlChatNotificationNotifications), pnlChatNotificationNotificationsList = GetString(pnlChatNotificationNotificationsList), btnChatNotificationPromptClose = GetString(btnChatNotificationPromptClose), wpPanelID = GetString(pnlWPNotifications), envelopeID = "#envelope_" + ClientID, bubbleBtnShow = GetString(btnShow), bubbleBtnClose = GetString(btnClose), bubbleLabel = GetString(lblInfoMessage), bubblePanel = GetString(pnlNotificationInfoBubble), strNoNotif = ResHelper.GetString("chat.notification.empty"), resNewNotif = ResHelper.GetString("chat.notification.youhave"), bubbleEnabled = EnableNotificationBubble && isLiveSite, isPreview = ViewMode.IsPreview(), notificationManagerOptions = new { eventName = "newnotification", soundFile = ChatSettingsProvider.EnableSoundLiveChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_notification.mp3") : String.Empty, notifyTitle = ResHelper.GetString("chat.notification.bubble.header") } }, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml } ); return(String.Format("InitChatNotification({0});", json)); }