Wikipedia:Übersicht der Versionshistorie von Wikoelsch importieren/script.js

// addLink function (origin)

function addLink(where, url, name, id, title, key, after) {
 var na = document.createElement('a');
 na.href = url;
 na.appendChild(document.createTextNode(name));
 var li = document.createElement('li');
 if (id) li.id = id;
 li.appendChild(na);
 var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
 if (after) {
  tabs.insertBefore(li,document.getElementById(after));
 } else {
  tabs.appendChild(li);
 }
 if (id) {
  if (key && title) {ta[id] = [key, title];}
  else if (key) {ta[id] = [key, ];}
  else if (title) {ta[id] = [, title];}
 }
 akeytt();
 return li;
}

// HTML replace function for history overview import (partial source; *)

 function replaceHistory() {
  var editForm = document.editform.wpTextbox1;
  editForm.value = editForm.value.replace(/\&amp\;/g, "&");
  editForm.value = editForm.value.replace(/(\<\/?(input|span)[^\>]*\>|\([^\)]+\) |\&action\=edit| class\=\"new\")/g, "");
  editForm.value = editForm.value.replace(/.*\<ul id\=\"pagehistory\"\>/, "== Frühere Artikel-Versionen bei http://wikoelsch.dergruenepunk.de/ ==\r\n\n:Artikel-Version  –  Benutzer bei Wikoelsch <sup>(Lokale Benutzerbeiträge)</sup>  –  ''(Zusammenfassung)''\r\n\n<div style=\"background-color: #F8F8FF; border: 1px solid #AAAAAA; padding: 5px;\">\r\n\n");
  editForm.value = editForm.value.replace(/\<li\>/g, "*");
  editForm.value = editForm.value.replace(/\<a href\=\"/g, "[http://wikoelsch.dergruenepunk.de");
  editForm.value = editForm.value.replace(/\" title\=\"[^\"]+\"\>/g, " ");
  editForm.value = editForm.value.replace(/\<\/a\>/g, "]  – ");
  editForm.value = editForm.value.replace(/\[http(\S+)(Benutzer\:|target\=)(\S+) ([^\]]+)\]/g, "[http$1$2$3 $4] <sup> ([[Special:Contributions/$3|$3]])</sup>");
  editForm.value = editForm.value.replace(/\<\/li\>/g, "\r\n");
  editForm.value = editForm.value.replace(/sup\> \&nbsp\;\&ndash\;\&nbsp\;([\r\n])/g, "sup>\r\n");
  editForm.value = editForm.value.replace(/→\] \&nbsp\;\&ndash\;\&nbsp\;/g, "→] ");
  editForm.value = editForm.value.replace(/ \((.+)\)([\r\n])/g, " ''($1)''\r\n");
  editForm.value = editForm.value.replace(/\<\/ul\>.*/, "\r\n</div>\r\n\n:Artikel-Version  –  Benutzer bei Wikoelsch <sup>(Lokale Benutzerbeiträge)</sup>  –  ''(Zusammenfassung)''");
  document.editform.wpSummary.value = "[[Wikipedia:Übersicht der Versionshistorie von Wikoelsch importieren|Versionshistorie von Wikoelsch.dergruenepunk.de]]";
 }
 addOnloadHook(function () {
  var title;
   if (!(title = document.getElementById('t-whatlinkshere') )) return;
   if (!(title = title.getElementsByTagName('a')[0] )) return;
   if (!(title = title.href )) return;
   if (!(title = title.replace(/^.*\/wiki\/Spe(c|z)ial:Whatlinkshere\//, '') )) return;
   addLink('p-navigation', 'http://wikoelsch.dergruenepunk.de/index.php/'+title,
           'Wikoelsch', 't-wikoelsch', 'wikoelsch.dergruenepunk.de', '', null);
  if (document.forms.editform) {
   addLink('p-cactions', 'javascript:replaceHistory()', 'HTML-Ersetzung',
           'ca-replacehistory', 'Übersicht der Versionshistorie ersetzen', '', 'ca-watch');
  }
 }); // Skriptende