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 5: Line 5:
 
document.body.insertAdjacentHTML( 'afterbegin', '<div id="jfatitle"><a href="/Main_Page">Justice for Animals .org</a></div>');
 
document.body.insertAdjacentHTML( 'afterbegin', '<div id="jfatitle"><a href="/Main_Page">Justice for Animals .org</a></div>');
 
})
 
})
 +
 +
 +
function jfa_copy_to_clipboard(val){
 +
    var dummy = document.createElement("input");
 +
    document.body.appendChild(dummy);
 +
    $(dummy).css('display','none');
 +
    dummy.setAttribute("id", "dummy_id");
 +
    document.getElementById("dummy_id").value=val;
 +
    dummy.select();
 +
    document.execCommand("copy");
 +
    document.body.removeChild(dummy);
 +
}
  
 
jQuery(document).ready(function () {
 
jQuery(document).ready(function () {
 
var jfa_short_url = jQuery("span.jfa-page-shorturl a").attr("href");
 
var jfa_short_url = jQuery("span.jfa-page-shorturl a").attr("href");
 
console.log(jfa_short_url);
 
console.log(jfa_short_url);
jQuery(".jfa-share-option-url a").attr("href",jfa_short_url);
+
//jQuery(".jfa-share-option-url a").attr("href",jfa_short_url);
 
 
 
jQuery(".jfa-share-option-url a").click(function(event) {
 
jQuery(".jfa-share-option-url a").click(function(event) {
 
event.preventDefault();
 
event.preventDefault();
alert( "Handler for .click() called." );
+
//alert( "Handler for .click() called." );
 +
jfa_copy_to_clipboard(jfa_short_url);
 
});
 
});
 
 
 
})
 
})

Revision as of 11:46, 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>

');

})


function jfa_copy_to_clipboard(val){

   var dummy = document.createElement("input");
   document.body.appendChild(dummy);
   $(dummy).css('display','none');
   dummy.setAttribute("id", "dummy_id");
   document.getElementById("dummy_id").value=val;
   dummy.select();
   document.execCommand("copy");
   document.body.removeChild(dummy);

}

jQuery(document).ready(function () { var jfa_short_url = jQuery("span.jfa-page-shorturl a").attr("href"); console.log(jfa_short_url); //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); });

})