User:P999/sandbox/TVF testing01.js

/* TVF testing01.js   based on Toggle VF    sandbox version  TESTING ONLY  */ // timestamp of TVF testing.js   30 May 2022  1947

// NB:  alert only works with text enclosed in double quotes

// timestamp 27 May 0614

// based on  Toggle VF  24 May 2022 //

// $(alert("testing"));  //                          this works

// $(alert("testing " + mytemp) );    << this runs but says var undefined  with  var mytemp = (this).html;

// $( ".mw-jump-link" ).hide;            example

/* Toggle VF */

// timestamp 24 May 2022  1800

var currpgName = mw.config.get( 'wgPageName' ); var currURL = document.location.href; var prntable = currURL.endsWith("&printable=yes"); var torf = prntable.toString; var myFlag;  // must be defined here var currFlag; var dquote = '"'; var journtitle = "blank"; var myslice = "blank"; var ident = "blank";

function chkmyFlag { try{ currFlag=window.localStorage.getItem("myFlag"); } catch (e) { }

if (currFlag=="VF" && torf=="true") {    nullFlag;

dotogg; } }

chkmyFlag;

function nullFlag { try { window.localStorage.setItem("myFlag", "null"); } catch(e) { } } function setFlag { try { window.localStorage.setItem("myFlag", "VF"); } catch (e) { } } function clrFlag { try { window.localStorage.clear; } catch(e){ } }

// Printable VF Button

mw.loader.using( 'mediawiki.util', function { $( document ).ready( function { var prntVF = mw.util.addPortletLink ( 'p-coll-print_export', 'https://en.wikipedia.org/w/index.php?title=' + encodeURIComponent(currpgName) + '&printable=yes', "Printable VF test", "p-VF", "Voice-friendly version for printing [v]","v");

$( prntVF ).click( function { 			setFlag;			});

}); });

// Toggle VF Button

