Benutzer:Neozoon/addotrs.js

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
 // <nowiki>
 // get URL parameters (used for page type variables)
 var UrlParameters = new Array ();
 readparams();
 
 function readparams() {
  var asReadInUrlParameters;
  var asReadInUrlParameter;
 
  // Get URL parameters
  asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
  for (i = 0; i < asReadInUrlParameters.length; i++) {
    asReadInUrlParameter = asReadInUrlParameters[i].split("=");
    UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
  }
 }
 
 function newtext (subj,text,wo)
  {  //wo=1 : Text austauschen
     //wo=2 : Text am Ende anhängen
     //wo=3 : Text vorne Einfügen
 
   if (subj > "") {
      if (document.editform.wpSummary.value > "") document.editform.wpSummary.value += ", ";
      document.editform.wpSummary.value = document.editform.wpSummary.value + subj;
   }
 
   switch (wo) {
       case 1 : document.editform.wpTextbox1.value=text+'\n'; break;
       case 2 : document.editform.wpTextbox1.value=document.editform.wpTextbox1.value+'\n'+text;break;
       case 3 : document.editform.wpTextbox1.value=text+'\n'+document.editform.wpTextbox1.value;break;
   }
   document.editform.wpTextbox1.focus();
  }
 
 var isEdit    = ((UrlParameters['action']=='edit') || (UrlParameters['action']=='submit'));
 if(!usersignature) var usersignature = "\~\~\~\~";
 var monthnames = new Array('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember');
 
 addOnloadHook(function() { // put onload in wikibits.js
 // From [[:en:Wikipedia:WikiProject_User_scripts/Scripts/Add_LI_link]]
        function aswcAddlilink(tabs, url, name, id, title, key) {
         var ta = new Array();
         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);
         //tabs.appendChild(li); // to end
         ta_hi = document.getElementById('t-whatlinkshere'); // to versions tab
         if (ta_hi) tabs.insertBefore(li, ta_hi);
         if (id) {
                 if (key && title) ta[id] = [key, title];
                 else if (key) ta[id] = [key, ''];
                 else if (title) ta[id] = ['', title];
         }
         akeytt(); // re-render the title and accesskeys from existing code in wikibits.js
         return li
        }; 
 
        aswcAddlilink(document.getElementById('p-tb').getElementsByTagName('ul')[0], "javascript:add_otrs();", /* LOCALIZABLE STRINGS START */ "OTRS" , "t-otrs", "OTRS-Freigabe substituiert ergänzen", "" /* LOCALIZABLE STRINGS END */);
        if(wgNamespaceNumber==6) aswcAddlilink(document.getElementById('p-tb').getElementsByTagName('ul')[0], "javascript:add_otrsaufschub();", /* LOCALIZABLE STRINGS START */ "OTRS-Aufschub" , "t-otrsaufschub", "OTRS-Aufschub ergänzen", "" /* LOCALIZABLE STRINGS END */);
 });

 function add_otrs() {
  var type = 0;
  if(wgNamespaceNumber==6) type = 1;
  if (!isEdit) {
   var linktoaddotrs = wgPageName;
   if(wgNamespaceNumber==0) linktoaddotrs = 'Diskussion:'+linktoaddotrs;
   location.href = "http://de.wikipedia.org/w/index.php?title=" + linktoaddotrs + "&action=edit&otrstype=" + type;
  } else {
   add_otrs2(type);
  }
 }
 
 function add_otrs2(type) {
  var counter = 0;
  while(counter != 3) {
    var ticketnummer=prompt('Ticketnummer:','');
    if (ticketnummer.search(/[^\d]/) == -1) {
     counter = 3;
     var otrs_text = "\{\{subst\:";
     var otrs_datum = ticketnummer.match(/\b(\d{4})(\d{2})(\d{2})/);
     var otrsyear = RegExp.$1;
     var otrsmonth = RegExp.$2;
     var otrsday = RegExp.$3;
     if(otrsmonth.search(/0[0-9]/)!=-1) { otrsmonth = monthnames[parseInt(otrsmonth.match(/0([0-9])/)[1])-1]; } else { otrsmonth = monthnames[parseInt(otrsmonth)-1]; }
     if(otrsday.search(/0[0-9]/)!=-1) otrsday = otrsday.match(/0([0-9])/)[1];
     if (type==0) {
       otrs_text = otrs_text + "OTRS-Freigabe\|" + otrsday + ". " + otrsmonth + " " + otrsyear + "\|" + ticketnummer + "\|" + usersignature + "\}\}";
       newtext("OTRS-Freigabe",otrs_text,3);
       document.editform.wpWatchthis.checked=false;
     } else {
       otrs_text = otrs_text + "OTRS-review\|" + otrsday + ". " + otrsmonth + " " + otrsyear + "\|" + ticketnummer + "\|" + usersignature + "\}\}";
       document.editform.wpSummary.value = "OTRS-Freigabe";
       document.editform.wpWatchthis.checked=false;
       var foundduep = false;
       if(document.editform.wpTextbox1.value.search(/Datei\überpr\üfung/)!=-1 || document.editform.wpTextbox1.value.search(/D\ÜP/)!=-1) foundduep = true;
       var replacedlicence = document.editform.wpTextbox1.value.match(/\|Genehmigung\s*\=\s?([^\n]*)(\n)/);
       replacedlicence = RegExp.$2.toString()+RegExp.$1.toString();
       if (document.editform.wpTextbox1.value.search(/\|Genehmigung/) == -1) {
         document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\|(\n)/,'{|'+$1+'|Genehmigung =')
       }
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\|Genehmigung(\s*)\=[^\r\n]*/, "|Genehmigung$1= " + otrs_text);
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{Datei\überpr\üfung[^\n]*\n/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{[lL]\öschen[^\n]*\(CE[S]?T\)\s*/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{[lL]\öschen[^\}\n]*\}\}\b/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{SLA[^\n]*\(CE[S]?T\)\s*/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{SLA[^\}\n]*\}\}\s*/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{D\ÜP[^\n]*\(CE[S]?T\)\s*/g, '');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\{\{D\ÜP[^\}\n]*\}\}\s*/g, '');
       if(foundduep) document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/(\n)\}\}(\n)/, '$1$2');
       document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\=\=[^\n]*Verwendung[^\n]des[^\n]Bildes[^\*]*(\*\[\[[^\]]*\]\])*\s*/g, '');
       if (document.editform.wpTextbox1.value.search(/\=\=.*Lizenz/)==-1) {
         newtext('','== [[Wikipedia:Lizenzvorlagen für Bilder|Lizenz]]: =='+replacedlicence,2);
       } else {
         document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\=\=.*Lizenz[^\n]*/,'== [[Wikipedia:Lizenzvorlagen für Bilder|Lizenz]]: =='+replacedlicence.toString());
       }
     }
   } else {
     counter = counter + 1;
   } 	
  }
 }
 
 if (UrlParameters["otrstype"]) { window.setTimeout(function() { addOnloadHook(add_otrs2(UrlParameters["otrstype"])); }, 500); }
 
 function add_otrsaufschub() {
  if (!isEdit) {
   location.href = "http://de.wikipedia.org/w/index.php?title=" + wgPageName + "&action=edit&otrsaufschub=1";
  } else {
   add_otrsaufschub2();
  }
 }
 
 function add_otrsaufschub2() {
  var counter = 0;
  while(counter != 3) {
    var ticketnummer=prompt('Ticketnummer:','');
    if (ticketnummer.search(/[^\d]/) == -1) {
     counter = 3;
     var otrsaufschub_text = " \{\{Dateiüberprüfung \(OTRS ausstehend\)\|" + ticketnummer + "\}\}";
     newtext("OTRS-Aufschub",otrsaufschub_text,3);
     document.editform.wpWatchthis.checked=false;
    } else {
      counter = counter + 1;
    }
  }
 }
 
 if (UrlParameters["otrsaufschub"]) { window.setTimeout(function() { addOnloadHook(add_otrsaufschub2()); }, 500); }
 // </nowiki>