Ejemplo n.º 1
0
        private static bool ElementIsItselfHidden(IDomElement el)
        {
            if (el.NodeNameID == HtmlData.tagINPUT && el.Type == "hidden")
            {
                return(true);
            }

            if (el.HasStyles)
            {
                if (el.Style["display"] == "none" || el.Style.NumberPart("opacity") == 0)
                {
                    return(true);
                }
                double?wid    = el.Style.NumberPart("width");
                double?height = el.Style.NumberPart("height");
                if (wid == 0 || height == 0)
                {
                    return(true);
                }
            }
            string widthAttr, heightAttr;

            widthAttr  = el.GetAttribute("width");
            heightAttr = el.GetAttribute("height");

            return(widthAttr == "0" || heightAttr == "0");
        }
Ejemplo n.º 2
0
        private static bool ElementIsItselfHidden(IDomElement el)
        {
            if (el.NodeNameID == HtmlData.tagINPUT && el.Type == "hidden")
            {
                return true;
            }

            if (el.HasStyles)
            {
                if (el.Style["display"] == "none" || el.Style.NumberPart("opacity") == 0)
                {
                    return true;
                }
                double? wid = el.Style.NumberPart("width");
                double? height = el.Style.NumberPart("height");
                if (wid == 0 || height == 0)
                {
                    return true;
                }
            }
            string widthAttr, heightAttr;
            widthAttr = el.GetAttribute("width");
            heightAttr = el.GetAttribute("height");

            return widthAttr == "0" || heightAttr == "0";
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the current value of the first element in the set of matched elements. When using Val()
        /// to access an OPTION group with the "multiple" flag set, this method with return a comma-
        /// separated string (rather than the array returned by jQuery) of each selected option. When
        /// there is no "value" property on an option, the text returned for the value of each selected
        /// option is the inner text of the OPTION element.
        /// </summary>
        ///
        /// <returns>
        /// A string of the value.
        /// </returns>
        ///
        /// <url>
        /// http://api.jquery.com/val/#val1
        /// </url>

        public string Val()
        {
            if (Length > 0)
            {
                IDomElement e = this.Elements.First();
                switch (e.NodeNameID)
                {
                case HtmlData.tagTEXTAREA:
                    return(e.Value);

                case HtmlData.tagINPUT:
                    string val = e.GetAttribute("value", String.Empty);
                    switch (e.GetAttribute("type", String.Empty))
                    {
                    case "radio":
                    case "checkbox":
                        if (String.IsNullOrEmpty(val))
                        {
                            val = "on";
                        }
                        break;

                    default:
                        break;
                    }
                    return(val);

                case HtmlData.tagSELECT:
                    string result = String.Empty;

                    var sel = (HTMLSelectElement)e;

                    if (!sel.Multiple)
                    {
                        return(sel.Value);
                    }
                    else
                    {
                        var selList = sel.ChildElementsOfTag <IHTMLOptionElement>(HtmlData.tagOPTION);
                        result = String.Join(",", selList
                                             .Where(item => item.HasAttribute("selected") && !item.Disabled)
                                             .Select(item => item.Value ?? item.TextContent));
                        return(result);
                    }

                case HtmlData.tagOPTION:
                    val = e.GetAttribute("value");
                    return(val ?? e.TextContent);

                default:
                    return(e.GetAttribute("value", String.Empty));
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        private bool IsValidOGNode(IDomElement elem)
        {
            if (!elem.HasAttribute("property"))
            {
                return(false);
            }

            return(elem.GetAttribute("property").StartsWith("og:"));
        }
Ejemplo n.º 5
0
        protected bool ElementIsItselfHidden(IDomElement el)
        {
            if (el.HasStyles)
            {
                if (el.Style["display"] == "none")
                {
                    return(true);
                }
                double?wid    = el.Style.NumberPart("width");
                double?height = el.Style.NumberPart("height");
                if (wid == 0 || height == 0)
                {
                    return(true);
                }
            }
            string widthAttr, heightAttr;

            widthAttr  = el.GetAttribute("width");
            heightAttr = el.GetAttribute("height");

            return(widthAttr == "0" || heightAttr == "0");
        }
Ejemplo n.º 6
0
 protected virtual bool HasRelNoFollow(IDomElement e)
 {
     return _config.IsRespectAnchorRelNoFollowEnabled && (e.HasAttribute("rel") && e.GetAttribute("rel").ToLower().Trim() == "nofollow");
 }
Ejemplo n.º 7
0
 private bool HasRelNoFollow(IDomElement e)
 {
     return _isRespectAnchorRelNoFollowEnabled && (e.HasAttribute("rel") && e.GetAttribute("rel").ToLower().Trim() == "nofollow");
 }
Ejemplo n.º 8
0
 private bool HasRelNoFollow(IDomElement e)
 {
     return(_isRespectAnchorRelNoFollowEnabled && (e.HasAttribute("rel") && e.GetAttribute("rel").ToLower().Trim() == "nofollow"));
 }
Ejemplo n.º 9
0
 protected virtual bool HasRelNoFollow(IDomElement e)
 {
     return(_config.IsRespectAnchorRelNoFollowEnabled && (e.HasAttribute("rel") && e.GetAttribute("rel").ToLower().Trim() == "nofollow"));
 }
        protected bool ElementIsItselfHidden(IDomElement el)
        {
            if (el.HasStyles)
            {
                if (el.Style["display"] == "none")
                {
                    return true;
                }
                double? wid = el.Style.NumberPart("width");
                double? height = el.Style.NumberPart("height");
                if (wid == 0 || height == 0)
                {
                    return true;
                }
            }
            string widthAttr,heightAttr;
            widthAttr = el.GetAttribute("width");
            heightAttr = el.GetAttribute("height");

            return widthAttr=="0" || heightAttr=="0";
        }
Ejemplo n.º 11
0
 private string ParseValueFromNode(IDomElement elem)
 {
     return(elem.GetAttribute("content", string.Empty));
 }
Ejemplo n.º 12
0
 private string ParseKeyFromNode(IDomElement elem)
 {
     return(elem.GetAttribute("property").Substring(3));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// True, if element has "rel" attribute == "nofollow"
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 protected virtual bool HasRelNoFollow(IDomElement element)
 {
     return(Config.IsRespectAnchorRelNoFollowEnabled &&
            element.HasAttribute(Rel) &&
            element.GetAttribute(Rel).ToLower().Trim() == NoFollow);
 }
Ejemplo n.º 14
0
 public virtual string GetAttributeValue(string attributeName)
 {
     return(_domElement.GetAttribute(attributeName));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Get the current value of the first element in the set of matched elements. When using Val()
        /// to access an OPTION group with the "multiple" flag set, this method with return a comma-
        /// separated string (rather than the array returned by jQuery) of each selected option. When
        /// there is no "value" property on an option, the text returned for the value of each selected
        /// option is the inner text of the OPTION element.
        /// </summary>
        ///
        /// <returns>
        /// A string of the value.
        /// </returns>
        ///
        /// <url>
        /// http://api.jquery.com/val/#val1
        /// </url>

        public string Val()
        {
            if (Length > 0)
            {
                IDomElement e = this.Elements.First();
                switch (e.NodeNameID)
                {
                case HtmlData.tagTEXTAREA:
                    return(e.InnerText);

                case HtmlData.tagINPUT:
                    string val = e.GetAttribute("value", String.Empty);
                    switch (e.GetAttribute("type", String.Empty))
                    {
                    case "radio":
                    case "checkbox":
                        if (String.IsNullOrEmpty(val))
                        {
                            val = "on";
                        }
                        break;

                    default:
                        break;
                    }
                    return(val);

                case HtmlData.tagSELECT:
                    string result = String.Empty;
                    // TODO optgroup handling (just like the setter code)
                    //var options = Find("option");
                    //if (options.Length == 0)
                    //{
                    //    return null;
                    //}

                    //foreach (IDomElement child in options)
                    //{
                    //    bool disabled = child.HasAttribute("disabled")
                    //        || (child.ParentNode.NodeNameID == HtmlData.tagOPTGROUP
                    //            && child.ParentNode.HasAttribute("disabled"));

                    //    if (child.HasAttribute("selected") && !disabled)
                    //    {
                    //        var optVal = child.GetAttribute("value");
                    //        if (optVal == null)
                    //        {
                    //            optVal = child.Cq().Text();
                    //        }
                    //        result = result.ListAdd(optVal, ",");
                    //        if (!e.HasAttribute("multiple"))
                    //        {
                    //            break;
                    //        }
                    //    }
                    //}

                    var sel = (HTMLSelectElement)e;
                    if (!sel.Multiple)
                    {
                        var opt = sel.SelectedItem;
                        result = opt != null?
                                 opt.GetAttribute("value") ??
                                 opt.InnerText:
                                 "";
                    }
                    else
                    {
                        var selList = sel.ChildElementsOfTag <IHTMLOptionElement>(HtmlData.tagOPTION);
                        result = String.Join(",", selList
                                             .Where(item => item.HasAttribute("selected") && !item.Disabled)
                                             .Select(item => item.Value ?? item.InnerText));
                    }

                    return(result);

                case HtmlData.tagOPTION:
                    val = e.GetAttribute("value");
                    return(val ?? e.InnerText);

                default:
                    return(e.GetAttribute("value", String.Empty));
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 16
0
 public void WidgetIdTest(CrawlResult result, IDomElement widget)
 {
     PAssert.IsTrue(() => "nav".Equals(widget.GetAttribute("id")));
 }