PageSourceSearch

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

js inesc-id.pt collected 2026-10-01 09:15:36 UTC 25,782 bytes, 762 lines download raw bytes

1// Function that creates a list of publications in the div element based on the data items in tempArray
2function jsFilter_createListPublications(div, tempArray, drawer) {
3  div.innerHTML = "";
4  const ul = iidHTML("ul", "", {}, {}, ["publicationListJS"]);
5  const fragment = document.createDocumentFragment(); // Create a DocumentFragment
6  switch (drawer) {
7    case "Article":
8      jsfilter_ArticleInfo(fragment, tempArray);
9      break;
10    case "InProceedings":
11      jsfilter_InProceedingsInfo(fragment, tempArray);
12      break;
13    case "Book":
14      jsfilter_BookInfo(fragment, tempArray);
15      break;
16    case "InBook":
17      jsfilter_InBookInfo(fragment, tempArray);
18      break;
19    case "Proceedings":
20      jsfilter_ProceedingsInfo(fragment, tempArray);
21      break;
22    case "Thesis":
23      jsfilter_ThesisInfo(fragment, tempArray);
24      break;
25    case "TechnicalReport":
26      jsfilter_TechnicalReportInfo(fragment, tempArray);
27      break;
28    case "Others":
29      jsfilter_OthersInfo(fragment, tempArray);
30      break;
31    default:
32      jsFilter_defaultInfo(fragment, tempArray);
33      break;
34  }
35
36  ul.appendChild(fragment);
37  div.appendChild(ul);
38}
39
40function jsfilter_createTitle(obj) {
41  if (obj["fileId"]) {
42    a = iidHTML("a", obj["bibtexTitle"], {"font-weight": "bold", }, {}, [ "filteringHyperlink", ]);
43    a.href = "https://iid-intranet.inesc-id.pt/publications/downloadfile?id=" + obj["fileId"];
44    a.target = "_blank";
45    return a;
46  }
47  else {
48    return iidHTML("strong", obj["bibtexTitle"]);
49  }
50}
51
52// Function that creates the author part of a publication
53function jsFilter_createPublicationAuthors(obj, li) {
54  obj["bibtexRankedAuthorsIdName"].forEach((element, index) => {
55    let a;
56    if (element["item4"]) {
57      a = iidHTML("a", element["item2"], {}, {}, [ "filteringHyperlink", ]);
58      a.href = jsFilter_urlREF + "member/" + element["item1"] + "/publications";
59      a.target = "_blank";
60      li.appendChild(a);
61
62      if (index < obj["bibtexRankedAuthorsIdName"].length - 1) {
63        a.textContent = a.textContent + ", ";
64      }
65    } else {
66      a = iidHTML("span", element["item2"], {}, {});
67      li.appendChild(a);
68
69      if (index < obj["bibtexRankedAuthorsIdName"].length - 1) {
70        a.textContent = a.textContent + ", ";
71      }
72    }
73  });
74}
75
76// Function that creates a list of publications according to tag
77function jsfilter_InProceedingsInfo(fragment, tempArray) {
78  tempArray.forEach((obj) => {
79    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
80    li.id = obj["bibtexTitle"];
81
82 //   const strong = iidHTML("strong", obj["bibtexTitle"]);
83    const strong = jsfilter_createTitle(obj);
84    li.appendChild(strong);
85    li.appendChild(iidHTML("br", ""));
86
87    jsFilter_createPublicationAuthors(obj, li);
88
89    li.appendChild(iidHTML("br", ""));
90
91    var spanText = "";
92
93    if (obj["bibtexBookTitle"] && obj["bibtexBookTitle"] != "")
94      spanText += obj["bibtexBookTitle"] + ", ";
95    else spanText += "[proceedings] ";
96
97    if (obj["bibtexSeries"] && obj["bibtexSeries"] != "")
98      spanText += obj["bibtexSeries"] + ", ";
99
100    if (obj["bibtexPublisher"] && obj["bibtexPublisher"] != "")
101      spanText += obj["bibtexPublisher"] + ", ";
102
103    if (
104      obj["bibtexVolume"] &&
105      obj["bibtexVolume"] != "" &&
106      obj["bibtexVolume"] != 0 &&
107      obj["bibtexVolume"] != "0"
108    )
109      spanText += "vol. " + obj["bibtexVolume"] + ", ";
110
111    if (obj["bibtexOrganization"] && obj["bibtexOrganization"] != "")
112      spanText += obj["bibtexOrganization"] + ", ";
113
114    if (obj["bibtexAddress"] && obj["bibtexAddress"] != "")
115      spanText += obj["bibtexAddress"] + " ";
116
117    const spanElement = iidHTML("span", spanText, {}, {});
118    li.appendChild(spanElement);
119
120    if (spanText.length > 0)
121      li.appendChild(iidHTML("br", ""));
122
123    const year = iidHTML("span", "", {}, {});
124    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
125    const publicationType = obj["publicationType"];
126    const bibtexDate = obj["bibtexDate"];
127    if (bibtexDate && contextMapping[publicationType]) {
128      const publicationList = obj[contextMapping[publicationType]];
129
130      if (!publicationList || !publicationList.includes(bibtexDate)) {
131        year.textContent = " " + bibtexDate;
132        li.appendChild(year);
133      }
134    } else if (bibtexDate) {
135      year.textContent = " " + bibtexDate;
136      li.appendChild(year);
137    }
138
139    fragment.appendChild(li);
140  });
141}
142
143// Function that creates a list of publications according to tag
144function jsfilter_ArticleInfo(fragment, tempArray) {
145  tempArray.forEach((obj) => {
146    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
147    li.id = obj["bibtexTitle"];
148
149 //   const strong = iidHTML("strong", obj["bibtexTitle"]);
150    const strong = jsfilter_createTitle(obj);
151    li.appendChild(strong);
152    li.appendChild(iidHTML("br", ""));
153
154    jsFilter_createPublicationAuthors(obj, li);
155
156    li.appendChild(iidHTML("br", ""));
157
158    var spanText = "";
159    if (obj["bibtexJournal"] && obj["bibtexJournal"] != "")
160      spanText += obj["bibtexJournal"] + " ";
161    else spanText += "[journal unknown], ";
162
163    if (
164      obj["bibtexVolume"] &&
165      obj["bibtexVolume"] != "" &&
166      obj["bibtexVolume"] != 0
167    )
168      spanText += "vol. " + obj["bibtexVolume"] + ", ";
169
170    if (obj["bibtexNumber"] && obj["bibtexNumber"] != "")
171      spanText += "n. " + obj["bibtexNumber"] + ", ";
172
173    if (obj["bibtexDOI"] && obj["bibtexDOI"] != "")
174      spanText += "DOI " + obj["bibtexDOI"] + " ";
175
176    const spanElement = iidHTML("span", spanText, {}, {});
177    li.appendChild(spanElement);
178
179    if (spanText.length > 0)
180      li.appendChild(iidHTML("br", ""));
181
182    const year = iidHTML("span", "", {}, {});
183    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
184    const publicationType = obj["publicationType"];
185    const bibtexDate = obj["bibtexDate"];
186    if (bibtexDate && contextMapping[publicationType]) {
187      const publicationList = obj[contextMapping[publicationType]];
188
189      if (!publicationList || !publicationList.includes(bibtexDate)) {
190        year.textContent = " " + bibtexDate;
191        li.appendChild(year);
192      }
193    } else if (bibtexDate) {
194      year.textContent = " " + bibtexDate;
195      li.appendChild(year);
196    }
197
198    fragment.appendChild(li);
199  });
200}
201
202// Function that creates a list of publications according to tag
203function jsfilter_OthersInfo(fragment, tempArray) {
204  tempArray.forEach((obj) => {
205    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
206    li.id = obj["bibtexTitle"];
207
208 //   const strong = iidHTML("strong", obj["bibtexTitle"]);
209    const strong = jsfilter_createTitle(obj);
210    li.appendChild(strong);
211    li.appendChild(iidHTML("br", ""));
212
213    jsFilter_createPublicationAuthors(obj, li);
214
215    li.appendChild(iidHTML("br", ""));
216
217    var spanText = "";
218    if (obj["bibtexHowPublished"] && obj["bibtexHowPublished"] != "")
219      spanText += obj["bibtexNumber"] + ", ";
220
221    if (obj["doi"] && obj["doi"] != "") spanText += "DOI " + obj["doi"] + " ";
222
223    const spanElement = iidHTML("span", spanText, {}, {});
224    li.appendChild(spanElement);
225
226    if (spanText.length > 0)
227      li.appendChild(iidHTML("br", ""));
228
229    if (obj["videoURL"] && obj["videoURL"] != "") {
230      const linkElement = iidHTML( "a", "Video Link", {}, {}, ["filteringHyperlink"]);
231      linkElement.href = obj["videoURL"];
232      linkElement.target = "_blank";
233      li.appendChild(linkElement);
234      li.appendChild(iidHTML("br", ""));
235    }
236
237    if (obj["supplementaryURL"] && obj["supplementaryURL"] != "") {
238      const linkElement = iidHTML( "a", "Other Link", {}, {}, ["filteringHyperlink"]);
239      linkElement.href = obj["supplementaryURL"];
240      linkElement.target = "_blank";
241      li.appendChild(linkElement);
242      li.appendChild(iidHTML("br", ""));
243    }
244
245    const year = iidHTML("span", "", {}, {});
246    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
247    const publicationType = obj["publicationType"];
248    const bibtexDate = obj["bibtexDate"];
249    if (bibtexDate && contextMapping[publicationType]) {
250      const publicationList = obj[contextMapping[publicationType]];
251
252      if (!publicationList || !publicationList.includes(bibtexDate)) {
253        year.textContent = " " + bibtexDate;
254        li.appendChild(year);
255      }
256    } else if (bibtexDate) {
257      year.textContent = " " + bibtexDate;
258      li.appendChild(year);
259    }
260
261    fragment.appendChild(li);
262  });
263}
264
265// Function that creates a list of publications according to tag
266function jsfilter_TechnicalReportInfo(fragment, tempArray) {
267  tempArray.forEach((obj) => {
268    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
269    li.id = obj["bibtexTitle"];
270
271 //   const strong = iidHTML("strong", obj["bibtexTitle"]);
272    const strong = jsfilter_createTitle(obj);
273    li.appendChild(strong);
274    li.appendChild(iidHTML("br", ""));
275
276    jsFilter_createPublicationAuthors(obj, li);
277
278    li.appendChild(iidHTML("br", ""));
279
280    var spanText = "";
281    if (
282      obj["bibtexNumber"] &&
283      obj["bibtexNumber"] != "" &&
284      obj["bibtexNumber"] != 0
285    )
286      spanText += "n." + obj["bibtexNumber"] + " ";
287
288    const spanElement = iidHTML("span", spanText, {}, {});
289    li.appendChild(spanElement);
290
291    if (spanText.length > 0)
292      li.appendChild(iidHTML("br", ""));
293
294    const year = iidHTML("span", "", {}, {});
295    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
296    const publicationType = obj["publicationType"];
297    const bibtexDate = obj["bibtexDate"];
298    if (bibtexDate && contextMapping[publicationType]) {
299      const publicationList = obj[contextMapping[publicationType]];
300
301      if (!publicationList || !publicationList.includes(bibtexDate)) {
302        year.textContent = " " + bibtexDate;
303        li.appendChild(year);
304      }
305    } else if (bibtexDate) {
306      year.textContent = " " + bibtexDate;
307      li.appendChild(year);
308    }
309
310    fragment.appendChild(li);
311  });
312}
313
314// Function that creates a list of publications according to tag
315function jsfilter_ThesisInfo(fragment, tempArray) {
316  tempArray.forEach((obj) => {
317    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
318    li.id = obj["bibtexTitle"];
319
320 //   const strong = iidHTML("strong", obj["bibtexTitle"]);
321    const strong = jsfilter_createTitle(obj);
322    li.appendChild(strong);
323    li.appendChild(iidHTML("br", ""));
324
325    jsFilter_createPublicationAuthors(obj, li);
326
327    li.appendChild(iidHTML("br", ""));
328
329    var spanText = "";
330    if (obj["bibtexAddress"] && obj["bibtexAddress"] != "")
331      spanText += obj["bibtexAddress"] + ", ";
332
333    if (obj["thesisType"] && obj["thesisType"] != "")
334      spanText += obj["thesisType"] + " ";
335
336    const spanElement = iidHTML("span", spanText, {}, {});
337    li.appendChild(spanElement);
338
339    if (spanText.length > 0)
340      li.appendChild(iidHTML("br", ""));
341
342    const year = iidHTML("span", "", {}, {});
343    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
344    const publicationType = obj["publicationType"];
345    const bibtexDate = obj["bibtexDate"];
346    if (bibtexDate && contextMapping[publicationType]) {
347      const publicationList = obj[contextMapping[publicationType]];
348
349      if (!publicationList || !publicationList.includes(bibtexDate)) {
350        year.textContent = " " + bibtexDate;
351        li.appendChild(year);
352      }
353    } else if (bibtexDate) {
354      year.textContent = " " + bibtexDate;
355      li.appendChild(year);
356    }
357
358    fragment.appendChild(li);
359  });
360}
361
362// Function that creates a list of publications according to tag
363function jsfilter_ProceedingsInfo(fragment, tempArray) {
364  tempArray.forEach((obj) => {
365    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
366    li.id = obj["bibtexTitle"];
367
368	   //   const strong = iidHTML("strong", obj["bibtexTitle"]);
369    const strong = jsfilter_createTitle(obj);
370    li.appendChild(strong);
371    li.appendChild(iidHTML("br", ""));
372
373    jsFilter_createPublicationAuthors(obj, li);
374
375    li.appendChild(iidHTML("br", ""));
376
377    var spanText = "";
378    if (obj["bibtexSeries"] && obj["bibtexSeries"] != "")
379      spanText += obj["bibtexSeries"] + ", ";
380
381    if (
382      obj["bibtexNumber"] &&
383      obj["bibtexNumber"] != "" &&
384      obj["bibtexNumber"] != 0
385    )
386      spanText += "n. " + obj["bibtexNumber"] + ", ";
387
388    if (obj["bibtexPublisher"] && obj["bibtexPublisher"] != "")
389      spanText += obj["bibtexPublisher"] + ", ";
390
391    if (obj["isbn"] && obj["isbn"] != "")
392      spanText += "ISBN " + obj["isbn"] + ", ";
393
394    if (obj["bibtexOrganization"] && obj["bibtexOrganization"] != "")
395      spanText += obj["bibtexOrganization"] + ", ";
396
397    if (obj["bibtexAddress"] && obj["bibtexAddress"] != "")
398      spanText += obj["bibtexAddress"] + " ";
399
400    const spanElement = iidHTML("span", spanText, {}, {});
401    li.appendChild(spanElement);
402
403    if (spanText.length > 0)
404      li.appendChild(iidHTML("br", ""));
405
406    const year = iidHTML("span", "", {}, {});
407    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
408    const publicationType = obj["publicationType"];
409    const bibtexDate = obj["bibtexDate"];
410    if (bibtexDate && contextMapping[publicationType]) {
411      const publicationList = obj[contextMapping[publicationType]];
412
413      if (!publicationList || !publicationList.includes(bibtexDate)) {
414        year.textContent = " " + bibtexDate;
415        li.appendChild(year);
416      }
417    } else if (bibtexDate) {
418      year.textContent = " " + bibtexDate;
419      li.appendChild(year);
420    }
421
422    fragment.appendChild(li);
423  });
424}
425
426// Function that creates a list of publications according to tag
427function jsfilter_InBookInfo(fragment, tempArray) {
428  tempArray.forEach((obj) => {
429    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
430    li.id = obj["bibtexTitle"];
431
432	   //   const strong = iidHTML("strong", obj["bibtexTitle"]);
433    const strong = jsfilter_createTitle(obj);
434    li.appendChild(strong);
435    li.appendChild(iidHTML("br", ""));
436
437    jsFilter_createPublicationAuthors(obj, li);
438
439    li.appendChild(iidHTML("br", ""));
440
441    var spanText = "";
442    if (obj["chapterTitle"] && obj["chapterTitle"] != "")
443      spanText += obj["chapterTitle"] + ", ";
444
445    if (obj["bibtexType"] && obj["bibtexType"] != "")
446      spanText += obj["bibtexType"] + ", ";
447
448    if (obj["bibtexSeries"] && obj["bibtexSeries"] != "")
449      spanText += obj["bibtexSeries"] + ", ";
450
451    if (
452      obj["bibtexEdition"] &&
453      obj["bibtexEdition"] != "" &&
454      obj["bibtexEdition"] != 0
455    )
456      spanText += "ed. " + obj["bibtexEdition"] + ", ";
457
458    if (
459      obj["bibtexNumber"] &&
460      obj["bibtexNumber"] != "" &&
461      obj["bibtexNumber"] != 0
462    )
463      spanText += "n. " + obj["bibtexNumber"] + ", ";
464
465    if (obj["bibtexPublisher"] && obj["bibtexPublisher"] != "")
466      spanText += obj["bibtexPublisher"] + ", ";
467
468    if (obj["bibtexAddress"] && obj["bibtexAddress"] != "")
469      spanText += obj["bibtexAddress"] + " ";
470
471    const spanElement = iidHTML("span", spanText, {}, {});
472    li.appendChild(spanElement);
473
474    if (spanText.length > 0)
475      li.appendChild(iidHTML("br", ""));
476
477    const year = iidHTML("span", "", {}, {});
478    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
479    const publicationType = obj["publicationType"];
480    const bibtexDate = obj["bibtexDate"];
481    if (bibtexDate && contextMapping[publicationType]) {
482      const publicationList = obj[contextMapping[publicationType]];
483
484      if (!publicationList || !publicationList.includes(bibtexDate)) {
485        year.textContent = " " + bibtexDate;
486        li.appendChild(year);
487      }
488    } else if (bibtexDate) {
489      year.textContent = " " + bibtexDate;
490      li.appendChild(year);
491    }
492
493    fragment.appendChild(li);
494  });
495}
496
497// Function that creates a list of publications according to tag
498function jsfilter_BookInfo(fragment, tempArray) {
499  tempArray.forEach((obj) => {
500    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
501    li.id = obj["bibtexTitle"];
502
503	   //   const strong = iidHTML("strong", obj["bibtexTitle"]);
504    const strong = jsfilter_createTitle(obj);
505    li.appendChild(strong);
506    li.appendChild(iidHTML("br", ""));
507
508    jsFilter_createPublicationAuthors(obj, li);
509
510    li.appendChild(iidHTML("br", ""));
511
512    var spanText = "";
513    if (obj["bibtexSeries"] && obj["bibtexSeries"] != "")
514      spanText += obj["bibtexSeries"] + ", ";
515    if (
516      obj["bibtexNumber"] &&
517      obj["bibtexNumber"] != "" &&
518      obj["bibtexNumber"] != 0
519    )
520      spanText += "n. " + obj["bibtexNumber"] + ", ";
521    if (obj["bibtexEdition"] && obj["bibtexEdition"] != "")
522      spanText += "ed. " + obj["bibtexEdition"] + " ";
523    if (obj["isbn"] && obj["isbn"] != "")
524      spanText += "ISBN " + obj["isbn"] + ", ";
525    if (obj["bibtexPublisher"] && obj["bibtexPublisher"] != "")
526      spanText += obj["bibtexPublisher"] + ", ";
527    if (obj["bibtexAddress"] && obj["bibtexAddress"] != "")
528      spanText += obj["bibtexAddress"] + " ";
529
530    const spanElement = iidHTML("span", spanText, {}, {});
531    li.appendChild(spanElement);
532
533    if (spanText.length > 0)
534      li.appendChild(iidHTML("br", ""));
535
536    if (obj["bibtexUrl"] && obj["bibtexUrl"] != "") {
537      const linkElement = iidHTML("a", "Link", {}, {}, [ "filteringHyperlink", ]);
538      linkElement.href = obj["bibtexUrl"];
539      linkElement.target = "_blank";
540      li.appendChild(linkElement);
541      li.appendChild(iidHTML("br", ""));
542    }
543
544    const year = iidHTML("span", "", {}, {});
545    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
546    const publicationType = obj["publicationType"];
547    const bibtexDate = obj["bibtexDate"];
548    if (bibtexDate && contextMapping[publicationType]) {
549      const publicationList = obj[contextMapping[publicationType]];
550
551      if (!publicationList || !publicationList.includes(bibtexDate)) {
552        year.textContent = " " + bibtexDate;
553        li.appendChild(year);
554      }
555    } else if (bibtexDate) {
556      year.textContent = " " + bibtexDate;
557      li.appendChild(year);
558    }
559
560    fragment.appendChild(li);
561  });
562}
563
564// Function that creates a list of publications using a default method
565function jsFilter_defaultInfo(fragment, tempArray) {
566  tempArray.forEach((obj) => {
567    const li = iidHTML("li", "", {}, {}, [ "publicationItem", ]);
568    li.id = obj["bibtexTitle"];
569
570	   //   const strong = iidHTML("strong", obj["bibtexTitle"]);
571    const strong = jsfilter_createTitle(obj);
572    li.appendChild(strong);
573    li.appendChild(iidHTML("br", ""));
574
575    jsFilter_createPublicationAuthors(obj, li);
576
577    li.appendChild(iidHTML("br", ""));
578
579    const a = iidHTML("span", "", {}, {});
580    if (
581      jsFilter_listMapping[jsFilter_currentContext][obj["publicationType"]] != null
582    ) {
583      if (
584        obj[ jsFilter_listMapping[jsFilter_currentContext][obj["publicationType"]] ] != null &&
585        obj[ jsFilter_listMapping[jsFilter_currentContext][obj["publicationType"]] ] != ""
586      ) {
587        a.textContent = obj[ jsFilter_listMapping[jsFilter_currentContext][ obj["publicationType"] ] ];
588        li.appendChild(a);
589      }
590    }
591
592    const vol = iidHTML("span", "", {}, {});
593    if (obj["bibtexVolume"] != 0) {
594      vol.textContent = " Vol " + obj["bibtexVolume"];
595      li.appendChild(vol);
596    }
597
598    const year = iidHTML("span", "", {}, {});
599    const contextMapping = jsFilter_listMapping[jsFilter_currentContext];
600    const publicationType = obj["publicationType"];
601    const bibtexDate = obj["bibtexDate"];
602    if (bibtexDate && contextMapping[publicationType]) {
603      const publicationList = obj[contextMapping[publicationType]];
604
605      if (!publicationList || !publicationList.includes(bibtexDate)) {
606        year.textContent = " " + bibtexDate;
607        li.appendChild(year);
608      }
609    } else if (bibtexDate) {
610      year.textContent = " " + bibtexDate;
611      li.appendChild(year);
612    }
613
614    const DOI = iidHTML("span", "", {}, {});
615    if (obj["bibtexDOI"] != null) {
616      DOI.textContent = " " + obj["bibtexDOI"];
617      li.appendChild(DOI);
618    }
619    fragment.appendChild(li);
620  });
621}
622
623// Returns true when the year slider should request additional periods from the
624// server rather than only filtering already-loaded data. Only the global
625// "all publications" view loads a limited period; the author/OU views load
626// their full (bounded) list up front, so they keep the plain filtering slider.
627function jsFilter_publicationsPeriodMode() {
628  return (
629    jsFilter_periodFetchEnabled === true &&
630    jsFilter_currentContext === "Publications" &&
631    (jsFilter_metaFilters["bibtexRankedAuthorsIdName"] == null ||
632      jsFilter_metaFilters["bibtexRankedAuthorsIdName"] === "") &&
633    (jsFilter_metaFilters["organizationalUnitIdAcronymName"] == null ||
634      jsFilter_metaFilters["organizationalUnitIdAcronymName"] === "")
635  );
636}
637
638// Fetches publications for [startYear, endYear]. In the WordPress plugin this
639// goes through the admin-ajax proxy; when run locally (index.html) it falls
640// back to the direct intranet API used by the other local-testing helpers.
641async function jsFilter_fetchPublicationsByPeriod(startYear, endYear) {
642  if (typeof jsFilter_ajaxUrl !== "undefined" && jsFilter_ajaxUrl) {
643    const url =
644      jsFilter_ajaxUrl +
645      "?action=iidc_publications_by_period&startYear=" +
646      encodeURIComponent(startYear) +
647      "&endYear=" +
648      encodeURIComponent(endYear);
649    const response = await fetch(url);
650    if (!response.ok)
651      throw new Error(
652        "Failed to fetch publications period. HTTP status: " + response.status
653      );
654    return await response.json();
655  }
656
657  const apiURL =
658    "https://iid-intranet.inesc-id.pt/api/publications/listbyperiod?startYear=" +
659    startYear +
660    "&endYear=" +
661    endYear;
662  const retrievedData = await jsFilter_fetchData(phpFile, apiURL);
663  return retrievedData && retrievedData.results ? retrievedData.results : [];
664}
665
666// Loads publications between newStartYear and the year currently loaded,
667// merges them into the dataset, and rebuilds the drawers so the listing covers
668// the wider period. The caller (the year slider) re-applies the active filters
669// afterwards. Returns true when new data was merged in.
670async function jsFilter_expandPublicationsPeriod(newStartYear) {
671  if (!jsFilter_publicationsPeriodMode()) return false;
672  if (jsFilter_loadedStartYear == null || newStartYear >= jsFilter_loadedStartYear)
673    return false;
674
675  const fetchStart = newStartYear;
676  const fetchEnd = jsFilter_loadedStartYear - 1;
677
678  let newData;
679  try {
680    newData = await jsFilter_fetchPublicationsByPeriod(fetchStart, fetchEnd);
681  } catch (error) {
682    console.error("Error fetching publications period:", error);
683    return false;
684  }
685  if (!Array.isArray(newData)) newData = [];
686
687  // Match the shape the template gives the initial payload, then turn the date
688  // into the integer year the slider and filters expect.
689  newData.forEach((element) => {
690    element["ranked"] = "";
691  });
692  newData = jsFilter_stringDataToInt(
693    newData,
694    jsFilter_orderMapping[jsFilter_currentContext]["Year"]
695  );
696
697  jsFilter_originalData = jsFilter_removeDuplicatesObjects(
698    jsFilter_originalData.concat(newData)
699  );
700  jsFilter_loadedStartYear = newStartYear;
701
702  // Rebuild the drawers so publication types only present in the newly loaded
703  // years get an entry; the caller then re-applies the current filters.
704  jsFilter_createList(jsFilter_originalData);
705  return true;
706}
707
708// These functions are used for local testing using the index.html, but not by the PHP plugin
709
710function jsFilter_getPublicationsByAuthor(authorID) {
711  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/publications/listbyauthorid?authorId=" + authorID;
712  jsFilter_fetchData(phpFile, dynamicApiURL)
713    .then(async (retrievedData) => {
714      if (retrievedData.results != null)
715        retrievedData.results.forEach((element) => {
716          element["organizationalUnitIdAcronymName"] = [];
717        });
718      const author = await jsFilter_getSingleAuthor(authorID);
719      var rankedNames = [];
720      await Promise.all(
721        author["rankedPublicationsId"].map(async (element) => {
722          const rankedPublication = await jsFilter_getPublicationsByID(element);
723          rankedNames.push(rankedPublication["bibtexTitle"]);
724        })
725      );
726      retrievedData.results.forEach((element) => {
727        element["ranked"] = "";
728        if (rankedNames.includes(element["bibtexTitle"]))
729          element["ranked"] = "flagRanked";
730      });
731      jsFilter_initList(retrievedData.results, author);
732    })
733    .catch((error) => { console.error("Error:", error); });
734}
735
736function jsFilter_getPublicationsByOUID(ouID) {
737  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/publications/listbyouid?ouId=" + ouID;
738  jsFilter_fetchData(phpFile, dynamicApiURL)
739    .then((retrievedData) => {
740      retrievedData.results.forEach((element) => { element["ranked"] = ""; });
741      jsFilter_initList(retrievedData.results);
742    })
743    .catch((error) => { console.error("Error:", error); });
744}
745
746function jsFilter_getPublications() {
747  const dynamicApiURL =
748    "https://iid-intranet.inesc-id.pt/api/publications/list";
749  jsFilter_fetchData(phpFile, dynamicApiURL)
750    .then((retrievedData) => {
751      retrievedData.results.forEach((element) => { element["ranked"] = ""; });
752      jsFilter_initList(retrievedData.results);
753    })
754    .catch((error) => { console.error("Error:", error); });
755}
756
757function jsFilter_getPublicationsByID(ID) {
758  const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/publications/getbyid?id=" + ID;
759  return jsFilter_fetchData(phpFile, dynamicApiURL)
760    .then((retrievedData) => { return retrievedData.results; })
761    .catch((error) => { console.error("Error:", error); });
762}

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.