main
js 22 lines 562 Bytes
Raw
1
2
3 import * as device from "./device.js";
4
5 export async function initialize(){
6 // set device class to body tag
7 setDeviceClass();
8 }
9
10 function setDeviceClass(){
11 device.determineInputType().then((type) => {
12 // Remove any class starting with 'device-' from <body>
13 const body = document.body;
14 body.classList.forEach(cls => {
15 if (cls.startsWith('device-')) {
16 body.classList.remove(cls);
17 }
18 });
19 // Add the new device class
20 body.classList.add(`device-${type}`);
21 });
22 }