Team:Uppsala/JavaScript

From 2014.igem.org

(Difference between revisions)
Line 47: Line 47:
   var button = $('.view');
   var button = $('.view');
   var op = $(button).css("opacity");
   var op = $(button).css("opacity");
 +
  var zi = $(button).css("z-index");
    
    
-
   if (!button.is(e.target) && op == 1)
+
   if (!button.is(e.target) && op == 1 && zi == 950)
{
{
   toggleVisibility('intro');
   toggleVisibility('intro');

Revision as of 19:06, 5 August 2014

jQuery(document).ready(function() {

   var button = ('.back-to-top'), timer;
   var offset = 500;
   var duration = 1000;
 jQuery(window).scroll(function() {
       if (jQuery(this).scrollTop() > offset) {
           jQuery(button).fadeIn(duration);
           clearTimeout(timer);
           timer = setTimeout(function() {
           jQuery(button).stop(true, true).fadeOut(duration);}, 2000);    
       }
        
        if (jQuery(this).scrollTop() < offset) {
        jQuery(button).fadeOut(duration);
        }
        
  });
      
   jQuery(button).click(function(event) {
       event.preventDefault();
       jQuery('html, body').animate({scrollTop: 0}, duration);
       return false;
   });

});

/* jQuery(document).ready(function() {

  var button = ('#intro');
  $(button).click(function() {
  var op = $(button).css("opacity");
  if (op == 1)

{

  toggleVisibility('intro');

}

  });
  

});

  • /

jQuery(document).ready(function() {


  $(document).click(function(e) {
  var button = $('.view');
  var op = $(button).css("opacity");
  var zi = $(button).css("z-index");


  if (!button.is(e.target) && op == 1 && zi == 950)

{

  toggleVisibility('intro');

}

  });
  

});

var keys = {};

$(document).keydown(function (e) { $('#secret').remove();

   keys[e.which] = true;
   printKeys();

});

function printKeys() {

   var html = ;

var test = 0;

   for (var i in keys) {

if( i == 69 || i == 71 || i == 73 || i ==77) test++ else test--

   }

if (test==4) { var img = $('<img />',{ id: 'secret', src: 'https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xfa1/t1.0-9/p417x417/10389042_690342884367707_4283038089202479847_n.jpg', alt:'MyAlt'}).appendTo($('#imagediv')); test=0; keys = {}; img.fadeOut( 2000 ); } else if(test < 0) keys = {}; }