<commit_before>'use strict';
/**
 * Backbone models & views representing and displaying a photo album
 */

// tell JSHint to assume existence of these global vars
/*global app, $, _, Backbone, alert, Photo*/

// Create the Album object
var Album = {
	Views : {}
};

//
// MODELS
//
	
/**
 * Represents an album.
 *
 * Includes all data about child photos.
 * Includes child albums, but not the child album's photos.
 */
Album.Model = Backbone.Model.extend({
	idAttribute: 'fullPath',

	/**
	 * Return the URL location of the album's JSON
	 */
	url: function() {
		// if not mock, return real URL
		if (!app.mock) {
			// Album IDs are of this format:
			//   2013
			//   2013/09-08
			//   2013/09-08/someSubAlbum
			var year = this.id.split('/')[0];
			
			// if the year is 2007 or greater, the album's in Gallery2
			if (year >= 2007) {
				return 'http://tacocat.com/pictures/main.php?g2_view=json.Album&album=' + this.id;
			}
			// 2006 and earlier years are in static JSON
			// at /oldpix/year/month/day/album.json
			// such as /oldpix/2001/12/31/album.json
			else {
				var path = this.id.replace('-', '/');
				return 'http://tacocat.com/oldpix/' + path + '/album.json';
			}
		}
		// else if it's a sub album with photos
		else if (this.id.indexOf('/') >= 0) {
			return 'mock/album.json.txt';
		}
		// else it's a year album
		else {
			return 'mock/album-year.json.txt';
		}
	},

	initialize: function() {
		_.bindAll(this, 'getPhotoByPathComponent', 'getNextPhoto', 'getPrevPhoto', 'getCreationDate', 'getTitle');
	},

	/**
	 * Find a photo by it's pathComponent, like 'flowers.jpg'
	 */
	getPhotoByPathComponent: function(pathComponent) {
		//console.log('Album.Model.getPhotoByPathComponent('+pathComponent+'): model: ', jQuery.extend(true, {}, this));<commit_msg>Fixed bug where root album was broken because it thought it was a 2006 or before album.<commit_after>'use strict';
/**
 * Backbone models & views representing and displaying a photo album
 */

// tell JSHint to assume existence of these global vars
/*global app, $, _, Backbone, alert, Photo*/

// Create the Album object
var Album = {
	Views : {}
};

//
// MODELS
//
	
/**
 * Represents an album.
 *
 * Includes all data about child photos.
 * Includes child albums, but not the child album's photos.
 */
Album.Model = Backbone.Model.extend({
	idAttribute: 'fullPath',

	/**
	 * Return the URL location of the album's JSON
	 */
	url: function() {
		// if not mock, return real URL
		if (!app.mock) {
			// Album IDs are of this format:
			//   2013
			//   2013/09-08
			//   2013/09-08/someSubAlbum
			var year = this.id.split('/')[0];
			
			// if the year is blank (the root album) or 2007 or greater, the album's in Gallery2
			if (!year || year >= 2007) {
				return 'http://tacocat.com/pictures/main.php?g2_view=json.Album&album=' + this.id;
			}
			// 2006 and earlier years are in static JSON
			// at /oldpix/year/month/day/album.json
			// such as /oldpix/2001/12/31/album.json
			else {
				var path = this.id.replace('-', '/');
				return 'http://tacocat.com/oldpix/' + path + '/album.json';
			}
		}
		// else if it's a sub album with photos
		else if (this.id.indexOf('/') >= 0) {
			return 'mock/album.json.txt';
		}
		// else it's a year album
		else {
			return 'mock/album-year.json.txt';
		}
	},

	initialize: function() {
		_.bindAll(this, 'getPhotoByPathComponent', 'getNextPhoto', 'getPrevPhoto', 'getCreationDate', 'getTitle');
	},

	/**
	 * Find a photo by it's pathComponent, like 'flowers.jpg'
	 */
	getPhotoByPathComponent: function(pathComponent) {
		//console.log('Album.Model.getPhotoByPathComponent('+pathComponent+'): model: ', jQuery.extend(true, {}, this));
{'fraction_non_alphanumeric': 0.15727891156462584, 'fraction_numerical': 0.025034013605442176, 'mean_word_length': 2.906482465462274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6051404', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1207, 'n_words': 355}