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: 438
  • CssElement.bas
    1.1 KB · Views: 436

Mashiane

Expert
Licensed User
Longtime User
Eish...

When you finally manage to find that OneEvery code base done in 2018 and run it only to run into...

1774124367983.png


and the only resemblance of what you did is somehow close in a thread post that is almost close but not close.

Then it hits you, hard drives crash, you loose things.... you need a better backup strategy like

1. BackUp One
2. BackUp of Backup One
3. Backup of BackUp of BackUp One

The list goes on..

Somewhere on Google Drive/Mega/pCloud... perhaps

:(:(:(:(

 
Top