|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <link rel="stylesheet" href="../../css/spectre.min.css"> |
| 4 | + <style> |
| 5 | + input.offset { |
| 6 | + width: 80px; |
| 7 | + } |
| 8 | + input.name { |
| 9 | + width: 150px; |
| 10 | + } |
| 11 | + </style> |
| 12 | + </head> |
| 13 | + <body> |
| 14 | + <p>The AQI and temp are sourced from IQAir, which requires "Allow Internet Access" to be enabled in Gadgetbridge.</p> |
| 15 | + <p>To use AQI, you need an IQAir API key. To get one for free, create an IQAir account, then create an API key in <a target="_blank" href="https://dashboard.iqair.com/personal/api-keys">your user dashboard</a>.</p> |
| 16 | + <p>To specify the IQAir source, find your city on the IQAir website, then copy and paste the URL. It should look something like https://www.iqair.com/usa/new-york/new-york-city</p> |
| 17 | + <table id="rows" class="table table-scroll"> |
| 18 | + <tr> |
| 19 | + <th>Name</th> |
| 20 | + <th>IQAir URL</th> |
| 21 | + </tr> |
| 22 | + </table> |
| 23 | + |
| 24 | + <button id="addrow" class="btn">+</button> |
| 25 | + <button id="delrow" class="btn">-</button> |
| 26 | + <br> |
| 27 | + <input id="api-key" type="text" placeholder="IQAir API Key"></input> |
| 28 | + <br> |
| 29 | + <button id="upload" class="btn btn-primary">Upload</button> |
| 30 | + <template id="row-template"> |
| 31 | + <tr class="row"> |
| 32 | + <td> |
| 33 | + <input type="text" class="name"></input> |
| 34 | + </td> |
| 35 | + <td> |
| 36 | + <input type="text" class="url"></input> |
| 37 | + </td> |
| 38 | + </tr> |
| 39 | + </template> |
| 40 | + |
| 41 | + <script src="../../core/lib/customize.js"></script> |
| 42 | + |
| 43 | + <script> |
| 44 | + let storedString = localStorage.getItem('airqualityclockinfo-config'); |
| 45 | + let stored = {}; |
| 46 | + if (storedString) { |
| 47 | + stored = JSON.parse(storedString); |
| 48 | + } |
| 49 | + |
| 50 | + if (stored.apiKey) { |
| 51 | + document.getElementById("api-key").value = stored.apiKey; |
| 52 | + } |
| 53 | + |
| 54 | + if (!stored.rows) { |
| 55 | + stored.rows = [ |
| 56 | + { |
| 57 | + name: "NYC", |
| 58 | + url: "https://www.iqair.com/usa/new-york/new-york", |
| 59 | + } |
| 60 | + ]; |
| 61 | + } |
| 62 | + |
| 63 | + let tbl = document.getElementById("rows"); |
| 64 | + let tmp = document.getElementById("row-template"); |
| 65 | + for (let i = 0; i < stored.rows.length; i++) { |
| 66 | + let row = tmp.content.cloneNode(true); |
| 67 | + let storedRow = stored.rows[i] |
| 68 | + row.querySelector(".name").value = storedRow.name; |
| 69 | + row.querySelector(".url").value = storedRow.url; |
| 70 | + tbl.append(row); |
| 71 | + } |
| 72 | + |
| 73 | + document.getElementById("addrow").addEventListener("click", function() { |
| 74 | + let tbl = document.getElementById("rows"); |
| 75 | + let tmp = document.getElementById("row-template"); |
| 76 | + let row = tmp.content.cloneNode(true); |
| 77 | + tbl.append(row); |
| 78 | + }); |
| 79 | + |
| 80 | + document.getElementById("delrow").addEventListener("click", function() { |
| 81 | + let tbl = document.getElementById("rows"); |
| 82 | + tbl.deleteRow(tbl.rows.length -1); |
| 83 | + }); |
| 84 | + |
| 85 | + document.getElementById("upload").addEventListener("click", function() { |
| 86 | + let config = { |
| 87 | + rows: [], |
| 88 | + apiKey: document.getElementById("api-key").value |
| 89 | + }; |
| 90 | + |
| 91 | + document.querySelectorAll(".row").forEach((row) => { |
| 92 | + let name = row.querySelector(".name").value; |
| 93 | + let url = row.querySelector(".url").value; |
| 94 | + if ( name != "" && url != "" ) { |
| 95 | + config.rows.push({ |
| 96 | + name: name, |
| 97 | + url: url, |
| 98 | + }); |
| 99 | + } |
| 100 | + }); |
| 101 | + |
| 102 | + localStorage.setItem('airqualityclockinfo-config', JSON.stringify(config)); |
| 103 | + |
| 104 | + // send finished app (in addition to contents of app.json) |
| 105 | + sendCustomizedApp({ |
| 106 | + storage:[ |
| 107 | + { |
| 108 | + name: "airqualityci.settings.json", |
| 109 | + content: JSON.stringify(config) |
| 110 | + }, |
| 111 | + ] |
| 112 | + }); |
| 113 | + }); |
| 114 | + </script> |
| 115 | + </body> |
| 116 | +</html> |
0 commit comments