<commit_before>var __ = window.__ = require('underscore'),
    Backbone = require('backbone'),
    $ = require('jquery');
Backbone.$ = $;
//add to global scope for non-modular libraries
window.Backbone = Backbone;
window.$ = $;
window.jQuery = $;
window.Backbone.$ = $;
window.focused = true;

// we need to know this for notifications
window.onfocus = function() {
  window.focused = true;
};

window.onblur = function() {
  window.focused = false;
};

var Polyglot = require('node-polyglot'),
    getBTPrice = require('./utils/getBitcoinPrice'),
    router = require('./router'),
    newRouter,
    userModel = require('./models/userMd'),
    userProfileModel = require('./models/userProfileMd'),
    languagesModel = require('./models/languagesMd'),
    mouseWheel = require('jquery-mousewheel'),
    mCustomScrollbar = require('./utils/jquery.mCustomScrollbar.js'),
    setTheme = require('./utils/setTheme.js'),
    pageNavView = require('./views/pageNavVw'),
    chatAppView = require('./views/chatAppVw'),
    newPageNavView,
    newSocketView,
    newChatAppView,
    user = new userModel(),
    userProfile = new userProfileModel(),
    languages = new languagesModel(),
    socketView = require('./views/socketVw'),
    guid = "",
    avatar_hash = "",
    cCode = "",
    serverUrlLocal = "",
    loadProfileCount = 1,
    loadProfileTimeout,
    loadProfileCountdownInterval,
    loadProfileCountdown = 5;

serverUrlLocal = localStorage.getItem("serverUrl") || "http://localhost:18469/api/v1/";

//set the urlRoot of the user model. Defaults to local host if not found
user.urlRoot = serverUrlLocal + "settings";

//set the urlRoot of the user model. Defaults to local host if not found
userProfile.urlRoot = serverUrlLocal + "profile";

//put language in the window so all templates and models can reach it. It's especially important in formatting currency.
window.lang = user.get("language");

//put polyglot in the window so all templates can reach it
window.polyglot = new Polyglot({locale: window.lang});

//retrieve the object that has a matching language code
window.polyglot.extend(__.where(languages.get('languages'), {langCode: window.lang})[0]);

//put the event bus into the window so it's available everywhere
window.obEventBus =  __.extend({}, Backbone.Events);

var setCurrentBitCoin = function(cCode, userModel, callback) {
  "use strict";
  getBTPrice(cCode, function (btAve, currencyList) {
    //put the current bitcoin price in the window so it doesn't have to be passed to models
    if (!btAve){
      currencyList = currencyList.join("\n");
      alert("Bitcoin prices for your selected currency are not available. Your currency has been set to BTC. " +
          "You can change this in the settings console. \n\n The following currencies are available: \n\n" + currencyList);
      window.currentBitcoin = 1;
      userModel.set('currency_code', 'BTC');
    }
    window.currentBitcoin = btAve;
    typeof callback === 'function' && callback();
  });
};

var isValidUrl = function(url) {
  var regexp = /(https?:\/\/)+[\w-]+(\.[\w-]+)+\.?(:\d+)+(\/\S*)?/;
  return regexp.test(url);
};

var loadDefaultServer = function(){
  "use strict";
  $('.js-loadingMessageModal').removeClass('hide').find('.js-closeIndexModal').addClass('hide');
  $('.js-indexLoadingMsg1').text("Information for your user profile could not be loaded.");
  $('.js-indexLoadingMsg2').text(serverUrlLocal + " could not be reached.");
  $('.js-indexLoadingMsg3').text("You can enter a different server below.");
  loadProfileCount = 3;
};

