-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'CHN' of https://github.com/asesidaa/TaikoLocalServer in…
…to CHN
- Loading branch information
Showing
17 changed files
with
170 additions
and
52 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Function to be called when the viewfinder size changes | ||
var title; | ||
var myDonName; | ||
var myDonNameOutline; | ||
var init = false | ||
const observer = new ResizeObserver(handleResize); | ||
function handleResize() { | ||
updateFit() | ||
} | ||
|
||
function waitForElm(selector) { | ||
return new Promise(resolve => { | ||
if (document.querySelector(selector)) { | ||
return resolve(document.querySelector(selector)); | ||
} | ||
|
||
const observer = new MutationObserver(mutations => { | ||
if (document.querySelector(selector)) { | ||
observer.disconnect(); | ||
resolve(document.querySelector(selector)); | ||
} | ||
}); | ||
|
||
observer.observe(document.body, { | ||
childList: true, | ||
subtree: true | ||
}); | ||
}); | ||
} | ||
|
||
// This is a monkey hack to detect when the page has changed (to stop the observer events) | ||
var pushState = history.pushState; | ||
history.pushState = function () { | ||
pushState.apply(history, arguments); | ||
init = false; | ||
observer.disconnect(); | ||
}; | ||
|
||
// Fetches all the relevant objects on the page so updateFit can reference them later | ||
function initNameplate() { | ||
if (window.location.href.indexOf("Profile") > -1) { | ||
waitForElm('#nameplate-title').then((elm) => { | ||
title = elm | ||
waitForElm('#nameplate-name').then((elm) => { | ||
myDonName = elm | ||
waitForElm('#nameplate-name-outline').then((elm) => { | ||
myDonNameOutline = elm | ||
observer.observe(document.getElementById('nameplate')); | ||
init = true | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
function updateFit() { | ||
textFit(title, { alignHoriz: true, alignVert: true }); | ||
textFit(myDonName, { alignHoriz: true, alignVert: true }); | ||
textFit(myDonNameOutline, { alignHoriz: true, alignVert: true }); | ||
} | ||
|
||
|
||
// Used to individually update texts on the nameplate | ||
function updateMyDonName(elm) { | ||
if (init) { | ||
myDonName.textContent = elm | ||
myDonNameOutline.textContent = elm | ||
updateFit() | ||
} | ||
} | ||
function updateTitle(elm) { | ||
if (init) { | ||
title.textContent = elm | ||
updateFit() | ||
} | ||
} | ||
|
||
// Called by html onload when the image of the nameplate is loaded (this ensures the first fit is properly done) | ||
function nameplateLoaded() { | ||
initNameplate() | ||
} |