Created
January 13, 2020 10:56
-
-
Save rozek/24f7824c601019ec867b6ed78d03620f to your computer and use it in GitHub Desktop.
Bangle.js: prints a list of all installed clocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Storage = require('Storage'); | |
let ClockList = []; | |
let FileList = Storage.list(); | |
for (let i = 0, l = FileList.length; i < l; i++) { | |
let FileName = FileList[i]; | |
if (FileName[0] === '+') { | |
try { | |
let AppType = Storage.readJSON(FileName)['type']; | |
if (AppType === 'clock') { | |
ClockList.push(FileName.slice(1)); | |
} | |
} catch (Signal) { /* nop */ } | |
} | |
} | |
ClockList.sort(); | |
print('list of installed clocks:'); | |
for (let i = 0, l = ClockList.length; i < l; i++) { | |
print(' -',ClockList[i].replace(/[\x00-\x1F\x7F-\x9F]/g, function (Match) { | |
let CharCode = Match.charCodeAt(0); | |
return '\\x' + (CharCode < 10 ? '0' : '') + CharCode.toString(16); | |
})); | |
} | |
print('done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment