Aggiunta copia clipboard + link modificato x prod
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
@using System
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<div class="input-group input-group-sm">
|
||||
@if (ShowText)
|
||||
{
|
||||
<input class="form-control" readonly type="text" value="@Text" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="form-control fas fa-eye-slash" readonly></span>
|
||||
}
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn @btnStyle" @onclick="CopyTextToClipboard" title="Copy to Clipboard">
|
||||
@if (copyDone)
|
||||
{
|
||||
<span><i class="far fa-thumbs-up"></i></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span><i class="far fa-copy"></i></span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
/// <summary>
|
||||
/// Metodi per copia verso clipboard:
|
||||
/// link:
|
||||
/// - https://chrissainty.com/copy-to-clipboard-in-blazor/
|
||||
/// - https://www.daveabrock.com/2021/02/18/copy-to-clipboard-markdown-editor/
|
||||
/// - https://www.meziantou.net/
|
||||
/// </summary>
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowText { get; set; } = true;
|
||||
|
||||
protected string btnStyle = "btn-primary";
|
||||
protected bool copyDone = false;
|
||||
|
||||
private async Task CopyTextToClipboard()
|
||||
{
|
||||
// cambio colore..
|
||||
btnStyle = "btn-success";
|
||||
copyDone = true;
|
||||
await JSRuntime.InvokeVoidAsync("clipboardCopy.copyText", Text);
|
||||
await Task.Delay(1100);
|
||||
// fix cambio colore..
|
||||
btnStyle = "btn-primary";
|
||||
copyDone = false;
|
||||
await Task.Delay(10);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,7 @@
|
||||
{
|
||||
<QrCodeDisplay rawCode="@qrCodeVal"></QrCodeDisplay>
|
||||
}
|
||||
<CopyToClipboard Text="@qrCodeVal"></CopyToClipboard>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -70,5 +70,6 @@
|
||||
|
||||
<script type="text/javascript" src="lib/qrcode.js"></script>
|
||||
<script type="text/javascript" src="lib/dispQr.js"></script>
|
||||
<script type="text/javascript" src="lib/CBCopy.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -21,5 +21,5 @@
|
||||
"ZCodeUrl": "https://qrcode.steamware.net/",
|
||||
"BaseUrl": "https://gwms.egalware.com/",
|
||||
"BaseAppPath": "/pizzaferri/",
|
||||
"jumpRedir": "~/../../"
|
||||
"jumpRedir": "~/../"
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
"ZCodeUrl": "https://qrcode.steamware.net/",
|
||||
"ChartWaitDelay": 10,
|
||||
"BaseUrl": "https://localhost:44339/",
|
||||
"BaseAppPath": "/pizzaferri/",
|
||||
"BaseAppPath": "",
|
||||
"jumpRedir": "~/../../",
|
||||
"logo": "img/LogoPizzaferri.jpg",
|
||||
"ReloadParamTimer": 15000,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
window.clipboardCopy = {
|
||||
copyText: function (text) {
|
||||
navigator.clipboard.writeText(text).then(function () {
|
||||
//alert("Copiato in clipboard!");
|
||||
})
|
||||
.catch(function (error) {
|
||||
alert(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user