MediaWiki:Gadget-importUtility.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
/// Gadget-importUtility.js
//  Support sysop on importing and exporting pages
/// 2018-08-24 PerfektesChaos@de.wikipedia
//  ResourceLoader: compatible; dependencies: NONE
//  Namespaces:     -1, 2, 4
//  Documentation:  [[w:de:Wikipedia:Technik/Skin/Gadgets/importUtility]]
/// Fingerprint:    #0#0#
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
// In memoriam Lady Whistler.
/// <nowiki>
/* global window: false                                                */
/* jshint bitwise:true, curly:true, eqeqeq:true, latedef:true,
          laxbreak:true,
          nocomma:true, strict:true, undef:true, unused:true           */



( function ( mw ) {
   "use strict";
   var Version    =  0.901,
       IUTIL      =  "importUtility",
       MaxAge     =  604800,
       SIGNATURE  =  "ext.gadget." + IUTIL;
   if ( ! mw.loader.getState( SIGNATURE ) ) {
      ( function () {
         var rls  =  { };
         rls[ SIGNATURE ]  =  "loading";
         mw.loader.state( rls );
      }() );
   }
   if ( typeof mw.libs[ IUTIL ]  !==  "object"   ||
        ! mw.libs[ IUTIL ] ) {
      mw.libs[ IUTIL ]  =  { };
   }
   mw.libs[ IUTIL ].type  =  IUTIL;
   IUTIL                  =  mw.libs[ IUTIL ];
   if ( typeof IUTIL.vsn  ===  "string" ) {
      IUTIL.vsn  =  "!=" + Version + " " + IUTIL.vsn;
   } else {
      IUTIL.vsn  =  "*=" + Version;
   }
   IUTIL.signature  =  SIGNATURE;



   if ( typeof IUTIL.doc  !==  "string" ) {
      if ( typeof IUTIL.cnf  !==  "object"   ||   ! IUTIL.cnf ) {
         IUTIL.cnf  =  { };
      }
      IUTIL.cnf.dewiki  = { archive:
                            { offer:    [ false, false ],
                              sectDone: "(erl.)",
                              sectTerm: "(erledigt)",
                              solved:   "{{Erledigt|",
                              stop:     "{{Nicht archivieren"
                                        + "|Zeigen=nein}}"
                            },
                            difflink:
                            { start:   "<init time=\"",
                              suggest: "Antrag"
                            },
                            edit:
                            { delIss: [ true, true ],
                              shift:    "\\* *'''Ziel:''' *"
                                      + "\\[{{fullurl:"
                                      + "([^|\n]*)"
                                      + "\\|action=history",
                              sketch:   "Versionsanzahl:",
                              source:   "\\* *'''Fremdlemma:''' *"
                                      + "\\[{{fullurl:"
                                      + "([a-z][-_a-z]+):"
                                      + "([^#|\n]+).*"
                                      + "\\|action=history",
                              staff:  "Versionen",
                              swap:   "{{Anfrage auf Upload stellen}}"
                            },
                         // lenient: false,   // permit template request
                            hold:
                            { section:  "(in Arbeit)",
                              stamp:    "/In Arbeit"
                            },
                            listed:
                            { search: "Wikipedia:Importwünsche/"
                                      + "Teilimport"
                            },
                            notify:
                            { sect:     "Dein Importwunsch zu"
                                        + " [[:{{{s}}}]]",
                              skeleton: "Wikipedia:Importwünsche/"
                                        + "Benutzernachricht"
                            },
                            quiet:
                            { source: "Wikipedia:Importwünsche/Robinson"
                            },
                            spec:
                            { "sourceTW": "WP:IMP",
                              "sourceIU": "WP:IU"
                            },
                            table:
                            { source:  "Benutzer:Importartikel",
                              support: "Importwünsche/Wartung"
                            },
                            minutes:  60,   // timeoffset
                            section:  "h2",
                            slang:    "de",
                            submitUP: "Importwünsche/Importupload",
                            submitTW: "Importwünsche"
                          };   // 2015-07-05
      IUTIL.doc  =  "[[w:de:Wikipedia:"
                    + "Technik/Skin/Gadgets/importUtility]]";
   }



   function family() {
      // Establish appropriate project configuration
      // Uses:
      //    >  .cnf.(DBname)
      //     < .cnf.project
      //    mw.config.get()
      //    mw.log()
      //    window.alert()
      // 2014-09-28 PerfektesChaos@de.wikipedia
      var self  =  mw.config.get( "wgDBname" ),
          r;
      if ( typeof IUTIL.cnf[ self ]  ===  "object" ) {
         IUTIL.cnf.project  =  IUTIL.cnf[ self ];
         r                  =  true;
      } else {
         mw.log( {loud:true},  "IUTIL family() " + self,  4 );
         window.alert( "importUtility *FATAL* Unknown wiki: " + self );
         r  =  false;
      }
      return r;
   }   // family()



   function fetch( access ) {
      // Make module available
      // Precondition:
      //    access  -- identifier of module
      // Postcondition:
      //    Returns true, if module already available and ready
      // Uses:
      //    >  .signature
      //    >  MaxAge
      //    >  .type
      //    mw.loader.getState()
      //    mw.config.get()
      //    mw.loader.load()
      // 2015-11-06 PerfektesChaos@de.wikipedia
      var r          =  false,
          signature  =  IUTIL.signature + "." + access,
          maxage     =  0,
          server     =  "//de.wikipedia.beta.wmflabs.org";
      if ( mw.loader.getState( signature ) ) {
         if ( typeof IUTIL[ access ]  ===  "object" ) {
            r  =  ( typeof IUTIL[ access ].fire  ===  "function" );
         }
      } else {
         if ( mw.config.get( "wgServer" )  !==  server ) {
            server  =  "https://de.wikipedia.org";
            maxage  =  MaxAge;
         }
         mw.loader.load( server + "/w/index.php?title="
                         + "MediaWiki:Gadget-"
                                      + IUTIL.type + "/" + access + ".js"
                         + "&bcache=1&maxage=" + maxage
                         + "&action=raw&ctype=text/javascript",
                         "text/javascript" );
      }
      return r;
   }   // fetch()



   function fire() {
      // Start additional tasks
      // Uses:
      //    >  .start
      //    fetch()
      // 2018-08-24 PerfektesChaos@de.wikipedia
      var launch  =  fetch( "utl" );
      if ( fetch( IUTIL.start )  &&  launch ) {
         IUTIL[ IUTIL.start ].fire();
      }
   }   // fire()



   function first() {
      // Start additional tasks, obey user options
      // Uses:
      //    mw.loader.using()
      //    (fire)
      // 2018-08-24 PerfektesChaos@de.wikipedia
      mw.loader.using( [ "user" ],
                       fire );
   }   // first()



   IUTIL.fire  =  function () {
      // Analyze any page loading; try async ressource loading first
      // Uses:
      //    this
      //    document
      //    >  .cnf.project.submitTW
      //    >  .cnf.project.submitUP
      //    >  .cnf.project.table.support
      //    >  .type
      //    >  .signature
      //     < .mode
      //     < .start
      //    mw.config.get()
      //    family()
      //    first()
      //    mw.loader.state()
      // 2018-08-24 PerfektesChaos@de.wikipedia
      var env  =  mw.config.get( [ "wgAction",
                                   "wgNamespaceNumber" ] ),
          rls  =  { },
          launch, s;
      switch ( env.wgNamespaceNumber ) {
         case -1 :   // Special:
            switch ( mw.config.get( "wgCanonicalSpecialPageName" ) ) {
               case "Import" :
                  this.mode  =  -1;
                  break;
               case "Export" :
                  this.mode  =  -9;
                  break;
               default:
                  this.mode  =  0;
            }   // switch wgCanonicalSpecialPageName
            if ( this.mode  &&  family() ) {
               this.start  =  "spec";
            }
            break;
         case 2 :   // User:
            if ( env.wgAction === "edit" ) {
               s  =  "&" + this.type + "=";
               if ( window.document.URL.indexOf( s )  >  0
                    &&   family() ) {
                  this.mode   =  10;
                  this.start  =  "mod";
               }
            }
            break;
         case 4 :   // Project:
            s  =  "|view|edit|submit|";
            if ( s.indexOf( env.wgAction )  >  0 ) {
               if ( env.wgAction === "edit" ) {
                  launch  =  ( window.document.URL.indexOf( "&section=" )
                               >  0 );
               } else {
                  launch  =  true;
               }
               if ( launch && family() ) {
                  switch ( mw.config.get( "wgTitle" ) ) {
                     case this.cnf.project.submitTW :
                        this.mode   =  1;
                        this.start  =  "proj";
                        break;
                     case this.cnf.project.submitUP :
                        this.mode   =  2;
                        this.start  =  "proj";
                        break;
                     case this.cnf.project.table.support :
                        this.mode   =  3;
                        this.start  =  "table";
                        break;
                  }   // switch wgTitle
               }
            }
            break;
      }   // switch wgNamespaceNumber
      if ( typeof IUTIL.start  ===  "string" ) {
         first();
      }
      rls[ IUTIL.signature ]  =  "ready";
      mw.loader.state( rls );
   };   // .fire()



   if ( typeof IUTIL.loaded  ===  "boolean" ) {
      if ( typeof IUTIL.start  ===  "string"   &&   family() ) {
         first();
      }
   } else {
      IUTIL.loaded  =  true;
      IUTIL.fire();
   }
}( window.mediaWiki, window.jQuery ) );



// Emacs
// Local Variables:
// coding: utf-8-dos
// fill-column: 80
// End:

/// EOF   importUtility.js    </nowiki>