-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
135 lines (102 loc) · 3.11 KB
/
index.php
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
130
131
132
133
134
135
<!doctype html>
<html>
<head>
<title>Kasi Nametest</title>
<script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script>
</head>
<body id=bb style="background-image:url(resource/kasi_bg.jpg);background-size:100% auto;background-position:0 0;text-align:center;padding-top:140px;" >
<script>
var location_s = "resource/rr/";
var kasi_s =
[
"gugulethu.png",
"khayelitsha.png",
"sosha.png",
"soweto.png",
"thembisa.png",
"umlazi.png",
"kwamashu.png"
];
FBInstant.initializeAsync()
.then(function(){
FBInstant.startGameAsync()
.then(function() {
alert('Hello '+FBInstant.player.getName());
for (var i=0; i < kasi_s.length; i++) {
var assetName = kasi_s[i];
var progress = ((i+1)/kasi_s.length) * 100;
game.load.image(location_s+assetName);
// Informs the SDK of loading progress
FBInstant.setLoadingProgress(progress);
}
// Retrieving context and player information can only be done
// once startGameAsync() resolves
var contextId = FBInstant.context.getID();
var contextType = FBInstant.context.getType();
});
}
);
</script>
<h1 id=title >Which Mzansi Kasi Are You From?</h1>
<p id=subject >
<strong>Type in your name to find out:</strong><br>
<input type=text id=u_name /><button onclick="start();" >START</button>
<script>
// document.getElementById("u_name").value = FBInstant.player.getName();
</script>
</p>
<p id=final style="display:none;font-size:1.5em;background-color:rgba(0,0,100,0.5);width:200px;" >
<a href="#" onclick=FBInstant.shareAsync(); target="_blank" style="color:red;text-decoration:none;" >Share</a> -
<a href=# onclick=re_start(); style="color:red;text-decoration:none;" >Restart</a>
</p>
<script>
var title_s =
[
"Gugulethu",
"Khayelitsha",
"Sosha",
"Soweto",
"Thembisa",
"Umlazi",
"Kwamashu"
];
var nn;
var ii;
function start(){
nn = document.getElementById("u_name").value;
ii = 0;
if(nn.length>=3){
if(/[q-z].*/.test(nn)){
while(ii<=1){
ii = Math.round(Math.random()*4);
}
}else if(/[a-j].*/.test(nn)){
ii = Math.round(Math.random()*1);
}else if(/[k-p].*/.test(nn)){
while(ii<=4){
ii = Math.round(Math.random()*6);
}
}
document.getElementById("bb").style.backgroundImage = "url("+location_s+kasi_s[ii]+")";
document.getElementById("title").innerHTML = nn+" you are from "+title_s[ii];
document.getElementById("title").style.color = "red";
document.getElementById("subject").style.display = "none";
document.getElementById("final").style.display = "inline-block";
}else{
alert("Name must be atleast three letters.");
}
}
function re_start(){
document.getElementById("bb").style.backgroundImage = "url(resource/kasi_bg.jpg)";
document.getElementById("title").innerHTML = "Which Mzansi Kasi Are You From?";
document.getElementById("title").style.color = "black";
document.getElementById("subject").style.display = "";
document.getElementById("final").style.display = "none";
preloadedInterstitial.showAsync()
.then(function() {
console.log('Interstitial ad finished successfully');
});
}
</script>
</body>
</html>