B4A Class HTMLElement & CSSElement Builder Classes

Hi there...

Well I wanted to create some HTML and CSS elements for something I am working on. Actually I'm trying to develop a webapp that will run inside a webview, just for fun. This should also execute commands and get and set data. WebViewExtras is coming handy for that.

So instead of having to write many .Append statements, well I have a few now, I decided on some generators instead. Here we go..

Example code...

B4X:
Dim elem As HTMLElement
    elem.Initialize("mashy","div")
    elem.ElementType = elem.EnumElementType.body
    elem.AddAttribute("writes","b4a")
    elem.AddAttribute("including","b4i")
    elem.AddAttribute("enjoying", "b4j")
    elem.AddClass("loves")
    elem.AddClass("what")
    elem.AddClass("he")
    elem.AddClass("has learned")
    elem.AddStyle1("background","green")
    elem.AddStyle1("width","50px")
    Log(elem.HTML)

Output...

B4X:
<body id="mashy"
writes="b4a" including="b4i" enjoying="b4j"
class="loves what he has learned" style="background:green; width:50px;">
</body>

The CssElement builder...

B4X:
Dim css As CssElement
    css.Initialize(".loves")
    css.AddAttribute("color","white")
    css.AddAttribute("background-image","mashy.png")
    Log(css.HTML)

and the output...

B4X:
.loves {color:white; background-image:mashy.png; }

PS: By the way this is what I'm using for the AMTileView and AMRadialMenu
 

Attachments

  • HTMLElement.bas
    7.8 KB · Views: 275
  • CssElement.bas
    1.1 KB · Views: 270
Cookies are required to use this site. You must accept them to continue using the site. Learn more…