gbmusic: reformat widget code
parent
94fe988b08
commit
ca394e3ff7
|
|
@ -1,6 +1,6 @@
|
||||||
(() => {
|
(() => {
|
||||||
if (global.gbmusic_active || !(require("Storage").readJSON("gbmusic.json", 1) || {}).autoStart) {
|
if (global.gbmusic_active || !(require("Storage").readJSON("gbmusic.json", 1) || {}).autoStart) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (typeof __FILE__ === 'string') { // only exists since 2v09
|
if (typeof __FILE__ === 'string') { // only exists since 2v09
|
||||||
const info = require("Storage").readJSON(__FILE__.split(".")[0]+".info", 1) || false;
|
const info = require("Storage").readJSON(__FILE__.split(".")[0]+".info", 1) || false;
|
||||||
|
|
@ -9,36 +9,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let state, info
|
let state, info;
|
||||||
function checkMusic() {
|
function checkMusic() {
|
||||||
if (state!=="play" || !info) {
|
if (state!=="play" || !info) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// playing music: launch music app
|
// playing music: launch music app
|
||||||
require("Storage").writeJSON("gbmusic.load.json", {
|
require("Storage").writeJSON("gbmusic.load.json", {
|
||||||
state: state,
|
state: state,
|
||||||
info: info,
|
info: info,
|
||||||
})
|
});
|
||||||
load("gbmusic.app.js")
|
load("gbmusic.app.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
const _GB = global.GB
|
const _GB = global.GB;
|
||||||
global.GB = (event) => {
|
global.GB = (event) => {
|
||||||
// we eat music events!
|
// we eat music events!
|
||||||
switch(event.t) {
|
switch(event.t) {
|
||||||
case "musicinfo":
|
case "musicinfo":
|
||||||
info = event
|
info = event;
|
||||||
delete(info.t)
|
delete (info.t);
|
||||||
checkMusic()
|
checkMusic();
|
||||||
break
|
break;
|
||||||
case "musicstate":
|
case "musicstate":
|
||||||
state = event.state
|
state = event.state;
|
||||||
checkMusic()
|
checkMusic();
|
||||||
break
|
break;
|
||||||
default:
|
default:
|
||||||
if (_GB) {
|
if (_GB) {
|
||||||
setTimeout(_GB, 0, event)
|
setTimeout(_GB, 0, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
})()
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue