-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathplaceholder.js
135 lines (116 loc) · 4.07 KB
/
placeholder.js
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
function ShowAdsPlaceholder() {
var adContainer = document.getElementById("gameContainer");
var AdsPlaceholderDiv = document.createElement("div");
AdsPlaceholderDiv.className = 'AdsPlaceholderDiv';
adContainer.appendChild(AdsPlaceholderDiv);
var skipAdButton = document.createElement("div");
skipAdButton.className = 'skipAdButton';
adContainer.appendChild(skipAdButton);
var skipAdTimer = document.createElement("div");
skipAdTimer.className = 'skipAdTimer';
adContainer.appendChild(skipAdTimer);
if (!window.jQuery) {
var jqueryUrl = 'jquery.min.js'/*tpa=http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js*/;
loadScript(jqueryUrl, jqueryLoaded);
} else {
jqueryLoaded();
}
}
function loadScript(url, callback) {
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState) {
//IE
script.onreadystatechange = function() {
if (script.readyState == "loaded" ||
script.readyState == "complete") {
script.onreadystatechange = null;
callback();
}
};
} else {
//Others
script.onload = function() {
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
function jqueryLoaded() {
showAdsPlaceholder();
}
function openY8InNewTab() {
url = 'https://www.y8.com';
var win = window.open(url, '_blank');
win.focus();
}
function showAdsPlaceholder() {
// must happen first to insert the framework for other inserts
window.setTimeout(insertAdsPlaceholderDiv(), 100);
// add skip timer text
window.setTimeout(function() {
insertSkipTimer(3000);
}, 200);
window.setTimeout(function() {
insertSkipTimer(2000);
}, 1000);
window.setTimeout(function() {
insertSkipTimer(1000);
}, 2000);
// add skip button and remove skip timer text
window.setTimeout(insertSkipButton, 3000);
}
skipAdsPlaceholder = function() {
removeAdsPlaceholderDiv();
}
function insertSkipTimer(_value) {
var st = '<br><br>' +
'<p style="color:white;background:transparent;border: none;top:5%;right:4.2%;position:fixed;>' +
'<font face="Arial" size="4">' +
'Skip Advertisement in ' + Math.floor(_value / 1000) +
'<\/font>' +
'<\/p>';
$(".skipAdTimer").empty();
$(".skipAdTimer").append(st);
}
function insertSkipButton() {
var ss =
'<button onclick="skipAdsPlaceholder()" style="background:transparent;border: none;top:5%;right:4.2%;position:fixed;">' +
'<img src="skip.png"/*tpa=http://storage-cf.y8.com/y8-studio/unity/config/shared/gamebreak/js/skip.png*/ style="background:transparent;border: none;width:38px; height:38px;"><\/button>';
$(".skipAdButton").append(ss);
$(".skipAdTimer").empty();
}
function insertAdsPlaceholderDiv() {
var gs = getAdsPlaceholderDiv();
$(".AdsPlaceholderDiv").append(gs);
}
function removeAdsPlaceholderDiv() {
if ($('.AdsPlaceholderDiv').length) {
$(".AdsPlaceholderDiv").empty();
}
if ($('.skipAdButton').length) {
$(".skipAdButton").empty();
}
if ($('.skipAdTimer').length) {
$(".skipAdTimer").empty();
}
}
function getAdsPlaceholderDiv() {
return (
'<div style="position:absolute; top: 0; left: 0; background-color:black; z-index:2147483644; overflow:auto; width:100%; height:100%; pointer-events:auto;">' +
'<div class="skipAdButton">' +
'<\/div>' +
'<div class="skipAdTimer">' +
'<\/div>' +
'<div style="text-align:center;position: relative;' +
'top:30%;' +
'z-index:2147483645;">' +
'<div>' +
'<button onclick="openY8InNewTab()">' +
'<img src="placeholder.png"/*tpa=http://storage-cf.y8.com/y8-studio/unity/config/shared/gamebreak/placeholder.png*/ style="background:transparent; border:none; width:300px; height:250px;"><\/button>' +
'<\/div>' +
'<\/div>' +
'<\/div>'
);
}