Difference between revisions of "Template:Greece/master script"

Line 1: Line 1:
 
console.log('master script');
 
console.log('master script');
 +
console.log('Location: ' + window.location.href);
 +
console.log('Referrer: ' + document.referrer);
 +
console.log('KEY: ' + sessionStorage.getItem('KEY'));
 +
console.log('LINK: ' + sessionStorage.getItem('LINK'));
 +
  
 
                 (function($) {
 
                 (function($) {

Revision as of 19:33, 27 September 2017

console.log('master script'); console.log('Location: ' + window.location.href); console.log('Referrer: ' + document.referrer); console.log('KEY: ' + sessionStorage.getItem('KEY')); console.log('LINK: ' + sessionStorage.getItem('LINK'));


                (function($) {
                    $.fn.goTo = function() {
                      $('html, body').animate({
                         scrollTop: $(this).offset().top + 'px'}, 1000);
                      return this; // for chaining...
                    }
                 })(jQuery);

var ref = document.location.href; var loc = 'https://2017.igem.org/Team:Greece/'+ sessionStorage.getItem('KEY');

if(!['Project', 'Model', 'human_practices', 'Achievements', 'Team'].indexOf(sessionStorage.getItem('KEY')) > -1 ){ console.log('If statement with indexof was executed'); if(ref !== loc || ref !== loc + '#'){ sessionStorage.setItem('KEY', ref.substr( ref.indexOf('Greece/')+7, ref.length )); } }

var master = sessionStorage.getItem('KEY'); var link = sessionStorage.getItem('LINK'); if(link != null){ history.replaceState(null, null, link); document.title = link.toUpperCase();

if(ref !== loc || ref !== loc + '#'){

  if(sessionStorage.getItem('LINK') !== master){
      sessionStorage.setItem('LINK', master);
  }

} }