Created
December 18, 2021 13:38
-
-
Save fernandovaller/3097b76a978915acfa38723d94031959 to your computer and use it in GitHub Desktop.
Script para exportar arquivos do LMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let data = []; | |
let dados = $('table.singleTable1 > tbody > tr'); | |
dados.each(function(index, el) { | |
let nome = $(el).find('td:nth-child(3)')[0]; | |
let categoria = $(el).find('td:nth-child(6) span')[0]; | |
let link = $(el).find('td:nth-child(10) a.icon-edit')[0]; | |
let id = (link.href).split('=')[1]; | |
//data.push(`[${id}]=${nome.innerHTML}`); | |
data.push({ | |
id: id, | |
nome: `${nome.innerHTML}`, | |
categoria: `${categoria.innerHTML}`, | |
url: `${link.href}` | |
}); | |
}); | |
//console.log(data); | |
function downloadObjectAsJson(exportObj, exportName) { | |
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj)); | |
var downloadAnchorNode = document.createElement('a'); | |
downloadAnchorNode.setAttribute("href", dataStr); | |
downloadAnchorNode.setAttribute("download", exportName + ".json"); | |
document.body.appendChild(downloadAnchorNode); // required for firefox | |
downloadAnchorNode.click(); | |
downloadAnchorNode.remove(); | |
} | |
downloadObjectAsJson(data, 'arquivos'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment