var CurrentUrl=""; var SiteUrl=""; var queryLimit = 4000; $(document).ready(function() { if(document.getElementById("NavegacionPQ") != null){ setNavigationNodes(); } } ); function setNavigationNodes(){ SiteUrl=_spPageContextInfo.webAbsoluteUrl; var Modulos= getModulesNode(); PaintMainNodes(Modulos); $("#NavegacionAuxiliarPQ").prop("style","position:absolute"); if(document.location.href.indexOf('NewForm.aspx') == -1 && document.location.href.indexOf('EditForm.aspx') == -1 && document.location.href.indexOf('DispForm.aspx') == -1){ PaintIconos(); } } function PaintMainNodes(Nodes){ $("#NavegacionPrincipalPQ").prop("style","display:flex;"); for(var i=0;i "+$(Nodes[i]).attr("Titulo")+""); } } } function SetNavegacion(Modulo){ $("#NavegacionPQ").empty(); $("#NavegacionAuxiliarPQ1").empty(); $("#NavegacionAuxiliarPQ2").empty(); 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"), Modulo: $(this).attr("ows_Modulo"), Hijo: ($(this).attr("ows_ModuloHijo")=="" ||$(this).attr("ows_ModuloHijo")==undefined )?"":$(this).attr("ows_ModuloHijo"), NombreCorto: ($(this).attr("ows_NombreCorto")=="" ||$(this).attr("ows_NombreCorto")==undefined )?"":$(this).attr("ows_NombreCorto"), }; List.push(Record); }); } }); PaintNodes(List,"NavegacionPQ"); } function SetNavegacionAuxiliar(Modulo,nivel){ if(Modulo!=""){ if(nivel==2){$("#NavegacionAuxiliarPQ2").empty();} else{$("#NavegacionAuxiliarPQ1").empty();$("#NavegacionAuxiliarPQ2").empty();} 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"), Modulo: $(this).attr("ows_Modulo"), Hijo: ($(this).attr("ows_ModuloHijo")=="" ||$(this).attr("ows_ModuloHijo")==undefined )?"":$(this).attr("ows_ModuloHijo"), NombreCorto: ($(this).attr("ows_NombreCorto")=="" ||$(this).attr("ows_NombreCorto")==undefined )?"":$(this).attr("ows_NombreCorto"), }; List.push(Record); }); } }); PaintNodes(List,"NavegacionAuxiliarPQ"+nivel); } } function PaintNodes(Nodes,selector){ for(var i=0;i ");} $("#NavegacionPQIconos").css("margin-top", "7em"); break; case "NavegacionAuxiliarPQ2": if(i==0){$("#"+selector).append(""); $("#"+selector).append("");} $("#NavegacionPQIconos").css("margin-top", "9em"); break; } $("#"+selector).prop("style","display:flex"); var titulo=""; ($(Nodes[i]).attr("NombreCorto")=="")?titulo=$(Nodes[i]).attr("Titulo"):titulo=$(Nodes[i]).attr("NombreCorto"); //Como boton var enlace="#"; enlace='"'+SiteUrl+$(Nodes[i]).attr("URL")+'"'; if(i==0){ Action="onclick='window.location= "+enlace+"'"; $("#"+selector).append(""); } else{ if($(Nodes[i]).attr("Hijo")==""){ Action="onclick='window.location="+enlace+"'"; } $("#"+selector).append(""); } } disableNavButtons(); } function getModulesNode(){ var Modulo=""; var Modules=[]; var Nodos=[]; var Method = "GetListItems"; var ListName = "NavegacionNodos"; var Fields = "" + "" + "" + "" + "" + ""; var Query = "1"; $().SPServices({ operation: Method, async: false, listName: ListName, CAMLViewFields: Fields, CAMLQuery: Query, completefunc: function(xData, Status){ // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ var Record = { URL: $(this).attr("ows_Link"), Titulo: $(this).attr("ows_Title"), Modulo: $(this).attr("ows_Modulo"), Tipo: ($(this).attr("ows_TipoNodo")=="" ||$(this).attr("ows_TipoNodo")==undefined )?"":$(this).attr("ows_TipoNodo"), }; Nodos.push(Record); }) } }); console.log("Nodos: "+Nodos) return Nodos; } function PaintIconos(){ $("#ContentArea").prop("style","margin:15px auto 40px") if(document.location.href.indexOf('SitePages') > -1) { CurrentUrl=document.location.href; } else{ var url=document.location.href.split('.aspx')[0].split('/'); var vista=url[url.length-1]; CurrentUrl=document.location.href.split("/"+vista+".aspx")[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]) ){ $("#NavegacionPQIconos").append("") } else{ $("#NavegacionPQIconos").append("") } } else if(Nodes[i].Tipo=="Calendario"){ var calendarLink=GetCalendarURL(Nodes[i]); $("#NavegacionPQIconos").append("") } } } disableNavButtons(); } function getNavigationNodes(relativeURL){ var Modulo=""; 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){ // Get Data $(xData.responseXML).SPFilterNode("z:row").each(function(){ Modulo=$(this).attr("ows_Modulo"); console.log("Modulo: "+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"), }; List.push(Record); }); } }); return List; } function GetCalendarURL(Nodo){ var SiteURL=_spPageContextInfo.webAbsoluteUrl; var ListURL=Nodo.URL; var ListGUID=""; var SiteName=_spPageContextInfo.webTitle; var ListName=""; 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; } /* Des-habilita los botones en caso de que no exista su Link */ function disableNavButtons(){ var i = 0; var elemEnlaces = $('[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=""; if($(link).prop("tagName")=="A"){ linkURL = link.attributes['href'].value.trim().replace(siteAbsoluteUrl, ''); } else if ($(link).prop("tagName")=="DIV"){ linkURL = link.attributes['data-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){ 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; }