'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
// table = document.getElementById('contenedor-resultados');
var div2table = $('.normativaItem').map(function () {
var issue = $(this);
var trline = issue.find('.export').map(function () {
return '
' + $(this).html();
}).get().join(' | ');
return '' + trline;
}).get().join('
');
table = "Título | Descripción |
"+ div2table +"
";
var ctx = {worksheet: "Export" || 'Worksheet', table: table};
window.location.href = uri + base64(format(template, ctx));
}
},
drawResult: function(callback) {
var html = "";
var _thisPlugin =this;
$("#exportExcel").on('click',function(e){
e.preventDefault();
_thisPlugin.exportExcel();
});
if(_thisPlugin.options.data.results.length != 0 ){
$.each(_thisPlugin.options.data.results, function(i, val) {
var url =encodeURI(window.location.protocol +"//"+ window.location.hostname + val.FileRef);
html += ''
html += '
';
html += '
';
html += '
' + val[_thisPlugin.options.columnNames.descripcion] + '
';
});
//_thisPlugin.$element.empty();
_thisPlugin.$element.append(html);
$(".fileContent").on("click",function(evt){
_thisPlugin.downloadFile(evt.currentTarget.hash.split('#')[1]);
});
callback();
}else{
_thisPlugin.$element.empty();
_thisPlugin.$element.append(html);
_thisPlugin.$element.append("No se encontraron resultados
");
}
}
};
/*plugin*/
$.fn.sharePointSearch = function(option) {
var args = Array.prototype.slice.call(arguments, 1);
var methodReturn;
var $this = $(this);
var data = $this.data('share-PointSearch');
var options = typeof option === 'object' ? option : {};
if (!data) $this.data('share-PointSearch', (data = new SharePointSearch (this, options)));
if (typeof option === 'string') methodReturn = data[option].apply(data, args);
return (methodReturn === undefined) ? $this : methodReturn;
};
$.fn.sharePointSearch.defaults = {
pageTitle:"Buscador de Normas",
defaultNorma:"",//Conpes,Leyes,Resoluciones,Decretos
listName: 'Leyes',
pagingOption:{
totalPages: 1,
totalPagesToShow: 1,
pageVariable: '{{page}}',
totalPagesVariable: '{{total_pages}}',
itemsPerPage: 100,
maxPages:5,
itemCount:0,
href: false,
page: null,
currPageIndex:1,
/*variables*/
skip:0,
first: 'Primero',
prev: 'Anterior',
next: 'Ver más resultados',
last: 'Último',
lastItemId:1
},
columnNames: {
numero:"Numero",
title: "Title",
anio: "A_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo"
},
data: null,
filterData: {
numero: null,
anio: null
}
};
$.fn.sharePointSearch.Constructor = SharePointSearch;
$.fn.sharePointSearch.noConflict = function() {
$.fn.sharePointSearch = old;
return this;
};
}( jQuery));
(function($){
$(document).ready(function() {
function GetParameterValues(param) {
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++) {
var urlparam = url[i].split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
}
}
if(GetParameterValues("t")!= null){
var norma="";//Conpes,Leyes,Resoluciones,Decretos
switch(parseInt(GetParameterValues("t"))){
case 1:
norma="Conpes";
break;
case 2:
norma="Leyes";
break;
case 3:
norma="Resoluciones";
break;
case 4:
norma="Decretos";
break;
};
$("#intiponorma").val(norma);
$(".tituloSalaPrensa").text(norma);
$("#intiponorma").attr('disabled','disabled');
}
/*suscribir eventos*/
$("#btnGuardar").on('click', function(e) {
e.preventDefault();// $(selector).pluginName('methodName', arg1, arg2, ... argn)
var options = null;
var extOptions = null;
options = {
listName: $("#intiponorma").val(),
pageTitle:"Buscador de Normas",
pagingOption:{
totalPages: 1,
totalPagesToShow: 1,
pageVariable: '{{page}}',
totalPagesVariable: '{{total_pages}}',
itemsPerPage: 100,
maxPages:5,
itemCount:0,
href: false,
page: null,
currPageIndex:1,
/*variables*/
skip:0,
first: 'Primero',
prev: 'Anterior',
next: 'Ver más resultados',
last: 'Último',
},
filterData: {
type:1,
numero0: $("#innumeronorma0").val() == "" ? null: $("#innumeronorma0").val(),
numero: $("#innumeronorma").val() == "" ? null: $("#innumeronorma").val(),
numero1: $("#innumeronorma1").val() == "" ? null: $("#innumeronorma1").val(),
anio: $("#inanio").val() == "" ? null: $("#inanio").val()
}
};
/*Condicionar Nombre de Columnas*/
switch ($("#intiponorma").val()) {
case "Conpes":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-conpes.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Conpes",
esVisible: "Item_x0020_Activo"
}
};
break;
case "Leyes":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-leyes.iqy",
columnNames: {
numero:"Numero",
title: "Title",
anio: "A_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo"
}
};
break;
case "Resoluciones":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-resoluciones.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo" }
};
break;
case "Decretos":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-decretos.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo"
}
};
break;
};
$.extend(options, extOptions);
$("#contenedor-resultados").empty();
$('#contenedor-resultados').sharePointSearch('init',options );
});
var options = null;
var extOptions = null;
options = {
listName: $("#intiponorma").val(),
pageTitle:"Buscador de Normas",
pagingOption:{
totalPages: 1,
totalPagesToShow: 1,
pageVariable: '{{page}}',
totalPagesVariable: '{{total_pages}}',
itemsPerPage: 100,
maxPages:5,
itemCount:0,
href: false,
page: null,
currPageIndex:1,
/*variables*/
skip:0,
first: 'Primero',
prev: 'Anterior',
next: 'Ver más resultados',
last: 'Último',
},
filterData: {
type:1,
numero0:null,
numero: null,
numero1:null,
anio: null }
};
/*Condicionar Nombre de Columnas*/
switch ($("#intiponorma").val()) {
case "Conpes":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-conpes.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Conpes",
esVisible: "Item_x0020_Activo"
}
};
break;
case "Leyes":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-leyes.iqy",
columnNames: {
numero:"Numero",
title: "Title",
anio: "A_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo"
}
};
break;
case "Resoluciones":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-resoluciones.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo" }
};
break;
case "Decretos":
extOptions = {
exportExcel:"https://www.minagricultura.gov.co/Normatividad/Documents/export-decretos.iqy",
columnNames: {
title: "Title",
numero: "Numero",
anio: "a_x00f1_o",
descripcion: "Descripcion",
esVisible: "Item_x0020_Activo"
}
};
break;
};
$.extend(options, extOptions);
$('#contenedor-resultados').sharePointSearch('init',options );
$("input").keyup(function() {
var maxChars = $(this).attr("maxlength");
if ($(this).val().length > maxChars) {
$(this).val($(this).val().substr(0, maxChars));
}
});
});
})(jQuery);