2018-11-27 07:05:02 +08:00
|
|
|
addEventListener("error", function(err){
|
2018-10-14 16:04:31 +08:00
|
|
|
var stack
|
|
|
|
if("error" in err){
|
|
|
|
stack = err.error.stack
|
|
|
|
}else{
|
|
|
|
stack = err.message + "\n at " + err.filename + ":" + err.lineno + ":" + err.colno
|
|
|
|
}
|
2018-12-04 06:23:11 +08:00
|
|
|
errorMessage(stack)
|
|
|
|
})
|
|
|
|
|
|
|
|
function errorMessage(stack){
|
2018-10-14 16:04:31 +08:00
|
|
|
localStorage["lastError"] = JSON.stringify({
|
2018-12-13 17:18:52 +08:00
|
|
|
timestamp: Date.now(),
|
2018-10-14 16:04:31 +08:00
|
|
|
stack: stack
|
|
|
|
})
|
2018-12-04 06:23:11 +08:00
|
|
|
}
|
2018-10-14 16:04:31 +08:00
|
|
|
|
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
|
2019-01-16 20:33:42 +08:00
|
|
|
|
|
|
|
if(/iPhone|iPad/.test(navigator.userAgent)){
|
|
|
|
var fullScreenSupported = false
|
|
|
|
}else{
|
|
|
|
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 = {}
|
2019-01-16 20:33:42 +08:00
|
|
|
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
|
|
|
|
}
|
2019-01-21 23:47:22 +08:00
|
|
|
var strings
|
2019-01-30 00:10:56 +08:00
|
|
|
var vectors
|
2018-10-14 16:04:31 +08:00
|
|
|
|
|
|
|
pageEvents.add(root, ["touchstart", "touchmove", "touchend"], event => {
|
2019-01-21 23:47:22 +08:00
|
|
|
if(event.cancelable && cancelTouch && event.target.tagName !== "SELECT"){
|
2018-10-14 16:04:31 +08:00
|
|
|
event.preventDefault()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var versionDiv = document.getElementById("version")
|
|
|
|
var versionLink = document.getElementById("version-link")
|
2019-02-15 06:10:34 +08:00
|
|
|
pageEvents.add(versionDiv, ["click", "touchend"], event => {
|
|
|
|
if(event.target === versionDiv){
|
|
|
|
versionLink.click()
|
|
|
|
pageEvents.send("version-link")
|
|
|
|
}
|
2018-10-14 16:04:31 +08:00
|
|
|
})
|
|
|
|
resizeRoot()
|
2018-10-14 19:25:10 +08:00
|
|
|
setInterval(resizeRoot, 100)
|
2018-10-15 06:00:40 +08:00
|
|
|
pageEvents.keyAdd(debugObj, "all", "down", event => {
|
2018-11-11 03:12:29 +08:00
|
|
|
if((event.keyCode === 186 || event.keyCode === 59) && event.ctrlKey && event.shiftKey && !event.altKey){
|
|
|
|
// Semicolon
|
2018-10-15 04:14:58 +08:00
|
|
|
if(debugObj.state === "open"){
|
|
|
|
debugObj.debug.minimise()
|
|
|
|
}else if(debugObj.state === "minimised"){
|
|
|
|
debugObj.debug.restore()
|
|
|
|
}else{
|
|
|
|
debugObj.debug = new Debug()
|
|
|
|
}
|
|
|
|
}
|
2018-10-15 06:00:40 +08:00
|
|
|
if(event.keyCode === 82 && debugObj.debug && debugObj.controller){
|
2018-11-11 03:12:29 +08:00
|
|
|
// R
|
2018-10-15 06:00:40 +08:00
|
|
|
debugObj.controller.restartSong()
|
|
|
|
}
|
2018-10-15 04:14:58 +08:00
|
|
|
})
|
2018-10-14 16:04:31 +08:00
|
|
|
|
Custom scripting, #song=, translations
- A song can be linked directly by adding "#song=<id>" to the url, replace `<id>` with the id in the database, after loading it jumps immediately jumps to the difficulty selection
- Added tutorial translations
- Fixed song preview not playing
- Use text fallback for the logo when there are no vectors
- Increased combo cache by 1 pixel
- A custom javascript file can be loaded from config.json by defining "custom_js" value
- Added lots of events to help writing custom js files: `version-link, title-screen, language-change, song-select, song-select-move, song-select-difficulty, song-select-back, about, about-link, tutorial, import-songs, import-songs-default, session, session-start, session-end, debug, load-song, load-song-player2, load-song-unfocused, load-song-cancel, load-song-error, game-start, key-events, p2-game-end, p2-disconnected, p2-abandoned, pause, unpause, pause-restart, pause-song-select, game-lag, scoresheet, scoresheet-player2`
- Event syntax example:
```js
addEventListener("game-start", event => {
console.log("game-start", event.detail)
})
```
2019-02-14 17:32:45 +08:00
|
|
|
var loader = new Loader(songId => {
|
|
|
|
new Titlescreen(songId)
|
2018-10-06 21:24:23 +08:00
|
|
|
})
|
2018-11-27 07:05:02 +08:00
|
|
|
|