2020-07-31 21:54:30 +02:00
|
|
|
import {OsmConnection} from "./Logic/Osm/OsmConnection";
|
2020-08-07 16:01:18 +02:00
|
|
|
import Combine from "./UI/Base/Combine";
|
|
|
|
import {Button} from "./UI/Base/Button";
|
|
|
|
import {TextField} from "./UI/Input/TextField";
|
|
|
|
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
|
|
|
import {UIElement} from "./UI/UIElement";
|
2020-08-17 17:23:15 +02:00
|
|
|
import {UIEventSource} from "./Logic/UIEventSource";
|
2020-07-31 21:54:30 +02:00
|
|
|
|
|
|
|
|
2020-08-30 01:13:18 +02:00
|
|
|
const connection = new OsmConnection(false, new UIEventSource<string>(undefined), "");
|
2020-08-07 16:01:18 +02:00
|
|
|
|
|
|
|
let rendered = false;
|
|
|
|
|
|
|
|
function createTable(preferences: any) {
|
|
|
|
if (rendered) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rendered = true;
|
|
|
|
const prefs = [];
|
|
|
|
console.log(preferences);
|
|
|
|
for (const key in preferences) {
|
|
|
|
console.log(key)
|
|
|
|
const pref = connection.GetPreference(key, "");
|
|
|
|
|
|
|
|
let value: UIElement = new FixedUiElement(pref.data);
|
|
|
|
if (connection.userDetails.data.csCount > 500 &&
|
|
|
|
(key.startsWith("mapcomplete") || connection.userDetails.data.csCount > 2500)) {
|
2020-10-02 19:00:24 +02:00
|
|
|
value = new TextField({
|
2020-08-07 16:01:18 +02:00
|
|
|
value: pref
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const c = [
|
|
|
|
"<tr><td>",
|
|
|
|
key,
|
|
|
|
"</td><td>",
|
|
|
|
new Button("delete", () => pref.setData("")),
|
|
|
|
"</td><td>",
|
|
|
|
value,
|
|
|
|
"</td></tr>"
|
|
|
|
];
|
|
|
|
prefs.push(...c);
|
|
|
|
}
|
|
|
|
|
|
|
|
const el = new Combine(
|
|
|
|
["<table>",
|
|
|
|
...prefs,
|
|
|
|
"</table>"]
|
|
|
|
); // .AttachTo("maindiv");
|
|
|
|
console.log(el.InnerRender())
|
|
|
|
el.AttachTo("maindiv");
|
|
|
|
}
|
|
|
|
|
2020-08-27 11:11:20 +02:00
|
|
|
connection.preferencesHandler.preferences.addCallback((prefs) => createTable(prefs))
|
2020-08-07 16:01:18 +02:00
|
|
|
|