// Export To File
function download(filename, text) {
    const element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    element.setAttribute('download', filename);
    element.style.display = 'none';
    document.body.appendChild(element);
    element.click();
    document.body.removeChild(element);
}
// Start file download.
document.getElementById("dwn-btn").addEventListener("click", function () {

    // Generate download of hello.txt file with some content
    //var bodySection = document.getElementById("text-val").value;
    // const headSection = document.querySelector('head').innerHTML;


    const headSection = `

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />


<!-- Bootstrap -->
<script src="../js/popper.min.js"></script>
<link href="../assets/bootstrap-4.6.0-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="../assets/bootstrap-4.6.0-dist//icon/bootstrap-icons2.css">

<!-- jquery -->
<script src="../js/jquery-3.5.1.min.js"></script>

<!-- main styles -->
<link href="../assets/css/css_panel/client.css" rel="stylesheet" type="text/css">

<!-- slider -->
<!-- <link href="../css/slider.css" rel="stylesheet" type="text/css" /> -->
<script src="../js/slider.js"></script>

<!-- clock -->
<link rel="stylesheet" href="./clock-apple.css">


`;


    let bodySection = document.getElementById("screen").outerHTML;
    const completeHtmlStructute = `
    <!DOCTYPE html>
    <html>
    <head>
    ${headSection}
    </head><body>
    ${bodySection}
    <script src="../assets/clock_appleFace/clock-apple__client.js"></script>
    <script src="../js/multiVideo__clientSide.js"></script>

    </body>
    </html>
    `
    let date = new Date();
    let dateForName = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate();
    const filename = `SampleDS-${dateForName}.html`;


    download(filename, completeHtmlStructute);
}, false);




// // Import From File
// var input = document.getElementById("myFile");
// var output;
// document.getElementById('myFile').addEventListener("change", function () {
//     if (this.files && this.files[0]) {
//         var myFile = this.files[0];
//         var reader = new FileReader();

//         reader.addEventListener('load', function (e) {
//             document.getElementById("screen").innerHTML = e.target.result;
//         });

//         reader.readAsText(myFile);
//     }
// });



