Jump to content

User:I9606/swl viewer.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by I9606 (talk | contribs) at 01:22, 27 September 2011. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// User scripts

//operates on pages where it can find semantic wiki links
$(document).ready(function(){
var subject = document.title.split("-")[0];
//<span class="swl" id="Phospholamban--substrate_for--protein_kinase_A">
//<span class="substrate"><a href="/wiki/Protein_kinase_A" title="Protein kinase A">
//<span title="Phospholamban substrate for PKA" style="border-bottom:1px dotted orange">protein kinase A</span>
//</a></span></span>

//When you mouse over a SWL indicated by its 'swl' class, get and show the elelements of the link   
   $(".swl").hover(function() {
console.log("hovering");
    //get semantic information out
      var predicate = ""; var object = "";
//<span class="swl">
//<span class="phosphorylated_by"><a href="/wiki/Protein_kinase_A" title="Protein kinase A">

	predicate = $("span",this).attr('class');
    object = $("a",this).attr('title');
    var link = "<a href=\"http://en.wikipedia.org/wiki/Category:SWL/"+predicate+"\">"+predicate+"</a>";
	console.log("embedded triple is "+ subject +" "+ predicate+" " + object);
    //add the info box holder
//render a clickable pop up window
    //Fade in Background to hide page
    $('body').append('<div id="fade"></div>'); 
    $('#fade').css({'filter' : 'alpha(opacity=50)'}).fadeIn(); 
    //display the information box
    $("body").append('<div id="popup_swl" class="popup_block">'+ subject +" "+link+" " + object +' <a href="#" class="close">(close)</a></div>');
    $("#popup_swl").css({'filter' : 'alpha(opacity=10)'}).fadeIn();
},
//handle mouse out
  function () {
//    $("#popup_swl").hide();
  }
);

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
        $("#popup_swl").remove();
    });
    return false;
});

});