You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
951 B

import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
static values = {
commands: String,
}
remoteControl() {
// cf <https://josm.openstreetmap.de/wiki/Help/RemoteControlCommands>
const baseurl = 'http://localhost:8111';
const _this = this, commands = JSON.parse(this.commandsValue);
for (var command in commands) {
var url = baseurl + '/' + command, params = new URLSearchParams();
for (var name in commands[command]) {
params.append(name, commands[command][name]);
}
if (Array.from(params.length > 0)) {
url += '?' + params.toString();
}
fetch(url)
.then(function (response) {
return response.text();
})
.then(function (text) {
});
}
}
}