var loadProfile = function() {

  var reloadProfile = function(){
    "use strict";
    $('.js-loadingMessageModal').removeClass('hide').find('.js-closeIndexModal').addClass('hide');
    loadProfileCountdown=5;

    if(loadProfileCount <= 3){
      loadProfileCountdownInterval = setInterval(function(){
        if(loadProfileCountdown > 0){
          $('.js-indexLoadingMsg4').text(loadProfileCountdown);
          loadProfileCountdown--;
        } else {
          $('.js-indexLoadingMsg4').text("");
          clearInterval(loadProfileCountdownInterval);
          loadProfileCount++;
          loadProfile();
        }
      }, 2000);
    } else {
      loadDefaultServer();
    }
  };

  //get the guid from the user profile to put in the user model
  userProfile.fetch({
    timeout: 5000,
    success: function (model, response) {
      $('.js-loadingModal').addClass('hide');
      "use strict";
      //clear the interval
      clearInterval(loadProfileCountdownInterval);
      //make sure profile is not blank
      if (response.profile){
        console.log("+++++++++++++++++++++Loop");
        //guid = response.profile.guid;
        //avatar_hash = response.profile.avatar_hash;
        setTheme(model.get('profile').primary_color, model.get('profile').secondary_color, model.get('profile').background_color, model.get('profile').text_color);
        //get the user
        user.fetch({
          success: function (model, response) {
            user.set('serverUrl', serverUrlLocal);
            //user.set('guid', guid);
            //user.set('avatar_hash', avatar_hash);
            cCode = model.get('currency_code');<commit_msg>Fix regex<commit_after>var __ = window.__ = require('underscore'),
    Backbone = require('backbone'),
    $ = require('jquery');
Backbone.$ = $;
//add to global scope for non-modular libraries
window.Backbone = Backbone;
window.$ = $;
window.jQuery = $;
window.Backbone.$ = $;
window.focused = true;

// we need to know this for notifications
window.onfocus = function() {
  window.focused = true;
};

window.onblur = function() {
  window.focused = false;
};

var Polyglot = require('node-polyglot'),
    getBTPrice = require('./utils/getBitcoinPrice'),
    router = require('./router'),
    newRouter,
    userModel = require('./models/userMd'),
    userProfileModel = require('./models/userProfileMd'),
    languagesModel = require('./models/languagesMd'),
    mouseWheel = require('jquery-mousewheel'),
    mCustomScrollbar = require('./utils/jquery.mCustomScrollbar.js'),
    setTheme = require('./utils/setTheme.js'),
    pageNavView = require('./views/pageNavVw'),
    chatAppView = require('./views/chatAppVw'),
    newPageNavView,
    newSocketView,
    newChatAppView,
    user = new userModel(),
    userProfile = new userProfileModel(),
    languages = new languagesModel(),
    socketView = require('./views/socketVw'),
    guid = "",
    avatar_hash = "",
    cCode = "",
    serverUrlLocal = "",
    loadProfileCount = 1,
    loadProfileTimeout,
    loadProfileCountdownInterval,
    loadProfileCountdown = 5;

serverUrlLocal = localStorage.getItem("serverUrl") || "http://localhost:18469/api/v1/";

//set the urlRoot of the user model. Defaults to local host if not found
user.urlRoot = serverUrlLocal + "settings";

//set the urlRoot of the user model. Defaults to local host if not found
userProfile.urlRoot = serverUrlLocal + "profile";

//put language in the window so all templates and models can reach it. It's especially important in formatting currency.
window.lang = user.get("language");

//put polyglot in the window so all templates can reach it
window.polyglot = new Polyglot({locale: window.lang});

//retrieve the object that has a matching language code
window.polyglot.extend(__.where(languages.get('languages'), {langCode: window.lang})[0]);

//put the event bus into the window so it's available everywhere
window.obEventBus =  __.extend({}, Backbone.Events);

var setCurrentBitCoin = function(cCode, userModel, callback) {
  "use strict";
  getBTPrice(cCode, function (btAve, currencyList) {
    //put the current bitcoin price in the window so it doesn't have to be passed to models
    if (!btAve){
      currencyList = currencyList.join("\n");
      alert("Bitcoin prices for your selected currency are not available. Your currency has been set to BTC. " +
          "You can change this in the settings console. \n\n The following currencies are available: \n\n" + currencyList);
      window.currentBitcoin = 1;
      userModel.set('currency_code', 'BTC');
    }
    window.currentBitcoin = btAve;
    typeof callback === 'function' && callback();
  });
};

var isValidUrl = function(url) {
  var regexp = /(https?:\/\/)+[\w-]+(\.[\w-]+)*(:\d+)+(\/\S*)?/;
  return regexp.test(url);
};

var loadDefaultServer = function(){
  "use strict";
  $('.js-loadingMessageModal').removeClass('hide').find('.js-closeIndexModal').addClass('hide');
  $('.js-indexLoadingMsg1').text("Information for your user profile could not be loaded.");
  $('.js-indexLoadingMsg2').text(serverUrlLocal + " could not be reached.");
  $('.js-indexLoadingMsg3').text("You can enter a different server below.");
  loadProfileCount = 3;
};

var loadProfile = function() {

  var reloadProfile = function(){
    "use strict";
    $('.js-loadingMessageModal').removeClass('hide').find('.js-closeIndexModal').addClass('hide');
    loadProfileCountdown=5;

    if(loadProfileCount <= 3){
      loadProfileCountdownInterval = setInterval(function(){
        if(loadProfileCountdown > 0){
          $('.js-indexLoadingMsg4').text(loadProfileCountdown);
          loadProfileCountdown--;
        } else {
          $('.js-indexLoadingMsg4').text("");
          clearInterval(loadProfileCountdownInterval);
          loadProfileCount++;
          loadProfile();
        }
      }, 3000);
    } else {
      loadDefaultServer();
    }
  };

  //get the guid from the user profile to put in the user model
  userProfile.fetch({
    timeout: 5000,
    success: function (model, response) {
      $('.js-loadingModal').addClass('hide');
      "use strict";
      //clear the interval
      clearInterval(loadProfileCountdownInterval);
      //make sure profile is not blank
      if (response.profile){
        console.log("+++++++++++++++++++++Loop");
        //guid = response.profile.guid;
        //avatar_hash = response.profile.avatar_hash;
        setTheme(model.get('profile').primary_color, model.get('profile').secondary_color, model.get('profile').background_color, model.get('profile').text_color);
        //get the user
        user.fetch({
          success: function (model, response) {
            user.set('serverUrl', serverUrlLocal);
            //user.set('guid', guid);
            //user.set('avatar_hash', avatar_hash);
            cCode = model.get('currency_code');
{'fraction_non_alphanumeric': 0.14951381534610572, 'fraction_numerical': 0.005198806200057765, 'mean_word_length': 3.4507283633247643, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5901876', 'n_tokens_mistral': 3034, 'n_tokens_neox': 2966, 'n_words': 760}