User:PerfektesChaos/js/citoidWikitext/dewiki/d.js

/// User:PerfektesChaos/js/citoidWikitext/dewiki.js // Create insertion for local wiki /// 2020-02-20 PerfektesChaos@de.wikipedia // ResourceLoader: compatible; //   dependencies: -- /// Fingerprint: #0#0# /// @license: CC-by-sa/4.0 GPLv3 /// /* 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   = -4.7,       Signature = "citoidWikitext",       Sub       = "dewiki",       TBIBRC    = { },       TINTQU    = { },       TLITER    = { },       TSPIEG    = { },       WIKI      = { templates: { } },       CITWT, QUERY,       fair, fast, favorite, favour, favoured,       fiddle, findGoogleBooks, fixed, re2F, reGoogleBooks, urlPatterns;

function facilitated { // Mark sub-module as ready // Uses: //   >  Signature //   >  Sub //   >  Version //    < CITWT //    < .signature //    < .vsn //    < .type //   mw.loader.getState //   mw.loader.state //   mw.hook // 2018-08-24 PerfektesChaos@de.wikipedia var sign     = "ext.gadget." + Signature, sub      = "/" + Sub, signature = sign + sub, s        = mw.loader.getState( signature ), rls, w;     if ( s !== "loaded"  &&  s !== "ready" ) { rls = { }; rls[ signature ] = "loaded"; mw.loader.state( rls ); if ( typeof mw.libs[ Signature ] !==  "object"   ||              !      mw.libs[ Signature ] ) { mw.libs[ Signature ] = { }; }        CITWT = mw.libs[ Signature ]; CITWT.signature = sign; if ( typeof CITWT.vsn ===  "string" ) { CITWT.vsn = CITWT.vsn + " "; } else { CITWT.vsn = ""; }        CITWT.vsn  = CITWT.vsn + "w:" + Version; CITWT.type = Signature; if ( typeof CITWT[ Sub ] !==  "object"   ||              !      CITWT[ Sub ] ) { CITWT[ Sub ] = { }; }        w = CITWT[ Sub ]; if ( typeof w.templates !==  "object"   ||              !      w.templates ) { w.templates = { }; }        for ( s in WIKI.templates ) { w.templates[ s ] = WIKI.templates[ s ]; }  // for s in WIKI.templates for ( s in WIKI ) { if ( typeof WIKI[ s ] !==  "object" ) { w[ s ] = WIKI[ s ]; }        }   // for s in WIKI rls[ signature ] = "ready"; mw.loader.state( rls ); mw.hook( Signature + sub + ".ready" ).fire; }  }   // facilitated

//---

fair = function ( apply ) { // Minor string polishing // Precondition: //   apply  -- string, with title // Postcondition: //   Returns string with URL or keyword/data, or false // Uses: //   >< CITWT.re      //    >< CITWT.re.pipesc //   >< CITWT.re.pipestart //   >< CITWT.re.pipeterminate //   >< CITWT.re.wwwSub // 2019-11-26 PerfektesChaos@de.wikipedia var r = apply; if ( r ) { if ( r.indexOf( "&#124;" ) >=  0 ) { if ( typeof CITWT.re !==  "object" ) { CITWT.re =  { }; }           if ( r.indexOf( " &#124; " )  >=  0 ) { if ( typeof CITWT.re.pipesc ===  "undefined" ) { CITWT.re.pipesc = new RegExp( " &#124; ", "g" ); }              r = r.replace( CITWT.re.pipesc,                              String.fromCharCode( 32, 8211, 32 ) ); }           if ( ! r.indexOf( "&#124;" ) ) { if ( typeof CITWT.re.pipestart ===  "undefined" ) { CITWT.re.pipestart = new RegExp( "^(&#124; *)+" ); }              r = r.replace( CITWT.re.pipestart, "" ); }           if ( r.lastIndexOf( "&#124;" )  ===  r.length - 6 ) { if ( typeof CITWT.re.pipeterminate ===  "undefined" ) { CITWT.re.pipeterminate = new RegExp( "( *&#124;)+$" ); }              r = r.replace( CITWT.re.pipeterminate, "" ); }        }         if ( ! r.indexOf( "www" ) ) { if ( typeof CITWT.re !==  "object" ) { CITWT.re =  { }; }           if ( typeof CITWT.re.wwwSub  ===  "undefined" ) { CITWT.re.wwwSub = new RegExp( "^(www[0-9]*.?\\.)"                                            + "\\w+\\.\\w+",                                             "g" ); }           r = r.replace( CITWT.re.wwwSub, "" ); }     }      return r;   };   // fair

fast = function ( all, address ) { // ID parameters of Vorlage:Literatur or Vorlage:BibRecord // Precondition: //   all      -- Array, with all assignments; [0] === assembly //   address  -- string, with URL // Postcondition: //   Modifies Array with template transclusion //   Returns string, with address, or false // Uses: //   >< urlPatterns // 2020-02-20 PerfektesChaos@de.wikipedia var r = address, s = address, e, g, i, n;     if ( typeof urlPatterns  !==  "object" ) { urlPatterns = [ [ "//arxiv\\.org/abs/(.+)$", "arXiv" ], [ "//adsabs\\.harvard\\.edu/(.+)$", "bibcode" ], [ "//portal\\.dnb\\.de/opac.+query=([0-9]+X?)$", "DNB" ], [ "//doi\\.org/(10\\.[^ ]+)(?: .*)?$", "DOI" ], [ "//dx\\.doi\\.org/(10\\.[^ ]+)(?: .*)?$", "DOI" ], [ "jstor\\.org/pss/(.+)$", "JSTOR" ], [ "jstor\\.org/stable/([0-9.a-z]+)(?:\\?seq=1.+)?$", "JSTOR" ], [ "jstor\\.org/discover/10\\.2307/([0-9.a-z]+)(?:\\?uid=.+)?$", "JSTOR" ], [ "www\\.worldcat\\.org/oclc/(.+)$", "OCLC" ], [ "ncbi\\.nlm\\.nih\\.gov/pmc/articles/pmc([0-9]+)", "PMC" ], [ "ncbi\\.nlm\\.nih\\.gov/pubmed/([0-9]+)", "PMID" ], [ "//nbn\\-resolving\\.de/urn:(.+)$", "URN" ], [ "//urn\\.nb\\.no/urn:(nbn:.+)$", "URN" ], [ "//urn\\.kb\\.se/resolve\\?urn=(.+)$", "URN" ] ];        n = urlPatterns.length; for ( i = 1; i < n;  i++ ) { urlPatterns[ i ][ 0 ] = new RegExp( urlPatterns[ i ][ 0 ] ); }  // for i      } else { n = urlPatterns.length; }     if ( s.indexOf( "%2F" )  > 0 ) { if ( typeof re2F !==  "object" ) { re2F = new RegExp( "%2F", "ig" ); }        s = s.replace( re2F, "/" ); }     for ( i = 1;  i < n;  i++ ) { e = urlPatterns[ i ]; g = s.match( e[ 0 ] ); if ( g ) { s = e[ 1 ]; r = CITWT.opus.fetch( all[ 0 ], s ); if ( ! r ) { // alle all flöhen for ( i = 1; i < all.length;  i++ ) { if ( all[ i ][ 0 ] === s ) { r = true; break;  // for i                  } }  // for i               if ( ! r ) { all.push( [ s, true, g[ 1 ] ] ); }           }            r = false; break;  // for i         } }  // for i      return r;   };   // fast

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: //   >  Signature //   >  QUERY //   console.log //   console.dir //   (QUERY.finish) // 2018-07-22 PerfektesChaos@de.wikipedia if ( typeof window.console ===  "object"   &&           typeof window.console.log  ===  "function" ) { window.console.log( Signature + " * " + 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) // 2018-01-01 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

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 //   fair //   console.log // 2020-02-20 PerfektesChaos@de.wikipedia var isbn = ( typeof assembly.ISBN ===  "object"                   &&     assembly.ISBN.length ), r   = CITWT.opus.fork( apply ), e, i, issn, g, l, re, red, 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  &&                    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 ); }              }               g = WIKI.family( assembly, "contributors" ); if ( g ) { if ( v ) { v = v + ", " + g;                 } else { v = g;                 } }              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" ); v = fair( v ); break; case "Sammelwerk": v = CITWT.opus.fetch( assembly, "publicationTitle" ); if ( v ) { v = fair( v ); if ( v === "Frankfurter Allgemeine Zeitung" ) { v = "FAZ"; }              }               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 ) { red = new RegExp( " *\\b(Aufl\\.?" +                                      "|Auflage" + "|ed\\.?" +                                      "|Edition)",                                       "gi" ); 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 ) ] ); }                 v = fast( r, v ); if ( ! v ) { l = true; }              } 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": case "LCCN": case "OCLC": if ( isbn ) { s = "-"; }  // fall through case "arXiv": case "DOI": 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 "Abruf": case "Sprache": case "GBS-id": // BibRecord v = ""; break; case "Seite": case "Spalten": case "Typ": case "Kommentar": case "record": case "format": // BibRecord v = ""; 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 ], [ "Abruf",              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 // 2019-06-16 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 ] = ""; }     }   // for s 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  ], [ "abruf",        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 //   fair //   WIKI.family //   .opus.freeze // 2019-11-25 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" ); v = fair( v ); maker = i;              break; case "titel": v = CITWT.opus.fetch( assembly, "title" ); v = fair( v ); break; case "werk": v = CITWT.opus.fetch( assembly, "publicationTitle" ); if ( v ) { v = fair( v ); switch ( v ) { case "Frankfurter Allgemeine Zeitung": v = "FAZ"; break; case "Spiegel Online": v = "Spiegel Online"; break; }  // switch v               } else { 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 "abruf": 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  ], [ "ISBN",            false ], [ "ISBNformalFalsch", false ], [ "Kapitel",         false ], [ "Seiten",          true  ], [ "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 // 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 string with list of persons, or false // 2018-07-14 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 ===  "object"   &&   e ) { 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 + "]"; }           } else { s = false; }           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; }( window.mediaWiki, window.jQuery ) );

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

/// EOF  citoidWikitext/dewiki/d.js