User:PerfektesChaos/js/isbnLib/qunit.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:PerfektesChaos/js/isbnLib/qunit. |
/// PerfektesChaos/js/isbnLib/qunit.js
/// 2018-09-04 PerfektesChaos@de.wikipedia
/// Fingerprint: #0#0#
/// QUNIT for ISBN utility package
/* 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 LIB = "isbnLib",
Version = 1.3,
Signature = "ext.gadget.isbnLib",
Console, Tests;
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
/*
* 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
*/
function T01 ( assign ) {
/**
Add resolvers to default catalogs
@param assign string with language code (not "qqq"), or false
@version 2016-04-02 PerfektesChaos@de.wikipedia
*/
var plus =
{ de: [ "http://gso.gbv.de/DB=2.1/CMD?ACT=SRCHA&IKT=1007&TRM=#"
]
};
LIB.furnish( plus );
return LIB.finder( assign );
} // T01()
Tests = [
{ f: "factory" },
{ f: "factory",
a: [ true ] },
{ f: "finder",
a: [ "de" ] },
{ f: "finder",
a: [ "en" ] },
{ f: "flip",
a: [ "3-7891-4161-5" ],
r: "978-3-7891-4161-4" },
{ f: "flip",
a: [ "978-3-7891-4161-4" ],
r: "3-7891-4161-5" },
{ f: "focus",
a: [ "3-7891-4161-5" ],
r: "de" },
{ f: "focus",
a: [ "9129657520" ],
r: "sv" },
{ f: "format",
a: [ "9129657520" ],
r: "91-29-65752-0" },
{ f: T01,
a: [ "de" ] }
]; // 2016-03-22
function factory () {
/**
Callback from library
@version 2016-04-02 PerfektesChaos@de.wikipedia
*/
var i, f, r, test, s;
for ( i = 0; i < Tests.length; i++ ) {
test = Tests[ i ];
switch ( typeof test.f ) {
case "function":
f = test.f;
s = f.name;
break;
case "string":
s = test.f;
f = LIB[ s ];
break;
default:
f = false;
} // switch typeof test.f
if ( typeof f === "function" ) {
if ( typeof test.a !== "object" ) {
test.a = null;
}
Console.log( " ....................... " + i + ". "
+ s + "( " + test.a + " )" );
try {
r = f.apply( LIB, test.a );
switch ( typeof r ) {
case "boolean":
case "number":
case "string":
Console.log( r );
if ( typeof test.r !== "undefined" ) {
if ( test.r === r ) {
Console.log( " ... ===" );
} else {
Console.log( " !!!!!!!! !==" );
}
}
break;
case "object":
if ( r &&
typeof Console.dir === "function" ) {
Console.dir( r );
} else if ( r ) {
Console.log( "{object}" );
} else {
Console.log( "{null}" );
}
break;
} // switch typeof r
} catch ( e ) {
Console.log( "ERROR " + s + "()",
test.a );
Console.log( e );
}
} else {
Console.error( "!!!! isbnLib.QUNIT.factory() f " + i );
}
} // for i
} // factory()
function featuring() {
/**
Add external tests
@version 2016-04-02 PerfektesChaos@de.wikipedia
*/
var i, test;
if ( typeof LIB.qunit === "object"
&& LIB.qunit &&
typeof LIB.qunit.length === "number" ) {
for ( i = 0; i < LIB.qunit.length; i++ ) {
test = LIB.qunit[ i ];
if ( typeof test === "object"
&& test &&
typeof test.f === "string"
&& test.f ) {
if ( typeof test.a !== "object" ) {
test.a = null;
}
if ( test.a &&
typeof test.a.length !== "number" ) {
test.a = null;
}
Tests.push( test );
} else {
Console.error( "!!!!!!!! invalid external test #" + i );
}
} // for i
}
} // featuring()
function fed( application ) {
/**
Callback from library
@version 2016-04-02 PerfektesChaos@de.wikipedia
@param application library object
*/
if ( typeof application === "object" ) {
LIB = application;
Console.log( ">>>>>>>>>>>>>>>>>> " + LIB.type + " " + LIB.vsn );
featuring();
factory();
} else {
Console.error( "isbnLib.QUNIT.fed() " + typeof application );
}
} // fed()
function first() {
/**
Internal initialization, last attempt to attach libraries
@version 2018-09-04 PerfektesChaos@de.wikipedia
*/
var rls = { };
rls[ Signature + ".qunit" ] = "ready";
mw.loader.state( rls );
if ( typeof window === "object" &&
typeof window.console === "object"
&& window.console &&
typeof window.console.log === "function" ) {
Console = window.console;
if ( typeof Console.clear === "function" ) {
Console.clear();
}
Console.log( "=========== " + LIB + " " + " QUNIT " + Version );
}
if ( Console ) {
if ( ! mw.loader.getState( Signature ) ) {
rls = { };
rls[ Signature ] = "loading";
mw.loader.load( "https://en.wikipedia.org/w/index.php?"
+ "title=User:PerfektesChaos/js/"
+ LIB + "/r.js"
+ "&bcache=1&maxage=600"
+ "&action=raw&ctype=text/javascript" );
}
mw.hook( LIB + ".ready" ).add( fed );
}
} // first()
// autoInit onLoad
first();
}( window.mediaWiki ) );
// Emacs
// Local Variables:
// coding: iso-8859-1-dos
// fill-column: 80
// End:
/// EOF </nowiki> isbnLib/qunit.js