mirror of https://github.com/zulip/zulip.git
Add preview_node functionality to util.js.
This shows a preview of a node given a reference to it like: <tag id=“id” class=“className”></tag>. It's intended to be used for reporting errors that are introduced by developers in features such as the upcoming progressive list rendering.
This commit is contained in:
parent
f08c8b1c56
commit
5e1471f5a3
|
@ -56,6 +56,27 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
|
|||
return first;
|
||||
};
|
||||
|
||||
// Produces an easy-to-read preview on an HTML element. Currently
|
||||
// only used for including in error report emails; be sure to discuss
|
||||
// with other developers before using it in a user-facing context
|
||||
// because it is not XSS-safe.
|
||||
exports.preview_node = function (node) {
|
||||
if (node.constructor === jQuery) {
|
||||
node = node[0];
|
||||
}
|
||||
|
||||
var tag = node.tagName.toLowerCase();
|
||||
var className = node.className.length ? node.className : false;
|
||||
var id = node.id.length ? node.id : false;
|
||||
|
||||
var node_preview = "<" + tag +
|
||||
(id ? " id='" + id + "'" : "") +
|
||||
(className ? " class='" + className + "'" : "") +
|
||||
"></" + tag + ">";
|
||||
|
||||
return node_preview;
|
||||
};
|
||||
|
||||
exports.same_stream_and_topic = function util_same_stream_and_topic(a, b) {
|
||||
// Streams and topics are case-insensitive.
|
||||
return ((a.stream_id === b.stream_id) &&
|
||||
|
|
Loading…
Reference in New Issue