load config in script
This commit is contained in:
parent
fb17f616a7
commit
ef70175403
38
script.js
38
script.js
|
@ -15,6 +15,16 @@ $(function () {
|
||||||
|
|
||||||
var gMidiOutTest;
|
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) {
|
if (!Array.prototype.indexOf) {
|
||||||
Array.prototype.indexOf = function (elt /*, from*/) {
|
Array.prototype.indexOf = function (elt /*, from*/) {
|
||||||
var len = this.length >>> 0;
|
var len = this.length >>> 0;
|
||||||
|
@ -1149,8 +1159,9 @@ $(function () {
|
||||||
if (channel_id == "") channel_id = "lobby";
|
if (channel_id == "") channel_id = "lobby";
|
||||||
|
|
||||||
const isSecure = globalThis.location.protocol == "https:";
|
const isSecure = globalThis.location.protocol == "https:";
|
||||||
const port =
|
const port = window.location.hostname.includes("multiplayerpiano.dev")
|
||||||
window.location.hostname.includes("multiplayerpiano.dev") ? 443 : 8443;
|
? 443
|
||||||
|
: 8443;
|
||||||
const gClient = new Client(
|
const gClient = new Client(
|
||||||
(isSecure ? "wss://" : "ws://") + window.location.hostname + ":" + port
|
(isSecure ? "wss://" : "ws://") + window.location.hostname + ":" + port
|
||||||
);
|
);
|
||||||
|
@ -1548,7 +1559,7 @@ $(function () {
|
||||||
|
|
||||||
var bottom = document.getElementById("bottom");
|
var bottom = document.getElementById("bottom");
|
||||||
|
|
||||||
var duration = 500;
|
var duration = 50;
|
||||||
var step = 0;
|
var step = 0;
|
||||||
var steps = 30;
|
var steps = 30;
|
||||||
var step_ms = duration / steps;
|
var step_ms = duration / steps;
|
||||||
|
@ -1605,6 +1616,7 @@ $(function () {
|
||||||
gClient.on("ch", function (ch) {
|
gClient.on("ch", function (ch) {
|
||||||
if (ch.ch.settings) {
|
if (ch.ch.settings) {
|
||||||
if (ch.ch.settings.color) {
|
if (ch.ch.settings.color) {
|
||||||
|
console.log("debug!!!", ch.ch.settings);
|
||||||
setColor(ch.ch.settings.color, ch.ch.settings.color2);
|
setColor(ch.ch.settings.color, ch.ch.settings.color2);
|
||||||
} else {
|
} else {
|
||||||
setColorToDefault();
|
setColorToDefault();
|
||||||
|
@ -2346,6 +2358,10 @@ $(function () {
|
||||||
|
|
||||||
var t = 0,
|
var t = 0,
|
||||||
d = 100;
|
d = 100;
|
||||||
|
|
||||||
|
$("#piano").addClass("slide");
|
||||||
|
|
||||||
|
requestAnimationFrame(() => {
|
||||||
$("#piano")
|
$("#piano")
|
||||||
.addClass("ease-out")
|
.addClass("ease-out")
|
||||||
.addClass("slide-" + opposite);
|
.addClass("slide-" + opposite);
|
||||||
|
@ -2363,6 +2379,7 @@ $(function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("#piano").removeClass("ease-in");
|
$("#piano").removeClass("ease-in");
|
||||||
}, (t += d));
|
}, (t += d));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var gHistoryDepth = 0;
|
var gHistoryDepth = 0;
|
||||||
|
@ -2691,7 +2708,7 @@ $(function () {
|
||||||
if (typeof input.volume === "undefined") {
|
if (typeof input.volume === "undefined") {
|
||||||
input.volume = 1.0;
|
input.volume = 1.0;
|
||||||
}
|
}
|
||||||
console.log("input", input);
|
// console.log("input", input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (midi.outputs.size > 0) {
|
if (midi.outputs.size > 0) {
|
||||||
|
@ -2706,7 +2723,7 @@ $(function () {
|
||||||
if (typeof output.volume === "undefined") {
|
if (typeof output.volume === "undefined") {
|
||||||
output.volume = 1.0;
|
output.volume = 1.0;
|
||||||
}
|
}
|
||||||
console.log("output", output);
|
// console.log("output", output);
|
||||||
}
|
}
|
||||||
gMidiOutTest = function (note_name, vel, delay_ms) {
|
gMidiOutTest = function (note_name, vel, delay_ms) {
|
||||||
var note_number =
|
var note_number =
|
||||||
|
@ -3038,7 +3055,16 @@ $(function () {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var ele = document.getElementById("email");
|
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.href = "mailto:" + email;
|
||||||
ele.textContent = email;
|
ele.textContent = email;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
Loading…
Reference in New Issue