mirror of https://github.com/espruino/BangleApps
Using custom.html again to ensure that data is uploaded.
parent
8b9a34aab0
commit
cc7e5600e3
|
@ -0,0 +1,43 @@
|
||||||
|
<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>
|
||||||
|
Puck.eval(`require("Storage").read(${JSON.stringify("ha.trigger.json")})`,data=>{
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// When the 'upload' button is clicked...
|
||||||
|
document.getElementById("upload").addEventListener("click", function() {
|
||||||
|
// get the text to add
|
||||||
|
var text = document.getElementById("triggers").value;
|
||||||
|
console.log(text);
|
||||||
|
// build the app's text using a templated String
|
||||||
|
var app = text;
|
||||||
|
// send finished app (in addition to contents of app.json)
|
||||||
|
sendCustomizedApp({
|
||||||
|
storage:[
|
||||||
|
{name:"ha.trigger.json", url:"ha.trigger.json", content:app},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
console.log("Sent ha.trigger.json!");
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,49 +0,0 @@
|
||||||
<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/interface.js"></script>
|
|
||||||
<script src="../../core/lib/espruinotools.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function loadData(){
|
|
||||||
Util.showModal("Download trigger from your BangleJs...")
|
|
||||||
|
|
||||||
try{
|
|
||||||
Puck.eval(`require("Storage").read(${JSON.stringify("ha.trigger.json")})`,data=>{
|
|
||||||
document.getElementById("triggers").innerHTML = data;
|
|
||||||
Util.hideModal();
|
|
||||||
});
|
|
||||||
} catch(ex){}
|
|
||||||
Util.hideModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeData(){
|
|
||||||
var data = document.getElementById("triggers").value;
|
|
||||||
console.log(data);
|
|
||||||
Puck.eval(`require("Storage").write(${JSON.stringify("ha.trigger.json")},${data})`, ()=>{});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("upload").addEventListener("click", function() {
|
|
||||||
writeData();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function onInit(){
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -8,7 +8,7 @@
|
||||||
"tags": "tool",
|
"tags": "tool",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"supports": ["BANGLEJS2"],
|
"supports": ["BANGLEJS2"],
|
||||||
"interface": "interface.html",
|
"custom": "trigger.html",
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
{"url":"screenshot.png"},
|
{"url":"screenshot.png"},
|
||||||
{"url":"screenshot_2.png"},
|
{"url":"screenshot_2.png"},
|
||||||
|
|
Loading…
Reference in New Issue