MediaWiki:CardToImage.js: mudanças entre as edições
Conteúdo deletado Conteúdo adicionado
Sem resumo de edição |
Sem resumo de edição |
||
Linha 1:
/* jshint esversion:
/**
* Convert a base64 string in a Blob according to the data and contentType.
Linha 10:
*/
function cardToImage() {
function b64toBlob(b64Data, contentType = '', sliceSize = 512) {▼
const byteCharacters = atob(b64Data);
▲function b64toBlob(b64Data, contentType, sliceSize) {
for (let offset =
const slice = byteCharacters.slice(offset, offset + sliceSize);
▲ let byteArrays = [];
const
for (let i = 0; i
const
▲ byteNumbers[i] = slice.charCodeAt(i);
▲ }
}
▲ byteArrays.push(byteArray);
return
}
// Generate screenshot and download▼
▲ let blob = new Blob(byteArrays, {type: contentType});
▲// Generate screenshot and download
▲let opt = {
scrollX: -window.scrollX,
scrollY: -window.scrollY,
};
html2canvas(element, opt).then(function (canvas) {
// Generate the base64 representation of the canvas
// Split the base64 string in data and contentType
// Get the content type
// get the real base64 content of the file
// Convert b64 to blob and store it into a variable (with real base64 as value)
// Generate file download
window.saveAs(canvasBlob,
});
}
| |||