forked from apoc/chaospott_mumble
		
	working bigbluebutton display
This commit is contained in:
		@@ -3,10 +3,12 @@
 | 
				
			|||||||
// icon-color: deep-green; icon-glyph: power-off;
 | 
					// icon-color: deep-green; icon-glyph: power-off;
 | 
				
			||||||
const mumbleApiUrl = "https://apoc.uber.space/chaospott_mumble.json";
 | 
					const mumbleApiUrl = "https://apoc.uber.space/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";
 | 
				
			||||||
@@ -42,6 +44,7 @@ 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.");
 | 
				
			||||||
@@ -72,10 +75,23 @@ 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){
 | 
					    switch(mumbleStatus.connected_users + bbbStatus.participantCount){
 | 
				
			||||||
      case 0:
 | 
					      case 0:
 | 
				
			||||||
        widget.backgroundColor = colorBorderClosed;
 | 
					        widget.backgroundColor = colorBorderClosed;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@@ -89,7 +105,7 @@ async function createWidget(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  widget.setPadding(0, 5, 0, 5);
 | 
					  widget.setPadding(0, 5, 0, 5);
 | 
				
			||||||
  canvasStack = widget.addStack();
 | 
					  canvasStack = widget.addStack();
 | 
				
			||||||
  canvasStack.setPadding(5, 15, 5, 15);
 | 
					  canvasStack.setPadding(8, 15, 8, 15);
 | 
				
			||||||
  canvasStack.cornerRadius = 15;
 | 
					  canvasStack.cornerRadius = 15;
 | 
				
			||||||
  canvasStack.layoutVertically();
 | 
					  canvasStack.layoutVertically();
 | 
				
			||||||
  canvasStack.backgroundColor = Color.dynamic(Color.white(), Color.black());
 | 
					  canvasStack.backgroundColor = Color.dynamic(Color.white(), Color.black());
 | 
				
			||||||
@@ -124,23 +140,27 @@ async function createWidget(){
 | 
				
			|||||||
  spaceLastUpdateLabel.font = Font.mediumSystemFont(6);
 | 
					  spaceLastUpdateLabel.font = Font.mediumSystemFont(6);
 | 
				
			||||||
  spaceLastUpdateLabel.applyRelativeStyle();
 | 
					  spaceLastUpdateLabel.applyRelativeStyle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const bottomRow = canvasStack.addStack();
 | 
					  const bottomRow = canvasStack.addStack();
 | 
				
			||||||
  bottomRow.useDefaultPadding();
 | 
					  bottomRow.useDefaultPadding();
 | 
				
			||||||
  bottomRow.centerAlignContent();
 | 
					  bottomRow.centerAlignContent();
 | 
				
			||||||
  const mumbleLabelStack = bottomRow.addStack();
 | 
					  const mumbleLabelStack = bottomRow.addStack();
 | 
				
			||||||
  mumbleLabelStack.layoutVertically();
 | 
					  mumbleLabelStack.layoutVertically();
 | 
				
			||||||
  const labelMumble = mumbleLabelStack.addText("Mumble");
 | 
					  const labelMumble = mumbleLabelStack.addText("M");
 | 
				
			||||||
  labelMumble.font = Font.regularSystemFont(14);
 | 
					  labelMumble.font = Font.regularSystemFont(12);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let mumbleLastUpdate = new Date(mumbleStatus.last_update * 1000);
 | 
					  let mumbleLastUpdate = new Date(mumbleStatus.last_update * 1000);
 | 
				
			||||||
  const labelMumbleUpdated = mumbleLabelStack.addDate(mumbleLastUpdate);
 | 
					  const labelMumbleUpdated = mumbleLabelStack.addDate(mumbleLastUpdate);
 | 
				
			||||||
  labelMumbleUpdated.font = Font.mediumSystemFont(6);
 | 
					  labelMumbleUpdated.font = Font.mediumSystemFont(6);
 | 
				
			||||||
  labelMumbleUpdated.applyTimeStyle();
 | 
					  labelMumbleUpdated.applyTimeStyle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  bottomRow.addSpacer(29);
 | 
					   bottomRow.addSpacer(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const mumbleValueStack = bottomRow.addStack();
 | 
					  const mumbleValueStack = bottomRow.addStack();
 | 
				
			||||||
  const labelMumbleUser = mumbleValueStack.addText(mumbleStatus.connected_users.toString(10));
 | 
					  const labelMumbleUser = mumbleValueStack.addText(mumbleStatus.connected_users.toString(10));
 | 
				
			||||||
  labelMumbleUser.font = Font.boldSystemFont(30);
 | 
					  labelMumbleUser.font = Font.boldSystemFont(23);
 | 
				
			||||||
  switch(mumbleStatus.connected_users){
 | 
					  switch(mumbleStatus.connected_users){
 | 
				
			||||||
    case 0:
 | 
					    case 0:
 | 
				
			||||||
      labelMumbleUser.textColor = colorMumbleClosed;
 | 
					      labelMumbleUser.textColor = colorMumbleClosed;
 | 
				
			||||||
@@ -152,6 +172,43 @@ async function createWidget(){
 | 
				
			|||||||
      labelMumbleUser.textColor = colorMumbleOpen;
 | 
					      labelMumbleUser.textColor = colorMumbleOpen;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    labelBBBUpdated = bbbLabelStack.addTexte("---");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  labelBBBUpdated.font = Font.mediumSystemFont(6);
 | 
				
			||||||
 | 
					  labelBBBUpdated.applyTimeStyle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  canvasStack.addSpacer(4)
 | 
					  canvasStack.addSpacer(4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dateStack = canvasStack.addStack();
 | 
					  dateStack = canvasStack.addStack();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user