<commit_before>//= require mithril/mithril.min.js
//= require jquery
//= require select
//= require underscore/underscore-min.js
//= require mithril-postgrest
//= require moment/min/moment.min.js
//= require lib/replace-diacritics
//= require chart.js/Chart.min.js
//= require i18n/translations
//= require ../analytics
//= require api/init
//= require catarse.js/dist/catarse.js
//= require_self

(function(m, c, Chart, analytics){
  Chart.defaults.global.responsive = true;
  Chart.defaults.global.responsive = false;
  Chart.defaults.global.scaleFontFamily = "proxima-nova";

  I18n.defaultLocale = "pt";
  I18n.locale = "pt";

  var adminRoot = document.getElementById('new-admin');

  if(adminRoot){
      var adminWrap = function(component, customAttr) {
          return {
              controller: function() {
                  var attr = customAttr;

                  return {
                      attr: attr
                  };
              },
              view: function(ctrl) {
                  return m('#app', [
                      m.component(c.root.Menu, ctrl.attr),
                      m.component(component, ctrl.attr),
                      (ctrl.attr.hideFooter ? '' : m.component(c.root.Footer, ctrl.attr))
                  ]);
              }
          };
      };
    m.route.mode = 'hash';

    m.route(adminRoot, '/', {
        '/': adminWrap(c.root.AdminContributions, {root: adminRoot, menuTransparency: false, hideFooter: true}),
        '/users': adminWrap(c.root.AdminUsers, { menuTransparency: false, hideFooter: true }),
        '/balance-transfers': adminWrap(c.root.AdminBalanceTranfers, { menuTransparency: false, hideFooter: true })
    });
  }

    var app = document.getElementById('application'),
        body = document.getElementsByTagName('body')[0];
    var firstRun = true;//Indica se é a primeira vez q executa um controller.

  var wrap = function(component, customAttr) {
      return {
        controller: function() {
            if(firstRun) {
                firstRun=false;
            } else {//só roda se nao for firstRun
                try {
                    analytics.pageView(false);
                } catch(e) {console.error(e);}
            }
            var parameters = app.getAttribute('data-parameters') ? JSON.parse(app.getAttribute('data-parameters')) : {};
            var attr = customAttr,
                projectParam = m.route.param('project_id') || parameters.project_id,
                projectUserIdParam = m.route.param('project_user_id') || parameters.user_id || parameters.project_user_id,
                userParam = m.route.param('user_id') || app.getAttribute('data-userid') || parameters.user_id,
                rewardIdParam = m.route.param('reward_id'),
                surveyIdParam = m.route.param('survey_id'),
                filterParam = m.route.param('filter'),
                thankYouParam = app && JSON.parse(app.getAttribute('data-contribution'));

            var addToAttr = function(newAttr) {
                attr = _.extend({}, newAttr, attr);
            };

            if(projectParam) {
                addToAttr({project_id: projectParam});
            }

            if(userParam) {
                addToAttr({user_id: userParam});
            }

            if(projectUserIdParam) {
                addToAttr({project_user_id: projectUserIdParam});
            }

            if(surveyIdParam) {
                addToAttr({survey_id: surveyIdParam});
            }

            if(rewardIdParam) {
                addToAttr({reward_id: rewardIdParam});
            }

            if(filterParam) {
                addToAttr({filter: filterParam});
            }

            if(thankYouParam) {
                addToAttr({contribution: thankYouParam});
            }

            if(window.localStorage && (window.localStorage.getItem('globalVideoLanding') !== 'true')) {
                addToAttr({withAlert: false});
            }

            if(document.getElementById('fixed-alert')) {
                addToAttr({withFixedAlert: true});
            }

            body.className = 'body-project closed';


            return {
                attr: attr
            };
        },
        view: function(ctrl){
            return m('#app', [
                m.component(c.root.Menu, ctrl.attr),
                m.component(c.root.CheckEmail, ctrl.attr),
                m.component(component, ctrl.attr),
                (ctrl.attr.hideFooter ? '' : m.component(c.root.Footer, ctrl.attr))
            ]);
        }
      };
  };

  if(app){
      var rootEl = app,
          isUserProfile = body.getAttribute('data-controller-name') == 'users' && body.getAttribute('data-action') == 'show' && app.getAttribute('data-hassubdomain') == 'true';

      m.route.mode = 'pathname';

      m.route(rootEl, '/', {
          '/': wrap(( isUserProfile ? c.root.UsersShow : c.root.ProjectsHome), {menuTransparency: true, footerBig: true, absoluteHome: isUserProfile}),
          '/explore': wrap(c.root.ProjectsExplore, {menuTransparency: true, footerBig: true}),
          '/start': wrap(c.root.Start, {menuTransparency: true, footerBig: true}),
          '/projects/:project_id/contributions/new': wrap(c.root.ProjectsContribution),
          '/projects/:project_id/contributions/:contribution_id/edit': wrap(c.root.ProjectsPayment, {menuShort: true}),
          '/pt/projects/:project_id/contributions/new': wrap(c.root.ProjectsContribution),
          '/pt/projects/:project_id/contributions/:contribution_id/edit': wrap(c.root.ProjectsPayment, {menuShort: true}),
          '/pt': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/flexible_projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/explore': wrap(c.root.ProjectsExplore, {menuTransparency: true, footerBig: true}),
          '/pt/start': wrap(c.root.Start, {menuTransparency: true, footerBig: true}),
          '/pt/projects/:project_id/contributions/:contribution_id': wrap(c.root.ThankYou, {menuTransparency: false, footerBig: false}),
          '/projects/:project_id/contributions/:contribution_id': wrap(c.root.ThankYou, {menuTransparency: false, footerBig: false}),
          '/pt/:project': wrap(c.root.ProjectsShow, {menuTransparency: false, footerBig: false}),
          '/projects/:project_id/insights': wrap(c.root.Insights, {menuTransparency: false, footerBig: false}),
          '/pt/projects/:project_id/insights': wrap(c.root.Insights, {menuTransparency: false, footerBig: false}),<commit_msg>add fallback_create route to js<commit_after>//= require mithril/mithril.min.js
//= require jquery
//= require select
//= require underscore/underscore-min.js
//= require mithril-postgrest
//= require moment/min/moment.min.js
//= require lib/replace-diacritics
//= require chart.js/Chart.min.js
//= require i18n/translations
//= require ../analytics
//= require api/init
//= require catarse.js/dist/catarse.js
//= require_self

(function(m, c, Chart, analytics){
  Chart.defaults.global.responsive = true;
  Chart.defaults.global.responsive = false;
  Chart.defaults.global.scaleFontFamily = "proxima-nova";

  I18n.defaultLocale = "pt";
  I18n.locale = "pt";

  var adminRoot = document.getElementById('new-admin');

  if(adminRoot){
      var adminWrap = function(component, customAttr) {
          return {
              controller: function() {
                  var attr = customAttr;

                  return {
                      attr: attr
                  };
              },
              view: function(ctrl) {
                  return m('#app', [
                      m.component(c.root.Menu, ctrl.attr),
                      m.component(component, ctrl.attr),
                      (ctrl.attr.hideFooter ? '' : m.component(c.root.Footer, ctrl.attr))
                  ]);
              }
          };
      };
    m.route.mode = 'hash';

    m.route(adminRoot, '/', {
        '/': adminWrap(c.root.AdminContributions, {root: adminRoot, menuTransparency: false, hideFooter: true}),
        '/users': adminWrap(c.root.AdminUsers, { menuTransparency: false, hideFooter: true }),
        '/balance-transfers': adminWrap(c.root.AdminBalanceTranfers, { menuTransparency: false, hideFooter: true })
    });
  }

    var app = document.getElementById('application'),
        body = document.getElementsByTagName('body')[0];
    var firstRun = true;//Indica se é a primeira vez q executa um controller.

  var wrap = function(component, customAttr) {
      return {
        controller: function() {
            if(firstRun) {
                firstRun=false;
            } else {//só roda se nao for firstRun
                try {
                    analytics.pageView(false);
                } catch(e) {console.error(e);}
            }
            var parameters = app.getAttribute('data-parameters') ? JSON.parse(app.getAttribute('data-parameters')) : {};
            var attr = customAttr,
                projectParam = m.route.param('project_id') || parameters.project_id,
                projectUserIdParam = m.route.param('project_user_id') || parameters.user_id || parameters.project_user_id,
                userParam = m.route.param('user_id') || app.getAttribute('data-userid') || parameters.user_id,
                rewardIdParam = m.route.param('reward_id'),
                surveyIdParam = m.route.param('survey_id'),
                filterParam = m.route.param('filter'),
                thankYouParam = app && JSON.parse(app.getAttribute('data-contribution'));

            var addToAttr = function(newAttr) {
                attr = _.extend({}, newAttr, attr);
            };

            if(projectParam) {
                addToAttr({project_id: projectParam});
            }

            if(userParam) {
                addToAttr({user_id: userParam});
            }

            if(projectUserIdParam) {
                addToAttr({project_user_id: projectUserIdParam});
            }

            if(surveyIdParam) {
                addToAttr({survey_id: surveyIdParam});
            }

            if(rewardIdParam) {
                addToAttr({reward_id: rewardIdParam});
            }

            if(filterParam) {
                addToAttr({filter: filterParam});
            }

            if(thankYouParam) {
                addToAttr({contribution: thankYouParam});
            }

            if(window.localStorage && (window.localStorage.getItem('globalVideoLanding') !== 'true')) {
                addToAttr({withAlert: false});
            }

            if(document.getElementById('fixed-alert')) {
                addToAttr({withFixedAlert: true});
            }

            body.className = 'body-project closed';


            return {
                attr: attr
            };
        },
        view: function(ctrl){
            return m('#app', [
                m.component(c.root.Menu, ctrl.attr),
                m.component(c.root.CheckEmail, ctrl.attr),
                m.component(component, ctrl.attr),
                (ctrl.attr.hideFooter ? '' : m.component(c.root.Footer, ctrl.attr))
            ]);
        }
      };
  };

  if(app){
      var rootEl = app,
          isUserProfile = body.getAttribute('data-controller-name') == 'users' && body.getAttribute('data-action') == 'show' && app.getAttribute('data-hassubdomain') == 'true';

      m.route.mode = 'pathname';

      m.route(rootEl, '/', {
          '/': wrap(( isUserProfile ? c.root.UsersShow : c.root.ProjectsHome), {menuTransparency: true, footerBig: true, absoluteHome: isUserProfile}),
          '/explore': wrap(c.root.ProjectsExplore, {menuTransparency: true, footerBig: true}),
          '/start': wrap(c.root.Start, {menuTransparency: true, footerBig: true}),
          '/projects/:project_id/contributions/new': wrap(c.root.ProjectsContribution),
          '/projects/:project_id/contributions/fallback_create': wrap(c.root.ProjectsContribution),
          '/projects/:project_id/contributions/:contribution_id/edit': wrap(c.root.ProjectsPayment, {menuShort: true}),
          '/pt/projects/:project_id/contributions/new': wrap(c.root.ProjectsContribution),
          '/pt/projects/:project_id/contributions/:contribution_id/edit': wrap(c.root.ProjectsPayment, {menuShort: true}),
          '/pt': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/flexible_projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/projects': wrap(c.root.ProjectsHome, {menuTransparency: true, footerBig: true}),
          '/pt/explore': wrap(c.root.ProjectsExplore, {menuTransparency: true, footerBig: true}),
          '/pt/start': wrap(c.root.Start, {menuTransparency: true, footerBig: true}),
          '/pt/projects/:project_id/contributions/:contribution_id': wrap(c.root.ThankYou, {menuTransparency: false, footerBig: false}),
          '/projects/:project_id/contributions/:contribution_id': wrap(c.root.ThankYou, {menuTransparency: false, footerBig: false}),
          '/pt/:project': wrap(c.root.ProjectsShow, {menuTransparency: false, footerBig: false}),
          '/projects/:project_id/insights': wrap(c.root.Insights, {menuTransparency: false, footerBig: false}),
          '/pt/projects/:project_id/insights': wrap(c.root.Insights, {menuTransparency: false, footerBig: false}),
{'fraction_non_alphanumeric': 0.14196625091709464, 'fraction_numerical': 0.0010271460014673515, 'mean_word_length': 2.238536469470183, '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': '4999290', 'n_tokens_mistral': 4008, 'n_tokens_neox': 3866, 'n_words': 651}