Skip to content

Instantly share code, notes, and snippets.

@iGallina
Created September 4, 2014 19:04
Show Gist options
  • Save iGallina/e47fd848761e35f20ae7 to your computer and use it in GitHub Desktop.
Save iGallina/e47fd848761e35f20ae7 to your computer and use it in GitHub Desktop.
SEI_extractor
var resultado = '';
$.each($('tr.infraTrClara'), function () {
// Atribuição
var proc_atribuido = '';
proc_atribuido = ($(this).children('td:last').text().trim() === "") ? '(sem alocação)' : $(this).children('td:last').text();
// Processo
var processo = $(this).children('td:nth-child(3)').find('a');
var m_over = $(processo).attr('onmouseover');
var processos = regex_matcher(m_over);
// Resultado
resultado = resultado + '\n' + proc_atribuido + ';' + processo.text() + ';' + processos[0] + ';' + processos[1] + ';;';
// Post-It
var img;
var imgs = ['Vazio'];
$(this).find('td:nth-child(2)').find('img').each(function() {
img = $(this);
imgs.splice(0, 1);
var img_src = $(this).attr('src');
if (img_src == 'imagens/sei_anotacao_pequeno.gif') {
img_src = 'img-amarelo';
} else if (img_src == 'imagens/sei_anotacao_prioridade_pequeno.gif') {
img_src = 'img-vermelho';
} else if (img_src == 'imagens/retorno_programado_atrasado.gif'){
img_src = 'retorno-programado';
} else {
img_src = 'Vazio';
}
var img_text = $(img).attr('onmouseover');
imgs.push([regex_matcher(img_text), img_src]);
resultado = resultado.substring(0, resultado.length - 2) + ';' + imgs + ';';
});
});
console.log(resultado);
function regex_matcher(string) {
var all_regex_matches = [];
var test_array = [];
var regex = new RegExp(/\'(.*?)\'/g);
while ((test_array = regex.exec(string)) !== null) {
all_regex_matches.push('' + test_array[1] + '');
}
return all_regex_matches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment