MediaWiki:Export2Doc.js: mudanças entre as edições

De Wikincat
Ir para navegação Ir para pesquisar
imp>Jaider
(jslint, eslint e jshint)
 
Sem resumo de edição
 
(Uma revisão intermediária por um outro usuário não está sendo mostrada)
Linha 1: Linha 1:
/* jshint esversion: 10 */
function Export2Doc( element, filename = "" ){
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>&nbsp;</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>&nbsp;</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], {
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>';
type: 'application/msword',
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>&nbsp;</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>&nbsp;</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;


// Specify link url
let blob = new Blob(["\ufeff", html], {
const url = `data:application/vnd.ms-word;charset=utf-8,${encodeURIComponent(html)}`;
type: "application/msword"
});


// Specify link url
// Specify file name
filename = filename ? `${filename}.doc` : 'document.doc';
let url = "data:application/vnd.ms-word;charset=utf-8," +
encodeURIComponent( html );


// Create download link element
// Specify file name
const downloadLink = document.createElement('a');
filename = (
filename
? filename + ".doc"
: "document.doc"
);


document.body.appendChild(downloadLink);
// Create download link element
let downloadLink = document.createElement( "a" );


if (navigator.msSaveOrOpenBlob) {
document.body.appendChild( downloadLink );
navigator.msSaveOrOpenBlob(blob, filename);
} else {
// Create a link to the file
downloadLink.href = url;


// Setting the file name
if( navigator.msSaveOrOpenBlob ){
navigator.msSaveOrOpenBlob( blob, filename );
downloadLink.download = filename;
} else {
// Create a link to the file
downloadLink.href = url;


// Setting the file name
// triggering the function
downloadLink.download = filename;
downloadLink.click();
}


document.body.removeChild(downloadLink);
//triggering the function
downloadLink.click();
}

document.body.removeChild( downloadLink );
}
}

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>&nbsp;</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>&nbsp;</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);
}