Exemple #1
0
 /// <summary>
 /// Creates a notification to add the given content to a specified div
 /// </summary>
 /// <param name="divId">the div to add content to</param>
 /// <param name="content">the content to add</param>
 /// <returns>the specified notification</returns>
 public static Notification AddContentToDiv(string divId, IJSValue content)
 {
     return(new ExecuteScriptNotification(
                JSElement.GetByID(divId).InnerHTML.Set(
                    JSElement.GetByID(divId).InnerHTML + content
                    ).GetJsCode(SessionData.CurrentSession, CallingContext.Inner)));
 }
Exemple #2
0
        /// <inheritdoc />
        public override string GetContent(SessionData sessionData)
        {
            var input = new JSInput(HInput.EInputType.text, Name, Value)
            {
                Class = Class, Style = Style, Title = Title
            };

            if (!string.IsNullOrWhiteSpace(Placeholder))
            {
                input.DescriptionTags = "placeholder='" + Placeholder + "' ";
            }

            if (!string.IsNullOrWhiteSpace(ID))
            {
                input.ID = ID;
            }
            else
            {
                input.ID = Hash.GetHash();
            }

            var container = new HContainer()
            {
                ID = ContainerID, Style = "display:none;"
            };

            input.onclick    = JSFunctionCall.DisplayElementByID(container.ID);
            input.onfocus    = input.onclick;
            input.oninput    = input.SetInnerHTMLWithNameValueAsync(JSElement.GetByID(container.ID), "/" + _pageUrl, JSFunctionCall.DisplayElementByID(container.ID));
            input.onfocusout = new JSIf(JSElement.GetByID(input.ID)["value"].IsEqualTo(new JSRawStringValue("")), JSFunctionCall.HideElementByID(container.ID));

            return(input + container);
        }
Exemple #3
0
        /// <inheritdoc />
        public override string GetContent(SessionData sessionData)
        {
            if (Values == null || Values.Count == 0)
            {
                Logger.LogExcept(new ArgumentException($"No Values given to cycle through."));
            }

            string defaultContents = "";

            foreach (var element in Values.First().Item2)
            {
                defaultContents += element.GetContent(sessionData);
            }

            var case0 = new JScript(JSElement.GetByID(hiddenElementID).Value.Set((JSStringValue)Values.First().Item1),
                                    JSElement.GetByID(ID).InnerHTML.Set((JSStringValue)defaultContents));

            var switchStatement = new JSSwitch(JSElement.GetByID(hiddenElementID).Value, case0, new Tuple <IJSValue, IJSPiece>((JSStringValue)Values.Last().Item1, case0));

            for (int i = 1; i < Values.Count; i++)
            {
                string contents = "";

                foreach (var element in Values[i].Item2)
                {
                    contents += element.GetContent(sessionData);
                }

                switchStatement.AddCase((JSStringValue)Values[i - 1].Item1,
                                        new JScript(JSElement.GetByID(hiddenElementID).Value.Set((JSStringValue)Values[i].Item1), JSElement.GetByID(ID).InnerHTML.Set((JSStringValue)contents)));
            }
            return(new HInput(HInput.EInputType.hidden, Name, Values.First().Item1)
            {
                ID = hiddenElementID
            } +
                   new HButton("", HButton.EButtonType.button, "", new JScript(switchStatement).ToString())
            {
                Elements = Values.First().Item2.ToList(), ID = ID, Class = Class, Style = Style, DescriptionTags = DescriptionTags, Title = Title
            });
        }
Exemple #4
0
        /// <summary>
        /// Retrieves the response-functions answer to the browser in a usable format.
        /// </summary>
        /// <param name="sessionData">the current sessionData</param>
        /// <returns>the responded message</returns>
        protected string GetResponse(SessionData sessionData)
        {
            string param = "";

            if (sessionData is HttpSessionData)
            {
                param = sessionData.GetHttpHeadValue("value");
            }

            if (param == null)
            {
                param = "";
            }

            var entries = _func(sessionData, param).ToArray();

            string ret = "";

            for (int i = 0; i < entries.Length; i++)
            {
                ret += new HLink(entries[i].Item1, entries[i].Item2)
                {
                    DescriptionTags = "onmousedown='" + new JScript(JSValue.CurrentBrowserURL.Set((JSStringValue)entries[i].Item2), JSElement.GetByID(ContainerID).Hide) + "'"
                };

                if (i + 1 < entries.Length)
                {
                    ret += new HNewLine();
                }
            }

            return(ret);
        }