BangleApps/apps/coin_info/interface.html

75 lines
2.5 KiB
HTML

<html>
<head>
<link rel="stylesheet" href="../../css/spectre.min.css">
</head>
<body>
<h3>Settings for Crypto-Coin Info</h3>
<p>Set Coinmarketcap API key and traceable tokens.</p>
<p>
<label for="apikey">API Key</label><br>
<input id="apikey" onkeyup="checkInput()" style="width:90%; margin: 3px"></input>
<label for="traceTokens">Traceable tokens. comma delimited</label><br>
<input id="traceTokens" onkeyup="checkInput()" style="width:90%; margin: 3px"></input>
<button id="upload" class="btn btn-primary">Save</button>
</p>
<h4>Where to get your personal API key?</h4>
<p>Go to <a href="https://coinmarketcap.com/api/">https://coinmarketcap.com/api/</a> and sign up for a free account.<br>
There are various pricing models with various degrees of API access. As of 2025.02.22 there is also a free tier.</p>
<script src="../../core/lib/interface.js"></script>
<script>
function checkInput() {
if(document.getElementById("apikey").value==="") {
document.getElementById('upload').disabled = true;
} else {
document.getElementById('upload').disabled = false;
}
}
checkInput();
var settings = {};
function onInit(){
console.log("Loading settings from BangleJs...");
try {
Util.readStorageJSON("coin_info.cmc_key.json", data=>{
if(data){
settings = data;
console.log("Got settings", settings);
document.getElementById("apikey").value = settings.apikey;
document.getElementById("traceTokens").value = settings.traceTokens;
console.log("Loaded settings from BangleJs.");
checkInput();
}
});
} catch(ex) {
console.log("(Warning) Could not load settings from BangleJs.");
console.log(ex);
}
}
document.getElementById("upload").addEventListener("click", function() {
try {
settings.apikey = document.getElementById("apikey").value;
settings.traceTokens = document.getElementById("traceTokens").value;
Util.showModal("Saving...");
Util.writeStorage("coin_info.cmc_key.json", JSON.stringify(settings), ()=>{
Util.hideModal();
});
console.log("Sent settings!");
} catch(ex) {
console.log("(Warning) Could not write settings to BangleJs.");
console.log(ex);
}
});
</script>
</body>
</html>