Sub Process_Globals
Private BANano As BANano 'ignore
' create our elements
Dim TextElem As BANanoElement
Dim QRCodeElem As BANanoElement
' and the qrcode javascript library
Dim qrcode As BANanoObject
End Sub
Sub AppStart
' you can change some output params here
BANano.Initialize("BANano", "BANanoQRCode",1)
' only qrcode is needed, no jquery
BANano.Header.AddJavascriptFile("https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js")
' start the build
BANano.Build(File.DirApp)
ExitApplication
End Sub
Sub BANano_Ready()
Dim body As BANanoElement = BANano.GetElement("#body")
' return the element with id "qrcode"
QRCodeElem = body.Append($"<input id="text" type="text" value="https://hogangnono.com" style="width:80%"/><br><div id="qrcode"></div>"$).Get("#qrcode")
' get the element with id "text"
TextElem.Initialize("#text")
' initalize the qrcode library
qrcode.Initialize2("QRCode", Array(QRCodeElem.ToObject, CreateMap("width" : 100, "height" : 100, "useSVG": True)))
' add some events to the text element (see note below)
TextElem.On("blur keydown", Me, "HandleMakeCode")
' make the code initialy
MakeCode
End Sub
public Sub MakeCode()
If Not(TextElem.GetValue) Then
BANano.Alert("Input a Text")
TextElem.RunMethod("focus", Null)
Return
End If
qrcode.RunMethod("makeCode", TextElem.GetValue)
End Sub
public Sub HandleMakeCode(event As BANanoEvent)
' if it was a key it must be 13, if not a key (from the blur), do it too
If Not(event.KeyCode) Or event.KeyCode = 13 Then
MakeCode
End If
End Sub