'use strict';

var snipt = {
  module: function() {
    var modules = {};

    return function(name) {
      if (modules[name]) {
        return modules[name];
      }

      return modules[name] = {};
    };
  }()
};

jQuery(function($) {
  var SiteView = snipt.module('site').SiteView;
  window.site = new SiteView();

  var $pres = $('td.code pre');
  $pres.each(function(i) {
    var pre = $pres.eq(i);
    pre.width(pre.parents('section.code').width() - 30);
  });
});

// Angular app init.
(function() {

  var root = this;

  // App definition.
  var app = angular.module('Snipt', ['ngRoute'], function($locationProvider) {
    $locationProvider.html5Mode(true);
  });

  // Use non-Django-style interpolation.
  app.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('{[{');
    $interpolateProvider.endSymbol('}]}');
  });

  root.app = app;

  if (root.ll) {
    if (root.location.pathname === '/account/stats/') {
      root.ll('tagEvent', 'Viewed stats page');
    }
  }

  app.controller('AppController', function($scope) {});

}).call(this);
