|
function logEventGame(id, type){ |
|
analytics.logEvent(id, { |
|
type: type |
|
}); |
|
|
|
} |
|
|
|
function loadGame(slug){ |
|
fetch("game/all.json",{ |
|
headers: { |
|
'Content-Type': 'application/json', |
|
}, |
|
}).then(response => response.json()) |
|
.then(data => { |
|
listGame = data; |
|
for (var j=0; j<listGame.length; j++) { |
|
if (listGame[j].slug == slug) { |
|
var tmp_url = ''; |
|
if(listGame[j].domain == 1){ |
|
tmp_url = 'https://webglmath.github.io/'+slug+"/"; |
|
} else if(listGame[j].domain == 2){ |
|
tmp_url = 'https://ubg77.github.io/edit/'+slug+"/"; |
|
} else if(listGame[j].domain == 3){ |
|
tmp_url = 'https://ubg77.github.io/game131022/'+slug+"/"; |
|
|
|
} else if(listGame[j].domain == 4){ |
|
tmp_url = 'https://ubg77.github.io/fix/'+slug+"/"; |
|
if(slug.indexOf("fnaf2") != -1){ |
|
tmp_url = 'https://ubg77.github.io/fix/'+slug; |
|
} |
|
} |
|
document.getElementById("gameframe").setAttribute("src",tmp_url); |
|
|
|
|
|
break; |
|
} |
|
} |
|
}); |
|
} |
|
var search = window.location.search; |
|
if(search){ |
|
|
|
|
|
} |
|
|
|
function open_fullscreen() { |
|
let game = document.getElementById("game-element"); |
|
if (game.requestFullscreen) { |
|
game.requestFullscreen(); |
|
} else if (game.mozRequestFullScreen) { |
|
game.mozRequestFullScreen(); |
|
} else if (game.webkitRequestFullscreen) { |
|
game.webkitRequestFullscreen(); |
|
} else if (game.msRequestFullscreen) { |
|
game.msRequestFullscreen(); |
|
} |
|
}; |
|
function playGame(){ |
|
var tmp = document.querySelector('#game-arena').dataset.url; |
|
document.querySelector('#game-arena').innerHTML = `<iframe id="game-element" allowfullscreen="" allow="autoplay; fullscreen; camera; focus-without-user-activation *; monetization; gamepad; keyboard-map *; xr-spatial-tracking; clipboard-write" name="gameFrame" scrolling="no" sandbox="allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts allow-same-origin allow-downloads" src="${tmp}"></iframe>`; |
|
} |
|
|
|
|
|
function loadGA(){ |
|
var r = document.createElement("script"); |
|
r.setAttribute("src", "https://www.googletagmanager.com/gtag/js?id=G-VDZ4RQ4RXR"), r.setAttribute("type", "text/javascript"), r.setAttribute("crossOrigin", "anonymous"), r.onload = function (){ |
|
window.dataLayer = window.dataLayer || []; |
|
function gtag(){dataLayer.push(arguments);} |
|
gtag('js', new Date()); |
|
|
|
gtag('config', 'G-VDZ4RQ4RXR', { |
|
'cookie_flags': 'SameSite=None;Secure' |
|
}); |
|
},document.head.appendChild(r); |
|
} |
|
setTimeout(() => {document.querySelector('.text-survey').style.display = "none"},3000); |
|
window.addEventListener('load', function() { |
|
loadGA(); |
|
fetch("/json/all.json",{ |
|
headers: { |
|
'Content-Type': 'application/json', |
|
}, |
|
}).then(response => response.json()) |
|
.then(data => { |
|
|
|
listGame = data; |
|
var html = ""; |
|
for (var j=0; j<listGame.length; j++) { |
|
var tmp = ""; |
|
var item = listGame[j]; |
|
var slug = item.slug; |
|
if(slug == '/'){ |
|
slug = '/'; |
|
} else { |
|
slug = `/${item.slug}.html`; |
|
} |
|
html += `<a href="${slug}" class="sc-wr3rvk-0 jcoQuw sc-963fcq-3 djzSvC sc-al88rd-4"> |
|
<img src="${item.img}" alt="${item.title}" loading="lazy" width="94" height="94" decoding="async" class="sc-18mcksl-1 jQcWfv"> |
|
<span class="sc-963fcq-0 ibRKmB global-cq-title">${item.title}</span> |
|
</a>` |
|
|
|
} |
|
document.querySelector('#listgame').innerHTML = html; |
|
|
|
}) |
|
}); |
|
function showPopup(){ |
|
document.querySelector('.popup-survey').style.display = "block"; |
|
} |
|
function closePopup(){ |
|
document.querySelector('.popup-survey').style.display = "none"; |
|
} |