<commit_before>var $ = require('jquery');
var cdb = require('cartodb.js');
var FavMapView = require('./fav_map_view');
var UserInfoView = require('./user_info_view');
var PaginationModel = require('new_common/views/pagination/model');
var PaginationView = require('new_common/views/pagination/view');
var UserUrl = require('new_common/urls/user_model');
var OrgUserUrl = require('new_common/urls/organization_user_model');
var UserSettingsView = require('new_public_dashboard/user_settings_view');
var MapCardPreview = require('new_dashboard/mapcard_preview');
var LikeView = require('new_common/views/likes/view');

$(function() {
  cdb.init(function() {
    cdb.templates.namespace = 'cartodb/';

    $(document.body).bind('click', function() {
      cdb.god.trigger('closeDialogs');
    });

    var authenticatedUser = new cdb.open.AuthenticatedUser();
    authenticatedUser.bind('change', function() {
      if (authenticatedUser.get('username')) {
        var user = new cdb.admin.User(authenticatedUser.attributes);
        var urlData = {
          user: user,
          account_host: window.account_host
        };
        var currentUserUrl;
        if (user.isOrgAdmin()) {
          currentUserUrl = new OrgUserUrl(urlData);
        } else {
          currentUserUrl = new UserUrl(urlData);
        }
        var userSettingsView = new UserSettingsView({
          el: $('.js-user-settings'),
          model: user,
          currentUserUrl: currentUserUrl
        });
        userSettingsView.render();

        $('.js-login').hide();
        $('.js-learn').show();
      }
    });

    var favMapView = new FavMapView(window.favMapViewAttrs);
    favMapView.render();

    var userInfoView = new UserInfoView({
      el: $('.js-user-info')
    });
    userInfoView.render();

    var paginationView = new PaginationView({
      el: '.js-content-footer',
      model: new PaginationModel(window.paginationModelAttrs)
    });
    paginationView.render();

    $('.MapCard').each(function() {
      var mapCardPreview = new MapCardPreview({
        el: $(this).find('.js-header'),
        vizjson: $(this).data('vizjson-url')
      });
      mapCardPreview.load();
    });

    $('.js-likes').each(function() {
      var likeModel = cdb.admin.Like.newByVisData({
        likeable: false,
        vis_id: $(this).data('vis-id'),
        liked: $(this).data('liked'),
        likes: $(this).data('likes-count')
      });
      authenticatedUser.bind('change', function() {
        if (authenticatedUser.get('username')) {
          likeModel.set('likeable', true);
        }
      });
      var likeView = new LikeView({
        el: this,
        model: likeModel
      });
      likeView.render();
    });

    authenticatedUser.fetch();
  });
});
<commit_msg>Don't try to load map card preview for fake cards<commit_after>var $ = require('jquery');
var cdb = require('cartodb.js');
var FavMapView = require('./fav_map_view');
var UserInfoView = require('./user_info_view');
var PaginationModel = require('new_common/views/pagination/model');
var PaginationView = require('new_common/views/pagination/view');
var UserUrl = require('new_common/urls/user_model');
var OrgUserUrl = require('new_common/urls/organization_user_model');
var UserSettingsView = require('new_public_dashboard/user_settings_view');
var MapCardPreview = require('new_dashboard/mapcard_preview');
var LikeView = require('new_common/views/likes/view');

$(function() {
  cdb.init(function() {
    cdb.templates.namespace = 'cartodb/';

    $(document.body).bind('click', function() {
      cdb.god.trigger('closeDialogs');
    });

    var authenticatedUser = new cdb.open.AuthenticatedUser();
    authenticatedUser.bind('change', function() {
      if (authenticatedUser.get('username')) {
        var user = new cdb.admin.User(authenticatedUser.attributes);
        var urlData = {
          user: user,
          account_host: window.account_host
        };
        var currentUserUrl;
        if (user.isOrgAdmin()) {
          currentUserUrl = new OrgUserUrl(urlData);
        } else {
          currentUserUrl = new UserUrl(urlData);
        }
        var userSettingsView = new UserSettingsView({
          el: $('.js-user-settings'),
          model: user,
          currentUserUrl: currentUserUrl
        });
        userSettingsView.render();

        $('.js-login').hide();
        $('.js-learn').show();
      }
    });

    var favMapView = new FavMapView(window.favMapViewAttrs);
    favMapView.render();

    var userInfoView = new UserInfoView({
      el: $('.js-user-info')
    });
    userInfoView.render();

    var paginationView = new PaginationView({
      el: '.js-content-footer',
      model: new PaginationModel(window.paginationModelAttrs)
    });
    paginationView.render();

    $('.MapCard').each(function() {
      var vizjson = $(this).data('vizjson-url');
      if (vizjson) {
        var mapCardPreview = new MapCardPreview({
          el: $(this).find('.js-header'),
          vizjson: vizjson
        });
        mapCardPreview.load();
      }
    });

    $('.js-likes').each(function() {
      var likeModel = cdb.admin.Like.newByVisData({
        likeable: false,
        vis_id: $(this).data('vis-id'),
        liked: $(this).data('liked'),
        likes: $(this).data('likes-count')
      });
      authenticatedUser.bind('change', function() {
        if (authenticatedUser.get('username')) {
          likeModel.set('likeable', true);
        }
      });
      var likeView = new LikeView({
        el: this,
        model: likeModel
      });
      likeView.render();
    });

    authenticatedUser.fetch();
  });
});

{'fraction_non_alphanumeric': 0.15538625088589653, 'fraction_numerical': 0.0, 'mean_word_length': 2.7987886944818303, 'pattern_counts': {'":': 0, '<': 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': '3225763', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1686, 'n_words': 296}