This is the Real Deal Bridge .ejs page, displaying the WebGL version of the application.
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-control" content="no-cache">
</head>
<body>
<div id="alreadyOpen" style="display: none; width: 100%; text-align: center;"><h3>You already have a Real Deal window open. Please close it and refresh this page.</h3></div>
<div id="unsupportedDevice" style="display: none; width: 100%; text-align: center;"><h3>Real Deal for web is not supported on your device. Please <a href="http://onelink.to/realdeal">click here</a> to find a version for your device.</h3></div>
<div id="gameContainer"></div>
<div id="loader">
<img class="logo" src="TemplateData/logo.png"></img>
<div class="spinner"></div>
<div class="progress"><div class="full"></div></div>
</div>
<!-- BEGIN WEBGL FILE BROWSER LIB -->
<form id="fileBrowserPopup" style="display: none;">
<img src="TemplateData/2x2.png" style="position: absolute; width: 100%; height: 100%;" />
<img src="TemplateData/White-Button.png" style="position: absolute; top: 35%; left: 38%; width: 25%; height: 30%;" />
<label for="fileToUpload">
<img src="TemplateData/upload_button.png" style="position: absolute; top: 45%; left: 42.8%; width: 16%; height: 10%;" />
</label>
<input type="File" name="fileToUpload" id="fileToUpload" style="width: 0px; height: 0px;" onchange="sendfile(event);return false;" />
<label for="closePopup">
<img src="TemplateData/close_button.png" style="position: absolute; top: 57%; left: 48.0%; width: 5%; height: 5%;" />
</label>
<input type="button" name="closePopup" id="closePopup" style="width: 0px; height: 0px;" onclick="hidePopup()" />
</form>
<!-- END WEBGL FILE BROWSER LIB -->
<!-- START PHOTON ACTIVE SCRIPT -->
<script>
var isActive;
document.onload = function(){
document.addEventListener('visibilitychange', function () {
if (document.visibilityState == "hidden") {
isActive = setInterval(function() { gameInstance.SendMessage("PUNManager", "SendServerAcks"); }, 250);
} else {
clearInterval(isActive);
isActive = false;
}
});
}
</script>
<!-- END PHOTON ACTIVE SCRIPT -->
<!-- START ENVIRONMENT HELPER SCRIPT -->
<script>
var env = '<%= process.env.ENVIRONMENT %>';
console.log("Environment: " + env);
function GetEnv(){
return env;
}
</script>
<!-- END ENV HELPER SCRIPT -->
</body>
<script>
//Block multiple tabs from being open at the same time
localStorage.openpages = Date.now();
var onLocalStorageEvent = function(e){
if(e.key == "openpages"){
// Emit that you're already available.
localStorage.page_available = Date.now();
}
if(e.key == "page_available"){
if(!IsSafari()){
alert("You already have a Real Deal window open. Please close it and refresh the page.");
document.getElementById("gameContainer").style.display = "none";
document.querySelector("#loader").style.display = "none";
document.getElementById("alreadyOpen").style.display = "block";
document.body.style.background = "#ffffff";
}
}
};
window.addEventListener('storage', onLocalStorageEvent, false);
</script>
<script type='text/javascript'>
function sendfile(e) {
var files = e.target.files;
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = (function (file) {
return function (e) {
gameInstance.SendMessage('FileBrowserDialogLib', 'ApplyFileName', escape(file.name));
(window.filedata = window.filedata ? window.filedata : {})[file.name] = e.target.result;
gameInstance.SendMessage("FileBrowserDialogLib", "FileUpload", file.name);
}
})(f);
reader.readAsArrayBuffer(f);
}
}
function hidePopup() {
gameInstance.SendMessage("FileBrowserDialogLib", "CloseFilePopupDialog");
}
</script>
<script type='text/javascript'>
//This is the stuff to print an image
function ImagetoPrint(source)
{
console.log("Creating print page");
return "<html><head><scri"+"pt>function step1(){\n" +
"setTimeout('step2()', 10);}\n" +
"function step2(){window.print();window.close()}\n" +
"</scri" + "pt></head><body onload='step1()'>\n" +
"<img src='" + source + "' style='max-width:3508px; max-height: 2480'/></body></html>";
}
var pwa = null;
function PrintImage(source)
{
console.log("Received " + source.length + " bytes to print");
var srcString = "data:image/png;base64,";
var binaryString = '';
for(var i = 0; i < source.length; i++){
binaryString += String.fromCharCode(source[i]);
}
srcString += btoa(binaryString);
var Pagelink = "about:blank";
if(pwa == null || pwa.closed){
var pwa = window.open(Pagelink, "_new");
if(pwa == null){
alert("You or your browser has disabled popups for this site. Please adjust your browser settings then try again.");
}else{
pwa.document.open();
pwa.document.write(ImagetoPrint(srcString));
pwa.document.close();
}
}else{
pwa.focus();
}
console.log("Printed");
}
</script>
<script src="Build/UnityLoader.js"></script>
<script>
if(IsMobileOrTablet()){
//Show the 1link thing
document.getElementById("unsupportedDevice").style.display = "block";
document.getElementById("gameContainer").style.display = "none";
document.querySelector("#loader").style.display = "none";
document.body.style.background = "#ffffff";
}else{
Instantiate();
}
var gameInstance;
function Instantiate(){
gameInstance = UnityLoader.instantiate("gameContainer", "Build/RealDealWeb.json", {onProgress: UnityProgress});
}
function UnityProgress(gameInstance, progress) {
if (!gameInstance.Module) {
return;
}
const loader = document.querySelector("#loader");
if (!gameInstance.progress) {
const progress = document.querySelector("#loader .progress");
progress.style.display = "block";
gameInstance.progress = progress.querySelector(".full");
loader.querySelector(".spinner").style.display = "none";
}
gameInstance.progress.style.transform = `scaleX(${progress})`;
if (progress === 1 && !gameInstance.removeTimeout) {
gameInstance.removeTimeout = setTimeout(function() {
loader.style.display = "none";
}, 100);
}
}
</script>