aboutsummaryrefslogtreecommitdiff
path: root/src/js/arching-kaos-web-ui-settings.js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-13 18:13:06 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-13 18:13:06 +0300
commitf6fc624b2a4c5fff80e8e070b5cb065bcced0aed (patch)
tree8ec19da31a8196cb30cecc053b10ee11a48b4835 /src/js/arching-kaos-web-ui-settings.js
parentb165b0e78e04d269eca33f78df6b86922fcae56e (diff)
downloadarching-kaos-web-ui-f6fc624b2a4c5fff80e8e070b5cb065bcced0aed.tar.gz
arching-kaos-web-ui-f6fc624b2a4c5fff80e8e070b5cb065bcced0aed.tar.bz2
arching-kaos-web-ui-f6fc624b2a4c5fff80e8e070b5cb065bcced0aed.zip
refactoring
Diffstat (limited to 'src/js/arching-kaos-web-ui-settings.js')
-rw-r--r--src/js/arching-kaos-web-ui-settings.js61
1 files changed, 51 insertions, 10 deletions
diff --git a/src/js/arching-kaos-web-ui-settings.js b/src/js/arching-kaos-web-ui-settings.js
index 601c176..3338d0f 100644
--- a/src/js/arching-kaos-web-ui-settings.js
+++ b/src/js/arching-kaos-web-ui-settings.js
@@ -87,31 +87,66 @@ var settingsPage = document.querySelector('#settings-section');
var settingsKeys = Object.keys(activeSettings);
+function renderCheck(container, value){
+ var checkbox = document.createElement('input');
+ checkbox.type = 'checkbox';
+ if (value === true){
+ checkbox.checked = true;
+ }
+ container.appendChild(checkbox);
+}
+
+function renderList(container, value){
+ var selectOptions = document.createElement('select');
+ for ( i = 0 ; i < value.list.length; i++ ){
+ var option = document.createElement("option");
+ if ( i === value.active ) {
+ option.selected = true;
+ };
+ option.innerText = value.list[i];
+ option.value = i;
+ selectOptions.appendChild(option);
+ }
+ container.appendChild(selectOptions);
+}
+
+function renderAssets(container, value){
+ var selectOptions = document.createElement('select');
+ for ( i = 0 ; i < value.list.length; i++ ){
+ var option = document.createElement("option");
+ if ( i === value.active ) {
+ option.selected = true;
+ };
+ option.innerText = value.list[i].code + "-" + value.list[i].issuer;
+ option.value = i;
+ selectOptions.appendChild(option);
+ }
+ container.appendChild(selectOptions);
+}
+
function settingPlaceToDOM(key, value){
- var container = document.createElement("div");
- var label = document.createElement("label");
- label.innerText=key;
- container.appendChild(label);
- var paragraph = document.createElement("p");
- container.appendChild(paragraph);
+ var container = document.createElement("fieldset");
+ container.innerText=key;
if ( Array.isArray(value) ){
- var ul = document.createElement("ul");
+ var ul = document.createElement("select");
value.map((v)=>{
if (v.constructor.name === "Object"){
Object.keys(v).forEach((value)=>{
- var li = document.createElement("li");
+ var li = document.createElement("option");
li.innerText = value + ': ' + v[value];
+ li.value = value;
ul.appendChild(li);
});
} else {
- var li = document.createElement("li");
+ var li = document.createElement("option");
li.innerText = v;
+ li.value = v;
ul.appendChild(li);
}
});
paragraph.appendChild(ul);
} else {
- paragraph.innerText = value;
+ container.innerText = value;
}
settingsPage.appendChild(container);
}
@@ -122,6 +157,12 @@ settingsKeys.forEach(
}
);
+/* Small dump as pre text */
+var predump = document.createElement('pre');
+predump.innerText = JSON.stringify(activeSettings, null, 2);
+settingsPage.appendChild(predump);
+/* END of: Small dump as pre text */
+
// console.log(activeSettings.ipfsGatewayAddress[activeSettings.ipfsSelectedGatewayAddress]);
// vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4