MediaWiki:Common.js: Difference between revisions

From Asian Canadian Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


var _gaq = _gaq || [];
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  _gaq.push(['_setAccount', 'UA-34237691-1']);
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  _gaq.push(['_trackPageview']);
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  (function() {
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  ga('create', 'UA-40836383-1', 'asiancanadianwiki.org');
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   ga('send', 'pageview');
   })();


onload=function(){
onload=function(){

Revision as of 15:16, 15 May 2013

/* Any JavaScript here will be loaded for all users on every page load. */

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-40836383-1', 'asiancanadianwiki.org');
  ga('send', 'pageview');

onload=function(){
  if (document.getElementsByClassName == undefined) {
    document.getElementsByClassName = function(className) {
      var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
        var allElements = document.getElementsByTagName("*");
        var results = [];

        var element;
        for (var i = 0; (element = allElements[i]) != null; i++) {
          var elementClass = element.className;
          if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
            results.push(element);
          }
        return results;
      }
    }
    makeExt('external');
    function makeExt(lclass) {
      links = document.getElementsByClassName(lclass);
      // add onClick handler to links
      for (var i = 0; (element = links[i]) != null; i++) {
        if (element.href.toLowerCase().indexOf("asiancanadianwiki.org") < 0) {
          element.href = "/frame/?l="+escape(element.href);
        }
      }
    }
}