{"size": 1473, "ext": "js", "max_stars_repo_path": "js/web/Cookie.js", "max_stars_repo_name": "ildar-shaimordanov/jsxt", "max_stars_repo_stars_event_min_datetime": "2015-12-07T02:54:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-19T19:09:22.000Z", "max_issues_repo_path": "js/web/Cookie.js", "max_issues_repo_name": "ildar-shaimordanov/jsxt", "max_issues_repo_issues_event_min_datetime": "2020-02-27T04:30:55.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-27T09:20:56.000Z", "max_forks_repo_path": "js/web/Cookie.js", "max_forks_repo_name": "ildar-shaimordanov/jsxt", "max_forks_repo_forks_event_min_datetime": "2015-12-23T08:32:44.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-09T18:49:47.000Z"}
{"max_stars_count": 22, "max_issues_count": 2, "max_forks_count": 11, "avg_line_length": 20.1780821918, "max_line_length": 74, "alphanum_fraction": 0.5410726409}
//
// JavaScript unit
// Cookie extensions
//
// Copyright (c) 2010 by Ildar Shaimordanov
//

var Cookie = {

	/**
	 * Returns the value of the existing cookie or 'null' othewise
	 *
	 * @param	String
	 * @return	String
	 * @access	public
	 */
	get: function(name)
	{
		var list = document.cookie.split(';');
		for (var i = 0; i < list.length; i++) {
			var c = list[i].replace(/^\s+/, '').split('=');
			if ( c[0] == name ) {
				return c[1];
			}
		}
		return null;
	},

	/**
	 * Sets a new cookie specified by name with value and additional options
	 * There are available options:
	 * -- expires
	 * -- domain
	 * -- path
	 * -- secure
	 *
	 * @param	String
	 * @return	Boolean
	 * @access	public
	 */
	set: function(name, value, options)
	{
		document.cookie = [
			name + '=' + escape(value), 
			options.expires ? '; expires=' + options.expires.toGMTString() : '', 
			options.path    ? '; path=' + options.path : '', 
			options.domain  ? '; domain=' + options.domain : '', 
			options.secure  ? '; secure' : ''
		].join('; ');
	},

	/**
	 * Removes an existing cookie. The options are available too: 
	 * -- expires
	 * -- domain
	 * -- path
	 * -- secure
	 *
	 * @param	String
	 * @return	Boolean
	 * @access	public
	 */
	unset: function(name, options)
	{
		if ( document.cookie.get(name) ) {
			options.expires = new Date(1970, 0, 1);
			document.cookie.set(name, '', options);
		}
	}

};

