Beispiel #1
0
        private static void Select_element(Item item)
        {
            HTMLcode.Append("<select ");
            Attributes attributes = item.attributes;

            if (attributes.name != null)
            {
                HTMLcode.Append($"name = \"{attributes.name}\" ");
            }
            if (attributes.required != null && attributes.required != false)
            {
                HTMLcode.Append("required ");
            }
            if (attributes.value != null)
            {
                HTMLcode.Append($"value = \"{attributes.value}\" ");
            }
            if (attributes.@class != null)
            {
                HTMLcode.Append($"class = \"{attributes.@class}\" ");
            }
            if (attributes.disabled != null && attributes.disabled != false)
            {
                HTMLcode.Append("disabled ");
            }
            HTMLcode.Append(">\n");
            if (attributes.label != null)
            {
                HTMLcode.Append(attributes.label + '\n');
            }
            if (attributes.options.Count != 0)
            {
                List <Option> options = attributes.options;
                for (int i = 0; i < options.Count; i++)
                {
                    HTMLcode.Append("<option ");
                    if (options[i].selected != null && options[i].selected != false)
                    {
                        HTMLcode.Append("selected ");
                    }
                    if (options[i].value != null)
                    {
                        HTMLcode.Append($"value = \"{options[i].value}\" ");
                    }
                    if (options[i].text != null)
                    {
                        HTMLcode.Append(">" + options[i].text);
                    }
                    else
                    {
                        HTMLcode.Append(">");
                    }
                    HTMLcode.Append("</option>\n");
                }
            }
            HTMLcode.Append("</select>\n");
        }
Beispiel #2
0
        private static void Button_element(Item item)
        {
            HTMLcode.Append($"<input type = \"{item.type}\" ");
            Attributes attributes = item.attributes;

            if (attributes.text != null)
            {
                HTMLcode.Append($"value = \"{attributes.text}\" ");
            }
            if (attributes.@class != null)
            {
                HTMLcode.Append($"class = \"{attributes.@class}\" ");
            }
            HTMLcode.Append(">\n");
        }
Beispiel #3
0
        private static void Radio_element(Item item)
        {
            Attributes    attributes = item.attributes;
            StringBuilder radioinput = new StringBuilder();

            radioinput.Append($"<input type = \"{item.type}\" ");
            if (attributes.name != null)
            {
                radioinput.Append($"name = \"{attributes.name}\" ");
            }
            if (attributes.required != null && attributes.required != false)
            {
                radioinput.Append("required ");
            }
            if (attributes.@class != null)
            {
                radioinput.Append($"class = \"{attributes.@class}\" ");
            }
            if (attributes.disabled != null && attributes.disabled != false)
            {
                radioinput.Append("disabled ");
            }
            var items = attributes.items;

            foreach (var itemofradio in items)
            {
                String attr = "";
                if (itemofradio.value != null)
                {
                    attr += $"value = \"{itemofradio.value}\" ";
                }
                if (itemofradio.@checked != null && itemofradio.@checked != false)
                {
                    attr += "checked ";
                }
                HTMLcode.Append(radioinput.ToString() + attr + ">");
                if (itemofradio.label != null)
                {
                    HTMLcode.Append(itemofradio.label + '\n');
                }
            }
        }
Beispiel #4
0
        private static void Checkbox_element(Item item)
        {
            HTMLcode.Append($"<input type = \"{item.type}\" ");
            Attributes attributes = item.attributes;

            if (attributes.name != null)
            {
                HTMLcode.Append($"name = \"{attributes.name}\" ");
            }
            if (attributes.required != null && attributes.required != false)
            {
                HTMLcode.Append("required ");
            }
            if (attributes.value != null)
            {
                HTMLcode.Append($"value = \"{attributes.value}\" ");
            }
            if (attributes.@class != null)
            {
                HTMLcode.Append($"class = \"{attributes.@class}\" ");
            }
            if (attributes.disabled != null && attributes.disabled != false)
            {
                HTMLcode.Append("disabled ");
            }
            if (attributes.@checked != null && attributes.@checked != false)
            {
                HTMLcode.Append("checked");
            }
            HTMLcode.Append(">");
            if (attributes.label != null)
            {
                HTMLcode.Append(attributes.label + '\n');
            }
            else
            {
                HTMLcode.Append('\n');
            }
        }
Beispiel #5
0
 public static void StartForm(Form form)
 {
     HTMLcode.Append($"<form name = \"{form.name}\">\n");
 }
Beispiel #6
0
 public static void Filler_element(Item item)
 {
     HTMLcode.Append(item.attributes.message + "\n");
 }
Beispiel #7
0
        private static void Text_element(Item item)
        {
            Attributes attributes = item.attributes;

            if (attributes.label != null)
            {
                HTMLcode.Append($"<b>{ attributes.label}</b>\n");
            }
            HTMLcode.Append($"<input type = \"{item.type}\" ");
            if (attributes.name != null)
            {
                HTMLcode.Append($"name = \"{attributes.name}\" ");
            }
            if (attributes.required != null && attributes.required != false)
            {
                HTMLcode.Append("required ");
            }
            if (attributes.value != null)
            {
                HTMLcode.Append($"value = \"{attributes.value}\" ");
            }
            String pattern = "";

            if (attributes.validationRules.Count != 0)
            {
                switch (attributes.validationRules[0].type)
                {
                case "tel":
                    pattern = "^(\\s*)?(\\+)?([- _():=+]?\\d[- _():=+]?){10,14}(\\s*)?$";
                    break;

                case "email":
                    pattern = "[a-zA-Z0-9]+(?:[._+-][a-zA-Z0-9]+)*)@([a-zA-Z0-9]+(?:[.-][a-zA-Z0-9]+)*[.][a-zA-Z]{2,}";
                    break;

                case "text":
                    pattern = "+";
                    break;

                default:
                    break;
                }
            }
            if (item.attributes.placeholder != null)
            {
                HTMLcode.Append($"placeholder = \"{attributes.placeholder}\" ");
                HTMLcode.Append($"pattern = \"{pattern} | ^(? !{attributes.placeholder})\"");
            }
            else
            {
                HTMLcode.Append($"pattern = \"{pattern}\"");
            }
            if (attributes.@class != null)
            {
                HTMLcode.Append($"class = \"{attributes.@class}\" ");
            }
            if (attributes.disabled != null && attributes.disabled != false)
            {
                HTMLcode.Append("disabled ");
            }
            HTMLcode.Append(">\n");
        }