70 lines
3.5 KiB
Plaintext
70 lines
3.5 KiB
Plaintext
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_QRScanner.ascx.cs" Inherits="MoonProTablet.WebUserControls.mod_QRScanner" %>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h3 class="text-center">QR-Scan USER LOGIN</h3>
|
|
</div>
|
|
<div class="col-12 text-center">
|
|
<asp:UpdatePanel runat="server" ID="upnDecode">
|
|
<ContentTemplate>
|
|
<asp:LinkButton runat="server" ID="lbtGo" CssClass="btn btn-success btn-sm" OnClick="lbtGo_Click"><i class="fa fa-arrow-circle-right"></i> GO</asp:LinkButton>
|
|
<asp:TextBox runat="server" ID="txtQRCode" Width="25em" AutoPostBack="true" OnTextChanged="txtQRCode_TextChanged" />
|
|
<asp:HyperLink runat="server" ID="hlReload" NavigateUrl="~/" CssClass="btn btn-success btn-sm"><i class="fa fa-arrow-circle-right"></i> GO</asp:HyperLink>
|
|
</ContentTemplate>
|
|
</asp:UpdatePanel>
|
|
</div>
|
|
<div class="col-12 text-center">
|
|
<video id="preview"></video>
|
|
<script type="text/javascript">
|
|
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
|
scanner.addListener('scan', function (content) {
|
|
var isUrl = content.includes("http");
|
|
if (isUrl) {
|
|
// se content è un URL --> faccio reload...
|
|
document.getElementById('<%= hlReload.ClientID %>').href = content;
|
|
document.getElementById('<%= hlReload.ClientID %>').click();
|
|
}
|
|
else {
|
|
// altrimenti salvo in textBox e processo
|
|
document.getElementById('<%= txtQRCode.ClientID %>').value = content;
|
|
document.getElementById('<%= lbtGo.ClientID %>').click();
|
|
}
|
|
});
|
|
Instascan.Camera.getCameras().then(function (cameras) {
|
|
if (cameras.length > 0) {
|
|
scanner.start(cameras[0]);
|
|
} else {
|
|
console.error('No cameras found.');
|
|
}
|
|
}).catch(function (e) {
|
|
console.error(e);
|
|
});
|
|
<%--function showCamera() {
|
|
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
|
scanner.addListener('scan', function (content) {
|
|
var isUrl = content.includes("http");
|
|
if (isUrl) {
|
|
// se content è un URL --> faccio reload...
|
|
document.getElementById('<%= hlReload.ClientID %>').href = content;
|
|
document.getElementById('<%= hlReload.ClientID %>').click();
|
|
}
|
|
else {
|
|
// altrimenti salvo in textBox e processo
|
|
document.getElementById('<%= txtQRCode.ClientID %>').value = content;
|
|
document.getElementById('<%= lbtGo.ClientID %>').click();
|
|
}
|
|
});
|
|
Instascan.Camera.getCameras().then(function (cameras) {
|
|
if (cameras.length > 0) {
|
|
scanner.start(cameras[0]);
|
|
} else {
|
|
console.error('No cameras found.');
|
|
}
|
|
}).catch(function (e) {
|
|
console.error(e);
|
|
});
|
|
}--%>
|
|
</script>
|
|
</div>
|
|
</div>
|