MediaWiki:Export2Doc.js
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
function Export2Doc( element, filename = "" ){
let content1 = '<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=Content-Type content="text/html; charset=utf-8"> <meta name=ProgId content=Word.Document> <meta name=Generator content="Microsoft Word 14"> <meta name=Originator content="Microsoft Word 14"> <!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Pages>1</o:Pages> <o:Words>95</o:Words> <o:Characters>516</o:Characters> <o:Lines>4</o:Lines> <o:Paragraphs>1</o:Paragraphs> <o:CharactersWithSpaces>610</o:CharactersWithSpaces> <o:Version>14.00</o:Version> </o:DocumentProperties> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast;} p {mso-style-noshow:yes; mso-style-priority:99; font-size:11.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast;} span.SpellE {mso-style-name:""; mso-spl-e:yes;} span.GramE {mso-style-name:""; mso-gram-e:yes;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:11.0pt;} @page WordSection1 {size:595.3pt 841.9pt; margin:70.85pt 3.0cm 70.85pt 3.0cm; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tabela normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <meta charset=utf-8> <!--[if gte mso 9]><xml><o:shapedefaults v:ext="edit" spidmax="1026"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]--> </head> <body lang=PT-BR style="tab-interval:35.4pt"> <div class=WordSection1>';
let content2 = '<p class=MsoNormal align=center style=\'text-align:center\'><span style=\'mso-fareast-font-family:"Times New Roman"\' font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:11.0pt;>';
let content3 = document.getElementById("cipParagraph").textContent;
let content4 = '<o:p></o:p></span></p><p class=MsoNormal><span style=\'mso-fareast-font-family:"Times New Roman"\' font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:11.0pt;><o:p> </o:p></span></p>';
let content5 = document.getElementById(element).innerHTML;
let content6 = '<p class=MsoNormal><span style=\'mso-fareast-font-family:"Times New Roman"\' font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:11.0pt;><o:p> </o:p></span></p><p class=MsoNormal align=center style=\'text-align:center\'><span style=\'mso-fareast-font-family:"Times New Roman"\' font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:11.0pt;>';
let content7 = document.getElementById("credit").textContent;
let content8 = "<o:p></o:p></span></p>";
let postHtml = "</div></body></" + "html>";
let html = content1 + content2 + content3 + content4 +
content5 + content6 + content7 + content8 + postHtml;
let blob = new Blob(["\ufeff", html], {
type: "application/msword"
});
// Specify link url
let url = "data:application/vnd.ms-word;charset=utf-8," +
encodeURIComponent( html );
// Specify file name
filename = (
filename
? filename + ".doc"
: "document.doc"
);
// Create download link element
let downloadLink = document.createElement( "a" );
document.body.appendChild( downloadLink );
if( navigator.msSaveOrOpenBlob ){
navigator.msSaveOrOpenBlob( blob, filename );
} else {
// Create a link to the file
downloadLink.href = url;
// Setting the file name
downloadLink.download = filename;
//triggering the function
downloadLink.click();
}
document.body.removeChild( downloadLink );
}