testing interface.html
parent
5cab67f226
commit
769ced85e4
|
|
@ -0,0 +1,58 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../../css/spectre.min.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Please select a gpx file to be converted to gpc and loaded.</p>
|
||||
|
||||
|
||||
<input type="file" is="gpx_file" id="fileInput" accept=".gpx">
|
||||
|
||||
<script src="../../core/lib/customize.js"></script>
|
||||
|
||||
<script type="module">
|
||||
|
||||
import init, { convert_gpx_strings } from "./pkg/gpconv.js";
|
||||
console.log("imported wasm");
|
||||
document.getElementById('fileInput').addEventListener('change', function selectedFileChanged() {
|
||||
if (this.files.length === 0) {
|
||||
console.log('No file selected.');
|
||||
return;
|
||||
}
|
||||
|
||||
let gpx_filename = this.files[0].name;
|
||||
let gpc_filename = gpx_filename.slice(0, gpx_filename.length-4) + ".gpc";
|
||||
while (gpc_filename.length > 28) {
|
||||
let new_name = prompt("enter a shorter destination filename than '" + gpc_filename + "' (28 chars max)", gpc_filename);
|
||||
if (new_name != null && new_name.slice(new_name.length-4) == ".gpc") {
|
||||
gpc_filename = new_name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function fileReadCompleted() {
|
||||
console.log("reading file completed");
|
||||
|
||||
init().then(() => {
|
||||
|
||||
let gpc_file = convert_gpx_strings(reader.result);
|
||||
let gpc_string = String.fromCharCode.apply(String, gpc_file);
|
||||
|
||||
console.log("uploading");
|
||||
sendCustomizedApp({
|
||||
storage:[
|
||||
{name:gpc_filename, url:'test.gpc', content:gpc_string},
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
reader.readAsText(this.files[0]);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue