<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <title>Game</title>
</head>

<body style="margin:0">

    @* Kch ho?ch HTML5 v?i tham s? truy?n san construct 3 trn url *@
    @* <iframe id="gameFrame"
            src="@root/DragDrop/index.html?gameType=0&msisdn=09&token=1234567890&transId=1234567"
            style="
            width:100%;
            height:100vh;
            border:none;
            display:block;
        ">
    </iframe> *@



    <iframe id="gameFrame"
            src="@root/DragDrop/index.html"
            style="
            width:100%;
            height:100vh;
            border:none;
            display:block;
        ">
    </iframe>
   



    @* o?n Js nh?n k?t qu? t? construct 3 v? *@
    <script>
        const frame = document.getElementById("gameFrame");
        console.log("MVC bat dau gui du lieu vao trong construct 3");
        window.addEventListener(
            "message",
            function (event) 
            {
                console.log("y l hm l?ng nghe s? kin t? construct 3 d?y ra MVC nh!!!!!!");
                console.log(event.data);

                //Khi trong construct 3 g?i ra s? ki?n ny th t?c l trong Construc 3
                if (event.data.type === "GAME_READY") 
                {
                    console.log("Gui INIT_GAME");
                    //Khi da nhan duoc su kien nay tu trong Construct 3 gui ra thi
                    // chung ta construct 3 da listener thanh cong
                    //Tien hanh gui cac thong so duoi vao construct3
                    frame.contentWindow.postMessage({
                        type: "INIT_GAME",
                        gameType: "Easy",
                        msisdn: "09",
                        token: "1234567890",
                        transId: "1234567890",
                        root: "@root"
                    }, "*");
                }

            }
        );


    </script>


</body>
</html>