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 23:51, 26 September 2011 (initial creation of mouseover popup). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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(){
 
//When you mouse over a SWL indicated by its 'genewiki' class, get the elelements of the link   
   $(".swl").hover(function() {
    //get semantic information out
    var subject = "";  var predicate = ""; var object = "";
    var triple_ = $(this).attr('id');
	var triple = triple_.split("--");
    subject = triple[0];
	predicate = triple[1];
    object = triple[2];
    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;
});
 
 
 
});