+async function main() {
+ document.getElementById('open').addEventListener('change', async ev => renderChordpro(await ev.target.files[0].text()));
+
+ const params = new URLSearchParams(document.location.search);
+ const loadURL = params.get('l');
+ if (loadURL) {
+ try {
+ const response = await fetch(loadURL);
+ if (response.ok) {
+ renderChordpro(await response.text());
+ } else {
+ console.warn('Failed to fetch', loadURL, ':', response.status, response.statusText);
+ }
+ } catch (error) {
+ console.warn('Failed to fetch', loadURL, ':', error);
+ }
+ }
+}
+
+main();