2018-10-14 16:04:31 +08:00
|
|
|
addEventListener("error", err => {
|
|
|
|
var stack
|
|
|
|
if("error" in err){
|
|
|
|
stack = err.error.stack
|
|
|
|
}else{
|
|
|
|
stack = err.message + "\n at " + err.filename + ":" + err.lineno + ":" + err.colno
|
|
|
|
}
|
|
|
|
localStorage["lastError"] = JSON.stringify({
|
|
|
|
timestamp: +new Date,
|
|
|
|
stack: stack
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-06 21:24:23 +08:00
|
|
|
function toggleFullscreen(){
|
|
|
|
if("requestFullscreen" in root){
|
|
|
|
if(document.fullscreenElement){
|
|
|
|
document.exitFullscreen()
|
|
|
|
}else{
|
|
|
|
root.requestFullscreen()
|
|
|
|
}
|
|
|
|
}else if("webkitRequestFullscreen" in root){
|
|
|
|
if(document.webkitFullscreenElement){
|
|
|
|
document.webkitExitFullscreen()
|
|
|
|
}else{
|
|
|
|
root.webkitRequestFullscreen()
|
|
|
|
}
|
|
|
|
}else if("mozRequestFullScreen" in root){
|
|
|
|
if(document.mozFullScreenElement){
|
|
|
|
document.mozCancelFullScreen()
|
|
|
|
}else{
|
|
|
|
root.mozRequestFullScreen()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-14 16:04:31 +08:00
|
|
|
|
|
|
|
function resizeRoot(){
|
|
|
|
if(lastHeight !== innerHeight){
|
|
|
|
lastHeight = innerHeight
|
|
|
|
root.style.height = innerHeight + "px"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 02:08:05 +08:00
|
|
|
function debug(){
|
|
|
|
if(debugObj.state === "open"){
|
|
|
|
debugObj.debug.clean()
|
|
|
|
return "Debug closed"
|
|
|
|
}else if(debugObj.state === "minimised"){
|
|
|
|
debugObj.debug.restore()
|
|
|
|
return "Debug restored"
|
|
|
|
}else{
|
|
|
|
debugObj.debug = new Debug()
|
|
|
|
return "Debug opened"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-13 02:04:28 +08:00
|
|
|
var root = document.documentElement
|
|
|
|
var fullScreenSupported = "requestFullscreen" in root || "webkitRequestFullscreen" in root || "mozRequestFullScreen" in root
|
2018-10-06 21:24:23 +08:00
|
|
|
|
|
|
|
var pageEvents = new PageEvents()
|
|
|
|
var snd = {}
|
|
|
|
var p2
|
2018-10-09 14:59:36 +08:00
|
|
|
var disableBlur = false
|
2018-10-14 16:04:31 +08:00
|
|
|
var cancelTouch = true
|
|
|
|
var lastHeight
|
2018-10-15 02:08:05 +08:00
|
|
|
var debugObj = {
|
|
|
|
state: "closed",
|
|
|
|
debug: null
|
|
|
|
}
|
2018-10-14 18:37:27 +08:00
|
|
|
var perf = {
|
|
|
|
blur: 0,
|
|
|
|
allImg: 0,
|
|
|
|
load: 0
|
|
|
|
}
|
2018-10-14 16:04:31 +08:00
|
|
|
|
|
|
|
pageEvents.add(root, ["touchstart", "touchmove", "touchend"], event => {
|
|
|
|
if(event.cancelable && cancelTouch){
|
|
|
|
event.preventDefault()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var versionDiv = document.getElementById("version")
|
|
|
|
var versionLink = document.getElementById("version-link")
|
|
|
|
pageEvents.add(versionDiv, ["click", "touchend"], () => {
|
|
|
|
versionLink.click()
|
|
|
|
})
|
|
|
|
resizeRoot()
|
2018-10-14 19:25:10 +08:00
|
|
|
setInterval(resizeRoot, 100)
|
2018-10-15 04:14:58 +08:00
|
|
|
pageEvents.keyAdd(debugObj, 186, "down", event => {
|
|
|
|
if(event.ctrlKey && event.shiftKey && !event.altKey){
|
|
|
|
if(debugObj.state === "open"){
|
|
|
|
debugObj.debug.minimise()
|
|
|
|
}else if(debugObj.state === "minimised"){
|
|
|
|
debugObj.debug.restore()
|
|
|
|
}else{
|
|
|
|
debugObj.debug = new Debug()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2018-10-14 16:04:31 +08:00
|
|
|
|
2018-10-06 21:24:23 +08:00
|
|
|
var loader = new Loader(() => {
|
|
|
|
new Titlescreen()
|
|
|
|
})
|