mirror of https://github.com/espruino/BangleApps
Fixes
parent
295a9b57f0
commit
aad3f43d87
|
@ -5,7 +5,13 @@
|
|||
<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"></textarea></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>
|
||||
|
@ -13,25 +19,16 @@
|
|||
|
||||
<script>
|
||||
var textAreaTrigger = document.getElementById("triggers");
|
||||
|
||||
var triggerJson = [
|
||||
{"display": "Open", "trigger": "OPEN_DOOR", "icon":"door"},
|
||||
{"display": "Office", "trigger": "TOGGLE_LIGHT", "icon":"light"},
|
||||
{"display": "Living Room", "trigger": "OVEN", "icon":"fire"}
|
||||
];
|
||||
try{
|
||||
Util.showModal("Downloading trigger from BangleJs...");
|
||||
Util.readStorageFile("ha.trigger.json", data=>{
|
||||
Util.hideModal();
|
||||
triggerJson = JSON.parse(data);
|
||||
textAreaTrigger.value = data;
|
||||
});
|
||||
console.log("Loaded from BangleJs:\n" + data);
|
||||
} catch(ex){
|
||||
console.log("(Warning) Failed loading ha.trigger.json from BangleJs. Using default.");
|
||||
}
|
||||
|
||||
triggerJson = JSON.stringify(triggerJson);
|
||||
textAreaTrigger.value = triggerJson;
|
||||
console.log(triggerJson);
|
||||
Util.hideModal();
|
||||
|
||||
/*
|
||||
* Upload trigger to BangleJs
|
||||
|
|
Loading…
Reference in New Issue