Merge pull request 'Remove all BBB stuff from chaospott_mumble.js' (#1) from Schnitzel/chaospott_mumble:main into main

Reviewed-on: apoc/chaospott_mumble#1
This commit is contained in:
apoc 2022-08-27 10:33:22 +00:00
commit d247ba4d72

View File

@ -3,12 +3,10 @@
// icon-color: deep-green; icon-glyph: power-off; // icon-color: deep-green; icon-glyph: power-off;
const mumbleApiUrl = "https://status.chaospott.de/chaospott_mumble.json"; const mumbleApiUrl = "https://status.chaospott.de/chaospott_mumble.json";
const spaceApiUrl = "https://status.chaospott.de/status.json"; const spaceApiUrl = "https://status.chaospott.de/status.json";
const bbbApiUrl = "https://unterricht.roschow.de/chaospott_bbb.json";
const logoUrl = "https://chaospott.de/images/logo.png"; const logoUrl = "https://chaospott.de/images/logo.png";
const logoLocalFilename = "chaospott_logo.png"; const logoLocalFilename = "chaospott_logo.png";
const mumbleLocalFilename = "chaospott_mumble.json"; const mumbleLocalFilename = "chaospott_mumble.json";
const spaceLocalFilename = "chaospott_space.json"; const spaceLocalFilename = "chaospott_space.json";
const bbbLocalFilename = "chaospott_bbb.json";
const title = "Chaospott"; const title = "Chaospott";
const subTitle = "Essen"; const subTitle = "Essen";
@ -44,7 +42,6 @@ async function createWidget(){
try { try {
var [mumbleStatus, mumbleFresh] = await getJSONandCache(mumbleLocalFilename, mumbleApiUrl); var [mumbleStatus, mumbleFresh] = await getJSONandCache(mumbleLocalFilename, mumbleApiUrl);
var [spaceStatus, spaceFresh] = await getJSONandCache(spaceLocalFilename, spaceApiUrl); var [spaceStatus, spaceFresh] = await getJSONandCache(spaceLocalFilename, spaceApiUrl);
var [bbbStatus, bbbFresh] = await getJSONandCache(bbbLocalFilename, bbbApiUrl);
} catch(err) { } catch(err) {
const errorList = new ListWidget(); const errorList = new ListWidget();
errorList.addText("Please enable internet for initial execution."); errorList.addText("Please enable internet for initial execution.");
@ -75,23 +72,10 @@ async function createWidget(){
colorBorderLonely = colorLonelyStale; colorBorderLonely = colorLonelyStale;
} }
if (bbbFresh){
colorBBBOpen = colorOpenFresh;
colorBBBClosed = colorClosedFresh;
colorBBBLonely = colorLonelyFresh;
} else {
colorBBBOpen = colorOpenStale;
colorBBBClosed = colorClosedStale;
colorBBBLonely = colorLonelyStale;
colorBorderOpen = colorOpenStale;
colorBorderClosed = colorClosedStale;
colorBorderLonely = colorLonelyStale;
}
if (spaceStatus.state.open){ if (spaceStatus.state.open){
widget.backgroundColor = colorBorderOpen; widget.backgroundColor = colorBorderOpen;
} else { } else {
switch(mumbleStatus.connected_users + bbbStatus.participantCount){ switch(mumbleStatus.connected_users){
case 0: case 0:
widget.backgroundColor = colorBorderClosed; widget.backgroundColor = colorBorderClosed;
break; break;
@ -174,37 +158,6 @@ async function createWidget(){
bottomRow.addSpacer(10); bottomRow.addSpacer(10);
const bbbLabelStack = bottomRow.addStack();
bbbLabelStack.layoutVertically();
const labelBBB = bbbLabelStack.addText("BBB");
labelBBB.font = Font.regularSystemFont(12);
let bbbLastUpdate = new Date(bbbStatus.startTime);
let labelBBBUpdated;
if(bbbStatus.active){
labelBBBUpdated = bbbLabelStack.addDate(bbbLastUpdate);
labelBBBUpdated.applyTimeStyle();
} else {
labelBBBUpdated = bbbLabelStack.addText("---");
}
labelBBBUpdated.font = Font.mediumSystemFont(6);
bottomRow.addSpacer(3);
const bbbValueStack = bottomRow.addStack();
const labelBBBUser = bbbValueStack.addText(bbbStatus.participantCount.toString(10));
labelBBBUser.font = Font.boldSystemFont(23);
switch(bbbStatus.participantCount){
case 0:
labelBBBUser.textColor = colorBBBClosed;
break;
case 1:
labelBBBUser.textColor = colorBBBLonely;
break;
default:
labelBBBUser.textColor = colorBBBOpen;
}
// //