<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { var rootStr = getParameterByName("RootFolder"); var listUrl; var j; if (rootStr != "") { // If you have added List if (rootStr.indexOf("List") >= 0) { j = 3; listUrl = rootStr.substring(0, findNthOccurrence(rootStr, '\/', j)); listUrl = listUrl.replace(' ', '%20'); } // If you have added Library else { j = 2; listUrl = rootStr.substring(0, findNthOccurrence(rootStr, '\/', j)); listUrl = listUrl.replace(' ', '%20'); } var count = rootStr.match(/\//g); if (count.length > j - 1) { var i = j; for (i; i < count.length; i++) { $("a[href='" + listUrl + "']").parent('h3').append('<span> > </span>'); var spanEle = document.createElement("span"); var anchorEle = document.createElement("a"); anchorEle.innerHTML = rootStr.substring(findNthOccurrence(rootStr, '\/', i) + 1, findNthOccurrence(rootStr, '\/', i + 1)); var rootFolder = rootStr.substring(0, findNthOccurrence(rootStr, '\/', i + 1)); anchorEle.href = location.href.replace(/(RootFolder=)[^\&]+/, '$1' + rootFolder); spanEle.appendChild(anchorEle); $("a[href='" + listUrl + "']").parent('h3').append(spanEle); } $("a[href='" + listUrl + "']").parent('h3').append('<span> > </span>'); var spanEle = document.createElement("span"); var anchorEle = document.createElement("a"); anchorEle.innerHTML = rootStr.substring(rootStr.lastIndexOf('\/') + 1, rootStr.length); anchorEle.href = '#'; spanEle.appendChild(anchorEle); $("a[href='" + listUrl + "']").parent('h3').append(spanEle); } $("a[href='" + listUrl + "']").attr('href', location.href.split('?')[0]); } }); function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } function findNthOccurrence(string, char, nth) { var firstIndex = string.indexOf(char); var lenUptofirstIndex = firstIndex + 1; if (nth == 1) { return firstIndex; } else { var strAfterFirstOccurrence = string.slice(lenUptofirstIndex); var nextOccurrence = findNthOccurrence(strAfterFirstOccurrence, char, nth - 1); if (nextOccurrence === -1) { return -1; } else { return lenUptofirstIndex + nextOccurrence; } } } </script>
// If you have added Library
Gokan Ozcifci edited Revision 6. Comment: Added version
Ed Price - MSFT edited Revision 2. Comment: Title casing
Ed Price - MSFT edited Revision 3. Comment: Ruined the code block
Naomi N edited Revision 1. Comment: minor edit
@Ed Price : why revision 3??