To get updates on new site content, like us on Facebook or follow us on Twitter.

Difference between revisions of "MediaWiki:Common.js"

From JFA Wiki
Line 42: Line 42:
 
event.preventDefault();
 
event.preventDefault();
 
//var jfa_plaintext = jQuery("#jfa-plaintext table tr:eq(1) td:eq(0)").html();
 
//var jfa_plaintext = jQuery("#jfa-plaintext table tr:eq(1) td:eq(0)").html();
var jfa_plaintext3 = jQuery("#jfa-plaintext table tr:eq(1)").text();
+
var jfa_plaintext = jQuery("#jfa-plaintext table tr:eq(1)").text();
 +
 +
// double up newlines to create blank line
 +
//someText = someText.replace(/(\r\n|\n|\r)/gm,"\n\n");
 +
jfa_plaintext = jfa_plaintext.replace(new RegExp('\r?\n','g'), '<br />');
 +
 
//jfa_copy_to_clipboard(jfa_short_url);
 
//jfa_copy_to_clipboard(jfa_short_url);
alert (jfa_plaintext3);
+
alert (jfa_plaintext);
 
 
 
});
 
});

Revision as of 14:00, 9 February 2019

/* Any JavaScript here will be loaded for all users on every page load. */

//Insert 'Justice for Animals .org' in the DOM, for the header jQuery(document).ready(function () {

document.body.insertAdjacentHTML( 'afterbegin', '

<a href="/Main_Page">Justice for Animals .org</a>

');

})

// copy to clipboard function //https://stackoverflow.com/questions/33855641/copy-output-of-a-javascript-variable-to-the-clipboard function jfa_copy_to_clipboard (text) {

   var dummy = document.createElement("textarea");
   document.body.appendChild(dummy);
   dummy.value = text;
   dummy.select();
   document.execCommand("copy");
   document.body.removeChild(dummy);

}

// handle share template jQuery(document).ready(function () { if ( jQuery( "#jfa-share" ).length ) {

// copy short url to clipboard var jfa_short_url = jQuery("span.jfa-page-shorturl a").attr("href");

// prevent bad hover tooltop jQuery(".jfa-share-option-url a").attr("href",jfa_short_url);

jQuery(".jfa-share-option-url a").click(function(event) { event.preventDefault(); //alert( "Handler for .click() called." ); jfa_copy_to_clipboard(jfa_short_url); alert("The short url for this page has been copied to your clipboard and is ready to paste!"); });

// if plain text exists, reveal second option and handle copy to clipboard if ( jQuery( "#jfa-plaintext" ).length ) { jQuery(".jfa-share-option-plaintext").css('display','inline');

// copy to clipboard on click jQuery(".jfa-share-option-plaintext a").click(function(event) { event.preventDefault(); //var jfa_plaintext = jQuery("#jfa-plaintext table tr:eq(1) td:eq(0)").html(); var jfa_plaintext = jQuery("#jfa-plaintext table tr:eq(1)").text();

// double up newlines to create blank line //someText = someText.replace(/(\r\n|\n|\r)/gm,"\n\n"); jfa_plaintext = jfa_plaintext.replace(new RegExp('\r?\n','g'), '
');

//jfa_copy_to_clipboard(jfa_short_url); alert (jfa_plaintext);

}); } }

})