Sha256: 4809a8bf5441aeb698a90070c903ebb94eff59727540299553995f09aa66f880

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

var SlackRubyBotServer = {};

$(document).ready(function() {

  SlackRubyBotServer.message = function(text) {
    $('#messages').fadeOut('slow', function() {
      $('#messages').fadeIn('slow').html(text)
    });
  };

  SlackRubyBotServer.error = function(xhr) {
    try {
      var message;
      if (xhr.responseText) {
        var rc = JSON.parse(xhr.responseText);
        if (rc && rc.message) {
          message = rc.message;
          if (message == 'invalid_code') {
            message = 'The code returned from the OAuth workflow was invalid.'
          } else if (message == 'code_already_used') {
            message = 'The code returned from the OAuth workflow has already been used.'
          }
        }
      }

      SlackRubyBotServer.message(message || xhr.statusText || xhr.responseText || 'Unexpected Error');

    } catch(err) {
      SlackRubyBotServer.message(err.message);
    }
  };

  // Slack OAuth
  var code = $.url('?code')
  if (code) {
    SlackRubyBotServer.message('Working, please wait ...');
    $('#register').hide();
    $.ajax({
      type: "POST",
      url: "/api/teams",
      data: {
        code: code
      },
      success: function(data) {
        SlackRubyBotServer.message('Team successfully registered!<br><br>DM <b>@bot</b> or create a <b>#channel</b> and invite <b>@bot</b> to it.');
      },
      error: SlackRubyBotServer.error
    });
  }
});

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.9.0 public/scripts/register.js
slack-ruby-bot-server-0.8.3 public/scripts/register.js
slack-ruby-bot-server-0.8.2 public/scripts/register.js
slack-ruby-bot-server-0.8.1 public/scripts/register.js
slack-ruby-bot-server-0.8.0 public/scripts/register.js
slack-ruby-bot-server-0.7.0 public/scripts/register.js
slack-ruby-bot-server-0.6.1 public/scripts/register.js
slack-ruby-bot-server-0.6.0 public/scripts/register.js
slack-ruby-bot-server-0.5.0 public/scripts/register.js
slack-ruby-bot-server-0.4.0 public/scripts/register.js
slack-ruby-bot-server-0.3.1 public/scripts/register.js
slack-ruby-bot-server-0.3.0 public/scripts/register.js
slack-ruby-bot-server-0.2.0 public/scripts/register.js
slack-ruby-bot-server-0.1.1 public/scripts/register.js
slack-ruby-bot-server-0.1.0 public/scripts/register.js