mirror of https://github.com/espruino/BangleApps
51 lines
1.6 KiB
HTML
51 lines
1.6 KiB
HTML
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
|
</head>
|
|
<body>
|
|
<h3>Upload Tiggers</h3>
|
|
<p>You must upload a list of json objects -- an example is given below</p>
|
|
<p><textarea id="triggers" style="width:500px; height:300px">
|
|
[
|
|
{"display": "Open", "trigger": "OPEN_DOOR", "icon":"door"},
|
|
{"display": "Office", "trigger": "TOGGLE_LIGHT", "icon":"light"},
|
|
{"display": "Living Room", "trigger": "OVEN", "icon":"fire"}
|
|
]
|
|
</textarea></p>
|
|
<p><button id="upload" class="btn btn-primary">Upload</button></p>
|
|
|
|
<script src="../../core/lib/customize.js"></script>
|
|
<script src="../../core/lib/interface.js"></script>
|
|
|
|
<script>
|
|
function onInit(){
|
|
try{
|
|
Util.readStorage("ha.trigger.json", data=>{
|
|
document.getElementById("triggers").innerHTML += data;
|
|
});
|
|
console.log("Loaded from BangleJs:\n" + data);
|
|
} catch(ex){
|
|
console.log("(Warning) Failed loading ha.trigger.json from BangleJs. Using default.");
|
|
console.log(ex);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Upload trigger to BangleJs
|
|
*/
|
|
document.getElementById("upload").addEventListener("click", function() {
|
|
// get the text to add
|
|
var triggers = document.getElementById("triggers").value;
|
|
// send finished app (in addition to contents of app.json)
|
|
sendCustomizedApp({
|
|
storage:[
|
|
{name:"ha.trigger.json", url:"ha.trigger.json", content:triggers},
|
|
]
|
|
});
|
|
console.log("Sent ha.trigger.json!");
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|