MediaWiki:Export2Doc.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
imported>Jaideraf m (uma edição) |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
/* jshint esversion: 10 */ |
|||
function Export2Doc( |
function Export2Doc(element, filename = '') { |
||
const 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>'; |
||
const content2 = |
|||
⚫ | |||
⚫ | |||
const content4 = |
|||
⚫ | |||
⚫ | |||
const 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;>"; |
||
⚫ | |||
⚫ | |||
⚫ | |||
const html = |
|||
content1 + |
|||
content2 + |
|||
content3 + |
|||
content4 + |
|||
content5 + |
|||
content6 + |
|||
content7 + |
|||
content8 + |
|||
postHtml; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
let html = content1 + content2 + content3 + content4 + |
|||
content5 + content6 + content7 + content8 + postHtml; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
// Specify file name |
|||
filename = filename ? `${filename}.doc` : 'document.doc'; |
|||
⚫ | |||
encodeURIComponent( html ); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
filename = ( |
|||
filename |
|||
? filename + ".doc" |
|||
: "document.doc" |
|||
); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
navigator.msSaveOrOpenBlob(blob, filename); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
// Setting the file name |
|||
⚫ | |||
downloadLink.download = filename; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
// triggering the function |
|||
downloadLink.click(); |
|||
⚫ | |||
⚫ | |||
//triggering the function |
|||
downloadLink.click(); |
|||
⚫ | |||
⚫ | |||
} |
} |
Edição atual tal como às 13h02min de 18 de março de 2024
/* jshint esversion: 10 */
function Export2Doc(element, filename = '') {
const 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>';
const 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;>";
const content3 = document.getElementById('cipParagraph').textContent;
const 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>';
const content5 = document.getElementById(element).innerHTML;
const 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;>";
const content7 = document.getElementById('credit').textContent;
const content8 = '<o:p></o:p></span></p>';
const postHtml = '</div></body></html>';
const html =
content1 +
content2 +
content3 +
content4 +
content5 +
content6 +
content7 +
content8 +
postHtml;
const blob = new Blob(['\ufeff', html], {
type: 'application/msword',
});
// Specify link url
const url = `data:application/vnd.ms-word;charset=utf-8,${encodeURIComponent(html)}`;
// Specify file name
filename = filename ? `${filename}.doc` : 'document.doc';
// Create download link element
const 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);
}