Advertisement
Guest User

for twitch dev discuss

a guest
Jan 11th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function()
  2.  {
  3.   /* Don't execute jQuery functions until the page has fully loaded, since we don't know if the elements we're trying to modify have been processed yet by the dom */
  4.   $(document).ready(function()
  5.    {
  6.     Twitch.init({ clientId: 'h3tleamdx2da66immwpbwe7dtd01n74' }, function(error, status)
  7.     {
  8.       console.log("Twitch SDK Loaded!");
  9.       /* When a user is authenticated, this will be true */
  10.       if(status.authenticated)
  11.       {
  12.         $('.AuthBox').hide();
  13.         $('.loggedInUserArea').show();
  14.         /* This should go here, since we need to know the user is authenticated */
  15.          
  16.       }
  17.      
  18.     });
  19.     Twitch.getStatus(function(err, status) {
  20.   if (status.authenticated) {
  21.      Twitch.api({method:'channel'}, function(error, channel) {
  22.       console.log(channel.stream_key);
  23.     });
  24.   }
  25. });
  26.      $('.twitch-connect').click(function() {
  27.       Twitch.login({
  28.         scope: ['user_read', 'channel_read']
  29.       });
  30.    });
  31.  
  32.  
  33.  
  34.   });
  35.  
  36.  
  37.     if (window.webkitNotifications) {
  38.       console.log("Notifications are supported!");
  39.     }
  40.     else {
  41.       console.log("Notifications are not supported for this Browser/OS version yet.");
  42.     }
  43.  
  44.  
  45.  
  46. $('.logout').click(function() {
  47.      Twitch.logout(function(error) {
  48.        
  49.     });
  50.     });
  51. }
  52.  
  53. ());  
  54.  
  55.  
  56.   function toggle_visibility(id)
  57.   {
  58.        var e = document.getElementById(id);
  59.        if(e.style.display == 'block')
  60.           e.style.display = 'none';
  61.        else
  62.           e.style.display = 'block';
  63.    
  64.  }
  65.  
  66. function liveNotify(channel)
  67. {
  68.     if (window.webkitNotifications.checkPermission() == 0)
  69.     {
  70.         liveNotification=window.webkitNotifications.createNotification(channel.icon,channel.display_name+"Just went live!","Streaming: "+channel.game+" on: ");
  71.         liveNotification.show();
  72.         }
  73.         else
  74.         {
  75.              window.webkitNotifications.requestPermission();
  76.         }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement