コード例 #1
0
    private string BuildStartupScript()
    {
        txtChatUserLoginRelogNickname.WatermarkText = ChatSettingsProvider.GuestPrefixSetting;

        string redirectURLLogout = RedirectURLLogout.Length > 0 ? RedirectURLLogout : ChatSettingsProvider.RedirectURLLogoutSetting;

        if (redirectURLLogout.Length > 0)
        {
            redirectURLLogout = ChatHelper.GetDocumentAbsoluteUrl(redirectURLLogout);
        }
        string redirectURLLogin = RedirectURLEnter.Length > 0 ? RedirectURLEnter : ChatSettingsProvider.RedirectURLLoginSetting;

        if (redirectURLLogin.Length > 0)
        {
            redirectURLLogin = ChatHelper.GetDocumentAbsoluteUrl(redirectURLLogin);
        }

        // Set onclick events
        btnChatUserLoggedInChangeNickname.OnClientClick = "ChatManager.Login.DisplayChangeNicknameForm('" + ClientID + "'); return false;";
        btnChatUserChangeNicknameButton.OnClientClick   = "ChatManager.Login.ChangeNickname($cmsj('#" + txtChatUserChangeNicknameInput.ClientID + "').val(), '" + ClientID + "'); return false;";
        btnChangeNicknameCancel.OnClientClick           = "ChatManager.Login.ChangeNickname(null, null, true); return false;";

        string json = JsonConvert.SerializeObject(
            new
        {
            pnlChatUserLoggedIn             = pnlChatUserLoggedIn.ClientID,
            pnlChatUserChangeNicknameForm   = pnlChatUserChangeNicknameForm.ClientID,
            lblChatUserLoggedInInfoValue    = lblChatUserLoggedInInfoValue.ClientID,
            btnChatUserChangeNicknameButton = btnChatUserChangeNicknameButton.ClientID,
            pnlChatUserLoginError           = pnlChatUserLoginError.ClientID,
            lblChatUserLoginErrorText       = lblChatUserLoginErrorText.ClientID,
            txtChatUserChangeNicknameInput  = txtChatUserChangeNicknameInput.ClientID,
            clientID = ClientID,
            pnlChatUserLoginRelog         = pnlChatUserLoginRelog.ClientID,
            btnLogout                     = btnChatUserLoggedInLogout.ClientID,
            resStrLogout                  = ResHelper.GetString("chat.login.resStrLogoutAnonym"),
            txtChatUserLoginRelogNickname = txtChatUserLoginRelogNickname.ClientID,
            lblChatUserLoginRelogNickname = lblChatUserLoginRelogNickname.ClientID,
            lblChatUserLoginRelogText     = lblChatUserLoginRelogText.ClientID,
            redirectURLLogout             = redirectURLLogout,
            redirectURLEnter              = redirectURLLogin,
            resStrLogAsAnonym             = ResHelper.GetString("chat.login.logasanonym"),
            resStrLogAsCMS                = ResHelper.GetString("chat.login.logascms"),
            btnChatUserLoginRelog         = btnChatUserLoginRelog.ClientID,
            resStrNoService               = ResHelper.GetString("chat.servicenotavailable")
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );

        return(String.Format("InitChatLogin({0});", json));
    }
コード例 #2
0
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        string redirectURL = RedirectURL.Length > 0 ? RedirectURL : ChatHelper.RedirectURLJoinSetting;

        // Set all the transformation settings for chat room window
        int roomSettingsId = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            guid                              = roomSettingsId,
            clientID                          = ClientID,
            groupID                           = GroupID,
            pnlChatRoomsList                  = pnlChatRoomsList.ClientID,
            pnlChatRoomsPrompt                = pnlChatRoomsPrompt.ClientID,
            btnChatRoomsPromptSubmit          = btnChatRoomsPromptSubmit.ClientID,
            pnlChatRoomsCreatePrompt          = pnlChatRoomsCreatePrompt.ClientID,
            txtChatRoomsCreateName            = txtChatRoomsCreateName.ClientID,
            chkChatRoomsCreateIsPrivate       = chkChatRoomsCreateIsPrivate.ClientID,
            txtChatRoomsCreatePassword        = txtChatRoomsCreatePassword.ClientID,
            chkChatRoomsCreateAllowAnonym     = chkChatRoomsCreateAllowAnonym.ClientID,
            btnChatRoomsCreatePromptSubmit    = btnChatRoomsCreatePromptSubmit.ClientID,
            lblChatRoomsCreateError           = lblChatRoomsCreateError.ClientID,
            txtChatRoomsPromptInput           = txtChatRoomsPromptInput.ClientID,
            btnChatRoomsCreateRoom            = btnChatRoomsCreateRoom.ClientID,
            templateListItem                  = ChatHelper.GetWebpartTransformation(ListItemTransformation, "chat.error.transformation.rooms"),
            loadingDiv                        = ChatHelper.GetWebpartLoadingDiv("ChatRoomsWPLoading", "chat.wploading.rooms"),
            txtChatRoomsCreateDescription     = txtChatRoomsCreateDescription.ClientID,
            btnChatRoomsPromptClose           = btnChatRoomsPromptClose.ClientID,
            btnChatRoomsCreatePromptClose     = btnChatRoomsCreatePromptClose.ClientID,
            btnChatRoomsDeletePromptSubmit    = btnChatRoomsDeletePromptSubmit.ClientID,
            btnChatRoomsDeletePromptClose     = btnChatRoomsDeletePromptClose.ClientID,
            pnlChatRoomsDeletePrompt          = pnlChatRoomsDeletePrompt.ClientID,
            btnChatRoomsAbandonPromptSubmit   = btnChatRoomsAbandonPromptSubmit.ClientID,
            btnChatRoomsAbandonPromptClose    = btnChatRoomsAbandonPromptClose.ClientID,
            pnlChatRoomsAbandonPrompt         = pnlChatRoomsAbandonPrompt.ClientID,
            pnlChatRoomsEditPrompt            = pnlChatRoomsEditPrompt.ClientID,
            txtChatRoomsEditName              = txtChatRoomsEditName.ClientID,
            txtChatRoomsEditDescription       = txtChatRoomsEditDescription.ClientID,
            chkChatRoomsEditIsPrivate         = chkChatRoomsEditIsPrivate.ClientID,
            txtChatRoomsEditPassword          = txtChatRoomsEditPassword.ClientID,
            chkChatRoomsEditAllowAnonym       = chkChatRoomsEditAllowAnonym.ClientID,
            btnChatRoomsEditPromptSubmit      = btnChatRoomsEditPromptSubmit.ClientID,
            btnChatRoomsEditPromptClose       = btnChatRoomsEditPromptClose.ClientID,
            txtChatRoomsEditPasswordConfirm   = txtChatRoomsEditPasswordConfirm.ClientID,
            lblChatRoomsEditError             = lblChatRoomsEditError.ClientID,
            passwordTxt                       = ResHelper.GetString("chat.password") + ":",
            passwordNewTxt                    = ResHelper.GetString("chat.passwordnew") + ":",
            lblChatRoomsEditPasswordNew       = lblChatRoomsEditPasswordNew.ClientID,
            txtChatRoomsCreatePasswordConfirm = txtChatRoomsCreatePasswordConfirm.ClientID,
            pnlChatRoomsEditError             = pnlChatRoomsEditError.ClientID,
            chkChatRoomsHasPassword           = chkChatRoomsHasPassword.ClientID,
            pnlChatRoomsCreateError           = pnlChatRoomsCreateError.ClientID,
            pnlFilterClientID                 = pnlChatRoomsFiltering.ClientID,
            pnlPagingClientID                 = pnlChatRoomsPaging.ClientID,
            pagingItems                       = PagingItems > 0 ? PagingItems : ChatHelper.WPPagingItems,
            groupPagesBy                      = GroupPagesBy >= 0 ? GroupPagesBy : ChatHelper.WPGroupPagesBy,
            pagingEnabled                     = EnablePaging,
            btnFilter                         = btnChatRoomsFilter.ClientID,
            txtFilter                         = txtChatRoomsFilter.ClientID,
            filterEnabled                     = EnableFiltering,
            pnlInfo                           = pnlChatRoomsInfo.ClientID,
            resStrNoFound                     = ResHelper.GetString("chat.rooms.notfound"),
            resStrResults                     = ResHelper.GetString("chat.rooms.results"),
            resStrTooltipPopup                = ResHelper.GetString("chat.enterwithpopup"),
            filterCount                       = ShowFilterItems >= 0 ? ShowFilterItems : ChatHelper.WPShowFilterLimit,
            passwordPromptError               = pnlChatRoomsPromptPasswordError.ClientID,
            redirectURL                       = ChatHelper.GetDocumentAbsoluteUrl(redirectURL),
            redirectGroup                     = RedirectGroup,
            envelopeID                        = "envelope_" + ClientID,
            pnlErrorCreate                    = pnlChatRoomsCreateErrorConfirm.ClientID,
            pnlErrorEdit                      = pnlChatRoomsEditErrorConfirm.ClientID,
            enablePopup                       = EnablePopup,
            passwordNotMatchStr               = ResHelper.GetString("administration-user_edit_password.passwordsdonotmatch")
        }
            );

        return(String.Format("InitChatRooms({0})", json));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatLeaveRoom_files/ChatLeaveRoom.js");

        string redirectURL = RedirectURL.Length > 0 ? RedirectURL : ChatSettingsProvider.RedirectURLLeaveSetting;

        // Prepare and run startup script
        string startupScript = String.Format("InitChatLeaveRoom({{groupID:{0}, clientID:'{1}', btnChatLeaveRoom:{2},pnlContent:{3}, redirectURL:{4}, envelopeID: '#envelope_{1}' }});",
                                             ScriptHelper.GetString(GroupID),
                                             ClientID,
                                             ScriptHelper.GetString("#" + btnChatLeaveRoom.ClientID),
                                             ScriptHelper.GetString('#' + pnlChatLeaveRoom.ClientID),
                                             redirectURL.Length > 0 ? ScriptHelper.GetString(ChatHelper.GetDocumentAbsoluteUrl(redirectURL)) : "\"\""
                                             );

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatLeaveRoom_" + ClientID, startupScript, true);
    }