Revision 639693 of "User:PerfektesChaos/common.js" on mediawikiwiki

mw.log  =  function (assign, apply, action, add) {
   // Popup message, if under development
   //    assign  -- debugging object
   //               >  .max     number of message boxes
   //               >  .say     identification of app
   //               >< .loud    false: silent
   //               >< .man     current message box count
   //    apply   -- message string
   //    action  -- level: 0=log 1=debug 2=info 3=warn 4=error
   //    add     -- additional object;  true: trace
   // Uses:
   //    Firebug support
   // 2012-11-18
   "use strict";
   var opt   =  assign;
   var show  =  apply;
   var s;
   var wc;
   if (typeof(opt)  === "string"  &&
       typeof(show) !== "string") {
      show  =  opt;
      opt   =  true;
   }
   if (opt === true) {
      opt  =  { loud: true,
                say:  ".log" };
   }
   if (opt) {
      if (typeof(opt) === "object") {
         if (opt.loud !== undefined) {
            if (opt.loud) {
               if (typeof(opt.max) !== "number") {
                  opt.max  =  20;
               }
               if (typeof(opt.man) !== "number") {
                  opt.man  =  0;
               }
               if (typeof(opt.say) === "string") {
                  s  =  opt.say + " ";
               } else {
                  s  =  "";
               }
               wc  =  window.console;
               if (typeof(wc) === "object") {
                  s  =  s + show;
                  switch (action) {
                  case 1 :
                     if (typeof(wc.debug) === "function") {
                        wc.debug(s);
                        break;
                     }
                  case 2 : //
                     if (typeof(wc.info) === "function") {
                        wc.info(s);
                        break;
                     }
                  case 3 : //
                     if (typeof(wc.warn) === "function") {
                        wc.warn(s);
                        break;
                     }
                  case 4 : //
                     if (typeof(wc.error) === "function") {
                        wc.error(s);
                        break;
                     }
                  default : //
                     if (typeof(wc.log) === "function") {
                        wc.log(s);
                     }
                  }   // switch action
                  if (add) {
                     switch (typeof(add)) {
                        case "function" :
                        case "object" :
                           if (typeof(wc.dir) === "function") {
                              wc.dir(add);
                              break;
                           }
                        case  "string": //
                           if (typeof(wc.debug) === "function") {
                              wc.debug(add);
                              break;
                           }
                        default : //
                           if (typeof(wc.trace) === "function") {
                              wc.trace();
                              break;
                           } else {
                              wc.log(add);
                           }
                     }   // switch typeof(add)
                  }
                  if (action) {
                     if ( ! opt.man
                          &&  typeof(action) === "number") {
                        if (action > 2) {
                           if (window.PerfektesChaos.g.client) {
                              if (window.PerfektesChaos.g.client.name
                                  === "firefox") {
                                 window.alert("Firebug console");
                                 opt.man  =  -1;
                              }
                           }
                        }
                     }
                  }
               } else {   // Fallback
                  if (typeof(opt.man) !== "number") {
                     opt.man  =  -1;
                  }
                  if (opt.man > opt.max) {
                     opt.loud  =  false;
                  } else {
                     opt.man++;
                     s  =  s + "   #" + opt.man;
                     if (typeof(action) === "number") {
                        s  =  s + "     " + action;
                     }
                     if (typeof(show) !== "number") {
                        s  =  s + "\n" + show;
                     }
                     if ( ! window.confirm(s) ) {
                        opt.loud  =  false;
                     }
                  }
               }
            }   // opt.loud
         }   // typeof opt.loud
      }   // opt object
   }   // opt
};   // mw.log()



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



mw.loader.load("//www.mediawiki.org/w/index.php?title=User:PerfektesChaos/js/paneMarker/r.js&action=raw&ctype=text/javascript&maxage=604800&smaxage=86400&*",
               "text/javascript");
mw.loader.load("//www.mediawiki.org/w/index.php?title=User:PerfektesChaos/js/resultListSort/r.js&action=raw&ctype=text/javascript&maxage=604800&smaxage=86400&*",
               "text/javascript");
mw.loader.load("//www.mediawiki.org/w/index.php?title=User:PerfektesChaos/js/userspaceLinks/r.js&action=raw&ctype=text/javascript&maxage=604800&smaxage=86400&*",
               "text/javascript");