diff --git a/OAuth/index.php b/OAuth/index.php index 9ad4397..19f282c 100644 --- a/OAuth/index.php +++ b/OAuth/index.php @@ -18,7 +18,7 @@ else if (empty($_GET["code"])) $code = $_GET["code"]; include "../api_key.php"; -$final_uri = "http://zovguran.net/Unalike/"; +$final_uri = $unalike_root_public; $postdata = array( "client_id" => $client_id, diff --git a/displayed.php b/displayed.php new file mode 100644 index 0000000..c01e671 --- /dev/null +++ b/displayed.php @@ -0,0 +1,55 @@ + +
+- - - - - Authorize this app again to get an access key. -
- Either your refresh token has expired, you have revoked access manually, or the application has been unregistered from the osu! api clients. -
- You might need to re-authorize this application from your account settings page. -
- - - - Please don't change the password because it breaks the invitation system. You are free to invite players, add any mods, change the team mode or win condition, and quit the match at any time, but the scores will only be evaluated after everyone has finished. - - -
- - - - Unalike is a lobby synchronization system that allows you and your friends to play the same song but on different difficulties. - The results are calculated based on your accuracy.- Log in using your osu! account to get started. - -
-+ + + Authorize this app again to get an access key. +
+ Either your refresh token has expired, you have revoked access manually, or the application has been unregistered from the osu! api clients. +
+ You might need to re-authorize this application from your account settings page. +
+ + BUG: Once all players are ready in a lobby, they remain ready until the map selector is opened or someone joins/leaves. +
+ + Please don't change the password because it breaks the invitation system. You are free to invite players, add any mods, change the team mode or win condition, and quit the match at any time, but the scores will only be evaluated after everyone has finished. Also, feel free to open slots and invite other friends to your difficulty, but the game will only start if everyone is ready. + + +
+ + + + Unalike is a lobby synchronization system that allows you and your friends to play the same song but on different difficulties. + The results are calculated based on your accuracy.+ Log in using your osu! account to get started. + +
+(Power mode is enabled!)
Unalike is not running.
'; + updateButtonSet(false); + + if (lobbiesContainer.innerHTML.trim().replace(/\s/g, "") != defaultLobbyContent.trim().replace(/\s/g, "")) { + lobbiesContainer.innerHTML = defaultLobbyContent; + } + + if (currentLobbiesContent != JSON.stringify(unalikeJson)) { + currentLobbiesContent = JSON.stringify(unalikeJson); + } + } + else { + newStatus = 'Unalike is up.
'; + + var full = false + var empty = false + if (unalikeJson.maxLobbies && !isEmpty(unalikeJson)) { + full = !(Object.keys(unalikeJson.lobbies).length < unalikeJson.maxLobbies) + } + if (!isEmpty(unalikeJson) && isEmpty(unalikeJson.lobbies)) { + updateButtonSet(true, false, full, true); + } + + if (unalikeJson.roundsPlayed) { + var plural = "s have"; + if (unalikeJson.roundsPlayed == 1) { + plural = " gas"; + } + newStatus += "" + unalikeJson.roundsPlayed + " game" + plural + " been played since boot."; + } + + if (unalikeJson.delay) { + newStatus += "
Current delay: " + unalikeJson.delay + " seconds between commands. (~" + unalikeJson.delay*4 + " seconds to create a lobby.)"; + } + // dynamicJsonElement = document.getElementById("dynamic-json"); + // dynamicJsonElement.innerHTML = JSON.stringify(unalikeJson); + + if (!isEmpty(unalikeJson.lobbies)) { + if (unalikeJson.playing) { + thisUpdateInterval = thisUpdateIntervalIfPlaying; + } + else { + thisUpdateInterval = thisUpdateIntervalIfLobby; + } + + var newLobbiesContent = ""; + var songsInContent = []; + + var counter = 2; + for (var lobby_id in unalikeJson.lobbies) { + var lobby = unalikeJson.lobbies[lobby_id]; + var playerList = []; + + if (!isEmpty(lobby.players)) { + for (var player of lobby.players) { + // playerList += "
Players:
' + + // 'Players: ' + playerList.join(", ") + '
'; + } + else + { + // playerList += "No one is in the lobby.
"; + } + + var title = 'Loading...[#" + score.place + "] " + score.username + ": " + score.accuracy.toFixed(2) + "%
"; + } + document.getElementById(elementId).innerHTML = newContent; + break; + } +} + +function refreshData() { + refreshRequest.open("GET", "./async/?", true); + refreshRequest.send(); + // console.log("Async request: ./async/?"); +} + +function refreshMultiplayer() { + multiplayerRequest.open("GET", "./async/match/?", true); + multiplayerRequest.send(); +} + +function refreshTemplate() { + var localItemName = localStoragePrefix + "lobby-template"; + + templateRequest.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + localStorage.setItem(localItemName, this.responseText); + updateTemplate(this.responseText); + } + }; + + if (localStorage.getItem(localItemName)) { + updateTemplate(localStorage.getItem(localItemName)); + } + else { + templateRequest.open("GET", "./async/lobby-template.html", true); + templateRequest.send(); + console.log("Async request: ./async/lobby-template.html"); + } +} + +function refreshSongInfo(elementId, beatmapId) { + var songInfoRequest = new XMLHttpRequest(); + var localItemName = localStoragePrefix + "beatmap-" + session_username + "-" + beatmapId; + + songInfoRequest.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var eId = elementId; + var bId = beatmapId; + var result = JSON.parse(this.responseText); + localStorage.setItem(localItemName, this.responseText); + updateSongInfo(eId, bId, result); + } + }; + + if (localStorage.getItem(localItemName)) { + var localJson = JSON.parse(localStorage.getItem(localItemName)); + updateSongInfo(elementId, beatmapId, localJson); + } + else { + var playerName = session_username; + songInfoRequest.open("GET", "./API/" + playerName + "/b/" + beatmapId, true); + songInfoRequest.send(); + console.log("Async request: ./API/" + playerName + "/b/" + beatmapId); + } +} + +function refreshMatchInfo(elementId, ualMatchId) { + var matchInfoRequest = new XMLHttpRequest(); + var localItemName = localStoragePrefix + "multiplayer-" + session_username + "-" + ualMatchId; + + matchInfoRequest.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var eId = elementId; + // var result = JSON.parse(this.responseText); + localStorage.setItem(localItemName, this.responseText); + updateMatchInfoContent(eId, this.responseText); + } + }; + + if (localStorage.getItem(localItemName)) { + updateMatchInfoContent(elementId, localStorage.getItem(localItemName)); + + } + else { + matchInfoRequest.open("GET", "./async/match/?render&select=" + ualMatchId, true); + matchInfoRequest.send(); + console.log("Async request: ./async/match/?render&select=" + ualMatchId); + } +}