{"size": 3320, "ext": "js", "max_stars_repo_path": "static/js/app.js", "max_stars_repo_name": "Teebr/Teebr", "max_stars_repo_stars_event_min_datetime": "2015-11-11T14:26:40.000Z", "max_stars_repo_stars_event_max_datetime": "2015-11-11T14:26:40.000Z", "max_issues_repo_path": "static/js/app.js", "max_issues_repo_name": "Teebr/Teebr", "max_issues_repo_issues_event_min_datetime": "2019-10-21T08:39:51.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-21T08:40:14.000Z", "max_forks_repo_path": "static/js/app.js", "max_forks_repo_name": "Teebr/Teebr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 26.9918699187, "max_line_length": 102, "alphanum_fraction": 0.5159638554}
var app = angular.module('tbTeebr',
  ['ui.bootstrap', 'tbUtils', 'mgo-mousetrap', 'ngAnimate', 'wu.masonry']);

app.config(function($interpolateProvider) {
  $interpolateProvider.startSymbol('_{');
  $interpolateProvider.endSymbol('}_');
});


/*== Filters ================================================================*/

app.filter("tweet_html_text", ["$sce", function($sce) {

  var re_hashtag = /(^|\s)#([a-z][^.\s]*)/gi,
      // see:
      // https://github.com/twitter/twitter-text/blob/master/js/pkg/twitter-text-1.9.4.js#L343
      re_stock =  /(^|\s)\$([a-z]{1,6}(?:[._][a-z]{1,2})?)(\s|$)/gi,

      re_mention = /(^|\s)@([a-z]\w*)/gi,

      re_url = /(^|\s)(https?:\/\/)([a-z0-9]+\.[a-z0-9]{2,}\S+)/g;

  function highlightTwitterFeatures(text, entities) {
    return text.replace(re_hashtag, function(_, before, tag) {

      return before + '<span class="status-hashtag">' +
        '<span class="status-hash">#</span>' +
          '<span class="status-hashtag-content">' + tag + '</span></span>';

    }).replace(re_stock, function(_, before, tag, after) {

      return before + '<span class="status-cashtag">' +
        '<span class="status-cash">$</span>' +
          '<span class="status-cashtag-content">' + tag + '</span></span>' +
            after;

    }).replace(re_mention, function(_, before, mention) {

      return before + '<span class="status-mention">' +
        '<span class="status-at">@</span>' +
          '<span class="status-mention-content">' + mention + '</span></span>';

    }).replace(re_url, function(_, before, protocol, url) {
      var full = protocol + url,
          max_length = 30,

          photos = entities.photos || [];

      for (var i=0, l=photos.length; i<l; i++) {
        if (photos[i].url == full) {

          // if this is a picture URL, remove it entirely because we'll show
          // the photo below the text
          return before;
        }
      }

      if (url.length > max_length) {
        url = url.slice(0, max_length-1) + "…";
      }

      return before + '<a rel="nofollow" target="_blank" ' +
        'class="status-link" href="' + full + '">' +
          '<span class="status-link-protocol">' + protocol + '</span>' +
            '<span class="status-link-url">' + url + '</span></a>';

    });
  }

  return function(s) {
    var text;

    if (!s) { return s; }

    if (s.text) {
        text = s.text;
    } else {
        text = s;
    }

    //text = text.replace(/</, '&lt;').replace(/>/, '&gt;');

    text = highlightTwitterFeatures(text, s.extra_entities || {});

    return $sce.trustAsHtml(text);
  };
}]);

app.filter("short_number", ["$sce", function($sce) {

  var units = [
    { suffix: "k", factor: 1000 },
    { suffix: "M", factor: 1000000 },
  ];

  function roundOneDecimal(n) {
      return (0|(n * 10))/10;
  }

  return function(text) {
    var n = +text,
        short = text,
        unit;

    if (isNaN(n)) {
        return text;
    }

    for (var i=0; i<units.length; i++) {
        unit = units[i];

        if (n > (unit.factor/10 * 6)) {
            short = "" + roundOneDecimal(n/unit.factor) + unit.suffix;
            break;
        }
    }

    text = '<span class="toggle-text short-number" data-toggle-text="' + n + '">' + short + '</span>';

    return $sce.trustAsHtml(text);
  };
}]);
