1// Function that creates a list of people in the div element based on the data items in tempArray 2function jsFilter_createListPeople(div, tempArray) { 3 div.innerHTML = ""; 4 const fragment = document.createDocumentFragment(); 5 6 tempArray.forEach((obj) => { 7 const card = jsFilter_createCard(obj); 8 fragment.appendChild(card); 9 }); 10 11 div.appendChild(fragment); 12} 13 14function iid_removePrefix(str, prefix) { 15 return str.startsWith(prefix) ? str.slice(prefix.length) : str; 16} 17 18// Function that creates a card based on the person in the obj variable 19function jsFilter_createCard(obj) { 20 const author = iidHTML("a", obj["publicName"], {}, {}, [ "filteringHyperlink", ]); 21 author.href = jsFilter_urlREF + "member/" + obj["id"] + "/publications"; 22 author.target = "_blank"; 23 24 if (obj["professionalCategory"]["name"] == "Não Especificado") 25 obj["professionalCategory"]["name"] = "INESC-ID"; 26 27 const role = iidHTML( "span", obj["professionalCategory"]["name"] + " | ", { "font-size": "small", "line-height": "0.8em" }, {}); 28 29 obj["activeOUsId"].forEach((id, index) => { 30 if (jsFilter_people_ous[id] != null) { 31 var currentText = iid_removePrefix(jsFilter_people_ous[id], "SA-"); 32 const area = iidHTML("a", currentText + " ", {}, {}, [ "filteringHyperlink", ]); 33 if (jsFilter_peopleScientificAreas[id] != null) { 34 area.href = jsFilter_urlREF + "ou/" + id + "/publications/"; 35 } else { 36 area.href = jsFilter_urlREF; 37 } 38 area.target = "_blank"; 39 role.appendChild(area); 40 } 41 }); 42 43 const divAuthor = iidHTML("div", "", {}, {}, [ "person-card-topJS", ]); 44 const divAuthorLeft = iidHTML("div", "", {}, {}, [ "person-card-imgJS", ]); 45 const divAuthorRight = iidHTML("div", "", {}, {}, [ "person-detailsJS", ]); 46 divAuthor.appendChild(divAuthorLeft); 47 divAuthor.appendChild(divAuthorRight); 48 49 const img = iidHTML( "img", "", { margin: "0 0 0 0", }, {}, ["profileImage"]); 50 if (obj["photo"] != "" && obj["photo"] != null) img.src = obj["photo"]; 51 else 52 img.src = "https://www.inesc-id.pt/wp-content/plugins/inesc-pages/images/account-1.svg"; 53 54 const telephone = iidHTML( "a", obj["telephoneNumber"], {}, {}, ["filteringHyperlink"]); 55 telephone.href = "tel:+" + obj["telephoneNumber"]; 56 const telephoneIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-phone"]); 57 58 const room = iidHTML("span", obj["room"], {}, {}, [ "filteringHyperlink", ]); 59 const roomIcon = iidHTML( "i", "", { "margin-right": "5px", "margin-left": "5px" }, {}, ["fa", "fa-fw", "fa-building-o"]); 60 61 const emailAddresses = iidHTML( "a", obj["institutionalEmailAddress"], {}, {}, ["filteringHyperlink"]); 62 emailAddresses.href = "mailto:" + obj["institutionalEmailAddress"]; 63 const emailIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-envelope-o"]); 64 65 const website = iidHTML("a", obj["website"], {}, {}, [ "filteringHyperlink", ]); 66 website.href = obj["website"]; 67 const websiteIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-globe"]); 68 69 divAuthorLeft.appendChild(img); 70 if (obj["cienciaId"] != "" && obj["cienciaId"] != null) { 71 const tempDiv = iidHTML("div", "", {}, {}, ["tempDiv"]); 72 73 let cienciaPattern = /\w{4}-\w{4}-\w{4}/; 74 if (obj["cienciaId"] != null && obj["cienciaId"] != "") { 75 obj["cienciaId"] = obj["cienciaId"].replace(/\s/g, ""); 76 if (obj["cienciaId"].match(cienciaPattern) != null) 77 obj["cienciaId"] = obj["cienciaId"].match(cienciaPattern)[0]; 78 } 79 const ciencia = iidHTML("a", obj["cienciaId"], {}, {}, [ "filteringHyperlink", ]); 80 ciencia.href = "https://www.cienciavitae.pt/" + obj["cienciaId"]; 81 ciencia.target = "_blank"; 82 const cienciaIcon = iidHTML( "i", "", { "margin-right": "5px", }, {}, ["fa", "fa-fw", "fa-graduation-cap"]); 83 84 tempDiv.appendChild(cienciaIcon); 85 tempDiv.appendChild(ciencia); 86 divAuthorRight.appendChild(tempDiv); 87 } 88 if (obj["orcid"] != "" && obj["orcid"] != null) { 89 const tempDiv = iidHTML("div", "", {}, {}, ["tempDiv"]); 90 91 let orcidPattern = /\w{4}-\w{4}-\w{4}-\w{4}/; 92 if (obj["orcid"] != null && obj["orcid"] != "") { 93 obj["orcid"] = obj["orcid"].replace(/\s/g, ""); 94 if (obj["orcid"].match(orcidPattern) != null) 95 obj["orcid"] = obj["orcid"].match(orcidPattern)[0]; 96 } 97 const orcid = iidHTML("a", obj["orcid"], {}, {}, [ "filteringHyperlink", ]); 98 orcid.href = "https://orcid.org/" + obj["orcid"]; 99 orcid.target = "_blank"; 100 const orcidIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa-brands", "fa-fw", "fa-orcid"]); 101 102 tempDiv.appendChild(orcidIcon); 103 tempDiv.appendChild(orcid); 104 divAuthorRight.appendChild(tempDiv); 105 } 106 if (obj["googleScholarId"] != "" && obj["googleScholarId"] != null) { 107 const tempDiv = iidHTML("div", "", {}, {}, ["tempDiv"]); 108 109 let scholarIDPattern = /\b[a-zA-Z0-9]{12}\b/; 110 if (obj["googleScholarId"] != null && obj["googleScholarId"] != "") { 111 obj["googleScholarId"] = obj["googleScholarId"].replace(/\s/g, ""); 112 if (obj["googleScholarId"].match(scholarIDPattern) != null) 113 obj["googleScholarId"] = obj["googleScholarId"].match(scholarIDPattern)[0]; 114 } 115 const scholarID = iidHTML( "a", obj["googleScholarId"], {}, {}, ["filteringHyperlink"]); 116 scholarID.href = "https://scholar.google.com/citations?user=" + obj["googleScholarId"]; 117 scholarID.target = "_blank"; 118 const scholarIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-google"]); 119 120 tempDiv.appendChild(scholarIcon); 121 tempDiv.appendChild(scholarID); 122 divAuthorRight.appendChild(tempDiv); 123 } 124 if (obj["researcherId"] != "" && obj["researcherId"] != null) { 125 const tempDiv = iidHTML("div", "", {}, {}, ["tempDiv"]); 126 127 let webOfSciencePattern = /\b[a-zA-Z]-[0-9]{4}-[0-9]{4}\b/; 128 if (obj["researcherId"] != null && obj["researcherId"] != "") { 129 obj["researcherId"] = obj["researcherId"].replace(/\s/g, ""); 130 if (obj["researcherId"].match(webOfSciencePattern) != null) 131 obj["researcherId"] = obj["researcherId"].match(webOfSciencePattern)[0]; 132 } 133 const webOfScience = iidHTML( "a", obj["researcherId"], {}, {}, ["filteringHyperlink"]); 134 webOfScience.href = "https://www.webofscience.com/wos/author/record/" + obj["researcherId"]; 135 webOfScience.target = "_blank"; 136 const webOfScienceIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-flask"]); 137 138 tempDiv.appendChild(webOfScienceIcon); 139 tempDiv.appendChild(webOfScience); 140 divAuthorRight.appendChild(tempDiv); 141 } 142 if (obj["scopusId"] != "" && obj["scopusId"] != null) { 143 const tempDiv = iidHTML("div", "", {}, {}, ["tempDiv"]); 144 const scopus = iidHTML("a", obj["scopusId"], {}, {}, [ "filteringHyperlink", ]); 145 scopus.href = "https://www.scopus.com/authid/detail.uri?authorId=" + obj["scopusId"]; 146 scopus.target = "_blank"; 147 const scopusIcon = iidHTML( "i", "", { "margin-right": "5px" }, {}, ["fa", "fa-fw", "fa-s"]); 148 tempDiv.appendChild(scopusIcon); 149 tempDiv.appendChild(scopus); 150 divAuthorRight.appendChild(tempDiv); 151 } 152 const bottomInfo = iidHTML("div", "", {}, {}, [ 153 "person-card-footerJS", 154 ]); 155 if (obj["telephoneNumber"] != "" && obj["telephoneNumber"] != null) { 156 const tempDiv = iidHTML("span"); 157 tempDiv.appendChild(telephoneIcon); 158 tempDiv.appendChild(telephone); 159 if (obj["room"] != "" && obj["room"] != null) { 160 room.textContent = obj["room"]["name"]; 161 tempDiv.appendChild(roomIcon); 162 tempDiv.appendChild(room); 163 } 164 bottomInfo.appendChild(tempDiv); 165 } 166 if ( 167 obj["institutionalEmailAddress"] != "" && 168 obj["institutionalEmailAddress"] != null 169 ) { 170 const tempDiv = iidHTML("span"); 171 tempDiv.appendChild(emailIcon); 172 tempDiv.appendChild(emailAddresses); 173 bottomInfo.appendChild(tempDiv); 174 } 175 if (obj["website"] != "" && obj["website"] != null) { 176 const tempDiv = iidHTML("span"); 177 tempDiv.appendChild(websiteIcon); 178 tempDiv.appendChild(website); 179 bottomInfo.appendChild(tempDiv); 180 } 181 const card = iidHTML("div", "", {}, {}, ["person-cardJS"]); 182 const cardB = iidHTML("b"); 183 cardB.appendChild(author); 184 role.appendChild(divAuthor); 185 role.appendChild(bottomInfo); 186 card.appendChild(cardB); 187 card.appendChild(role); 188 return card; 189} 190 191// Function that creates the correct roles from the intranet
192function jsFilter_calculateRoles(data) { 193 data.forEach((element) => { 194 var newRoles = []; 195 element["roleTypesId"] = jsFilter_removeDuplicatesArray(element["roleTypesId"]); 196 element["roleTypesId"].forEach((role) => { 197 if (jsFilter_researchers[role] != null) { 198 if (jsFilter_researchers[role] == "Early Stage Researcher" || 199 jsFilter_researchers[role] == "Doctoral Student" || 200 jsFilter_researchers[role] == "Master's Student" || 201 jsFilter_researchers[role] == "Graduation Student" || 202 jsFilter_researchers[role] == "Intern") { 203 element["activeRoles"].forEach((otherRole) => { 204 if (otherRole["name"] == "Doctoral Student") { newRoles.push({ id: "jsFilter_doctoralStudent", }); } 205 else if (otherRole["name"] == "Master's Student") { newRoles.push({ id: "jsFilter_otherStudent", }); } 206 else if (otherRole["name"] == "Graduation Student") { newRoles.push({ id: "jsFilter_otherStudent", }); } 207 else if (otherRole["name"] == "Intern") { newRoles.push({ id: "jsFilter_otherStudent", }); } 208 else if (otherRole["name"].toLowerCase().includes("student")) { 209 newRoles.push({ 210 id: "jsFilter_otherStudent", 211 }); 212 } 213 }); 214 } else { 215 if (jsFilter_researchers[role] == "External Collaborator") { 216 newRoles.push({ id: "11f51963-0d45-41da-9e6d-e6c563fd8f75", }); 217 } else { 218 if (element["isIntegratedResearcher"]) { 219 newRoles.push({ id: "jsFilter_integratedResearcher", }); 220 } else { 221 newRoles.push({ id: "jsFilter_affiliatedResearcher", }); 222 } 223 } 224 } 225 } else if (jsFilter_staff[role] != null) { 226 newRoles.push({ id: role, }); 227 } 228 }); 229 element["activeRoles"].forEach((role) => { 230 if (jsFilter_researchers[role.id] != null) { 231 if (jsFilter_researchers[role.id] == "Early Stage Researcher" || jsFilter_researchers[role.id] == "Doctoral Student") { 232 element["activeRoles"].forEach((otherRole) => { 233 if (otherRole["name"] == "Doctoral Student") { 234 newRoles.push({ id: "jsFilter_doctoralStudent", }); 235 } else if (otherRole["name"].toLowerCase().includes("student")) { 236 newRoles.push({ id: "jsFilter_otherStudent", }); 237 } 238 }); 239 } else { 240 if (jsFilter_researchers[role.id] == "External Collaborator") { 241 newRoles.push({ id: "11f51963-0d45-41da-9e6d-e6c563fd8f75", }); 242 } else { 243 if (element["isIntegratedResearcher"]) { 244 newRoles.push({ id: "jsFilter_integratedResearcher", }); 245 } else { 246 newRoles.push({ id: "jsFilter_affiliatedResearcher", }); 247 } 248 } 249 } 250 } else if (jsFilter_staff[role.id] != null) { 251 newRoles.push({ id: role.id, }); 252 } 253 }); 254 element["newRoleTypesId"] = newRoles; 255 }); 256} 257 258// These functions are used for local testing using the index.html, but not by the PHP plugin 259 260function jsFilter_getPeople() { 261 jsFilter_currentContext = "People"; 262 const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/persons/listbystatus?status=Active"; 263 jsFilter_fetchData(phpFile, dynamicApiURL) 264 .then((retrievedData) => { jsFilter_initList(retrievedData.results); }) 265 .catch((error) => { console.error("Error:", error); }); 266} 267 268async function jsFilter_getSingleAuthor(authorID) { 269 const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/persons/getbyid?id=" + authorID; 270 return jsFilter_fetchData(phpFile, dynamicApiURL) 271 .then((retrievedData) => { 272 var tempArraySA = []; 273 retrievedData.results["activeOUsId"].forEach((element2) => { 274 if (jsFilter_peopleScientificAreas[element2] != null) 275 tempArraySA.push({ item1: element2 }); 276 }); 277 retrievedData.results["organizationalUnitIdAcronymName"] = tempArraySA; 278 return retrievedData.results; 279 }) 280 .catch((error) => { console.error("Error:", error); }); 281} 282 283function jsFilter_getPeopleByOUID(ouID) { 284 const dynamicApiURL = "https://iid-intranet.inesc-id.pt/api/persons/list"; 285 jsFilter_fetchData(phpFile, dynamicApiURL) 286 .then((retrievedData) => { 287 var tempData = retrievedData.results.filter(function (obj) { 288 return obj["activeOUsId"].includes(ouID); 289 }); 290 jsFilter_initList(tempData); 291 }) 292 .catch((error) => { console.error("Error:", error); }); 293}
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.