<commit_before>/* Router: maps hash navigation */

$.ajaxSetup({
  headers: {
    "Authorization": "Token " + window.access_token,
    "Content-Type": "application/json"
  }
});

Atmo.Router = Backbone.Router.extend({
  routes: {
    "": "instances",
    "instances": "instances",
    "instances/:instance_id": "select_instance",
    "volumes": "volumes",
    "volumes/:volume_id": "select_volume",
    "new_instance": "new_instance",
    "new_instance/:image_query": "select_image",
    "settings": "settings"
  },
  initialize: function () {
    Atmo.profile = new Atmo.Models.Profile();
    Atmo.profile.fetch({
      async: false,
      success: function (profile, foo, bar) {
        $("#username").html(profile.get('id'));

        window.Intercom('boot', {
          app_id: window.intercom_app_id,
          name: profile.get("username"),
          username: profile.get("username"),
          email: profile.get("email"),
          company: {
            id: window.intercom_company_id,
            name: window.intercom_company_name
          }
          // TODO: The current logged in user's sign-up date as a Unix timestamp.
          //created_at: 1234567890
        });
      },
      error: function () {
        // If we end up here, the user has an iPlant account but doesn't
        // have access to Atmosphere itself.
        // Redirect the user to the forbidden page with more info
        window.location.pathname = "/forbidden";
      }
    });



    Atmo.Utils.update_weather();
    Atmo.providers = new Atmo.Collections.Providers();
    Atmo.providers.fetch({
      async: false,
      success: function (providers, foo, bar) {
      }
    });
    Atmo.identities = new Atmo.Collections.Identities();
    Atmo.identities.fetch({
      async: false
    });

    var identity = Atmo.profile.get('selected_identity');<commit_msg>redirect to maintenance page on any 503<commit_after>/* Router: maps hash navigation */

$.ajaxSetup({
  headers: {
    "Authorization": "Token " + window.access_token,
    "Content-Type": "application/json"
  }
});

// Watch all AJAX requests for 503 responses.  If any request returns a 503,
// Atmosphere is under maintenance so redirect to the maintenance page
$(document).ajaxError(function(e, response, xhr){
  if(response.status === 503){
    window.location.pathname = "/atmo_maintenance";
  }
});

Atmo.Router = Backbone.Router.extend({
  routes: {
    "": "instances",
    "instances": "instances",
    "instances/:instance_id": "select_instance",
    "volumes": "volumes",
    "volumes/:volume_id": "select_volume",
    "new_instance": "new_instance",
    "new_instance/:image_query": "select_image",
    "settings": "settings"
  },
  initialize: function () {
    Atmo.profile = new Atmo.Models.Profile();
    Atmo.profile.fetch({
      async: false,
      success: function (profile, foo, bar) {
        $("#username").html(profile.get('id'));

        window.Intercom('boot', {
          app_id: window.intercom_app_id,
          name: profile.get("username"),
          username: profile.get("username"),
          email: profile.get("email"),
          company: {
            id: window.intercom_company_id,
            name: window.intercom_company_name
          }
          // TODO: The current logged in user's sign-up date as a Unix timestamp.
          //created_at: 1234567890
        });
      },
      error: function (attrs, response, xhr) {
        if(response.status === 503){
          // if profile returns a 503, Atmosphere is under maintenance
          // so redirect to the maintenance page
          window.location.pathname = "/atmo_maintenance";
        }else{
          // If we end up here, the user has an iPlant account but doesn't
          // have access to Atmosphere itself. Redirect the user to the
          // forbidden page with more info
          window.location.pathname = "/forbidden";
        }
      }
    });



    Atmo.Utils.update_weather();
    Atmo.providers = new Atmo.Collections.Providers();
    Atmo.providers.fetch({
      async: false,
      success: function (providers, foo, bar) {
      }
    });
    Atmo.identities = new Atmo.Collections.Identities();
    Atmo.identities.fetch({
      async: false
    });

    var identity = Atmo.profile.get('selected_identity');
{'fraction_non_alphanumeric': 0.1351981351981352, 'fraction_numerical': 0.008857808857808859, 'mean_word_length': 2.517213114754098, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '925392', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1264, 'n_words': 308}