'Class module
Sub Class_Globals
Public ABMComp As ABMCustomComponent
Dim mAPIKey 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, APIKey As String)
ABMComp.Initialize("ABMComp", Me, InternalPage, ID, "")
mAPIKey = APIKey
End Sub
Sub ABMComp_Build(InternalPage As ABMPage, internalID As String) As String
Return $"<div id="${internalID}render" class="g-recaptcha" data-sitekey="${mAPIKey}"></div>"$
End Sub
' Is useful to run some initalisation script.
Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String)
Dim script As String = $"grecaptcha.render(
"${internalID}render",
{"sitekey": "${mAPIKey}", "theme": "light"}
) "$
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
' flush not needed, it's done in the refresh method in the lib
End Sub
public Sub Reset(InternalPage As ABMPage)
Dim script As String = $"grecaptcha.reset()"$
InternalPage.ws.Eval(script, Null)
InternalPage.ws.Flush
End Sub
public Sub CheckValidation(InternalPage As ABMPage) As Boolean
Dim script As String = $"return (grecaptcha && grecaptcha.getResponse().length !== 0);"$
Dim ret As Future = InternalPage.ws.EvalWithResult(script, Null)
InternalPage.ws.Flush
Return ret.Value
End Sub
' runs when a refresh is called
Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String)
Dim script As String = $""$
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