MediaWiki:Common.js: Difference between revisions

From canbudget Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 3: Line 3:
function showNav() {
function showNav() {
   $(".noprint").show();
   $(".noprint").show();
   $('#content').css('margin-left', '10em').css('padding', '1em');
   $('#content').css('margin-left', '10em');
   $('#wnavcontrol').remove();
   $('#wnavcontrol').remove();
   var dshow = "<span id='wnavcontrol' onclick='hideNav()' style='float: right; font-weight: bold; color: blue'>-Wiki</span>";
   var dshow = "<span id='wnavcontrol' style='float: right'><a onclick='clickSupport(1)'>FB Credits 1</a>, <a onclick='clickSupport(5)'>5</a>, <a onclick='clickSupport(10)'>10</a> | <a onclick='hideNav()' style='font-weight: bold'>-Wiki</a></span>";
   $('#firstHeading').before(dshow).fadeIn();
   $('#firstHeading').before(dshow).fadeIn();
}
}
Line 11: Line 11:
function hideNav() {
function hideNav() {
   $(".noprint").hide();
   $(".noprint").hide();
   $('#content').css('margin-left', '0em').css('padding', '0em');
   $('#content').css('margin-left', '0em').css('padding', '0.2em').css('background-image', 'none');
   if (wnavcontrol) {
   if (wnavcontrol) {
       $('#wnavcontrol').remove();
       $('#wnavcontrol').remove();
   }
   }
   var dshow = "<span id='wnavcontrol' onclick='showNav()' style='float: right; font-weight: bold; color: blue'>+Wiki</span>";
   var dshow = "<span id='wnavcontrol' style='float: right'><a onclick='clickSupport(1)'>FB Credits 1</a>, <a onclick='clickSupport(5)'>5</a>, <a onclick='clickSupport(10)'>10</a> | <a onclick='showNav()' style='font-weight: bold'>+Wiki</a></span>";
   $('#firstHeading').before(dshow).fadeIn();
   $('#firstHeading').before(dshow).fadeIn();
   wnavcontrol = true;
   wnavcontrol = true;
Line 23: Line 23:
   $('#firstHeading').wrap('<div style="width: 100%" />');
   $('#firstHeading').wrap('<div style="width: 100%" />');


   hideNav();
   showNav();
 
  FB.init({appId: 129531840449132, status: true, cookie: true});
 


   if (document.getElementsByClassName == undefined) {
   if (document.getElementsByClassName == undefined) {
Line 49: Line 52:
     }
     }
}
}
    function clickSupport(num) {
      document.write('<script src="http://connect.facebook.net/en_US/all.js"></script>');
      // Assign an internal ID that points to a database record
      var order_info = 'canbudget'+num;
      // calling the API ...
      var obj = {
        method: 'pay',
        order_info: order_info,
        purchase_type: 'item'
      };
      FB.ui(obj, callback);
    }
   
    var callback = function(data) {
      if (data['order_id']) {
        return true;
      } else {
        //handle errors here
        return false;
      }
    };
    function writeback(str) {
      document.getElementById('output').innerHTML=str;
    }

Latest revision as of 17:39, 20 March 2013

var wnavcontrol = false;

function showNav() {
  $(".noprint").show();
  $('#content').css('margin-left', '10em');
  $('#wnavcontrol').remove();
  var dshow = "<span id='wnavcontrol' style='float: right'><a onclick='clickSupport(1)'>FB Credits 1</a>, <a onclick='clickSupport(5)'>5</a>, <a onclick='clickSupport(10)'>10</a> | <a onclick='hideNav()' style='font-weight: bold'>-Wiki</a></span>";
  $('#firstHeading').before(dshow).fadeIn();
}

function hideNav() {
  $(".noprint").hide();
  $('#content').css('margin-left', '0em').css('padding', '0.2em').css('background-image', 'none');
  if (wnavcontrol) {
      $('#wnavcontrol').remove();
  }
  var dshow = "<span id='wnavcontrol' style='float: right'><a onclick='clickSupport(1)'>FB Credits 1</a>, <a onclick='clickSupport(5)'>5</a>, <a onclick='clickSupport(10)'>10</a> | <a onclick='showNav()' style='font-weight: bold'>+Wiki</a></span>";
  $('#firstHeading').before(dshow).fadeIn();
  wnavcontrol = true;
}

onload=function(){
  $('#firstHeading').wrap('<div style="width: 100%" />');

  showNav();

  FB.init({appId: 129531840449132, status: true, cookie: true});


  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++) {
        element.href = "/frame/?l="+escape(element.href);
      }
    }
}


    function clickSupport(num) {
      document.write('<script src="http://connect.facebook.net/en_US/all.js"></script>');
      // Assign an internal ID that points to a database record
      var order_info = 'canbudget'+num;

      // calling the API ...
      var obj = {
        method: 'pay',
        order_info: order_info,
        purchase_type: 'item'
      };

      FB.ui(obj, callback);
    }
    
    var callback = function(data) {
      if (data['order_id']) {
        return true;
      } else {
        //handle errors here
        return false;
      }
    };

    function writeback(str) {
      document.getElementById('output').innerHTML=str;
    }