/// Entlehnt aus User:PerfektesChaos/js/citoidWikitext/dewiki.js
// Create insertion for local wiki
/// 2017-06-11 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: --
/// Fingerprint: #0#0#
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
/// <nowiki>
/* global window: false */
/* jshint forin: false,
bitwise:true, curly:true, eqeqeq:true, latedef:true,
laxbreak:true,
nocomma:true, strict:true, undef:true, unused:true */
( function ( mw ) {
"use strict";
var VERSION = -3.33,
MW_LIB = "citoidWikitext",
Sub = "dewiktionary",
TBIBRC = { },
TINTQU = { },
TLITER = { },
TSPIEG = { },
CITWT, QUERY, WIKI,
favorite, favour, favoured,
fiddle, findGoogleBooks, fixed, reGoogleBooks;
if ( typeof mw.libs[ MW_LIB ] !== "object" ||
! mw.libs[ MW_LIB ] ) {
mw.libs[ MW_LIB ] = { };
}
CITWT = mw.libs[ MW_LIB ];
if ( typeof CITWT.vsn === "string" ) {
CITWT.vsn = CITWT.vsn + " ";
} else {
CITWT.vsn = "";
}
CITWT.vsn = CITWT.vsn + "w:" + VERSION;
CITWT.type = MW_LIB;
if ( typeof CITWT[ Sub ] !== "object" || ! CITWT[ Sub ] ) {
CITWT[ Sub ] = { };
}
WIKI = CITWT[ Sub ];
if ( typeof WIKI.templates !== "object" || ! WIKI.templates ) {
WIKI.templates = { };
}
function facilitated() {
// Mark sub-module as ready
// Uses:
// > Sub
// > .type
// < .signature
// mw.loader.getState()
// mw.loader.state()
// mw.hook()
// 2016-01-02 PerfektesChaos@de.wikipedia
var sub = "/" + Sub,
signature;
CITWT.signature = "ext.gadget." + CITWT.type;
signature = CITWT.signature + sub;
if ( mw.loader.getState( signature ) !== "ready" ) {
mw.loader.state( signature, "ready" );
mw.hook( CITWT.type + sub + ".ready" ).fire();
}
} // facilitated()
//-----------------------------------------------------------------------
favorite = function () {
// Additional research result
// Postcondition:
// Returns Array, with template transclusion
// Uses:
// > QUERY.scheme
// > QUERY.seek
// 2017-06-11 PerfektesChaos@de.wikipedia
return [ [ QUERY.scheme + "|" + QUERY.seek,
false,
true ] ];
}; // favorite()
favour = function ( jqXHR, textStatus /* , errorThrown */ ) {
// Additional research failed
// Uses:
// > QUERY
// console.log()
// console.dir()
// (QUERY.finish)
// 2017-06-07 PerfektesChaos@de.wikipedia
if ( typeof window.console === "object" &&
typeof window.console.log === "function" ) {
window.console.log( CITWT.type + " * " + Sub );
if ( textStatus &&
typeof textStatus === "object" &&
typeof window.console.dir === "function" ) {
window.console.dir( textStatus );
}
}
if ( QUERY ) {
QUERY.finish( false );
}
}; // favour()
favoured = function ( arrived ) {
// Additional research returned
// Precondition:
// arrived -- object, full result
// Uses:
// > QUERY.scheme
// >< QUERY
// < QUERY.priority
// (QUERY.finish)
// 2017-06-11 PerfektesChaos@de.wikipedia
var r;
if ( arrived && typeof arrived === "object" &&
typeof arrived.query === "object"
&& arrived.query &&
typeof arrived.query.pageids === "object"
&& arrived.query.pageids[ 0 ] &&
typeof arrived.query.pageids[ 0 ] === "string"
&& arrived.query.pageids[ 0 ].indexOf( "-" ) < 0 ) {
QUERY.priority = true;
r = QUERY.scheme;
} else {
r = false;
}
QUERY.finish( r );
if ( ! r ) {
QUERY = false;
}
}; // favoured()
fiddle = function ( assembly ) {
// Improve ISBN
// Precondition:
// assembly -- combined result
// mw.libs.WikiSyntaxTextMod.util has been loaded
// Postcondition:
// Modifies assembly, if appropriate
// Uses:
// mw.libs.WikiSyntaxTextMod.util.isbn.faith()
// 2015-06-27 PerfektesChaos@de.wikipedia
var n, s, wstm;
if ( typeof assembly[ "ISBN-type" ] === "number" &&
typeof assembly[ "ISBN-invalid" ] === "boolean" &&
! assembly[ "ISBN-invalid" ] &&
typeof assembly.year === "number" ) {
n = assembly[ "ISBN-type" ];
if ( ( assembly.year < 2007 ) === ( n === 13 ) ) {
if ( typeof mw.libs.WikiSyntaxTextMod === "object" ) {
wstm = mw.libs.WikiSyntaxTextMod;
s = assembly.ISBN[ 0 ];
if ( typeof wstm.util === "object" &&
typeof wstm.util.isbn.faith === "function" ) {
if ( n === 13 ) {
s = s.substr( 4 );
} else {
s = "978-" + s;
}
s = s.substr( 0, s.length - 1 );
n = wstm.util.isbn.faith( s, n );
if ( n >= 0 ) {
if ( n < 10 ) {
s = s + n;
} else {
s = s + "X";
}
assembly.ISBN[ 0 ] = s;
}
}
}
}
}
}; // fiddle()
findGoogleBooks = function ( address ) {
// Test for books.google.*
// Precondition:
// address -- string, with URL
// Postcondition:
// Returns true if assigned to books.google.*
// Uses:
// >< reGoogleBooks
// 2017-01-17 PerfektesChaos@de.wikipedia
if ( ! reGoogleBooks ) {
reGoogleBooks = new RegExp( "^https?://books\\.google\\."
+ "(?:com|[a-z][a-z])/" );
}
return reGoogleBooks.test( address );
}; // findGoogleBooks()
function getStringFromArray(v,assembly,prop) {
var i;
if (assembly[prop] instanceof Array && assembly[prop].length > 0) {
for (i = 0; i < assembly[prop].length; i++) {
if (assembly[prop][i] instanceof Array && assembly[prop][i].length > 0) {
v = (v || '') + assembly[prop][i].join('');
}
}
}
return v;
}
fixed = function ( assembly, all, apply ) {
// Format Vorlage:Literatur oder Vorlage:BibRecord
// Precondition:
// assigned -- object, with extended query result
// all -- Array, with all results; [0] === assembly
// apply -- Array, with template definition
// Postcondition:
// Returns Array with template transclusion
// Uses:
// this
// .opus.fork()
// WIKI.family()
// findGoogleBooks()
// .opus.freeze()
// .opus.fetch()
// console.log()
// 2017-06-11 PerfektesChaos@de.wikipedia
var isbn = ( typeof assembly.ISBN === "object"
&& assembly.ISBN.length ),
r = CITWT.opus.fork( apply ),
red = new RegExp( " *\\b(Aufl\\.|Auflage|ed\\.|Edition)",
"gi" ),
e, i, issn, g, l, re, s, v;
switch ( typeof assembly.ISSN ) {
case "string":
issn = assembly.ISSN;
break;
case "object":
if ( assembly.ISSN &&
typeof assembly.ISSN[ 0 ] === "string" ) {
issn = assembly.ISSN[ 0 ];
}
break;
} // switch typeof assembly.ISSN
for ( i = 1; i < r.length; i++ ) {
e = r[ i ];
l = false;
s = e[ 0 ];
v = false;
switch ( s ) {
case "Autor":
v = WIKI.family( assembly, "authors" );
if ( ! v && assembly.hasOwnProperty("author")) {
v = getStringFromArray(v, assembly, "author");
}
if ( ! v && assembly.hasOwnProperty("contributor")) {
v = getStringFromArray(v, assembly, "contributor");
}
if ( ! v &&
typeof assembly.title === "string" &&
all.length > 1 ) {
g = all[ 2 ];
if ( g.domain === "dnb.de" &&
typeof g.title === "string" &&
! g.title.indexOf( assembly.title ) ) {
v = g.title.substr( assembly.title.length );
}
}
break;
case "Hrsg":
case "Herausgeber":
v = WIKI.family( assembly, "editors" );
break;
case "Titel":
if ( typeof assembly.bookTitle === "string" ) {
if ( typeof assembly.title === "string" ) {
assembly.chapter = assembly.title;
}
assembly.title = assembly.bookTitle;
}
v = CITWT.opus.fetch( assembly, "title" );
break;
case "Sammelwerk":
v = CITWT.opus.fetch( assembly, "publicationTitle" );
break;
case "Reihe":
v = CITWT.opus.fetch( assembly, "seriesTitle" );
l = true;
break;
case "Band":
v = CITWT.opus.fetch( assembly, "volume" );
break;
case "Nummer":
v = CITWT.opus.fetch( assembly, "issue" );
break;
case "Auflage":
if ( issn ) {
l = true;
} else {
v = CITWT.opus.fetch( assembly, "edition" );
if ( v ) {
v = v.replace( red, "" );
}
}
break;
case "Verlag":
v = CITWT.opus.fetch( assembly, "publisher" );
if ( v ) {
re = new RegExp( " *GmbH" );
v = v.replace( re, "" );
}
break;
case "Ort":
if ( issn ) {
l = true;
} else {
v = CITWT.opus.fetch( assembly, "place" );
}
break;
case "Datum":
case "Jahr":
v = CITWT.opus.fetch( assembly, "date" );
if ( v && isbn ) {
v = v.substr( 0, 4 );
}
break;
case "Kapitel":
v = CITWT.opus.fetch( assembly, "chapter" );
l = true;
break;
case "Seiten":
v = CITWT.opus.fetch( assembly, "pages" );
if ( v && v.indexOf( "-" ) > 0 ) {
v = v.replace( /-/g, String.fromCharCode( 8211 ) );
}
break;
case "Online":
if ( typeof assembly.itemType === "string" &&
assembly.itemType.indexOf( "Article" ) > 0 &&
typeof assembly.url === "string" ) {
v = assembly.url;
if ( typeof assembly.domain === "string" ) {
v = "[" + v + " " + assembly.domain + "]";
}
if ( ! findGoogleBooks( v ) ) {
r.push( [ "Abruf",
true,
CITWT.opus.freeze( 10 ) ] );
}
} else {
l = true;
}
break;
case "Abruf":
l = true;
break;
case "ISBN":
if ( issn ) {
l = true;
} else if ( isbn ) {
if ( typeof apply.ISBNformalFalsch === "boolean" &&
CITWT.opus.fetch( assembly, "ISBN-invalid" ) ) {
v = false;
} else {
v = assembly.ISBN[ 0 ];
}
}
break;
case "ISBNistFormalFalsch":
if ( CITWT.opus.fetch( assembly, "ISBN-invalid" ) ) {
v = "1";
}
l = true;
break;
case "ISBNformalFalsch":
if ( CITWT.opus.fetch( assembly, "ISBN-invalid" ) ) {
if ( isbn ) {
v = assembly.ISBN[ 0 ];
}
} else {
v = false;
}
l = true;
break;
case "ISSN":
v = issn;
if ( isbn && ! v ) {
l = true;
}
// l = isbn;
break;
case "DNB":
if ( isbn ) {
s = "-";
} // fall through
case "arxiv":
case "DOI":
case "LCCN":
case "OCLC":
case "PMC":
case "PMID":
case "URN":
v = CITWT.opus.fetch( assembly, s.toUpperCase() );
l = true;
/*
if ( v &&
s === "PMID" &&
CITWT.opus.fetch( assembly, "PMC" ) ) {
v = false;
}
*/
if ( v && s === "PMC" &&
v.substr( 0, 3 ) === "PMC" ) {
v = v.substr( 3 );
}
break;
case "Originalsprache":
v = CITWT.opus.fetch( assembly, "originalLang" );
break;
case "TitelErg":
case "Originaltitel":
case "Übersetzer":
case "Linktext":
case "URL":
case "Zugriff":
case "Sprache":
case "GBS-id":
// BibRecord
v = "";
break;
case "Seite":
case "Spalten":
case "Typ":
case "Kommentar":
case "record":
case "format":
// BibRecord
v = "{{{" + s + "|}}}";
break;
default:
if ( typeof window.console === "object" &&
typeof window.console.log === "function" ) {
window.console.log( "citoidWikitext.dewiki.fixed() p="
+ s );
}
} // switch e[ 0 ]
e.push( v );
if ( l && ! v ) {
r[ i ] = false;
}
} // for i
s = CITWT.opus.fetch( assembly, "url" );
if ( s && findGoogleBooks( s ) ) {
// TODO Evaluation Vorlage:Google Buch
v = CITWT.opus.fetch( assembly, "domain" );
if ( v ) {
r.push( [ "Online",
true,
"[" + s + " books." + v + "]" ] );
}
}
return r;
}; // fixed()
//-----------------------------------------------------------------------
TBIBRC.template = [ [ "BibRecord", true, true, false ],
[ "Autor", true ],
[ "Herausgeber", true ],
[ "Titel", true ],
[ "TitelErg", true ],
[ "ISBN", true ],
[ "ISBNistFormalFalsch", true ],
[ "Jahr", true ],
[ "Verlag", true ],
[ "Ort", true ],
[ "Auflage", true ],
[ "Originaltitel", true ],
[ "Originalsprache", true ],
[ "Übersetzer", true ],
[ "Band", true ],
[ "Reihe", true ],
[ "Nummer", true ],
[ "Linktext", true ],
[ "URL", true ],
[ "Zugriff", true ],
[ "Sprache", true ],
[ "GBS-id", true ],
[ "Seite", true ],
[ "Seiten", true ],
[ "Spalten", true ],
[ "Typ", true ],
[ "Kapitel", true ],
[ "Kommentar", true ],
[ "record", true ],
[ "format", true ] ];
TBIBRC.fire = function ( assembly, all ) {
// Format Vorlage:BibRecord
// Precondition:
// assembly -- object, with extended query result
// all -- Array, with all results; [0] === assembly
// Postcondition:
// Returns string with template transclusion
// Uses:
// > TBIBRC.template
// .opus.fetch()
// fiddle()
// fixed()
// .opus.fruit()
// 2015-06-27 PerfektesChaos@de.wikipedia
var pass = { Kapitel: "chapter",
Seiten: "pages" },
r, s, supply;
for ( s in pass ) {
supply = pass[ s ];
if ( ! CITWT.opus.fetch( assembly, supply ) ) {
assembly[ supply ] = "{{{" + s + "|}}}";
}
} // for slang in pass
fiddle( assembly );
r = fixed( assembly, all, TBIBRC.template );
r = CITWT.opus.fruit( r, 0 );
return r;
}; // TBIBRC.fire()
//-----------------------------------------------------------------------
TINTQU.template = [ [ "Internetquelle", true, false, false ],
[ "url", true ],
[ "autor", false ],
[ "hrsg", true ],
[ "titel", true ],
[ "werk", true ],
[ "datum", false ],
[ "format", false ],
[ "sprache", false ],
[ "archiv-url", true ],
[ "archiv-datum", true ],
[ "offline", true ],
[ "zugriff", true ] ];
TINTQU.fire = function ( assembly ) {
// Format Vorlage:Internetquelle
// Precondition:
// assembly -- object, with extended query result
// Postcondition:
// Returns Array with template transclusion
// Uses:
// this
// > TINTQU.template
// .opus.fork()
// .opus.fetch()
// WIKI.family()
// .opus.freeze()
// 2017-02-07 PerfektesChaos@de.wikipedia
var r = CITWT.opus.fork( this.template ),
e, got, i, maker, re, stored, v;
for ( i = 1; i < r.length; i++ ) {
e = r[ i ];
v = false;
switch ( e[ 0 ] ) {
case "url":
v = CITWT.opus.fetch( assembly, "url" );
break;
case "autor":
v = WIKI.family( assembly, "authors" );
break;
case "hrsg":
v = CITWT.opus.fetch( assembly, "websiteTitle" );
if ( v ) {
v = v.replace( /^(www.?\.)\w+\.\w+$/, "" );
}
maker = i;
break;
case "titel":
v = CITWT.opus.fetch( assembly, "title" );
break;
case "werk":
v = CITWT.opus.fetch( assembly, "publicationTitle" );
if ( ! v ) {
v = CITWT.opus.fetch( assembly, "domain" );
}
if ( v ) {
v = v.replace( /^(www.?\.)\w+\.\w+$/, "" );
if ( v === r[ maker ][ 2 ] ) {
r[ maker ][ 2 ] = false;
}
}
break;
case "datum":
v = CITWT.opus.fetch( assembly, "date" );
break;
case "format":
v = CITWT.opus.format( assembly );
break;
case "sprache":
v = CITWT.opus.fetch( assembly, "language" );
break;
case "archiv-url":
v = CITWT.opus.fetch( assembly, "archive" );
if ( v ) {
if ( v.indexOf( "//web.archive.org/web/" ) > 0 ) {
re = "web\\.archive\\.org/web";
} else if ( v.indexOf( "//archive.is/" ) > 0 ) {
re = "archive\\.is";
} else {
re = false;
}
if ( re ) {
re = new RegExp( "^https?://" + re +
"/([12][9012][0-9][0-9])" +
"([01][0-9])" +
"([0-3][0-9])" +
"[0-9]+/" );
got = re.exec( v );
if ( got ) {
stored = got[ 1 ] + "-" +
got[ 2 ] + "-" +
got[ 3 ];
}
}
}
break;
case "archiv-datum":
if ( stored ) {
v = stored;
}
break;
case "offline":
break;
case "zugriff":
if ( ! stored ) {
v = CITWT.opus.freeze( 10 );
}
break;
} // switch e[ 0 ]
e.push( v );
} // for i
return r;
}; // TINTQU.fire()
//-----------------------------------------------------------------------
TLITER.template = [ [ "Literatur", true, true, false ],
[ "Autor", true ],
[ "Hrsg", false ],
[ "Titel", true ],
// [ "TitelErg", false ],
[ "Sammelwerk", false ],
[ "Reihe", false ],
[ "Band", false ],
[ "Nummer", false ],
[ "Auflage", false ],
[ "Verlag", true ],
[ "Ort", true ],
[ "Datum", true ],
[ "Kapitel", false ],
[ "Seiten", true ],
[ "ISBN", false ],
[ "ISBNformalFalsch", false ],
[ "ISSN", false ],
[ "Online", false ],
[ "Abruf", false ],
[ "arxiv", false ],
[ "DOI", false ],
[ "DNB", false ],
[ "LCCN", false ],
[ "OCLC", false ],
[ "PMC", false ],
[ "PMID", false ],
[ "URN", false ] ];
TLITER.fire = function ( assembly, all ) {
// Format Vorlage:Literatur
// Precondition:
// assembly -- object, with extended query result
// all -- Array, with all results; [0] === assembly
// Postcondition:
// Returns Array with template transclusion
// Uses:
// > TLITER.template
// TSPIEG.fire()
// fiddle()
// fixed()
// TINTQU.fire()
// 2015-06-27 PerfektesChaos@de.wikipedia
var r;
if ( assembly.domain === "spiegel.de" ) {
r = TSPIEG.fire( assembly );
} else {
fiddle( assembly );
r = fixed( assembly, all, TLITER.template );
}
if ( ! r ) {
r = TINTQU.fire( assembly );
}
return r;
}; // TLITER.fire()
//-----------------------------------------------------------------------
TSPIEG.template = [ [ "Der Spiegel", false, true ],
[ "ID", true ],
[ "Autor", false ],
[ "Titel", true ],
[ "Jahr", true ],
[ "Nr", true ] ];
TSPIEG.fire = function ( assembly ) {
// Format Vorlage:Der Spiegel
// Precondition:
// assembly -- object, with extended query result
// Postcondition:
// Returns Array with template transclusion, or false
// Uses:
// this
// > TSPIEG.template
// .opus.fork()
// WIKI.family()
// .opus.fetch()
// 2015-05-01 PerfektesChaos@de.wikipedia
var r = CITWT.opus.fork( this.template ),
e, i, v;
for ( i = 1; i < r.length; i++ ) {
e = r[ i ];
v = false;
switch ( e[ 0 ] ) {
case "ID":
if ( typeof assembly.url === "string" ) {
v = assembly.url.replace( /^.+print\/d-(\d+)\.html$/,
"$1" );
}
break;
case "Autor":
v = WIKI.family( assembly, "authors" );
if ( ! v &&
typeof assembly.year === "number" &&
assembly.year < 2000 ) {
r[ i ] = false;
}
break;
case "Titel":
v = CITWT.opus.fetch( assembly, "title" );
break;
case "Jahr":
v = CITWT.opus.fetch( assembly, "year" );
break;
case "Nr":
v = CITWT.opus.fetch( assembly, "issue" );
break;
} // switch e[ 0 ]
e.push( v );
} // for i
return r;
}; // TSPIEG.fire()
//-----------------------------------------------------------------------
WIKI.templates.Google_Buch = function ( appendix ) {
// Interprete {{Google_Buch}}
// Precondition:
// appendix -- string, with parameter sequence
// Postcondition:
// Returns string with URL or keyword/data, or false
// Uses:
// .core.fold()
// mw.util.rawurlencode()
// 2015-05-14 PerfektesChaos@de.wikipedia
var p = CITWT.core.fold( appendix ),
r = "http://books.google.";
if ( typeof p.Land === "string" && p.Land === "US" ) {
r = r + "com/books?";
} else {
r = r + "de/books?";
}
if ( typeof p.BuchID === "string" && p.BuchID ) {
r = r + "id=" + p.BuchID;
if ( typeof p.Band === "string" && p.Band ) {
r = r + "&pg=RA" + p.Band;
}
if ( typeof p.Seite === "string" && p.Seite ) {
r = r + "&pg=PA" + p.Seite;
}
if ( typeof p.SeitenID === "string" && p.SeitenID ) {
r = r + "&pg=" + p.SeitenID;
}
} else if ( typeof p.Suchbegriff === "string"
&& p.Suchbegriff ) {
r = r + "q=" + mw.util.rawurlencode( p.Suchbegriff );
} else {
r = false;
}
return r;
}; // WIKI.templates.Google_Buch()
//-----------------------------------------------------------------------
WIKI.stiff = "|book|bookSection|conferencePaper|dictionaryEntry|"
+ "encyclopediaArticle|journalArticle|magazineArticle|"
+ "manuscript|newspaperArticle|report|thesis|";
WIKI.family = function ( assembly, access ) {
// Create comma separated list of persons: given-name family-name
// Precondition:
// assembly -- object, with query result
// access -- string, with component name
// Postcondition:
// Returns Array with template transclusion, or false
// 2015-06-15 PerfektesChaos@de.wikipedia
var e, i, o, r, s;
if ( typeof assembly[ access ] === "object" ) {
o = assembly[ access ];
for ( i = 0; i < o.length; i++ ) {
e = o[ i ];
if ( typeof e.family === "string" ) {
s = e.family;
} else {
s = "";
}
if ( typeof e.given === "string" ) {
s = e.given + ( s ? " " : "" ) + s;
}
if ( typeof e.name === "string" ) {
if ( s ) {
s = s + " (" + e.name + ")";
} else {
s = e.name;
}
}
if ( typeof e.extra === "string" ) {
s = s + " [" + e.extra + "]";
}
if ( s ) {
r = ( r ? r + ", " : "" ) + s;
}
} // for i
} else {
r = false;
}
return r;
}; // WIKI.family()
WIKI.favorite = function ( ask, advance ) {
// Create additional research for local wiki
// Precondition:
// ask -- TASK.query with details
// .doi
// .isbn
// .pmid
// advance -- function, to report completion
// Postcondition:
// Returns object, with page query details
// .jq ajax spec
// .found function, if success
// .fault function, if failure
// false, if no favorite
// Uses:
// < QUERY
// mw.util.wikiScript()
// (favoured)
// (favour)
// 2017-06-11 PerfektesChaos@de.wikipedia
var support = "|doi|isbn|pmid|",
r, scheme, seek;
if ( typeof ask.scheme === "string" &&
support.indexOf( "|" + ask.scheme + "|" ) >= 0 ) {
scheme = "Bib" + ask.scheme.toUpperCase();
seek = ask[ ask.scheme ];
QUERY = ask;
QUERY.finish = advance;
QUERY.priority = false;
QUERY.scheme = scheme;
QUERY.seek = seek;
QUERY.beforeSend = "json";
r = { jq: { url: mw.util.wikiScript( "api" )
+ "?action=query&prop=revisions"
+ "&indexpageids&format=json"
+ "&titles=Template:" + scheme + "/" + seek
+ "&rvlimit=1" },
found: favoured,
fault: favour
};
} else {
QUERY = false;
}
return r;
}; // WIKI.favorite()
WIKI.fire = function ( assigned ) {
// Create insertion for local wiki
// Precondition:
// assigned -- Array, with query results
// [0] -- object, with extended query result
// [>0] -- objects, with further results
// false, if favorite
// Postcondition:
// Returns Array, with template transclusion
// string, for insertion
// false
// Uses:
// > QUERY
// > QUERY.priority
// > WIKI.stiff
// favorite()
// TBIBRC.fire()
// TLITER.fire()
// TINTQU.fire()
// 2017-06-07 PerfektesChaos@de.wikipedia
var lit, r, top;
if ( QUERY && QUERY.priority ) {
r = favorite();
} else if ( assigned ) {
top = assigned[ 0 ];
if ( CITWT.bibRecord ) {
if ( CITWT.bibRecord.launch ) {
r = TBIBRC.fire( top, assigned );
}
} else {
lit = ( top.isbn || typeof top.issn === "string" );
if ( ! lit &&
typeof top.itemType === "string" &&
WIKI.stiff.indexOf( "|" + top.itemType + "|" )
>= 0 ) {
lit = true;
}
if ( lit &&
typeof top.urlQuery === "string" &&
top.urlQuery.indexOf( "/wiki/" ) > 0 ) {
lit = false;
}
if ( lit &&
typeof top.itemType === "string" &&
top.itemType === "encyclopediaArticle" &&
typeof top.url === "string" &&
top.url.indexOf( "/w/index.php?title=" ) > 0 ) {
lit = false;
}
if ( lit ) {
r = TLITER.fire( top, assigned );
} else {
r = TINTQU.fire( top );
}
}
}
return r;
}; // WIKI.fire()
facilitated();
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/citoidWikitext/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript");
}( window.mediaWiki, window.jQuery ) );
// Emacs
// Local Variables:
// coding: utf-8-unix
// fill-column: 80
// End: