"ui"; storage = storages.create("mower-ng helper"); const config_items = { wx: 10, wy: 10, http_proto: "http", host: "127.0.0.1", port: "58000", auto_close: false, }; config = {}; Object.entries(config_items).forEach(([key, value]) => { config[key + "_"] = storage.get(key, value); Object.defineProperty(config, key, { get() { return this[key + "_"]; }, set(new_value) { this[key + "_"] = new_value; storage.put(key, new_value); }, }); }); Object.defineProperties(config, { scheduler_url: { get() { return `${this.http_proto}://${this.host}:${this.port}/scheduler`; }, }, ws_url: { get() { ws_proto = this.http_proto == "https" ? "wss" : "ws"; return `${ws_proto}://${this.host}:${this.port}/ws`; }, }, }); function save_config() { config.http_proto = ui.proto.getText(); config.host = ui.host.getText(); config.port = ui.port.getText(); config.auto_close = ui.auto_close.isChecked(); } w = null; ui.layout(