MediaWiki:Common.js: Difference between revisions

From Asian Canadian Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
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. */
function include(filename) {
var head = document.getElementsByTagName('head')[0];
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
head.appendChild(script)
}


include('/js/jquery-1.3.2.js');
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
include('/js/jquery.history.js');
  (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 = [];


include('/js/jquery.galleriffic.js');
        var element;
include('/js/jquery.opacityrollover.js');
        for (var i = 0; (element = allElements[i]) != null; i++) {
//include('/js/jquery.dogallery.js');
          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);
        }
      }
    }
}


alert("glarg");
function include(url){  
jQuery(document).ready(function($) {
     if(url.match(/\.js$/)) {
    var gallery = $('#thumbs');
         type = 'text/javascript';
     if (gallery) {
alert(gallery);
        gallery.galleriffic({
        delay:                    3000, // in milliseconds
        numThumbs:                20, // The number of thumbnails to show page
        preloadAhead:              40, // Set to -1 to preload all images
        enableTopPager:            false,
        enableBottomPager:        true,
        maxPagesToShow:            7,  // The maximum number of pages to display in either the top or bottom pager
        imageContainerSel:        '', // The CSS selector for the element within which the main slideshow image should be rendered
        controlsContainerSel:      '', // The CSS selector for the element within which the slideshow controls should be rendered
        captionContainerSel:      '', // The CSS selector for the element within which the captions should be rendered
        loadingContainerSel:      '', // The CSS selector for the element within which should be shown when an image is loading
        renderSSControls:          true, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:        true, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:              'Play',
        pauseLinkText:            'Pause',
        prevLinkText:              'Previous',
        nextLinkText:              'Next',
        nextPageLinkText:          'Next &rsaquo;',
        prevPageLinkText:          '&lsaquo; Prev',
        enableHistory:            true, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
        enableKeyboardNavigation:  true, // Specifies whether keyboard navigation is enabled
        autoStart:                true, // Specifies whether the slideshow should be playing or paused when the page first loads
        syncTransitions:          false, // Specifies whether the out and in transitions occur simultaneously or distinctly
        defaultTransitionDuration: 1000, // If using the default transitions, specifies the duration of the transitions
        onSlideChange:            undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:          undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
        onTransitionIn:            undefined, // accepts a delegate like such: function(slide, caption, isSync) { ... }
        onPageTransitionOut:      undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:        undefined, // accepts a delegate like such: function() { ... }
        onImageAdded:              undefined, // accepts a delegate like such: function(imageData, $li) { ... }
         onImageRemoved:            undefined  // accepts a delegate like such: function(imageData, $li) { ... }
      });
     } else {
     } else {
         alert("no gallery");
         type = 'text/css';
    }
    // Create the appropriate element.
    var tag = null;
    switch( type ){
        case 'text/javascript' :
            tag = document.createElement( 'script' );
            tag.type = type;
            tag.src = url;
            break;
        case 'text/css' :
            tag = document.createElement( 'link' );
            tag.rel = 'stylesheet';
            tag.type = type;
            tag.href = url;
            break;
    }
    document.getElementsByTagName("head")[0].appendChild(tag);
}
}
});




include('/js/packery.pkgd.min.js');
include('/js/pack.js');


/* We only want the thunbnails to display when javascript is disabled */
(function(d, s, id) {
document.write('<style>.noscript { display: none; }</style>');
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.4";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

Latest revision as of 16:39, 23 August 2015

/* 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);
        }
      }
    }
}

function include(url){ 
    if(url.match(/\.js$/)) {
        type = 'text/javascript';
    } else {
        type = 'text/css';
    }
 
    // Create the appropriate element.
    var tag = null;
    switch( type ){
        case 'text/javascript' :
            tag = document.createElement( 'script' );
            tag.type = type;
            tag.src = url;
            break;
        case 'text/css' :
            tag = document.createElement( 'link' );
            tag.rel = 'stylesheet';
            tag.type = type;
            tag.href = url;
            break;
    }
 
    document.getElementsByTagName("head")[0].appendChild(tag);
}


include('/js/packery.pkgd.min.js');
include('/js/pack.js');

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.4";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));