MediaWiki

MediaWiki:HighlightTermsURL.js

Revision as of 09:40, 11 July 2008 by Acyuta (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//jQuery function to parse url_terms from url when current page was linked from Vaniquotes
//The vaniquotes link was modified to include these url_terms in order to highlight them in the current page in Vanisource

document.write('<script type="text/javascript" src="'+$jquery_dir+'/Jquery.highlight_sanskrit.js"'+$raw_mode+'></script>');
document.write('<script type="text/javascript" src="'+$jquery_dir+'/Jquery.getParams.js'+$raw_mode+'"></script>');

$(document).ready(function() {
  //First check if the current page is an Article
  if (wgIsArticle && location.search && wgAction == "view") {
    if (this.location.search) {
      var url_string = $.getURLParam('terms');
      var url_terms = decodeURI(url_string).split('+');
      if (url_terms.length > 0 ) {
        for (var i = 0, len = url_terms.length; i < len; ++i) {
          //sanitize text for search
          if (url_terms[i] != "") {
            url_term = url_terms[i];
            $('#bodyContent').highlight_sanskrit(url_term);
          }
        }
      }
      $.scrollTo('span.highlight_terms', '1500', {offset:-100});
    }
  }
});