미디어위키:Gadget-xash3d.js: 두 판 사이의 차이
둘러보기로 이동
검색으로 이동
imported>Senouis (jquery) |
imported>Senouis 편집 요약 없음 |
||
4번째 줄: | 4번째 줄: | ||
* 제작자: [[사용자:senouis]] | * 제작자: [[사용자:senouis]] | ||
**/ | **/ | ||
function xash3d_asyncJSLoader(url) { | |||
try { | |||
var scriptElement = document.createElement("script"); | |||
scriptElement.src = url; | |||
scriptElement.async = true; // force asynchronous loading | |||
scriptElement.type = "text/javascript"; | |||
var contextsection = document.getElementById("mw-content-text"); | |||
scriptElement.addEventListener("load", function (ev) { | |||
resolve({ status: true }); | |||
}); | |||
scriptElement.addEventListener("error", function (ev) { | |||
reject({ | |||
status: false, | |||
message: "Failed to load the script" | |||
}); | |||
}); | |||
contextsection.appendChild(scriptElement); | |||
} catch (e) { | |||
reject(e); | |||
} | |||
} | |||
function xash3d_loadElement() { | function xash3d_loadElement() { | ||
try { | try { | ||
40번째 줄: | 62번째 줄: | ||
var xashlauncher = document.getElementById("xash-launch"); | var xashlauncher = document.getElementById("xash-launch"); | ||
xashlauncher.innerHTML = "Command-line arguments: <input name=\"d\" type=text id=\"iArgs\" /><br><br><input type=button onclick=\"startXash();return false;\" value=\"Launch Xash3D!\" />"; | xashlauncher.innerHTML = "Command-line arguments: <input name=\"d\" type=text id=\"iArgs\" /><br><br><input type=button onclick=\"startXash();return false;\" value=\"Launch Xash3D!\" />"; | ||
if (document.createElement("detect").style.textShadow === "") { | |||
document.getElementsByTagName("html")[0].className += " textshadow"; | |||
} | |||
// now load js files from external server | |||
} catch (e){ | } catch (e){ | ||
console.log("initiating xash3d for libertygame failed, stop loading elements..."); | console.log("initiating xash3d for libertygame failed, stop loading elements..."); |
2023년 3월 27일 (월) 00:26 판
/**
* Xash3D for Libertygame loader
* external server code: https://github.com/Xen-alpha/Xen-alpha.github.io
* 제작자: [[사용자:senouis]]
**/
function xash3d_asyncJSLoader(url) {
try {
var scriptElement = document.createElement("script");
scriptElement.src = url;
scriptElement.async = true; // force asynchronous loading
scriptElement.type = "text/javascript";
var contextsection = document.getElementById("mw-content-text");
scriptElement.addEventListener("load", function (ev) {
resolve({ status: true });
});
scriptElement.addEventListener("error", function (ev) {
reject({
status: false,
message: "Failed to load the script"
});
});
contextsection.appendChild(scriptElement);
} catch (e) {
reject(e);
}
}
function xash3d_loadElement() {
try {
// Game canvas
var canvas = document.createElement("canvas");
canvas.style = "display:none;";
canvas.class = "emscripten";
canvas.id = "canvas";
canvas.oncontextmenu = "event.preventDefault()";
var canvasparent = document.getElementsByClassName("emscripten_border")[0]; // first element of emscripten-border
canvasparent.appendChild(canvas);
// screen option
var gamecontrol = document.getElementById('xash-controls');
var a1 = document.createElement("a");
a1.class = "xash-glow";
a1.innerHTML = "<span><input type=\"checkbox\" id=\"resize\">Resize canvas</span>";
gamecontrol.appendChild(a1);
var a2 = document.createElement("a");
a2.class = "xash-glow";
a2.innerHTML = "<span><input type=\"checkbox\" id=\"pointerLock\" checked>Lock/hide mouse pointer </span>";
gamecontrol.appendChild(a2);
var controlinputspan = document.createElement("span");
controlinputspan.innerHTML = "<input type=\"button\" value=\"Fullscreen\" onclick=\"Module.requestFullscreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)\">";
gamecontrol.appendChild(controlinputspan);
var outputcontainer = document.getElementById("xash-output-container");
outputcontainer.innerHTML = "<textarea id=\"xash-output\" rows=\"8\"></textarea>";
// game option
var gameoptionsTitle = document.getElementById("optionsTitle");
gameoptionsTitle.innerHTML = "<a class=\"glow\"><u><h1>Game Options</h1></u></a>";
var pkgHider = document.getElementById("pkgHider");
pkgHider.innerHTML = "<input name=\"b\" type=\"radio\" id=\"rPackage\" checked=true />Emscripten package from server (cached in IndexedDB if availiable)<select id=\"selectPkg\" style=\"display:none\"></select><br>";
var zipHider = document.getElementById("zipHider");
zipHider.innerHTML = "<input name=\"b\" type=radio id=\"rZip\" />ZIP archive from server (slower, but smaller, no IndexedDB cache)<select id=\"selectZip\" style=\"display:none\"></select><br>";
var localHider = document.getElementById("localHider");
localHider.innerHTML = "<input name=\"b\" type=radio id=\"rLocalZip\" />Local ZIP file:<input type=file name=\"c\" id=\"iZipFile\" />";
var xashlauncher = document.getElementById("xash-launch");
xashlauncher.innerHTML = "Command-line arguments: <input name=\"d\" type=text id=\"iArgs\" /><br><br><input type=button onclick=\"startXash();return false;\" value=\"Launch Xash3D!\" />";
if (document.createElement("detect").style.textShadow === "") {
document.getElementsByTagName("html")[0].className += " textshadow";
}
// now load js files from external server
} catch (e){
console.log("initiating xash3d for libertygame failed, stop loading elements...");
}
}
$(xash3d_loadElement);