Commit 3d81a2c4 authored by Romain Courteaud's avatar Romain Courteaud Committed by Rafael Monnerat

slapos_jio: use domsugar in rjs_gadget_slapos_label_listbox_field_html

parent df92f04d
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="domsugar.js"></script>
<script src="gadget_slapos_label_listbox_field.js"></script> <script src="gadget_slapos_label_listbox_field.js"></script>
</head> </head>
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.62049.17150.785</string> </value> <value> <string>999.37330.56513.53265</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1555532209.61</float> <float>1661864726.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*globals window, document, rJS, JSON */ /*globals window, document, rJS, JSON, domsugar */
/*jslint indent: 2, nomen: true, maxlen: 80*/ /*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, document, rJS, JSON) { (function (window, document, rJS, JSON, domsugar) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -9,28 +9,33 @@ ...@@ -9,28 +9,33 @@
return {}; return {};
}) })
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, a, pre, value; var gadget = this,
return gadget.getElement() a,
.push(function (element) { pre,
value = options.value; value = options.value,
if (typeof options.value === "string") { element = gadget.element;
if (options.value.startsWith("http://") || if (typeof value === "string") {
options.value.startsWith("https://")) { if (value.startsWith("http://") ||
a = document.createElement('a'); value.startsWith("https://")) {
a.setAttribute("href", options.value); domsugar(element, [
a.setAttribute("target", "_blank"); domsugar('a', {
a.innerText = options.value; href: value,
value = a.outerHTML; target: '_blank',
} else if (options.value.indexOf("\n") !== -1) { text: value
pre = document.createElement('pre'); })
pre.innerText = options.value; ]);
value = pre.outerHTML; // } else if (options.value.indexOf("\n") !== -1) {
}
element.innerHTML = value;
} else { } else {
element.innerHTML = JSON.stringify(value); domsugar(element, [
domsugar('pre', {
text: value
})
]);
} }
return element; } else {
domsugar(element, {
text: JSON.stringify(value)
}); });
}
}); });
}(window, document, rJS, JSON)); }(window, document, rJS, JSON, domsugar));
\ No newline at end of file \ No newline at end of file
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.2322.46712.16657</string> </value> <value> <string>1002.40907.53458.50261</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1658871156.69</float> <float>1661864631.42</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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