var fs = require("fs");

function createHtml(url) {
    var template =
        `<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <meta name="viewport"
        content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="full-screen" content="true" />
    <meta name="screen-orientation" content="portrait" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="360-fullscreen" content="true" />
    <!-- <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
    <!-- 小程序分享得用这个 -->
    <!-- <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> -->
    <!-- 易盾js -->
    <!-- <script type="text/javascript" src="//cstaticdun.126.net/load.min.js"></script> -->
    <!-- 渲染引擎 -->
    <script src="//yun.duiba.com.cn/db_games/libs0924/fyge158.min.js" crossorigin="anonymous"></script>
    <!-- svga解析js（按需） -->
    <!-- <script src="//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js" crossorigin="anonymous"></script> -->
    <!-- 音效引擎（按需） -->
    <!-- <script src="//yun.duiba.com.cn/db_games/libs0924/howler.min.js"></script> -->
    <!-- vConsole -->
    <script src="//yun.duiba.com.cn/db_games/libs0924/vConsole.min.js"></script>
    <!-- 淘宝小程序webview sdk -->
    <!-- <script type="text/javascript" src="https://appx/web-view.min.js"></script> -->
    <style>
        html,
        body {
            padding: 0;
            margin: 0;
            border: 0;

            width: 100%;
            height: 100%;
            overflow: hidden;
            position: absolute;
            background-color: #015581;
        }
    </style>
</head>

<body>
    <div id="__loading__" style="position:absolute;left:50%;top:50%;margin-left:-45px;color:#ffffff">拼命加载中...</div>
    <div id="cusEngine" style="line-height:0;font-size:0;position:absolute;">
        <canvas id="canvas" style="width: 100%;height: 100%"></canvas>
    </div>
</body>
<script>
    window.addEventListener("load", function () {
        //获取canvas
        var canvas = document.getElementById("canvas");
        canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
        canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
        var main = new Main(canvas);
        var mouseEvent = main.stage.onMouseEvent.bind(main.stage);
        canvas.addEventListener("touchstart", mouseEvent, false);
        canvas.addEventListener('touchmove', mouseEvent, false);
        canvas.addEventListener('touchend', mouseEvent, false);
        window.stage = main.stage
    })
</script>
<script src="//yun.duiba.com.cn/db_games/${url}/output.js" crossorigin="anonymous"></script>

</html>`;

    //写入released
    fs.writeFileSync("./released/index.html", template)
}



module.exports = createHtml