1/* 2 BreadCrumbs.js 3 Errol Sayre 4 [email protected] 5 6 Provided by the Office of Research and Sponsored Programs 7 The University of Mississippi 8 9 This script is free to be used but provides no warranty of function or quality. 10*/ 11 12// BreadCrumb configuration 13// set up the site prefix 14var sitePrefix = "/ro/"; 15 // Please note that we don't use the whole prefix, just the important 16 // part that we need for the server so as to make this script easy for 17 // us to migrate between testing and live server. You can use whatever you 18 // like here. 19 20// set up the bread crumb separator text 21var breadCrumbSeparator = ""; 22 23// set up our list of crumb items 24 // The bread crumb items refer to items on your site that require special 25 // labels. You can specify a label specifically using the URI of the 26 // file/folder or generically for all occurences of a file/folder. 27var breadCrumbLabels = new Array(); 28// generic labels 29 30 31//despre 32breadCrumbLabels["misiune.php"] = "Misiune"; 33breadCrumbLabels["istoric.php"] = "Istoric"; 34breadCrumbLabels["identitate.php"] = "Identitate"; 35breadCrumbLabels["strategii_de_dezvoltare_si_asigurarea_calitatii.php"] = "Strategii de dezvoltare si asigurarea calitatii"; 36breadCrumbLabels["brosuri_de_prezentare.php"] = "Brosuri de prezentare"; 37breadCrumbLabels["tur_virtual.php"] = "Tur Virtual"; 38 39breadCrumbLabels["rectorat.php"] = "Rectorat"; 40breadCrumbLabels["consiliul_de_administratie.php"] = "Consiliul de Administratie"; 41breadCrumbLabels["secretariat_general.php"] = "Secretariat General"; 42breadCrumbLabels["dga.php"] = "DGA"; 43breadCrumbLabels["comisia_de_etica.php"] = "Comisia de etica"; 44breadCrumbLabels["infrastructura.php"] = "Infrastructura"; 45 46 47//structura 48breadCrumbLabels["facultati_si_departamente.php"] = "Facultati si departamente"; 49breadCrumbLabels["extensii.php"] = "Extensii"; 50breadCrumbLabels["unitati_administrative.php"] = "Unitati institutionale"; 51breadCrumbLabels["unitati_didactice_auxiliare.php"] = "Unitati didactice auxiliare"; 52breadCrumbLabels["centre_de_limbi_moderne.php"] = "Centre de limbi moderne"; 53breadCrumbLabels["centre_culturale_straine.php"] = "Centre culturale straine"; 54breadCrumbLabels["edituri.php"] = "Edituri"; 55breadCrumbLabels["reviste.php"] = "Reviste"; 56breadCrumbLabels["libraria_universitatii.php"] = "Libraria Universitatii"; 57breadCrumbLabels["gradina_botanica.php"] = "Gradina Botanica"; 58breadCrumbLabels["parcul_sportiv.php"] = "Parcul sportiv"; 59breadCrumbLabels["observatorul_astronomic.php"] = "Observatorul Astronomic"; 60breadCrumbLabels["centrul_arcalia.php"] = "Centrul Arcalia"; 61breadCrumbLabels["centrul_belis.php"] = "Centrul Belis"; 62breadCrumbLabels["complexul_baru_mare.php"] = "Complexul Baru-Mare"; 63breadCrumbLabels["complexul_de_natatie.php"] = "Complexul de Natatie"; 64 65//programe academice 66breadCrumbLabels["licenta.php"] = "Licenta"; 67breadCrumbLabels["master.php"] = "Master"; 68breadCrumbLabels["netraditional.php"] = "Ãnvatamânt netraditional"; 69breadCrumbLabels["formare_continua.php"] = "Programe postuniversitare de Formare Continua"; 70breadCrumbLabels["conversie_profesionala.php"] = "Programe de conversie profesionala a cadrelor didactice din invatamantul preuniversitar"; 71breadCrumbLabels["resurse.php"] = "Resurse"; 72 73//facilitati 74breadCrumbLabels["be.php"] = "Biblioteci electronice"; 75breadCrumbLabels["cdu.php"] = "Centrul de Dezvoltare Universitara"; 76breadCrumbLabels["cf.php"] = "Transfer tehnologic"; 77breadCrumbLabels["cmp.php"] = "Centrul de Management de Proiecte"; 78breadCrumbLabels["unitati.php"] = "Facilitati"; 79 80// specific labels 81breadCrumbLabels["/"] = ""; 82breadCrumbLabels["/ro/"] = ""; 83breadCrumbLabels["/ro/despre/"] = "Despre"; 84 85breadCrumbLabels["/ro/programe_academice/"] = "Programe academice"; 86breadCrumbLabels["/ro/structura/"] = "Structura"; 87breadCrumbLabels["/ro/facilitati/"] = "Facilitati"; 88breadCrumbLabels["/ro/studenti/"] = "Studenti"; 89breadCrumbLabels["/ro/publice/"] = "Informatii publice"; 90breadCrumbLabels["/ro/taxe/"] = "Taxe"; 91breadCrumbLabels["/ro/infoubb/"] = "Info UBB"; 92breadCrumbLabels["/ro/personalubb/"] = "Personal UBB"; 93 94//facultati 95breadCrumbLabels["facultati"] = "FacultÄÅ£i"; 96breadCrumbLabels["matematica_informatica"] = "Facultatea de Matematica Èi InformaticÄ"; 97breadCrumbLabels["fizica"] = "Facultatea de FizicÄ"; 98breadCrumbLabels["chimie_si_inginerie_chimica"] = "Facultatea de Chimie Åi Inginerie ChimicÄ"; 99breadCrumbLabels["biologie_si_geologie"] = "Facultatea de Biologie Åi Geologie"; 100breadCrumbLabels["geografie"] = "Facultatea de Geografie"; 101breadCrumbLabels["stiinta_si_ingineria_mediului"] = "Facultatea de ÅtiinÅ£a Åi Ingineria Mediului"; 102breadCrumbLabels["drept"] = "Facultatea de Drept"; 103breadCrumbLabels["psihologie_si_stiinte_ale_educatiei"] = "Facultatea de Psihologie Åi ÅtiinÅ£e ale EducaÅ£iei"; 104breadCrumbLabels["litere"] = "Facultatea de Litere"; 105breadCrumbLabels["istorie_si_filosofie"] = "Facultatea de Istorie Åi Filosofie";
106breadCrumbLabels["sociologie_si_asistenta_sociala"] = "Facultatea de Sociologie Åi AsistenÅ£Ä SocialÄ"; 107breadCrumbLabels["stiinte_economice_si_gestiunea_afacerilor"] = "Facultatea de ÅtiinÅ£e Economice Åi Gestiunea Afacerilor"; 108breadCrumbLabels["studii_europene"] = "Facultatea de Studii Europene"; 109breadCrumbLabels["business"] = "Facultatea de Business"; 110breadCrumbLabels["stiinte_politice_administrative_si_ale_comunicarii"] = "Facultatea de ÅtiinÅ£e Politice, Administrative Åi ale ComunicÄrii"; 111breadCrumbLabels["educatie_fizica_si_sport"] = "Facultatea de EducaÅ£ie FizicÄ Åi Sport"; 112breadCrumbLabels["teologie_ortodoxa"] = "Facultatea de Teologie OrtodoxÄ"; 113breadCrumbLabels["teologie_greco_catolica"] = "Facultatea de Teologie Greco CatolicÄ"; 114breadCrumbLabels["teologie_reformata"] = "Facultatea de Teologie ReformatÄ Èi MuzicÄ"; 115breadCrumbLabels["teologie_romano_catolica"] = "Facultatea de Teologie Romano CatolicÄ"; 116breadCrumbLabels["teatru_si_film"] = "Facultatea de Teatru Åi Film"; 117breadCrumbLabels["inginerie"] = "Facultatea de Inginerie"; 118breadCrumbLabels["stiinte_medicale_si_ale_sanatatii"] = "Facultatea de ÈtiinÈe Medicale Èi ale SÄnÄtÄÈii"; 119 120function displayBreadCrumbs(attempts) 121{ 122 // locate the breadcrumb container 123 var theBreadCrumbBar = null; 124 if (document.all) 125 { 126 theBreadCrumbBar = document.all.BreadCrumbBar; 127 } 128 else 129 { 130 theBreadCrumbBar = document.getElementById("BreadCrumbBar"); 131 } 132 133 // check to make sure that we have our breadcrumb bar 134 if (theBreadCrumbBar != null) 135 { 136 // get the current url 137 // we'll want to ensure that we get the start of our site so, we'll 138 // ignore everything up to and including our site prefix 139 var thePath = location.href; 140 var theProtocol = ""; 141 var theSite = ""; 142 143 // strip out the protocol from the path 144 theProtocol = thePath.substring(0, thePath.indexOf("://") + 3); 145 thePath = thePath.substring(thePath.indexOf("://") + 3); 146 147 // strip out the site name 148 theSite = thePath.substring(0, thePath.indexOf(sitePrefix)); 149 thePath = thePath.substring(thePath.indexOf(sitePrefix)); 150 151 // strip out the site prefix 152 thePath = thePath.substring(thePath.indexOf(sitePrefix) + sitePrefix.length); 153 154 // remove hash links 155 var theHash = ""; 156 if (thePath.indexOf("#") > -1) 157 { 158 theHash = thePath.substring(thePath.indexOf("#")); 159 thePath = thePath.substring(0, thePath.indexOf("#")); 160 } 161 162 // remove query parameters 163 if (thePath.indexOf("?") > -1) 164 { 165 thePath = thePath.substring(0, thePath.indexOf("?")); 166 } 167 168 169 // break out the individual pieces of the location 170 var crumbs = thePath.split("/"); 171 var currentPath = sitePrefix; 172 var crumbCount = 0; 173 174 // add a "home" link 175 // create a bread crumb container 176 var breadCrumb = document.createElement("span"); 177 breadCrumb.setAttribute("class", "breadCrumb"); 178 179 // determine the crumb label 180 // first use the default 181 var crumbLabel = "Home"; 182 183 // second look for a generic label 184 if ((breadCrumbLabels[sitePrefix] != null)) 185 { 186 crumbLabel = breadCrumbLabels[sitePrefix]; 187 } 188 189 // third look for a specific label 190 if ((breadCrumbLabels[currentPath] != null)) 191 { 192 crumbLabel = breadCrumbLabels[currentPath]; 193 } 194 195 // add the text 196 // check to see if there are any crumbs after this one 197 if ((0 < crumbs.length) && 198 (crumbs[0] != "index.php") && 199 (crumbs[0] != "")) 200 { 201 // create a new link 202 var linkTag = document.createElement("a"); 203 linkTag.href = theProtocol + theSite + currentPath; 204 linkTag.appendChild(document.createTextNode(crumbLabel)); 205 breadCrumb.appendChild(linkTag); 206 } 207 else 208 { 209 // add the text together 210 breadCrumb.appendChild(document.createTextNode(crumbLabel)); 211 } 212 theBreadCrumbBar.appendChild(breadCrumb); 213 214 // increment our count of crumbs 215 crumbCount++; 216 217 // loop through the crumbs 218 for (var crumbIndex = 0; crumbIndex < crumbs.length; crumbIndex++) 219 { 220 // setup the current path 221 currentPath += crumbs[crumbIndex]; 222 if (crumbIndex + 1 < crumbs.length) 223 { 224 currentPath += "/"; 225 } 226 if ((crumbs[crumbIndex] != "") && 227 (crumbs[crumbIndex].indexOf("index.php") == -1)) 228 { 229 // add this crumb to the list 230 // create a bread crumb container 231 var breadCrumb = document.createElement("span"); 232 breadCrumb.setAttribute("class", "breadCrumb"); 233 234 // add a greater than to the left hand side 235 if (crumbCount > 0) 236 { 237 breadCrumb.appendChild(document.createTextNode(breadCrumbSeparator)); 238 } 239 240 // determine the crumb label 241 // first use the crumb itself 242 var crumbLabel = crumbs[crumbIndex].replace(/_/g, " ").replace(".php", "").replace(/\?year=/," ").capitalize(); 243 244 // second look for a generic label 245 if ((breadCrumbLabels[crumbs[crumbIndex]] != null)) 246 { 247 crumbLabel = breadCrumbLabels[crumbs[crumbIndex]]; 248 } 249 250 // third look for a specific label 251 if ((breadCrumbLabels[currentPath] != null)) 252 { 253 crumbLabel = breadCrumbLabels[currentPath]; 254 } 255 256 // add the text 257 // check to see if there are any crumbs after this one 258 if ((crumbIndex + 1 < crumbs.length) && 259 (crumbs[crumbIndex + 1] != "index.php") && 260 (crumbs[crumbIndex + 1] != "")) 261 { 262 // create a new link 263 var linkTag = document.createElement("a"); 264 linkTag.href = theProtocol + theSite + currentPath; 265 linkTag.appendChild(document.createTextNode(crumbLabel)); 266 breadCrumb.appendChild(linkTag); 267 } 268 else 269 { 270 // add the text together 271 breadCrumb.appendChild(document.createTextNode(crumbLabel)); 272 } 273 theBreadCrumbBar.appendChild(breadCrumb); 274 275 // increment our count of crumbs 276 crumbCount++; 277 } 278 } 279 } 280 else if (attempts < 5) 281 { 282 // try again in a few seconds 283 attempts++; 284 setTimeout("displayBreadCrumbs(" + attempts + ");", 100); 285 } 286} 287 288// add a handy function to the string class 289String.prototype.capitalize = function() 290{ 291 return this.replace(/\w+/g, function(a) 292 { 293 return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase(); 294 }); 295}; 296 297// set us up to display bread crumbs 298displayBreadCrumbs(1); // JavaScript Document
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.