Nexus hack: add a display of the date and season to the status bar

edited September 2020 in Mechanic's Corner
Mostly a proof-of-concept of how to add things to the Nexus interface. A few lines of code that add to the status bar the current date and season.

1) add to your onLoad near the top:
// create a new UI element in the status bar
var newNode = document.createElement('div');
newNode.setAttribute("id", "status-date");
var referenceNode = document.querySelector('#status-ping');
referenceNode.after(newNode);
send_GMCP("IRE.Time.Request", "");
2) add to your onGMCP, or integrate into any existing IRE.Time.List and IRE.Time.Update logic you have there:
if (args.gmcp_method == "IRE.Time.List" || args.gmcp_method == "IRE.Time.Update") {
  $('#status-date').text(args.gmcp_args.year + '-' + String(args.gmcp_args.mon).padStart(2,'0') + '-' + String(args.gmcp_args.day).padStart(2,'0') + ' ' + ['mwinter','lwinter','espring','mspring','lspring','esummer','msummer','lsummer','eautumn','mautumn','lautumn','e-winter'][args.gmcp_args.mon-1]);
};
Result:


Adding a display of the moon phase is left as an exercise for the student. (Note though that Nexus is going to keep forcing the width of this element to what it likes, no matter how much you set it to what you like, so you might find it works better to add a second element for that. As it is, I had to abbreviate the season names pretty harshly.)

Comments

Sign In or Register to comment.