var next="center"; mw.loader.using( 'mediawiki.util', function { $( document ).ready( function { var ToggVF = mw.util.addPortletLink( "p-tb", "#", "Toggle VF test", "t-Toggle VF","Convert to Voice-Friendly format[4]",'4'); // alert('next is: ' + next); $( ToggVF ).click( function {			dotogg;		if (next=="center") {firstHeading.style.textAlign = "center";   		$( ".Template-Fact" ).hide; next="left"; }	else         {firstHeading.style.textAlign = "left";			$( ".Template-Fact" ).show; next="center";}	} ); } );

} );

// = = = = = = = = = = = = = = = = = = = =

function dotogg {

$( 'head' ).append( '' + ' ul { list-style: none; }' + ' ' );

$( ".wgCoordinates" ).hide; $( ".mw-headline[id='References'] " ).hide; $( ".mw-jump-link" ).hide; $( ".mw-message-box-warning" ).hide; $( ".reference" ).hide; $( "ol.references" ).hide; $( ".toc" ).hide; $( ".template" ).hide; $( ".Template-Fact" ).hide; $( ".collapsible" ).hide; $( ".navbox" ).hide; $( ".navbar" ).hide; $( ".thumb" ).hide; $( ".wikitable" ).hide; $( ".toccolours" ).hide; $( ".hatnote" ).hide; $( ".hlist" ).hide; $( ".mw-headline[id='External_Links'] " ).hide; $( "#External_links" ).hide;

//

$( ".ambox" ).hide; $( ".mbox" ).hide; $( ".ombox" ).hide; $( ".dmbox" ).hide; $( ".fmbox" ).hide; $( ".geobox" ).hide; $( ".messagebox" ).hide; $( ".warningbox" ).hide; $( ".sidebar" ).hide; $( ".infobox" ).hide; $( ".infobox.sisterproject" ).hide; $( ".infobox.subdivision" ).hide; $( ".dablink" ).hide; $( ".metadata" ).hide; $( ".editlink" ).hide; // $( "#siteSub" ).hide; $( ".printfooter" ).hide; $( "#catlinks, .catlinks" ).hide; $( "#footer" ).hide; $( "#header" ).hide; $( ".image" ).hide; $( ".metadata" ).hide; $( ".protected" ).hide; $( ".boilerplate" ).hide; $( ".mw-editsection-bracket" ).hide; $( ".mw-editsection" ).hide; $( ".noprint" ).hide; $( ".vector-menu-content-list" ).hide; $( ".vector-menu-heading-label" ).hide; $( ".wb-langlinks-edit" ).hide; $( ".mw-portlet" ).hide; $( ".portlet" ).hide; $( ".compact-ambox" ).hide; $( ".image" ).hide; $( ".thumbimage" ).hide; $( "table" ).hide;

$( 'a[href*="/wiki/ISBN_(identifier)"]').hide; $( 'a[href*="Special:BookSources"]').hide;

// $( 'a[rel*=”nofollow”][title*=”(identifier)”]' ).show;  shows all items in Bib

//  $('[rel*=”nofollow”][class$=”dentifier])”]' ).alert("found");

// alert("test in progress");      successfully displayed alert

// var text = $('a').text;

// journtitle = currpgName;  //  this works

// alert("nothing here 1");

/* $("p").click(function{  alert((this).html); });

// var mytemp = "whatever";                     //  this works // var mytemp = document.location.href;         //  this works // var mytemp = document.getElementsByTagName("p")[0].innerHTML;  mytemp is blank // var mytemp = document.getElementsByTagName("*")[0].innerHTML;  this brought up a lot of text including title of article and seems to be user info // var mytemp = document.getElementsByTagName("*")[1].innerHTML;   much text; looks same as found by * 0

// alert("testing: mytemp is " + mytemp);   this works

// $( "a" ).alert("test" + (this).html );

// alert( "You have " + $(".overdue").size + " books overdue." );        example

// $( "document.getElementsByTagName("p")[0].innerHTML']" ).show; // journtitle = 'found'; alert( "Current journtitle is " + journtitle + "." );

// alert( "Current journtitle is " + journtitle + "." );

/* $(".overdue").each( function {   alert("Your book is overdue."); });

/* this works!! // trying completely new method     AND IT WORKS!! $( "a[rel*='nofollow']" ).each( function {	alert("match found"); });

/* this works  proceeds item by item and shows popup $( "a[rel*='nofollow']" ).each( function {	alert("match found  " + $(".external text").text); });

// SO says this re chaining     a=$('[myc="blue"][myid="1"][myid="3"]');

// $("li.selectable a, td.selectable a").click(...   supp  ex of AND

//               $(".intro,.demo")   example of OR /*  This worked perfectly!

$( "a[class*='external'], a[rel='nofollow']" ).each( function {	alert("match found!!!"); });



// alert("nothing here 2");

// Problem found:  A stray  slash asterisk  in the section just below this code! Now AOK

/*  works perfectly $( "a[class*='external'], a[rel='nofollow']" ).each( function {     journtitle = "whatever you prefer";	 alert("match found: " + journtitle ); });

/* THIS CODE WORKS $( "a[class*='external'],a[rel='nofollow'],[header=’Bibliography’]" ).each( function {       journtitle = $(this).text;               alert("match found: " + journtitle + " --- ");

})



/*

$( "a[class*='external'],a[rel='nofollow'],[header=’Bibliography’]" ).each( function {        journtitle = $(this).text;        //   $("this").text(journtitle);         alert("match found: " + journtitle );       //  alert("match found: " + journtitle + " --- ");

});



// alert("nothing here 3");

// $('a').text;    $(“[header=’Bibliography’]”

// alert("nothing here 4");  //  this works, and I know the select a[rel*=   works, // so problem must be in how I am combining them ...

// $( "a[title*='identifie']" ).hide;  //  this hides all journal id numbers      << // $( "a[rel*='nofollow']" ).hide;    // this hides all id labels                 <<

// $( "a[class*='external'],a[rel='nofollow'],[header=’Bibliography’]" ).show;

// alert("nothing here 5");

// a=$('[myc="blue"][myid="1"][myid="3"]');  how to set - exam from OS

// $( "a[class*='external']" ).alert("Here I am");    DNW

// $( 'a[href*="/wiki/ISBN_(identifier)"]').hide;

// $( "a[class*='external']" ).alert("Here I am");   does nothing!

// a[title*='identifie'].ident = $(this).text;  ?? // alert('ident is ' + ident);   ?? // $( "a[class*='external'][rel*='nofollow']" )  <<  aok

/* $( "a[class*='external'][rel*='nofollow']" ).each( function {       journtitle = $(this).text;       firstchar = journtitle.substring(0,1);       // alert("this is firstchar  " + firstchar);        if (firstchar==dquote)          {              //      alert("this is firstchar  " + firstchar);                        document.writeln(('journtitle is ' + journtitle);

// return(false);

}	})

// rem  $(selector).text    <<  acc to W3 //  alert($(".external text").html);

// alert($(".external text").innerHTML); <<  this works, returning 'undefined'

// $('a').text;

// alert($(" class*='external text' rel='nofollow' href*=’//www’ ").innerHTML);

/*

this works:

// journtitle  = ($( "a[class*='external text'][rel*='nofollow']" )[0].innerHTML); // alert(journtitle);



// journtitle = ($( "[class*='citation journal']" )[0].innerHTML); // alert(journtitle);

// alert($( "a[class*='external text'][rel*='nofollow']" )[0].innerHTML);  <<  this works

// journtitle = $( 'a[href*="https://doi.org/"]').innerHTML; // alert(journtitle);

/* alert(journtitle + " +++ "); these  +++  appear at the very end of the data dump, proving that the whole mess is loaded into journtitle all at once; the only way to avoid this would be to use .each

// $('element').html(hyperLinkText); // write it somewhere

// alert($(".external text").$(this).text);

/* $( "a[class*='external'][rel*='nofollow']" ).each( function {       journtitle = $(this).html;       alert(journtitle.substring(0,1));        alert('journtitle is ' + journtitle);	})

*/ // $( "[class*='external'][rel*='nofollow'][class*='atitle']" ).alert('match');

// journtitle = ".external text.text"; // alert(journtitle);

// $( "[journtitle]" ).show;

// ACTIVE  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

alert("1944");

$( "[title*='identifie']" ).hide;  //  this hides all journal ident numbers $( "[rel*='nofollow']" ).hide; // this hides all ident labels

// $( "[rel*='nofollow'][class*='external']" ).journtitle=$('a').text; NG

journtitle = ($( "a[class*='external text'][rel*='nofollow']" )[0].innerHTML); alert("journtitle is " + journtitle); myslice=$journtitle.slice(0,1); alert("myslice is " + myslice); if (myslice != '"' ) hide$('a'); // if (myslice == '"' ) show$('a');

/* NOTE: I have removed $( 'a[href*="/wiki/ASIN_(identifier)"]').hide; and other similars bc now dealt with by the global code $( "a[title*='identifie']" ).hide;

// +++  rem -- I still need to deal with  archived  and those linked-to numbers  +++

}

// --