'Class module
Sub Class_Globals
Public ABMComp As ABMCustomComponent
Public myText As String
Public myWidth As Int
Public myHeight As Int
Public myColorDark As String
Public myColorLight As String
Public myCorrectLevel As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String, text As String, width As Int, height As Int, colorDark As String, colorLight As String, correctLevel As String)
ABMComp.Initialize("ABMComp", Me, InternalPage, ID)
myText = text
myWidth = width
myHeight = height
myColorDark = colorDark
myColorLight = colorLight
myCorrectLevel = correctLevel
End Sub
Sub ABMComp_Build(internalID As String) As String
Return $"<div id="${internalID}svg"/></div><script>var qrcode${internalID};</script>"$
End Sub
' Is useful to run some initalisation script.
Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String)
Dim script As String = $"qrcode${internalID} = new QRCode(document.getElementById("${internalID}svg"), {
text: "${myText}",
width: ${myWidth},
height: ${myHeight},
colorDark : "${myColorDark}",
colorLight : "${myColorLight}",
correctLevel : ${myCorrectLevel}
});"$
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
' flush not needed, it's done in the refresh method in the lib
End Sub
' runs when a refresh is called
Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String)
Dim script As String = $"qrcode${internalID}.clear();
qrcode${internalID}.makeCode("${myText}");"$
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
End Sub
' do the stuff needed when the object is removed
Sub ABMComp_CleanUp(InternalPage As ABMPage, internalID As String)
End Sub