xref: /freebsd/contrib/libxo/xohtml/xohtml.js (revision d8a0fe102c0cfdfcd5b818f850eff09d8536c9bc)
1jQuery(function($) {
2    setTimeout(function() {
3        var $top = $("html body");
4        $top.find('[class~="data"]').each(function() {
5            var help = $(this).attr('data-help'),
6                type = $(this).attr('data-type'),
7                xpath = $(this).attr('data-xpath'),
8                tag = $(this).attr('data-tag'),
9                output = "";
10            if (help) {
11                output += "<b>Help</b>: " + help  + "<br/>";
12            }
13            if (type) {
14                output += "<b>Type</b>: " + type  + "<br/>";
15            }
16            if (xpath) {
17                output += "<div class='xpath-wrapper'>"
18                    + "<a class='xpath-link' href='#'>"
19                    + "show xpath</a><div class='xpath'>"
20                    + xpath + "</div></div><br/>";
21            }
22            if (output.length > 0) {
23                output = "<div>" + output + "</div>";
24            }
25
26            $(this).qtip({
27                content: {
28                    title: "<b>" + tag + "</b>",
29                    text: function () {
30                        var div = $(output);
31                        div.find(".xpath-link")
32                        .click(function() {
33                            var xpath = $(this).next();
34                            if (xpath.is(":hidden")) {
35                                xpath.show();
36                                $(this).text("hide xpath");
37                            } else {
38                                xpath.hide();
39                                $(this).text("show xpath");
40                            }
41                            return false;
42                        });
43                        return div;
44                    }
45                },
46                hide: {
47                    fixed: true,
48                    delay: 300
49                },
50                style: "qtip-tipped"
51            });
52        });
53    }, 0);
54});