Skip to content
Snippets Groups Projects
Commit c8917d92 authored by lowercasedonkey's avatar lowercasedonkey
Browse files

health

parent bde0bb63
No related branches found
No related tags found
1 merge request!8026Custom slave to js
...@@ -74,6 +74,24 @@ App.Markets["Custom Slave"] = function() { ...@@ -74,6 +74,24 @@ App.Markets["Custom Slave"] = function() {
function health() { function health() {
const el = document.createElement("div"); const el = document.createElement("div");
createDescription(el, description, "health-text");
const choices = {
"Healthy": 0,
"Extremely healthy": 1
};
el.append(choicesMaker("health", choices, refresh));
function description() {
if (slave.health === 0) {
return `Healthy.`;
} else {
return `Extremely healthy.`;
}
}
function refresh() {
jQuery("#health-text").empty().append(description());
}
return el; return el;
} }
...@@ -89,4 +107,20 @@ App.Markets["Custom Slave"] = function() { ...@@ -89,4 +107,20 @@ App.Markets["Custom Slave"] = function() {
span.append(text()); span.append(text());
element.append(span); element.append(span);
} }
function choicesMaker(slaveParam, choices, refresher) {
const linkArray = [];
for (const choice in choices) {
linkArray.push(
App.UI.DOM.link(
choice,
() => {
_.set(slave, slaveParam, choices[choice]);
refresher();
}
)
);
}
return App.UI.DOM.generateLinksStrip(linkArray);
}
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment