MediaWiki:Common.js: Difference between revisions

From Fischer Diaries

(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: $(document).ready(function() { $(document).keydown(function(e) { switch(e.which) { case...")
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:
     }
     }
   });
   });
  if ($('a[rel="prev"]').length > 0 || $('a[rel="next"]').length > 0) {
    // check cookie
    var visited = $.cookie("display-navigation")
    if (visited == null) {
  $('#footer').append('<div id="navigationHelp" class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-body"><p>You can navigate between dates by hitting left and right arrows.</p></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div></div></div></div>');
      $('#navigationHelp').modal('show');
    }
    var date = new Date();
    date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
    // set cookie
    $.cookie('display-navigation', 'yes', { expires: date, path: '/' });
  }
});
});

Latest revision as of 20:45, 28 March 2020

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
  $(document).keydown(function(e) {
    switch(e.which) {
      case 37: // left
        if ($('a[rel="prev"]').length > 0) {
          $('a[rel="prev"]')[0].click();
          e.preventDefault(); // prevent the default action (scroll / move caret)
        }
        break;

      case 39: // right
        if ($('a[rel="next"]').length > 0) {
          $('a[rel="next"]')[0].click();
          e.preventDefault(); // prevent the default action (scroll / move caret)
        }
        break;
     default: return; // exit this handler for other keys
    }
  });

  if ($('a[rel="prev"]').length > 0 || $('a[rel="next"]').length > 0) {
    // check cookie
    var visited = $.cookie("display-navigation")

    if (visited == null) {
	  $('#footer').append('<div id="navigationHelp" class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-body"><p>You can navigate between dates by hitting left and right arrows.</p></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div></div></div></div>');
      $('#navigationHelp').modal('show');
    }

    var date = new Date();
    date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
    // set cookie
    $.cookie('display-navigation', 'yes', { expires: date, path: '/' });
  }
});