MediaWiki:Gadget-importUtility/mod.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/mod.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
//  Modify (user) page
//  ResourceLoader: compatible;  dependencies: user, mediawiki.util
//  Namespaces:     2
//  Documentation:  [[w:de:Wikipedia:Technik/Skin/Gadgets/importUtility]]
/// Fingerprint: #0#0#
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
/// <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,
       Self       =  "mod",
       IUTIL      =  "importUtility",
       SIG        =  "ext.gadget." + IUTIL,
       SIGNATURE  =  SIG + "." + Self;
   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  =  IUTIL.vsn + " ";
   } else {
      IUTIL.vsn  =  "";
   }
   IUTIL.vsn  =  IUTIL.vsn + Self.substr( 0, 1 ) + "=" + Version;



//-----------------------------------------------------------------------



   if ( typeof IUTIL.mod  !==  "object" ) {
      // Open edit action on user page
      // Dependencies: mediawiki.api
      IUTIL.mod  =  { };



      IUTIL.mod.fiat  =  function () {
         // Start page adaption
         // Precondition:
         //    resources available
         // Uses:
         //    this
         //    >  .type
         //    >< mw.libs.WikiSyntaxTextMod
         //     < .mod.source
         //     < .mod.wstm
         //    mw.util.getParamValue()
         //    mw.loader.load()
         //    (.mod.finalize)
         // Remark: Used as event handler -- 'this' is not IUTIL.mod
         // 2014-10-10 PerfektesChaos@de.wikipedia
         var g, shift, slang;
         IUTIL.mod.source  =  mw.util.getParamValue( IUTIL.type );
         if ( IUTIL.mod.source ) {
            g  =  /^([-a-z_A-Z]+):/.exec( IUTIL.mod.source );
            if ( g ) {
               slang  =  g[1];
            }
         }
alert(".mod.fiat() "+slang+" * Noch nicht soweit");
slang=(mw.config.get("wgUserName")==="PerfektesChaos"?slang:false);
         if ( slang ) {
            shift  =  mw.config.get( "wgContentLanguage" );
            if ( typeof mw.libs.WikiSyntaxTextMod  !==  "object"
                 ||   ! mw.libs.WikiSyntaxTextMod ) {
               mw.libs.WikiSyntaxTextMod  =  { };
            }
            IUTIL.mod.wstm         =  mw.libs.WikiSyntaxTextMod;
            IUTIL.mod.wstm.config  =
                                 { lang: { accept: slang,
                                           write:  { lang:     shift,
                                                     linklang: slang } },
                                   mod:  { hook:     IUTIL.mod.finalize,
                                           template: { noop: true } }
                                 };
            if ( typeof IUTIL.mod.wstm.api  ===  "object" ) {
               IUTIL.mod.wstm.api.run();
            } else {
               mw.loader.load( "https://en.wikipedia.org/w/index.php"
                               + "?title=User:PerfektesChaos"
                               + "/js/WikiSyntaxTextMod/r.js"
                               + "&bcache=1&maxage=86400"
                               + "&action=raw&ctype=text/javascript",
                               "text/javascript" );
            }
         }
      };   // .mod.fiat()



      IUTIL.mod.finalize  =  function ( adjust ) {
         // Postprocess page content
         // Precondition:
         //    adjust  -- text content
         // Postcondition:
         //    Returns modified text content
         // Uses:
         //    this
         //    > .mod.source
         //    > .type
         //    .cnf.feature()
         // 2014-10-10 PerfektesChaos@de.wikipedia
         var r  =  adjust;
         if ( adjust.indexOf( "{{Importartikel}}" )  <  0 ) {
            r  =  "{{Importartikel}}\n\n" + adjust
                  + "\n\n----\n\n[[:" + IUTIL.mod.source + "]]";
         } else {
            window.alert( IUTIL.type + "\n\n"
                          +  IUTIL.cnf.feature( "ErrorAlready",
                                                false ) );
         }
         return r;
      };   // .mod.finalize()



      IUTIL.mod.fire  =  function () {
         // Initialize page adaption
         // Uses:
         //    >< .start
         //    mw.loader.using()
         //    (.mod.fiat)
         // 2014-10-10 PerfektesChaos@de.wikipedia
         if ( typeof IUTIL.start  ===  "string" ) {
            IUTIL.start  =  false;
            mw.loader.using( [ "mediawiki.util" ],
                             this.fiat );
         }
      };   // .mod.fire()
   }   // .mod



//-----------------------------------------------------------------------



   function fire() {
      // Script unit has been loaded
      // Uses:
      //    >  SIGNATURE
      //    >  .type
      //    >  Self
      //    >  Version
      //    mw.loader.getState()
      //    mw.loader.state()
      //    mw.hook()
      // 2018-08-24 PerfektesChaos@de.wikipedia
      var rls, sign;
      if ( mw.loader.getState( SIGNATURE )  !==  "ready" ) {
         rls  =  { };
         rls[ SIGNATURE ]  =  "ready";
         mw.loader.state( rls );
         sign  =  IUTIL.type + "." + Self;
         mw.hook( sign + ".ready" ).fire( { type: sign,
                                            vsn:  Version } );
         mw.hook( IUTIL.type + ".utl.ready" ).add( IUTIL[ Self ].fire );
      }
   }   // fire()



   fire();
}( window.mediaWiki, window.jQuery ) );



// Emacs
// Local Variables:
// End:

/// EOF   importUtility/mod.js    </nowiki>