var CurrentUrl=""; var SiteUrl=""; var queryLimit = 4000; var vista=""; var Multimodulo=false; $(document).ready(function() { if(document.getElementById("NavegacionPQ") != null){ if(document.location.href.indexOf('NewForm.aspx') == -1 && document.location.href.indexOf('EditForm.aspx') == -1 && document.location.href.indexOf('DispForm.aspx') == -1) setNavigationNodes(); disableNavButtons(); } } ); function setNavigationNodes(){ SiteUrl=_spPageContextInfo.webAbsoluteUrl; if(document.location.href.indexOf('SitePages') > -1) { CurrentUrl=document.location.href; } else{ var url=document.location.href.split('.aspx')[0].split('/'); vista=url[url.length-1]+".aspx"; CurrentUrl=document.location.href.split("/"+vista)[0].replace("/Forms",""); } var Nodes = getNavigationNodes(CurrentUrl.split(SiteUrl)[1]); for(var i=0;i") } else{ if(Nodes[i].Tipo=="Enlace" || Nodes[i].Tipo==""){ if($(Nodes[i]).attr("URL") == decodeURI(CurrentUrl.split(SiteUrl)[1]) ){ $("#NavegacionPQ").append("") } else{ $("#NavegacionPQ").append("") } } else if(Nodes[i].Tipo=="Calendario"){ var calendarLink=GetCalendarURL(Nodes[i]); $("#NavegacionPQ").append("") } } } //$("#NavegacionPQ").after("
 
"); } function getNavigationNodes(relativeURL){ var Modulo=""; Multimodulo=false; var Method = "GetListItems"; var ListName = "NavegacionNodos"; var Fields = "" + "" + ""; var Query = "" + decodeURI(relativeURL) + "0"; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ var ItemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount"); if(parseInt(ItemCount) > 1){Multimodulo=true;} // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ Modulo=$(this).attr("ows_Modulo"); console.log("Modulo: "+Modulo); }); } }); if(Multimodulo){ var Query = "" + decodeURI(relativeURL) + "0" + decodeURI(vista) + ""; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ var ItemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount"); if(parseInt(ItemCount) > 1){Multimodulo=true;} // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ Modulo=$(this).attr("ows_Modulo"); }); } }); } var List = []; var EnableSearch = true; var Method = "GetListItems"; var ListName = "NavegacionNodos"; var Fields = "" + "" + "" + "" + "" + "" + ""; var Query = "" + Modulo + ""; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ // Get Data List = []; $(xData.responseXML).SPFilterNode("z:row").each(function(){ var Record = { URL: $(this).attr("ows_Link"), Image: $(this).attr("ows_Imagen"), Titulo:$(this).attr("ows_Title"), Tipo: ($(this).attr("ows_TipoNodo")=="" ||$(this).attr("ows_TipoNodo")==undefined )?"":$(this).attr("ows_TipoNodo"), Vista:(Multimodulo && $(this).attr("ows_Vista") != undefined )? "/"+$(this).attr("ows_Vista") : "" }; List.push(Record); }); } }); return List; } /* Des-habilita los botones en caso de que no exista su Link */ function disableNavButtons(){ var i = 0; var elemEnlaces = $('a[class="navigationReplace"]'); var siteAbsoluteUrl = _spPageContextInfo.webAbsoluteUrl; if (elemEnlaces.length > 0){ var SitepagesGUID=""; devolverListas(["SitePagesLog"],false,function(guids){SitepagesGUID=guids[0]}) var allPages=[] if(SitepagesGUID!="SitePagesLog"){allPages = getAllSitePages();} else{return ;} var allLists = getAllLists(); for(linkCount = 0; linkCount < elemEnlaces.length; linkCount++){ var Exists = false; var link = elemEnlaces[linkCount]; var linkURL =linkURL=link.attributes['href'].value.trim().replace(siteAbsoluteUrl, ''); // Check. if (linkURL.indexOf('SitePages/') > -1){ for(pageCount = 0; pageCount < allPages.length; pageCount++){ if (allPages[pageCount].RelativeURL.toLowerCase().trim().replace(/ /g,"%20") == linkURL.toLowerCase().trim().replace(/ /g,"%20")){ Exists = true; } } } else if (linkURL.indexOf('Lists/') > -1){ if(linkURL.indexOf('.aspx') > -1 ){linkURL="/"+linkURL.split('/').slice(1,-1).join('/');} for(guidCount = 0; guidCount < allLists.length; guidCount++){ if (allLists[guidCount].RelativeURL.toLowerCase().trim().replace(/ /g,"%20") == linkURL.toLowerCase().trim().replace(/ /g,"%20")){ Exists = true; } } } else{ // Biblioteca. for(guidCount = 0; guidCount < allLists.length; guidCount++){ if (allLists[guidCount].RelativeURL.toLowerCase().trim().replace(/ /g,"%20") == linkURL.toLowerCase().trim().replace(/ /g,"%20").replace("/forms","")){ Exists = true; } } } // Disable. if (Exists != true){ $(link).closest('div').remove(); } } } } /* Recupera la información de la lista GUIDS */ function getAllLists(){ var List = []; var EnableSearch = true; var StartID = 0; var Method = "GetListItems"; var ListName = "GUIDS"; var Fields = "" + "" + "" + "" + ""; var Query = "" + StartID + ""; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLRowLimit: queryLimit, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ var Record = { ID: parseInt($(this).attr("ows_ID")), Title: (($(this).attr("ows_Title") != undefined) ? $(this).attr("ows_Title") : ''), Clave: (($(this).attr("ows_Clave") != undefined) ? $(this).attr("ows_Clave") : ''), RelativeURL: (($(this).attr("ows_RelativeURL") != undefined) ? $(this).attr("ows_RelativeURL") : ''), }; List.push(Record); }); // Ask for more EnableSearch = false; if($(xData.responseXML).SPFilterNode("z:row").length>=queryLimit){ StartID += queryLimit; EnableSearch = true; } } }); return List; } /* Recupera la información de la lista GUIDS */ function getAllSitePages(){ var List = []; var EnableSearch = true; var StartID = 0; var Method = "GetListItems"; var ListName = "SitePagesLog"; var Fields = "" + "" + "" + "" + ""; var Query = "" + StartID + ""; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLRowLimit: queryLimit, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ var Record = { ID: parseInt($(this).attr("ows_ID")), Title: (($(this).attr("ows_Title") != undefined) ? $(this).attr("ows_Title") : ''), Clave: (($(this).attr("ows_Clave") != undefined) ? $(this).attr("ows_Clave") : ''), RelativeURL: (($(this).attr("ows_RelativeURL") != undefined) ? $(this).attr("ows_RelativeURL") : ''), }; List.push(Record); }); // Ask for more EnableSearch = false; if($(xData.responseXML).SPFilterNode("z:row").length>=queryLimit){ StartID += queryLimit; EnableSearch = true; } } }); return List; } function GetCalendarURL(Nodo){ var SiteURL=_spPageContextInfo.webAbsoluteUrl; var ListURL=Nodo.URL; var ListGUID=""; var SiteName=_spPageContextInfo.webTitle; var ListName="";//ListURL.split('/')[1]; var Method = "GetListItems"; var ListName = "GUIDS"; var Fields = "" + "" + "" + "" + ""; var Query = "" + ListURL + ""; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLRowLimit: queryLimit, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ ListGUID=$(this).attr("ows_Clave") ; ListName=$(this).attr("ows_Title") ; }); } }); var link="stssync://sts/?ver=1.1&type=calendar&cmd=add-folder&base-url="+encodeURIComponent(SiteURL)+"&list-url="+encodeURIComponent(ListURL)+"&guid="+encodeURIComponent("{"+ListGUID+"}")+"&site-name="+encodeURIComponent(SiteName)+"&list-name="+encodeURIComponent(ListName); return link; } //