Difference between revisions 137876 and 137879 on testwiki

/// mw:User:PerfektesChaos/js/paneMarker/?.js
/// 2012-06-19 [email protected]
/// Fingerprint: #0#0#
// Mark browser panes (tabbed or window) if particular action taken.
// Try to exchange wiki-favicon for a red one if editing a wiki page.
// Insert indicating character before document title.

// Requires: JavaScript 1.3
(contracted; show full)      // Try to exchange wiki-favicon
      // Precondition:
      //    apply  -- true:   red icon (page used in vulnerable mode)
      //              false:  show user defined default project icon
      // Uses:
      //    >  this
      //    >  .site

      //    >  .config.favicon
      //    >  .config.appleIcon
      //    >  .config.faviconICO
      //    >  .config.faviconPNG
      //    .file()
      // 2012-06-19 [email protected]
      var $apple,
          $head       =  $( document ).find( "head" ),
          $favicon,
          iapple     =  false,
          lawi,
         =  ( typeof apply === "boolean" ),
 light     =  apply,
          n         =  n0,
          apple offer     =  false,
          png         =  [ "wmf", "f7" ]false,
          s;
      // https://secure.wikimedia.org/favicon.ico
      if ( $head.length ) {
         if ( law ) {apply ) {
            png  =  [ "wmf", "f7" ];
            if ( this.site === "commonswiki" ) {
               apple  =  [ "commons", "70" ];
               png    =  [ "commons", "e7" ];
            } else if ( this.site === "metawiki" ) {
               png    =  [ "meta", "96" ];
            } else if ( this.site === "testwiki" ) {
               apple  =  [ "wikipedia", "f1" ];
(contracted; show full)            } else if ( this.site.slice( -10 )  ===  "wiktionary" ) {
//             apple  =  [ "wiktionary", "##" ];   // Perhelion
               png    =  [ "wikipedia", "fb" ];
            } else {
               apple  =  [ "wmf", "a9" ];
            }
         }
         
$favicon  =  $head.find( "link" ).filter( function() {
                              return ( this.rel === "shortcut icon" );
                                                           } );
         if ( lawif ( apply ) {
            $apple  =  $head.find( "link" ).filter( function() {
                              return ( this.rel === "apple-touch-icon" );
                                                               } );
            if ( $apple.length === 1 ) {
               s  =  false;
               switch ( typeof this.config.appleIcon ) {
                  case "string" :
                     s  =  this.config.appleIcon;
                     break;
                  case "boolean" :
                     if ( ! this.config.appleIcon  ) {
                        break;
                     }
                     // fall through
                  default:
                     if ( apple ) {
                        s  =  this.file( "Apple-touch-icon-red-",
                                         apple[0],
                                         apple[1] );
                     }
               }   // switch   typeof .config.appleIcon
               if ( s ) {
                  $apple.detach();
                  $apple.attr( "href", s );
                  $head.append( $apple );
               }
            }
         }
         if ( light ) {
            $favicon  =  $head.find( "link" ).filter( function() {
                              return ( this.rel === "shortcut icon" );
                                                                 } );
            n  =  $favicon.length;
         }
         if ( n ) {
            if ( lawapply ) {
               s  =  false;
               switch ( typeof this.config.faviconPNG ) {
                  case "string" :
                     s  =  this.config.faviconPNG;
                     break;
                  case "boolean" :
                     if ( ! this.config.faviconPNG ) {
                        break;
                     }
                     // fall through
                  default:
                     s  =  this.file( "Favicon-red-", png[0], png[1] );
               }   // switch   typeof .config.faviconPNG
               if ( s ||offer  =  [  [ s, "image/png" ]  ];
               s      =  this.config.faviconICO ) {
;
                        for ( i = 0;  i < n;  i++ ) {
                     $favicon.eq( i ).detach(if ( s ) {
                  if ( typeof s === "string" ) {
                     offer.push( [ s, "image/x-icon" ] );
                  }

   // for i
              }
        if ( n > 1 )    } else {
               s      $favicon  =  $favicon.eq( 0 )=  this.config.favicon;
                  }if ( s ) {
                  if ( typeof this.config.faviconICOs === "string" ) {
                     $favicon.attr( "href", this.config.faviconICO );
                     $favicon.attr( "type", "image/x-icon" )offer  =  [  [ s, null ]  ];
                     switch ( s.slice( -4 ).toLowerCase() ) {
                        case ".ico" :
                           offer[0][1]  =  "image/x-icon";
                           break;
                       $head.append( $favicon );
           case ".png" :
                           offer[0][1]  =  "image/png";
                           break;
                     }   // switch   s.slice( -4 ).toLowerCase()
                  }
               }
            }
            if ( soffer ) {
               for ( i = 0;  i < n;  i++ ) {
              $favicon  =  $favicon.cloneeq( i ).detach();
               }      }// for i
                  }
                  if ( s ) {
                     $favicon.attr( "type", "image/png" );
                     $favicon.attr( "href", s );
                     $head.append( $favicon );
                  }
               }
            } else {if ( n > 1 ) {
                  $favicon  =  $favicon.eq( 0 );
               }
               for ( i = 0;  i < offer.length;  i++ ) {
                  $favicon.attr( "href", offer[i][0] );
                  $favicon.attr( "type", offer[i][1] );
                  if ( i + 1  <  offer.length ) {
                     $favicon  =  $favicon.clone();
                  }
               }   // for i
            }
         }   // $favicon.length
      }   // $head
   };   // .favicon()



   mw.libs.paneMarker.file  =  function ( album, assign, access ) {
      // Retrieve PNG file URL at commons
      // Precondition:
      //    album   -- apple or favicon prefix
      //    assign  -- site
      //    access  -- hashcode octet
      // Postcondition:
      //    Returns URL
      // 2012-06-07 [email protected]
      var r  =  "//upload.wikimedia.org/wikipedia/commons/"
                +  access.substr( 0, 1 )  +  "/"  +  access  +  "/"
                +  album  +  assign  +  ".png";
      return r;
   };   // .file()



   mw.libs.paneMarker.flag  =  function ( action ) {
      // Put character together with document title
      // Precondition:
      //    action  -- "Diff", "History", "Links", "Vitally", "*"
      // Uses:
      //    >  this
      //    >  .config.leave
      //    >  .site
      //    >  .heads
      //    >  .config.charDiff
      //    >  .config.charHistory
      //    >  .config.charLinks
      //    >  .config.charVitally
      //    >  .config.chars
      //    >  .config.lowChar
(contracted; show full)   mw.libs.paneMarker.fresh  =  function () {
      // Run paneMarker in this particular situation
      // Precondition:
      //    Page may be under loading, but not necessarily ready.
      //    .using( [ "user", "mediawiki.util" ] )
      // Uses:
      //    >  .opt.*

      //    >  .config.least
      //    >  .jQuery.browser
      //    >< this.*
      //     < .config.*
      //     < .site
      //     < .nsN
      //     < .lazy
      //    .flag()
      //    mw.config.get()
(contracted; show full)// Emacs
// Local Variables:
// encoding: utf-8-dos
// coding: utf-8-dos
// fill-column: 80
// End:

/// EOF </nowiki>   paneMarker/?.js