2020-04-08 13:26:38 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.css">
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/lint/lint.min.css">
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2020-08-24 10:59:52 +00:00
|
|
|
<script src="../../core/lib/customize.js"></script>
|
2020-04-08 13:26:38 +00:00
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/javascript/javascript.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/lint/lint.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/lint/javascript-lint.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/javascript-hint.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jshint/2.11.0/jshint.min.js"></script>
|
|
|
|
<p>Type your javascript code here</p>
|
|
|
|
<p><textarea id="custom-js"></textarea></p>
|
2022-03-08 13:00:31 +00:00
|
|
|
<p>Then click <button id="upload" class="btn btn-primary">Upload</button> <span id="btninfo" style="color:orange"></span></p>
|
2020-04-08 13:26:38 +00:00
|
|
|
<script>
|
|
|
|
const item = "custom.boot.js";
|
|
|
|
const id = "custom-js";
|
|
|
|
const sample = "//Bangle.setOptions({wakeOnBTN2:false});";
|
2022-03-08 13:00:31 +00:00
|
|
|
var customBootCode = null;
|
2020-04-08 13:26:38 +00:00
|
|
|
var editor = {};
|
|
|
|
|
|
|
|
if (localStorage.getItem(item) === null) {
|
|
|
|
localStorage.setItem(item, sample);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById(id).value = localStorage.getItem(item);
|
|
|
|
|
|
|
|
// The code editor
|
|
|
|
var lintFlags = {
|
|
|
|
esversion: 6, // Enable ES6 for literals, arrow fns, binary
|
|
|
|
evil: true, // don't warn on use of strings in setInterval
|
|
|
|
laxbreak: true, // don't warn about newlines in expressions
|
|
|
|
laxcomma: true // don't warn about commas at the start of the line
|
|
|
|
};
|
|
|
|
editor = CodeMirror.fromTextArea(document.getElementById(id), {
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
matchBrackets: true,
|
|
|
|
mode: { name: "javascript", globalVars: false },
|
|
|
|
lineWrapping: true,
|
|
|
|
showTrailingSpace: true,
|
|
|
|
lint: lintFlags,
|
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-lint-markers"],
|
|
|
|
lineNumbers: true
|
|
|
|
});
|
2022-03-08 13:00:31 +00:00
|
|
|
function hasWarnings() {
|
|
|
|
return editor.state.lint.marked.length!=0;
|
|
|
|
}
|
2020-04-08 13:26:38 +00:00
|
|
|
|
2022-03-08 13:00:31 +00:00
|
|
|
editor.on("change", function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
if (hasWarnings()) {
|
|
|
|
document.getElementById("btninfo").innerHTML = "There are warnings in the code to be uploaded";
|
|
|
|
document.getElementById("upload").classList.add("disabled");
|
|
|
|
} else {
|
|
|
|
document.getElementById("btninfo").innerHTML = "";
|
|
|
|
document.getElementById("upload").classList.remove("disabled");
|
2020-04-08 13:26:38 +00:00
|
|
|
}
|
2022-03-08 13:00:31 +00:00
|
|
|
}, 500);
|
|
|
|
})
|
|
|
|
|
|
|
|
document.getElementById("upload").addEventListener("click", function() {
|
|
|
|
if (!hasWarnings()) {
|
|
|
|
customBootCode = editor.getValue();
|
|
|
|
localStorage.setItem(item, customBootCode);
|
|
|
|
sendCustomizedApp({
|
|
|
|
storage: [{ name: item, content: customBootCode }]
|
|
|
|
});
|
|
|
|
}
|
2020-04-08 13:26:38 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|