generated from nestjs/typescript-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
129 lines (119 loc) · 4.73 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rakuen</title>
<link rel="stylesheet" href="./src/template//style.css" />
<style>
html,
body {
height: 100vh;
width: 100vw;
margin: 0;
padding: 0;
}
.webgl-content {
position: unset;
transform: unset;
}
#gameContainer {
margin: auto !important;
}
.footer {
display: none;
}
</style>
</head>
<body>
<div class="webgl-content">
<div id="gameContainer" style="width: 960px; height: 600px"></div>
<div class="footer"></div>
</div>
<script src="./src/template/UnityProgress.js"></script>
<script src="./src/UnityLoader.js"></script>
<script>
// TODO: Should be returned when the message is received
setTimeout(() => {
window.postMessage(
`{"type":"init","strInit":"40855225,ピョンテ69号"}`,
"*"
);
}, 3000);
</script>
<script type="text/javascript">
let initCallback;
function setEnableLog(enable) {}
function init(callback) {
initCallback = callback;
console.log("[iframe] init(callback)", initCallback);
let message = { type: "init", func: initCallback };
console.log("[iframe] message : ", message);
// window.postMessage(JSON.stringify(message), "*");
//parent.init(callback)
}
let purchaseCallBack;
let paramPurchase;
function startPurchase(purchase, purchaseCallFunc) {
purchaseCallBack = purchaseCallFunc;
paramPurchase = purchase;
console.log(
"[iframe] startPurchase(purchase, purchaseCallFunc)",
purchase,
purchaseCallFunc
);
let message = { type: "startPurchase", funcParam: purchase };
console.log("[iframe] startPurchase message : ", message);
window.parent.postMessage(JSON.stringify(message), "*");
}
console.log("child load");
window.addEventListener("message", function (event) {
console.log("[iframe] event : ", event);
console.log("[iframe] event.data : ", event.data);
var json = JSON.parse(event.data);
if (event.data != "postmessage.test") {
if (json.type == "userinfo") {
console.log("userinfo response : ", json);
} else if (json.type == "payment") {
// {"type":"payment","result":1,"payment_id":"0"};
console.log(
"[iframe] payment response : ",
json.result,
json.payment_id
);
console.log(
"purchaseCallBack(event.data) : purchaseCallBack ",
purchaseCallBack,
"event.data : ",
event.data
);
purchaseCallBack(event.data);
} else if (json.type == "msgadd") {
console.log("msgadd response : ", json);
} else if (json.type == "init") {
console.log("init response : ", json);
initCallback(json.strInit);
} else if (json.type == "startPurchase") {
console.log("startPurchase response : ", json);
console.log(
"startPurchase(paramPurchase) : purchaseCallBack ",
purchaseCallBack,
"paramPurchase : ",
paramPurchase
);
purchaseCallBack(paramPurchase);
}
}
});
</script>
<script>
var gameInstance = UnityLoader.instantiate(
"gameContainer",
"./data/DMM_R.json",
{ onProgress: UnityProgress }
);
</script>
<script type="module" src="./src/loadMock.js"></script>
</body>
</html>