Created
July 15, 2016 13:13
-
-
Save vedovelli/308fc20fc6bdc728d9d4e1905894bf4c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
getChartsContents () { | |
const domEls = jQuery('.oct-chart svg') // acesso todos os SVG da pagina | |
const quantity = domEls.length | |
let i = 0 | |
let contents = [] | |
for (i; i < quantity; i++) { // neste loop pegarei o conteudo dos SVG e transformarei para Base64 | |
/** | |
* Serialize SVG to String | |
*/ | |
let svg = (new XMLSerializer).serializeToString(domEls[i]) | |
/** | |
* This will ensure non-Latin chars are properly escaped | |
*/ | |
svg = unescape(encodeURIComponent(svg)) | |
/** | |
* Add to array to be returned encoded as Base64 | |
*/ | |
contents.unshift(window.btoa(svg)) | |
} | |
return contents | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment