<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_MU_svgViewer.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_MU_svgViewer" %>

<div id="uplTavola">
    <link href="../api/getMUCss" rel="stylesheet" id="dynCss" />
</div>
<asp:HiddenField ID="hfBatchId" runat="server" Value="0" />
<asp:HiddenField ID="hfSheetId" runat="server" Value="0" />
<asp:HiddenField ID="hfFilename" runat="server" Value="" />
<asp:HiddenField ID="hfCurrRev" runat="server" Value="0" />
<asp:HiddenField ID="hfCurrBunkRev" runat="server" Value="0" />
<script type="text/javascript">
    lastVal = 0;
    my_function();
    setInterval("my_function();", 1000);
    function my_function() {
        BunkId = document.getElementById('<%=hfBatchId.ClientID%>').value;
        SheetId = document.getElementById('<%=hfSheetId.ClientID%>').value;
        lastVal = document.getElementById('<%=hfCurrRev.ClientID%>').value;
        lastValBunk = document.getElementById('<%=hfCurrBunkRev.ClientID%>').value;
        // commento sennò ricarica sempre
        document.getElementById("dynCss").href = "../api/getMUCss/" + SheetId;
        $.ajax({
            url: "../api/getMUCssRev/" + SheetId
        }).then(function (data) {
            //console.log("Check cssRev: data=" + data + " | lastVal=" + lastVal);
            // se è cambiato...
            if (data != lastVal) {
                console.log("Changed cssRev: data=" + data + " | lastVal=" + lastVal);
                // aggiorno e ricarico css
                //document.getElementById("dynCss").href = "../api/getMUCss/" + SheetId;
                $('#uplTavola').load(location.href + ' #dynCss');
                document.getElementById('<%=hfCurrRev.ClientID%>').value = data;
            }
        });
        // qui leggo la versione del BUNK (con cambio foglio...)
        $.ajax({
            url: "../api/getMUSheetRev/" + BunkId
        }).then(function (data) {
            //console.log("Check SheetReview: data=" + data + " | lastValBunk=" + lastValBunk);
            // se è cambiato...
            if (data != lastValBunk) {
                console.log("Changed SheetReview: data=" + data + " | lastValBunk=" + lastValBunk);
                // ricarico intera pagina!
                location.reload();
                document.getElementById('<%=hfCurrBunkRev.ClientID%>').value = data;
            }
        });
    }
</script>
<svg width="2000" height="1000" xmlns='http://www.w3.org/2000/svg' runat="server" id="svgTable" class="img-fluid">
</svg>
