{"size": 2163, "ext": "js", "max_stars_repo_path": "js/fb.js", "max_stars_repo_name": "TheReal768/2bitfinity", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/fb.js", "max_issues_repo_name": "TheReal768/2bitfinity", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/fb.js", "max_forks_repo_name": "TheReal768/2bitfinity", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.4647887324, "max_line_length": 87, "alphanum_fraction": 0.5880721221}

  // Additional JS functions here
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '217751578420551', // App ID
      //channelUrl : '//www.stanford.edu/~gstang/nalini/channel.html', // Channel File
      //status     : true, // check login status
      status     : false, // check login status
      //cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });
}

 // Load the SDK Asynchronously
(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/en_US/all.js#xfbml=1&appId=217751578420551";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


function postToFeed(score) {
//function postToFeed() {
        //var score = Math.pow(2,grid.maxValue());
        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri: 'mirri66.github.io/2bitfinity',
          link: 'http://mirri66.github.io/2bitfinity/',
          //picture: 'http://mirri66.github.io/2bitfinity/logo.png',
          picture: screenshot(),
          name: '2bitfinity',
          caption: 'Life after 2048',
          description: 'My highest tile was ' + score + ' on 2bitfinity!'
        };
/*
        function callback(response) {
          document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }
*/
        function callback(response) {
          if (response && response.post_id) {
            //alert('Post was published.');
          } else {
            //alert('Post was not published.');
          }
        }
        FB.ui(obj, callback);
}


function screenshot(){

  var grid = document.getElementById('thegrid') 
  html2canvas(grid, {
    onrendered: function(canvas) {
      // canvas is the final rendered <canvas> element
      var data = canvas.toDataURL("image/png");
      var encodedPng = data.substring(data.indexOf(',') + 1, data.length);
      var decodedPng = Base64Binary.decode(encodedPng);
    //  return decodedPng;
      return data;
    }
});

}


 