load config in script

This commit is contained in:
Hri7566 2024-10-23 02:28:41 -04:00
parent fb17f616a7
commit ef70175403
1 changed files with 55 additions and 29 deletions

View File

@ -15,6 +15,16 @@ $(function () {
var gMidiOutTest;
// base64 idea from yellowberry
let base64config, configs;
try {
base64config = document.getElementById("config").innerText;
configs = JSON.parse(atob(base64config));
} catch (err) {
console.warn("Unable to parse server config:", err);
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt /*, from*/) {
var len = this.length >>> 0;
@ -1149,8 +1159,9 @@ $(function () {
if (channel_id == "") channel_id = "lobby";
const isSecure = globalThis.location.protocol == "https:";
const port =
window.location.hostname.includes("multiplayerpiano.dev") ? 443 : 8443;
const port = window.location.hostname.includes("multiplayerpiano.dev")
? 443
: 8443;
const gClient = new Client(
(isSecure ? "wss://" : "ws://") + window.location.hostname + ":" + port
);
@ -1548,7 +1559,7 @@ $(function () {
var bottom = document.getElementById("bottom");
var duration = 500;
var duration = 50;
var step = 0;
var steps = 30;
var step_ms = duration / steps;
@ -1605,6 +1616,7 @@ $(function () {
gClient.on("ch", function (ch) {
if (ch.ch.settings) {
if (ch.ch.settings.color) {
console.log("debug!!!", ch.ch.settings);
setColor(ch.ch.settings.color, ch.ch.settings.color2);
} else {
setColorToDefault();
@ -2346,6 +2358,10 @@ $(function () {
var t = 0,
d = 100;
$("#piano").addClass("slide");
requestAnimationFrame(() => {
$("#piano")
.addClass("ease-out")
.addClass("slide-" + opposite);
@ -2363,6 +2379,7 @@ $(function () {
setTimeout(function () {
$("#piano").removeClass("ease-in");
}, (t += d));
});
}
var gHistoryDepth = 0;
@ -2691,7 +2708,7 @@ $(function () {
if (typeof input.volume === "undefined") {
input.volume = 1.0;
}
console.log("input", input);
// console.log("input", input);
}
}
if (midi.outputs.size > 0) {
@ -2706,7 +2723,7 @@ $(function () {
if (typeof output.volume === "undefined") {
output.volume = 1.0;
}
console.log("output", output);
// console.log("output", output);
}
gMidiOutTest = function (note_name, vel, delay_ms) {
var note_number =
@ -3038,7 +3055,16 @@ $(function () {
}
try {
var ele = document.getElementById("email");
var email = ele.getAttribute("obscured").replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
var email = ele
.getAttribute("obscured")
.replace(/[a-zA-Z]/g, function (c) {
return String.fromCharCode(
(c <= "Z" ? 90 : 122) >=
(c = c.charCodeAt(0) + 13)
? c
: c - 26
);
});
ele.href = "mailto:" + email;
ele.textContent = email;
} catch (e) {}