Commit 80b7a6f4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio: use domsugar in rjs_gadget_slapos_label_listbox_field_html

parent 9c54847f
......@@ -8,6 +8,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="domsugar.js"></script>
<script src="gadget_slapos_label_listbox_field.js"></script>
</head>
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.62049.17150.785</string> </value>
<value> <string>999.37330.56513.53265</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1555532209.61</float>
<float>1661864726.71</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals window, document, rJS, JSON */
/*globals window, document, rJS, JSON, domsugar */
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, document, rJS, JSON) {
(function (window, document, rJS, JSON, domsugar) {
"use strict";
rJS(window)
......@@ -9,28 +9,33 @@
return {};
})
.declareMethod("render", function (options) {
var gadget = this, a, pre, value;
return gadget.getElement()
.push(function (element) {
value = options.value;
if (typeof options.value === "string") {
if (options.value.startsWith("http://") ||
options.value.startsWith("https://")) {
a = document.createElement('a');
a.setAttribute("href", options.value);
a.setAttribute("target", "_blank");
a.innerText = options.value;
value = a.outerHTML;
} else if (options.value.indexOf("\n") !== -1) {
pre = document.createElement('pre');
pre.innerText = options.value;
value = pre.outerHTML;
}
element.innerHTML = value;
} else {
element.innerHTML = JSON.stringify(value);
}
return element;
var gadget = this,
a,
pre,
value = options.value,
element = gadget.element;
if (typeof value === "string") {
if (value.startsWith("http://") ||
value.startsWith("https://")) {
domsugar(element, [
domsugar('a', {
href: value,
target: '_blank',
text: value
})
]);
// } else if (options.value.indexOf("\n") !== -1) {
} else {
domsugar(element, [
domsugar('pre', {
text: value
})
]);
}
} else {
domsugar(element, {
text: JSON.stringify(value)
});
}
});
}(window, document, rJS, JSON));
\ No newline at end of file
}(window, document, rJS, JSON, domsugar));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.2322.46712.16657</string> </value>
<value> <string>1002.40907.53458.50261</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1658871156.69</float>
<float>1661864631.42</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment