Changes for page People in ErUM-Data

Last modified by Benjamin Fischer on 2025/03/26 13:22

From version 29.2
edited by admin
on 2024/10/23 14:19
Change comment: There is no comment for this version
To version 28.4
edited by admin
on 2024/10/23 12:58
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -23,5 +23,5 @@
23 23   'defaultOrder': 'asc'
24 24  })
25 25  #set ($columns = ['affiliation', 'URL', "content", "tags", "tags", "tags", '_actions'])
26 -#livetable('research_groups' $columns $columnsProperties $options)
26 +#livetable('research groups' $columns $columnsProperties $options)
27 27  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -1,4 +1,4 @@
1 -const tabName = "research_groups";
1 +const tabName = "research groups";
2 2  const tagCols = [
3 3   ["Community", "KAT", "KET", "KfB", "KFN", "KFS", "KFSI", "KHuK", "RDS", "beyond ErUM"],
4 4   ["Experiment", "CMS", "ATLAS", "Belle2", "CTA", "Auger"],
... ... @@ -45,17 +45,34 @@
45 45  });
46 46  
47 47  document.observe(`xwiki:livetable:${tabName}:receivedEntries`, ({memo: {data}}) => {
48 + debugger;
49 + return;
48 48   for (const row of data.rows) {
49 - const a = new Element("a", { href: row.URL });
50 - a.innerHTML = row.affiliation_value.split("\n").map((a, i) => i ? a : `<b class="wikiexternallink">${a}</b>`).join("<br/>");
51 - a.title = row.doc_title;
52 - if (row.content !== "-") {
53 - a.dataset.content = row.content;
54 - a.dataset.toggle = "popover";
51 + const ol = new DOMParser().parseFromString(row.doc_location, "text/xml").documentElement;
52 + const li = ol.children;
53 +
54 + li[0].remove(); // remove "Event"
55 + for (let i = 1; i < li.length - 1; i++) // intermediate
56 + li[i].textContent = li[i].textContent; // remove link
57 +
58 + const a = li[li.length - 1].children[0];
59 + const u = new URL(row.link_value);
60 + let icon;
61 + if (u.hostname.includes("github")) icon = "github";
62 + if (u.hostname.includes("gitlab")) icon = "gitlab";
63 + if (u.hostname.includes("google")) icon = "google";
64 + if (u.pathname.endsWith(".pdf")) icon = "file-pdf-o";
65 + if (icon) {
66 + const s = a.ownerDocument.createElement("span");
67 + s.textContent = " ";
68 + s.setAttribute("class", `fa fa-${icon}`);
69 + s.setAttribute("style", "padding-right: .3em;");
70 + a.insertBefore(s, a.firstChild);
55 55   }
72 + a.setAttribute("class", "wikiexternallink");
73 + a.setAttribute("href", u.href);
56 56  
57 - row.affiliation = a.outerHTML;
58 - delete a;
75 + row.doc_location = ol.outerHTML;
59 59  
60 60   // tags
61 61   const tags = new Set(row.tags_value.slice(1, -1).split(", "));
... ... @@ -69,18 +69,5 @@
69 69   }
70 70  });
71 71  
72 -require(['jquery', 'bootstrap'], function($) {
73 - const ttApply = () => {
74 - $(`#${tabName} [data-toggle="popover"]`).popover({
75 - html: true,
76 - container: `#${tabName}`,
77 - trigger: "hover",
78 - });
79 - };
80 80  
81 - document.observe(`xwiki:livetable:${tabName}:displayComplete`, ttApply);
82 - ttApply();
83 -});
84 84  
85 -
86 -