Jump to content

User:PerfektesChaos/js/externalLinkProblem/prego/d.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// User:PerfektesChaos/js/externalLinkProblem/prego/d.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
// Sub-module: Equip Special:Blankpage
// ResourceLoader:  compatible;
//                  dependencies: No MW
/// 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  =  -2.8,
       ELP      =  "externalLinkProblem",
       Sub      =  "prego";
   if ( typeof mw.libs[ ELP ]  !==  "object"   ||   ! mw.libs[ ELP ] ) {
      mw.libs[ ELP ]  =  { };
   }
   mw.libs[ ELP ].type  =  ELP;
   ELP                  =  mw.libs[ ELP ];



   /*
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License as
    * published by the Free Software Foundation; either version 2 of the
    * License, or (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program;
    * if not, write to the Free Software Foundation, Inc.,
    * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    * http://www.gnu.org/copyleft/gpl.html
    */



   if ( typeof ELP[ Sub ]  !==  "object" ) {
      ELP[ Sub ]  =  { };
   }
   if ( typeof ELP.lang  !==  "object" ) {
      ELP.lang  =  { slang: "en" };
   }
   if ( typeof ELP[ Sub ].texts  !==  "object" ) {
      ELP[ Sub ].vsn    =  Version;
      ELP[ Sub ].texts  =  {
         // 2015-10-22 PerfektesChaos@de.wikipedia
         "^show":   {"en": "External-Link-Problem",
                     "de": "External-Link-Problem"},
         "^suffix": {"en": "&#8211; Manage external links with problems",
                     "de": "&#8211; Problematische Weblinks managen"},
         "^^last":  {"en": "Recent Changes treated like watchlist",
                     "de": "Letzte Änderungen"
                           + " wie Beobachtungsliste behandeln"},
         "^^later": {"en": "Show watchlist after clearing",
                     "de": "Beobachtungsliste bereinigt anzeigen"},
         "^^lazy":  {"en": "No comparison with effective URL"
                           + " (on talk page)",
                     "de": "Kein Abgleich mit den wirksamen URL"
                           + " (auf der Diskussionsseite)"},
         "^^levels":{"en": "Show path segmentation",
                     "de": "Pfad segmentiert darstellen"},
         "^^list":  {"en": "Show bot activity on watchlist",
                     "de": "Bot auf Beobachtungsliste anzeigen"},
         "^^lone":  {"en": "No advertising on talk page",
                     "de": "Kein Hinweis auf der Diskussionsseite"},
         "^^lookup":{"en": "Link Google search",
                     "de": "Google-Suche verlinken"},
         "^^loose": {"en": "Open always a new tab/window for"
                           + " linked pages",
                     "de": "Immer ganz neues Fenster/Tab"
                           + " für verlinkte Ziele öffnen"},
         "^^low":   {"en": "Do not show any details",
                     "de": "Keine Details ermitteln"},
         "^^mode":  {"en": "List of details",
                     "de": "Liste der Details"},
         "^^mode0": {"en": "Start hidden",
                     "de": "Anfangs zugeklappt"},
         "^^mode1": {"en": "Remember last state in tab/window",
                     "de": "Letzten Zustand im Fenster/Tab merken"},
         "^^mode2": {"en": "Start always opened",
                     "de": "Anfangs immer aufgeklappt"}
      };   // .prego.texts
   }



   function facilitated() {
      // Mark sub-module as ready
      // Uses:
      //    >  .signature
      //    >  Sub
      //    >  .type
      //    mw.loader.getState()
      //    mw.loader.state()
      //    mw.hook()
      // 2018-08-24 PerfektesChaos@de.wikipedia
      var rls, signature, sub;
      if ( typeof ELP.signature  ===  "string" ) {
         sub        =  "/" + Sub;
         signature  =  ELP.signature + sub;
         if ( mw.loader.getState( signature )  !==  "ready" ) {
            rls = { };
            rls[ signature ] = "ready";
            mw.loader.state( rls );
            mw.hook( ELP.type + sub + ".ready" ).fire();
         }
      }
   }   // facilitated()

   }   // facilitated()



   function favorite() {
      // Detect support page in user language
      // Uses:
      //    this
      //    >  .lang.slang
      //    >  .support
      // 2014-01-20 PerfektesChaos@de.wikipedia
      var r;
      switch ( ELP.lang.slang ) {
         case "de" :
            r  =  "de.wikipedia.org";
            break;
         default:
            r  =  "en.wikipedia.org";
      }   // switch .slang
      return "//" + r + "/wiki/" + ELP.support;
   }   // favorite()



   function form() {
      // Equip Special:Blankpage with entry and form
      // Uses:
      //    >  Sub
      //    >  .prego.texts
      //    >  .project.trigger
      //    >  .config
      //    >  .type
      //    >  .prego.lib
      //    favorite()
      //    mw.libs.preferencesGadgetOptions.form()
      // 2015-11-10 PerfektesChaos@de.wikipedia
      var texts  =  ELP[ Sub ].texts,
          dialog, opts;
      if ( ELP.project.trigger[ 0 ] === "talk" ) {
         opts  =  [ { signature: "list",
                      type:      "checkbox",
                      show:      texts[ "^^list" ],
                      val:       ( ELP.config.list ? true
                                                   : false ) },
                    { signature: "later",
                      type:      "checkbox",
                      show:      texts[ "^^later" ],
                      val:       ( ELP.config.later ? true
                                                    : false ) },
                    { signature: "last",
                      type:      "checkbox",
                      show:      texts[ "^^last" ],
                      val:       ( ELP.config.last ? true
                                                   : false ) },
                    { signature: "lone",
                      type:      "checkbox",
                      show:      texts[ "^^lone" ],
                      val:       ( ELP.config.lone ? true
                                                   : false ) },
                    { signature: "lazy",
                      type:      "checkbox",
                      show:      texts[ "^^lazy" ],
                      val:       ( ELP.config.lazy ? true
                                                   : false ) },
                    { signature: "loose",
                      type:      "checkbox",
                      show:      texts[ "^^loose" ],
                      val:       ( ELP.config.loose ? true
                                                    : false ) }
                   ];
      } else {
         opts  =  [ ];
      }
      opts.push( { signature: "low",
                   type:      "checkbox",
                   show:      texts[ "^^low" ],
                   val:       ( ELP.config.low ? true
                                               : false ) },
                 { signature: "mode",
                   type:      "radio",
                   show:      texts[ "^^mode" ],
                   val:       ( ELP.config.mode ? ELP.config.mode
                                                :  0 ),
                   poly:      [ { val:  0,
                                  show: texts[ "^^mode0" ] },
                                { val:  1,
                                  show: texts[ "^^mode1" ] },
                                { val:  2,
                                  show: texts[ "^^mode2" ] }
                              ] },
                 { signature: "levels",
                   type:      "checkbox",
                   show:      texts[ "^^levels" ],
                   val:       ( ELP.config.levels ? true
                                                  : false ) },
                 { signature: "lookup",
                   type:      "checkbox",
                   show:      texts[ "^^lookup" ],
                   val:       ( ELP.config.lookup ? true
                                                  : false ) } );
      dialog  =  { script:  ELP.type,
                   show:    texts[ "^show" ],
                   support: favorite(),
                   suffix:  texts[ "^suffix" ],
                   opts:    opts };
      ELP[ Sub ].lib.form( dialog );
   }   // form()



   ELP[ Sub ].fire  =  function () {
      // Start possible actions on Special:Blankpage
      // Uses:
      //    >  Sub
      //    >  .prego.lib
      //    >< .request
      //    form()
      // Remark: May be used as event handler -- 'this' is not accessed
      // 2016-10-04 PerfektesChaos@de.wikipedia
      facilitated();
      if ( typeof ELP.request  ===  "string"   &&
           ELP.request === Sub   &&
           typeof ELP[ Sub ].lib  ===  "object" ) {
         ELP.request  =  false;
         form();
      }
   };   // .prego.fire()



   function first() {
      // Initialize sub-module
      // Uses:
      //    >  Sub
      //    facilitated()
      //    .featuring()
      //    (.prego.fire)
      // 2015-10-22 PerfektesChaos@de.wikipedia
      facilitated();
      if ( typeof ELP.featuring  ===  "function" ) {
         ELP.featuring( ELP[ Sub ].fire );
      }
   }   // first()
   first();   // autorun
}( window.mediaWiki, window.jQuery ) );



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

/// EOF </nowiki>   externalLinkProblem/prego/d.js