Building an iPad Dashboard with JavaScript
In this blog post, I will walk you through the process of building a signups counter for the JavaScript Course using JavaScript. This counter allows me to keep track of how many people have signed up for the course, which is open from Nov 15 to Nov 22.
Although this counter may seem unnecessary, I often find myself working on such projects when I want to procrastinate and avoid important tasks.
Initially, I considered different approaches, such as creating an iOS widget with JavaScript using Scriptable. However, I decided to keep it simple and opted for a web page instead. By keeping the web page open on my iPad, I can conveniently view it from my desk or any other location.
To prevent the display from sleeping, I set the iPad to never sleep and configured the page to automatically refresh every 2 minutes. The advantage of using a web page is that I can access it from any device, including the iPad, iPhone, or Mac.
To fetch the data I need, I developed a Node.js program. The first step was to create a function to retrieve the required data:
1 | const getData = async () => { |
I made this function asynchronous due to the inclusion of a fetch request, which is likely to be necessary in your own implementation as well.
For those curious, I store all the signups in an Airtable record. Therefore, inside the getData()
function, I included the code required to fetch the count from Airtable.
Next, I created a simple Express server to serve an HTML page displaying the count prominently in the center:
1 | const express = require('express') |
By running this program locally on your computer, you can access it from devices connected to the same Wi-Fi network. Alternatively, you can use a localhost tunnel service. If you prefer, you can also host the web page on the internet.
In my case, I hosted the app on a server I use for my Node scripts. This allows me to access it from anywhere, even when I’m on a 4G network. Additionally, if desired, I can also AirPlay the dashboard to an Apple TV, which would display the signups count on a large television screen.
By following these steps, you too can build your own dashboard for the iPad using JavaScript. It’s a practical way to keep track of important metrics or simply indulge in some productive procrastination.
Tags: JavaScript, dashboard, iPad, web development, Node.js, Express