PageSourceSearch

https://www.inesc-id.pt/wp-content/plugins/inesc-pages/js/intranet…/jsFilter_projects.js?ver=1790239247

js inesc-id.pt collected 2026-09-24 08:41:43 UTC 4,348 bytes, 121 lines download raw bytes

1// Function that creates a list of projects in the div element based on the data items in tempArray
2function jsFilter_createListProjects(div, tempArray) {
3  div.innerHTML = "";
4  const ul = iidHTML("ul", "", {}, {}, ["publicationListJS"]);
5  const fragment = document.createDocumentFragment();
6  tempArray.forEach((obj) => {
7    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
8    li.id = obj["name"];
9
10    var acronym;
11    if (obj["url"] != null && obj["url"] != "") {
12      acronym = iidHTML("a", obj["acronym"], {}, {}, [ "filteringHyperlink", ]);
13      acronym.href = obj["url"];
14      acronym.target = "_blank";
15    } else {
16      acronym = iidHTML("span", obj["acronym"]);
17    }
18    li.appendChild(acronym);
19
20    const name = iidHTML("span", " - " + obj["name"]);
21    li.appendChild(name);
22
23    const primeContractorIdName = iidHTML( "span", ", " + obj["primeContractorIdName"].item2);
24    li.appendChild(primeContractorIdName);
25
26    const financedByIdName = iidHTML( "span", ", " + obj["financedByIdName"].item2);
27    li.appendChild(financedByIdName);
28
29    var year;
30    if (obj["endDate"] != null && obj["endDate"] != "") {
31      year = iidHTML( "span", ", " + "(" + obj["beginDate"] + "-" + obj["endDate"] + ")");
32    } else {
33      year = iidHTML( "span", ", " + "(" + obj["beginDate"] + "-Ongoing)");
34    }
35    li.appendChild(year);
36    li.appendChild(iidHTML("br", ""));
37
38    fragment.appendChild(li);
39  });
40  ul.appendChild(fragment);
41  div.appendChild(ul);
42}
43
44// These functions are used for local testing using the index.html, but not by the PHP plugin
45
46function jsFilter_getProjects() {
47  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/projects/list";
48  jsFilter_fetchData(phpFile, dynamicApiURL)
49    .then((retrievedData) => {
50      jsFilter_initList(retrievedData.results);
51    })
52    .catch((error) => { console.error("Error:", error); });
53}
54
55async function jsFilter_getAllProjectsByOUID() {
56  jsFilter_currentContext = "Projects";
57  const allPublications = [];
58  const publicationAreaMap = {};
59  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/projects/listbyouid?ouId=";
60  const keys = Object.keys(jsFilter_peopleScientificAreas);
61
62  try {
63    await Promise.all(
64      keys.map(async (key) => {
65        const retrievedData = await jsFilter_fetchData( phpFile, dynamicApiURL + key);
66        retrievedData.results.forEach((element) => {
67          const scientificArea = key;
68          if (
69            !publicationAreaMap[
70              element[jsFilter_frontEndID[jsFilter_currentContext]]
71            ]
72          ) {
73            publicationAreaMap[
74              element[jsFilter_frontEndID[jsFilter_currentContext]]
75            ] = [{ item1: scientificArea }];
76          } else {
77            publicationAreaMap[
78              element[jsFilter_frontEndID[jsFilter_currentContext]]
79            ].push({
80              item1: scientificArea,
81            });
82          }
83
84          element["organizationalUnitIdAcronymName"] = scientificArea;
85        });
86
87        allPublications.push(...retrievedData.results);
88      })
89    );
90  } catch (error) { console.error("Error:", error); }
91
92  allPublications.forEach((obg) => {
93    obg["organizationalUnitIdAcronymName"] = publicationAreaMap[obg[jsFilter_frontEndID[jsFilter_currentContext]]];
94    obg["type"] = jsFilter_projectTypes[obg["typeId"]];
95  });
96  jsFilter_initList(allPublications);
97}
98
99function jsFilter_getProjectsByOUID(ouID) {
100  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/projects/listbyouid?ouId=" + ouID;
101  jsFilter_fetchData(phpFile, dynamicApiURL)
102    .then((retrievedData) => {
103      jsFilter_initList(retrievedData.results);
104    })
105    .catch((error) => { console.error("Error:", error); });
106}
107
108function jsFilter_getProjectsByAuthor(authorID) {
109  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/projects/listbyparticipantid?participantId=" + authorID;
110  jsFilter_fetchData(phpFile, dynamicApiURL)
111    .then(async (retrievedData) => {
112      if (retrievedData.results != null) {
113        retrievedData.results.forEach((element) => {
114          element["organizationalUnitIdAcronymName"] = [];
115        });
116        const author = await jsFilter_getSingleAuthor(authorID);
117        jsFilter_initList(retrievedData.results, author);
118      }
119    })
120    .catch((error) => { console.error("Error:", error); });
121}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.