Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function()
- {
- /* 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 */
- $(document).ready(function()
- {
- Twitch.init({ clientId: 'h3tleamdx2da66immwpbwe7dtd01n74' }, function(error, status)
- {
- console.log("Twitch SDK Loaded!");
- /* When a user is authenticated, this will be true */
- if(status.authenticated)
- {
- $('.AuthBox').hide();
- $('.loggedInUserArea').show();
- /* This should go here, since we need to know the user is authenticated */
- }
- });
- Twitch.getStatus(function(err, status) {
- if (status.authenticated) {
- Twitch.api({method:'channel'}, function(error, channel) {
- console.log(channel.stream_key);
- });
- }
- });
- $('.twitch-connect').click(function() {
- Twitch.login({
- scope: ['user_read', 'channel_read']
- });
- });
- });
- if (window.webkitNotifications) {
- console.log("Notifications are supported!");
- }
- else {
- console.log("Notifications are not supported for this Browser/OS version yet.");
- }
- $('.logout').click(function() {
- Twitch.logout(function(error) {
- });
- });
- }
- ());
- function toggle_visibility(id)
- {
- var e = document.getElementById(id);
- if(e.style.display == 'block')
- e.style.display = 'none';
- else
- e.style.display = 'block';
- }
- function liveNotify(channel)
- {
- if (window.webkitNotifications.checkPermission() == 0)
- {
- liveNotification=window.webkitNotifications.createNotification(channel.icon,channel.display_name+"Just went live!","Streaming: "+channel.game+" on: ");
- liveNotification.show();
- }
- else
- {
- window.webkitNotifications.requestPermission();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement