<commit_before>define(["Tone/core/Tone", "Tone/core/Context"], function (Tone) {

	/**
	 *  @class Tone.AudioNode is a base class for classes which process audio.
	 *         AudioNodes have inputs and outputs.
	 *  @param	{AudioContext=} context	The audio context to use with the class
	 *  @extends {Tone}
	 */
	Tone.AudioNode = function(){
		Tone.call(this);

		//use the default context if one is not passed in
		var options = Tone.defaults(arguments, ["context"], {
			"context" : Tone.context
		});

		/**
		 * The AudioContext of this instance
		 * @private
		 * @type {AudioContext}
		 */
		this._context = options.context;
	};

	Tone.extend(Tone.AudioNode);

	/**
	 * Get the audio context belonging to this instance.
	 * @type {AudioNode}
	 * @memberOf Tone.AudioNode#
	 * @name context
	 * @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "context", {
		get : function(){
			return this._context;
		}
	});

	/**
	 *  Create input and outputs for this object.
	 *  @param  {Number}  [input=0]   The number of inputs
	 *  @param  {Number}  [outputs=0]  The number of outputs
	 *  @return  {Tone.AudioNode}  this
	 *  @private
	 */
	Tone.AudioNode.prototype.createInsOuts = function(inputs, outputs){

		if (inputs === 1){
			this.input = this.context.createGain();
		} else if (inputs > 1){
			this.input = new Array(inputs);
		}

		if (outputs === 1){
			this.output = this.context.createGain();
		} else if (outputs > 1){
			this.output = new Array(outputs);
		}
	};

	/**
	 *  The number of inputs feeding into the AudioNode.
	 *  For source nodes, this will be 0.
	 *  @type {Number}
	 *  @name numberOfInputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfInputs", {
		get : function(){
			if (this.input){
				if (Tone.isArray(this.input)){
					return this.input.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

	/**
	 *  The number of outputs coming out of the AudioNode.
	 *  @type {Number}
	 *  @name numberOfOutputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfOutputs", {
		get : function(){
			if (this.output){
				if (Tone.isArray(this.output)){
					return this.output.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

		/**
	 *  connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
	 *  @param  {Tone | AudioParam | AudioNode} unit
	 *  @param {number} [outputNum=0] optionally which output to connect from
	 *  @param {number} [inputNum=0] optionally which input to connect to
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.connect = function(unit, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			outputNum = Tone.defaultArg(outputNum, 0);
			this.output[outputNum].connect(unit, 0, inputNum);
		} else {
			this.output.connect(unit, outputNum, inputNum);
		}
		return this;
	};

	/**
	 *  disconnect the output
	 *  @param {Number|AudioNode} output Either the output index to disconnect
	 *                                   if the output is an array, or the
	 *                                   node to disconnect from.
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.disconnect = function(destination, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			if (Tone.isNumber(destination)){
				this.output[destination].disconnect();
			} else {
				outputNum = Tone.defaultArg(outputNum, 0);
				this.output[outputNum].disconnect(destination, 0, inputNum);
			}
		} else {
			this.output.disconnect.apply(this.output, arguments);
		}
	};

	/**
	 *  Connect the output of this node to the rest of the nodes in series.
	 *  @example
	 *  //connect a node to an effect, panVol and then to the master output
	 *  node.chain(effect, panVol, Tone.Master);
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.chain = function(){
		var currentUnit = this;
		for (var i = 0; i < arguments.length; i++){
			var toUnit = arguments[i];
			currentUnit.connect(toUnit);
			currentUnit = toUnit;
		}
		return this;
	};

	/**
	 *  connect the output of this node to the rest of the nodes in parallel.
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.fan = function(){
		for (var i = 0; i < arguments.length; i++){
			this.connect(arguments[i]);
		}
		return this;
	};

	if (window.AudioNode){
		//give native nodes chain and fan methods
		AudioNode.prototype.chain = Tone.AudioNode.prototype.chain;
		AudioNode.prototype.fan = Tone.AudioNode.prototype.fan;
	}

	/**
	 * Dispose and disconnect
	 * @return {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.dispose = function () {
		if (!Tone.isUndef(this.input)){
			if (this.input instanceof AudioNode){
				this.input.disconnect();
			}
			this.input = null;
		}
		if (!Tone.isUndef(this.output)){
			if (this.output instanceof AudioNode){
				this.output.disconnect();
			}
			this.output = null;
		}
		this._context = null;
		return this;
	};

	return Tone.AudioNode;
});
<commit_msg>updating jsdoc type<commit_after>define(["Tone/core/Tone", "Tone/core/Context"], function (Tone) {

	/**
	 *  @class Tone.AudioNode is a base class for classes which process audio.
	 *         AudioNodes have inputs and outputs.
	 *  @param	{AudioContext=} context	The audio context to use with the class
	 *  @extends {Tone}
	 */
	Tone.AudioNode = function(){
		Tone.call(this);

		//use the default context if one is not passed in
		var options = Tone.defaults(arguments, ["context"], {
			"context" : Tone.context
		});

		/**
		 * The AudioContext of this instance
		 * @private
		 * @type {AudioContext}
		 */
		this._context = options.context;
	};

	Tone.extend(Tone.AudioNode);

	/**
	 * Get the audio context belonging to this instance.
	 * @type {Tone.Context}
	 * @memberOf Tone.AudioNode#
	 * @name context
	 * @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "context", {
		get : function(){
			return this._context;
		}
	});

	/**
	 *  Create input and outputs for this object.
	 *  @param  {Number}  [input=0]   The number of inputs
	 *  @param  {Number}  [outputs=0]  The number of outputs
	 *  @return  {Tone.AudioNode}  this
	 *  @private
	 */
	Tone.AudioNode.prototype.createInsOuts = function(inputs, outputs){

		if (inputs === 1){
			this.input = this.context.createGain();
		} else if (inputs > 1){
			this.input = new Array(inputs);
		}

		if (outputs === 1){
			this.output = this.context.createGain();
		} else if (outputs > 1){
			this.output = new Array(outputs);
		}
	};

	/**
	 *  The number of inputs feeding into the AudioNode.
	 *  For source nodes, this will be 0.
	 *  @type {Number}
	 *  @name numberOfInputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfInputs", {
		get : function(){
			if (this.input){
				if (Tone.isArray(this.input)){
					return this.input.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

	/**
	 *  The number of outputs coming out of the AudioNode.
	 *  @type {Number}
	 *  @name numberOfOutputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfOutputs", {
		get : function(){
			if (this.output){
				if (Tone.isArray(this.output)){
					return this.output.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

		/**
	 *  connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
	 *  @param  {Tone | AudioParam | AudioNode} unit
	 *  @param {number} [outputNum=0] optionally which output to connect from
	 *  @param {number} [inputNum=0] optionally which input to connect to
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.connect = function(unit, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			outputNum = Tone.defaultArg(outputNum, 0);
			this.output[outputNum].connect(unit, 0, inputNum);
		} else {
			this.output.connect(unit, outputNum, inputNum);
		}
		return this;
	};

	/**
	 *  disconnect the output
	 *  @param {Number|AudioNode} output Either the output index to disconnect
	 *                                   if the output is an array, or the
	 *                                   node to disconnect from.
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.disconnect = function(destination, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			if (Tone.isNumber(destination)){
				this.output[destination].disconnect();
			} else {
				outputNum = Tone.defaultArg(outputNum, 0);
				this.output[outputNum].disconnect(destination, 0, inputNum);
			}
		} else {
			this.output.disconnect.apply(this.output, arguments);
		}
	};

	/**
	 *  Connect the output of this node to the rest of the nodes in series.
	 *  @example
	 *  //connect a node to an effect, panVol and then to the master output
	 *  node.chain(effect, panVol, Tone.Master);
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 *  @private
	 */
	Tone.AudioNode.prototype.chain = function(){
		var currentUnit = this;
		for (var i = 0; i < arguments.length; i++){
			var toUnit = arguments[i];
			currentUnit.connect(toUnit);
			currentUnit = toUnit;
		}
		return this;
	};

	/**
	 *  connect the output of this node to the rest of the nodes in parallel.
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 *  @private
	 */
	Tone.AudioNode.prototype.fan = function(){
		for (var i = 0; i < arguments.length; i++){
			this.connect(arguments[i]);
		}
		return this;
	};

	if (window.AudioNode){
		//give native nodes chain and fan methods
		AudioNode.prototype.chain = Tone.AudioNode.prototype.chain;
		AudioNode.prototype.fan = Tone.AudioNode.prototype.fan;
	}

	/**
	 * Dispose and disconnect
	 * @return {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.dispose = function () {
		if (!Tone.isUndef(this.input)){
			if (this.input instanceof AudioNode){
				this.input.disconnect();
			}
			this.input = null;
		}
		if (!Tone.isUndef(this.output)){
			if (this.output instanceof AudioNode){
				this.output.disconnect();
			}
			this.output = null;
		}
		this._context = null;
		return this;
	};

	return Tone.AudioNode;
});
<|endoftext|>


<commit_before>/*
 *	@author Interactive agency "Central marketing" http://iacm.ru
 *	@copyright Copyright (c) 2015, Interactive agency "Central marketing"
 *	@license http://opensource.org/licenses/MIT The MIT License (MIT)
 *	@version 3.0 at 14/09/2015 (16:50)
 *
 *	goodshare.js
 *
 *	Useful jQuery plugin that will help your website visitors share a link on social networks and microblogs.
 *	Easy to install and configuring on any of your website!
 */
;(function($, document, window, undefined) {
	$(document).ready(function() {
		goodshare = {
			init: function(_element, _options) {
				/*
				 *	Default options:
				 *
				 *	(social) type = vk
				 *	url = current browser adress stroke
				 *	title = current document <title>
				 */
				var self = goodshare, options = $.extend({
					type:	'vk',
					url:	location.href,
					title:	document.title,
					text:	'',
					image:	''
				}, $(_element).data(), _options);
				/*
				 *	Open popup
				 */
				if (self.popup(link = self[options.type](options)) !== null) return false;
			},
			/*
			 *	Share link > Vkontakte
			 *	http://vk.com
			 */
			vk: function(_options) {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:	'',
					image:	''
				}, _options);
				return 'http://vk.com/share.php?'
					+ 'url='          + encodeURIComponent(options.url)
					+ '&title='       + encodeURIComponent(options.title)
					+ '&description=' + encodeURIComponent(options.text)
					+ '&image='       + encodeURIComponent(options.image);
			},
			/*
			 *	Share link > Odnoklassniki
			 *	http://ok.ru
			 */
			ok: function() {
				var options = $.extend({
					url:    location.href,
					text:   ''
				});
				return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1'
					+ '&st.comments=' + encodeURIComponent(options.text)
					+ '&st._surl='    + encodeURIComponent(options.url);
			},
			/*
			 *	Share link > Facebook
			 *	http://facebook.com
			 */
			fb: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					image:  '',
					text:   ''
				});
				return 'http://www.facebook.com/sharer.php?s=100'
					+ '&p[title]='     + encodeURIComponent(options.title)
					+ '&p[summary]='   + encodeURIComponent(options.text)
					+ '&p[url]='       + encodeURIComponent(options.url)
					+ '&p[images][0]=' + encodeURIComponent(options.image);
			},
			/*
			 *	Share link > LiveJournal
			 *	http://livejournal.com
			 */
			lj: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://livejournal.com/update.bml?'
					+ 'subject='        + encodeURIComponent(options.title)
					+ '&event='         + encodeURIComponent('' + options.title + ' ' + options.text)
					+ '&transform=1';
			},
			/*
			 *	Share link > Twitter
			 *	http://twitter.com
			 */
			tw: function() {
				var options = $.extend({
					url:        location.href,
					title:      document.title
				});
				return 'http://twitter.com/share?'
					+ 'text='      + encodeURIComponent(options.title)
					+ '&url='      + encodeURIComponent(options.url);
			},
			/*
			 *	Share link > Google Plus
			 *	http://plus.google.com
			 */
			gp: function() {
				var options = $.extend({
					url:    location.href
				});
				return 'https://plus.google.com/share?url='
					+ encodeURIComponent(options.url);
			},
			/*
			 *	Share link > My@Mail.Ru
			 *	http://my.mail.ru
			 */
			mr: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					image:  '',
					text:   ''
				});
				return 'http://connect.mail.ru/share?'
					+ 'url='          + encodeURIComponent(options.url)
					+ '&title='       + encodeURIComponent(options.title)
					+ '&description=' + encodeURIComponent(options.text)
					+ '&imageurl='    + encodeURIComponent(options.image);
			},
			/*
			 *	Share link > LinkedIn
			 *	http://linkedin.com
			 */
			li: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://www.linkedin.com/shareArticle?mini=true'
					+ '&url='       + encodeURIComponent(options.url)
					+ '&title='     + encodeURIComponent(options.title)
					+ '&summary='   + encodeURIComponent(options.text);
			},
			/*
			 *	Share link > tumblr
			 *	http://tumblr.com
			 */
			tm: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://www.tumblr.com/share/link?'
					+ 'url='		+ encodeURIComponent(options.url)
					+ '&name='     		+ encodeURIComponent(options.title)
					+ '&description='	+ encodeURIComponent(options.text);
			},
			/*
			 *	Share link > Blogger
			 *	https://www.blogger.com
			 */
			bl: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.blogger.com/blog-this.g?'
					+ 'u='	+ encodeURIComponent(options.url)
					+ '&n='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Pinterest
			 *	http://www.pinterest.com
			 */
			pt: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.pinterest.com/pin/create/button/?'
					+ 'url='		+ encodeURIComponent(options.url)
					+ '&description='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Evernote
			 *	http://www.evernote.com
			 */
			en: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.evernote.com/clip.action?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title)
					+ '&body='	+ encodeURIComponent(options.text + '
' + options.title + '');
			},
			/*
			 *	Share link > Digg
			 *	http://www.digg.com
			 */
			di: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://digg.com/submit?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Yandex.Zakladki
			 *	http://zakladki.yandex.ru
			 */
			yz: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://zakladki.yandex.ru/newlink.xml?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&name='	+ encodeURIComponent(options.title)
					+ '&descr='	+ encodeURIComponent(options.text);
			},
			/*
			 *	Share link > Reddit
			 *	http://www.reddit.com
			 */
			rd: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://www.reddit.com/submit?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Surfingbird
			 *	http://www.surfingbird.ru
			 */
			sb: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://surfingbird.ru/share?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Popup window
			 */
			popup: function(url) {
				return window.open(url, '', 'toolbar=0,status=0,scrollbars=0,width=626,height=436');
			}
		};
		/*
		 *	Share counter > Vkontakte
		 *	http://vk.com
		 */
		$.getJSON('https://vk.com/share.php?act=count&index=1&url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {});
		VK = {};
	        VK.Share = {};
		VK.Share.count = function(index, count) {
			if (count >= 1000) $('[data-counter="vk"]').text(count/1000 + 'k');
			else if (count >= 1000000) $('[data-counter="vk"]').text(count/1000000 + 'M');
			else $('[data-counter="vk"]').text(count);
	        };
		/*
		 *	Share counter > Odnoklassniki
		 *	http://ok.ru
		 */
		$.getJSON('https://connect.ok.ru/dk?st.cmd=extLike&uid=1&ref=' + encodeURIComponent(location.href) + '&callback=?', function(response) {});
		ODKL = {};
		ODKL.updateCount = function(index, count) {
			if (count >= 1000) $('[data-counter="ok"]').text(count/1000 + 'k');
			else if (count >= 1000000) $('[data-counter="ok"]').text(count/1000000 + 'M');
			else $('[data-counter="ok"]').text(count);
		};
		/*
		 *	Share counter > Facebook
		 *	http://facebook.com
		 */
		$.getJSON('https://api.facebook.com/method/links.getStats?format=json&urls=' + encodeURIComponent(location.href) + '&format=json&callback=?', function(response) {
			if (response[0].share_count >= 1000) $('[data-counter="fb"]').text(response[0].share_count/1000 + 'k');
			else if (response[0].share_count >= 1000000) $('[data-counter="fb"]').text(response[0].share_count/1000000 + 'M');
			else $('[data-counter="fb"]').text(response[0].share_count);
	        });
		/*
		 *	Share counter > Twitter
		 *	http://twitter.com
		 */
		$.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {
			if (response.count >= 1000) $('[data-counter="tw"]').text(response.count/1000 + 'k');
			else if (response.count >= 1000000) $('[data-counter="tw"]').text(response.count/1000000 + 'M');
			else $('[data-counter="tw"]').text(response.count);
	        });
		/*
		 *	Share counter > Google Plus
		 *	http://plus.google.com
		 */
		$.ajax({
			type: 'POST',
			url: 'https://clients6.google.com/rpc',
			processData: true,
			contentType: 'application/json',
			data: JSON.stringify({
				'method': 'pos.plusones.get',
				'id': location.href,
				'params': {
					'nolog': true,
					'id': location.href,
					'source': 'widget',
					'userId': '@viewer',
					'groupId': '@self'
				},
				'jsonrpc': '2.0',
				'key': 'p',
				'apiVersion': 'v1'
			}),
			success: function(response) {
				if (response.result.metadata.globalCounts.count >= 1000) $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count/1000 + 'k');
				else if (response.result.metadata.globalCounts.count >= 1000000) $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count/1000000 + 'M');
				else $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count);
			}
	        });
		/*
		 *	Init goodshare link click
		 */
		$(document).on('click', '.goodshare', function(event) {
			event.preventDefault();
			goodshare.init(this);
		});
	});
})(jQuery, document, window);
<commit_msg>Init goodshare.js v3.0<commit_after>/*
 *	@author Interactive agency "Central marketing" http://iacm.ru
 *	@copyright Copyright (c) 2015, Interactive agency "Central marketing"
 *	@license http://opensource.org/licenses/MIT The MIT License (MIT)
 *	@version 3.0 at 14/09/2015 (16:50)
 *
 *	goodshare.js
 *
 *	Useful jQuery plugin that will help your website visitors share a link on social networks and microblogs.
 *	Easy to install and configuring on any of your website!
 */
;(function($, document, window, undefined) {
	$(document).ready(function() {
		goodshare = {
			init: function(_element, _options) {
				/*
				 *	Default options:
				 *
				 *	(social) type = vk
				 *	url = current browser adress stroke
				 *	title = current document <title>
				 */
				var self = goodshare, options = $.extend({
					type:	'vk',
					url:	location.href,
					title:	document.title,
					text:	'',
					image:	''
				}, $(_element).data(), _options);
				/*
				 *	Open popup
				 */
				if (self.popup(link = self[options.type](options)) !== null) return false;
			},
			/*
			 *	Share link > Vkontakte
			 *	http://vk.com
			 */
			vk: function(_options) {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:	'',
					image:	''
				}, _options);
				return 'http://vk.com/share.php?'
					+ 'url='          + encodeURIComponent(options.url)
					+ '&title='       + encodeURIComponent(options.title)
					+ '&description=' + encodeURIComponent(options.text)
					+ '&image='       + encodeURIComponent(options.image);
			},
			/*
			 *	Share link > Odnoklassniki
			 *	http://ok.ru
			 */
			ok: function() {
				var options = $.extend({
					url:    location.href,
					text:   ''
				});
				return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1'
					+ '&st.comments=' + encodeURIComponent(options.text)
					+ '&st._surl='    + encodeURIComponent(options.url);
			},
			/*
			 *	Share link > Facebook
			 *	http://facebook.com
			 */
			fb: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					image:  '',
					text:   ''
				});
				return 'http://www.facebook.com/sharer.php?'
					+ 'u='     + encodeURIComponent(options.url);
			},
			/*
			 *	Share link > LiveJournal
			 *	http://livejournal.com
			 */
			lj: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://livejournal.com/update.bml?'
					+ 'subject='        + encodeURIComponent(options.title)
					+ '&event='         + encodeURIComponent('' + options.title + ' ' + options.text)
					+ '&transform=1';
			},
			/*
			 *	Share link > Twitter
			 *	http://twitter.com
			 */
			tw: function() {
				var options = $.extend({
					url:        location.href,
					title:      document.title
				});
				return 'http://twitter.com/share?'
					+ 'url='      + encodeURIComponent(options.url)
					+ '&text='      + encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Google Plus
			 *	http://plus.google.com
			 */
			gp: function() {
				var options = $.extend({
					url:    location.href
				});
				return 'https://plus.google.com/share?url='
					+ encodeURIComponent(options.url);
			},
			/*
			 *	Share link > My@Mail.Ru
			 *	http://my.mail.ru
			 */
			mr: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					image:  '',
					text:   ''
				});
				return 'http://connect.mail.ru/share?'
					+ 'url='          + encodeURIComponent(options.url)
					+ '&title='       + encodeURIComponent(options.title)
					+ '&description=' + encodeURIComponent(options.text)
					+ '&imageurl='    + encodeURIComponent(options.image);
			},
			/*
			 *	Share link > LinkedIn
			 *	http://linkedin.com
			 */
			li: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://www.linkedin.com/shareArticle?'
					+ 'url='       + encodeURIComponent(options.url);
			},
			/*
			 *	Share link > tumblr
			 *	http://tumblr.com
			 */
			tm: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://www.tumblr.com/share/link?'
					+ 'url='		+ encodeURIComponent(options.url)
					+ '&name='     		+ encodeURIComponent(options.title)
					+ '&description='	+ encodeURIComponent(options.text);
			},
			/*
			 *	Share link > Blogger
			 *	https://www.blogger.com
			 */
			bl: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.blogger.com/blog-this.g?'
					+ 'u='	+ encodeURIComponent(options.url)
					+ '&n='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Pinterest
			 *	http://www.pinterest.com
			 */
			pt: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.pinterest.com/pin/create/button/?'
					+ 'url='		+ encodeURIComponent(options.url)
					+ '&description='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Evernote
			 *	http://www.evernote.com
			 */
			en: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'https://www.evernote.com/clip.action?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title)
					+ '&body='	+ encodeURIComponent(options.text + '
' + options.title + '');
			},
			/*
			 *	Share link > Digg
			 *	http://www.digg.com
			 */
			di: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://digg.com/submit?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Yandex.Zakladki
			 *	http://zakladki.yandex.ru
			 */
			yz: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://zakladki.yandex.ru/newlink.xml?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&name='	+ encodeURIComponent(options.title)
					+ '&descr='	+ encodeURIComponent(options.text);
			},
			/*
			 *	Share link > Reddit
			 *	http://www.reddit.com
			 */
			rd: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title
				});
				return 'http://www.reddit.com/submit?'
					+ 'url='	+ encodeURIComponent(options.url)
					+ '&title='	+ encodeURIComponent(options.title);
			},
			/*
			 *	Share link > Surfingbird
			 *	http://www.surfingbird.ru
			 */
			sb: function() {
				var options = $.extend({
					url:    location.href,
					title:  document.title,
					text:   ''
				});
				return 'http://surfingbird.ru/share?'
					+ 'url='			+ encodeURIComponent(options.url)
					+ '&title='			+ encodeURIComponent(options.title)
					+ '&description='	+ encodeURIComponent(options.text);
			},
			/*
			 *	Popup window
			 */
			popup: function(url) {
				return window.open(url, '', 'toolbar=0,status=0,scrollbars=0,width=626,height=436');
			}
		};
		/*
		 *	Share counter > Vkontakte
		 *	http://vk.com
		 */
		$.getJSON('https://vk.com/share.php?act=count&index=1&url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {});
		VK = {};
	        VK.Share = {};
		VK.Share.count = function(index, count) {
			if (count >= 1000) $('[data-counter="vk"]').text(count/1000 + 'k');
			else if (count >= 1000000) $('[data-counter="vk"]').text(count/1000000 + 'M');
			else $('[data-counter="vk"]').text(count);
	        };
		/*
		 *	Share counter > Odnoklassniki
		 *	http://ok.ru
		 */
		$.getJSON('https://connect.ok.ru/dk?st.cmd=extLike&uid=1&ref=' + encodeURIComponent(location.href) + '&callback=?', function(response) {});
		ODKL = {};
		ODKL.updateCount = function(index, count) {
			if (count >= 1000) $('[data-counter="ok"]').text(count/1000 + 'k');
			else if (count >= 1000000) $('[data-counter="ok"]').text(count/1000000 + 'M');
			else $('[data-counter="ok"]').text(count);
		};
		/*
		 *	Share counter > Facebook
		 *	http://facebook.com
		 */
		$.getJSON('https://api.facebook.com/method/links.getStats?format=json&urls=' + encodeURIComponent(location.href) + '&format=json&callback=?', function(response) {
			if (response[0].share_count >= 1000) $('[data-counter="fb"]').text(response[0].share_count/1000 + 'k');
			else if (response[0].share_count >= 1000000) $('[data-counter="fb"]').text(response[0].share_count/1000000 + 'M');
			else $('[data-counter="fb"]').text(response[0].share_count);
	        });
		/*
		 *	Share counter > Twitter
		 *	http://twitter.com
		 */
		$.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {
			if (response.count >= 1000) $('[data-counter="tw"]').text(response.count/1000 + 'k');
			else if (response.count >= 1000000) $('[data-counter="tw"]').text(response.count/1000000 + 'M');
			else $('[data-counter="tw"]').text(response.count);
	        });
		/*
		 *	Share counter > Google Plus
		 *	http://plus.google.com
		 */
		$.ajax({
			type: 'POST',
			url: 'https://clients6.google.com/rpc',
			processData: true,
			contentType: 'application/json',
			data: JSON.stringify({
				'method': 'pos.plusones.get',
				'id': location.href,
				'params': {
					'nolog': true,
					'id': location.href,
					'source': 'widget',
					'userId': '@viewer',
					'groupId': '@self'
				},
				'jsonrpc': '2.0',
				'key': 'p',
				'apiVersion': 'v1'
			}),
			success: function(response) {
				if (response.result.metadata.globalCounts.count >= 1000) $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count/1000 + 'k');
				else if (response.result.metadata.globalCounts.count >= 1000000) $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count/1000000 + 'M');
				else $('[data-counter="gp"]').text(response.result.metadata.globalCounts.count);
			}
	        });
		/*
		 *	Init goodshare link click
		 */
		$(document).on('click', '.goodshare', function(event) {
			event.preventDefault();
			goodshare.init(this);
		});
	});
})(jQuery, document, window);
<|endoftext|>


<commit_before>/**
 * Manage meteor_login_token cookie
 * Necessary for authentication when the
 * Authorization header is not set
 *
 * E.g on first page loading
 */
import Cookies from 'universal-cookie';

import { Meteor } from 'meteor/meteor';

const cookie = new Cookies();

function setToken(loginToken, expires) {
  if (loginToken && expires !== -1) {
    cookie.set('meteor_login_token', loginToken, {
      path: '/',
      expires,
    });
  } else {
    cookie.remove('meteor_login_token', {
      path: '/',
    });
  }
}

function initToken() {
  const loginToken = global.localStorage['Meteor.loginToken'];
  const loginTokenExpires = new Date(global.localStorage['Meteor.loginTokenExpires']);

  if (loginToken) {
    setToken(loginToken, loginTokenExpires);
  } else {
    setToken(null, -1);
  }
}

Meteor.startup(() => {
  initToken();
});

// TODO: cleanup
// This part of the code overrides the default localStorage function,
// so that when Meteor.loginToken is set, it is also automatically
// stored as a cookie (necessary for SSR to work as expected for all HTTP requests)
const originalSetItem = Meteor._localStorage.setItem;
Meteor._localStorage.setItem = function setItem(key, value) {
  if (key === 'Meteor.loginToken') {
    Meteor.defer(initToken);
  }
  originalSetItem.call(Meteor._localStorage, key, value);
};
const originalRemoveItem = Meteor._localStorage.removeItem;
Meteor._localStorage.removeItem = function removeItem(key) {
  if (key === 'Meteor.loginToken') {
    Meteor.defer(initToken);
  }
  originalRemoveItem.call(Meteor._localStorage, key);
};
<commit_msg>Handle missing localStorage in client auth<commit_after>/**
 * Manage meteor_login_token cookie
 * Necessary for authentication when the
 * Authorization header is not set
 *
 * E.g on first page loading
 */
import Cookies from 'universal-cookie';

import { Meteor } from 'meteor/meteor';

const cookie = new Cookies();

function setToken(loginToken, expires) {
  if (loginToken && expires !== -1) {
    cookie.set('meteor_login_token', loginToken, {
      path: '/',
      expires,
    });
  } else {
    cookie.remove('meteor_login_token', {
      path: '/',
    });
  }
}

function initToken() {
  let loginToken, loginTokenExpires;
  try {
    // Get Meteor.loginToken from localStorage. This is wrapped in a try-catch
    // because some browsers (especially mobile browsers) don't have
    // localStorage, and throw a wide variety of Sentry-polluting errors here.
    loginToken = global.localStorage['Meteor.loginToken'];
    loginTokenExpires = new Date(global.localStorage['Meteor.loginTokenExpires']);
  } catch(e) {
    return;
  }

  if (loginToken) {
    setToken(loginToken, loginTokenExpires);
  } else {
    setToken(null, -1);
  }
}

Meteor.startup(() => {
  initToken();
});

// TODO: cleanup
// This part of the code overrides the default localStorage function,
// so that when Meteor.loginToken is set, it is also automatically
// stored as a cookie (necessary for SSR to work as expected for all HTTP requests)
const originalSetItem = Meteor._localStorage.setItem;
Meteor._localStorage.setItem = function setItem(key, value) {
  if (key === 'Meteor.loginToken') {
    Meteor.defer(initToken);
  }
  originalSetItem.call(Meteor._localStorage, key, value);
};
const originalRemoveItem = Meteor._localStorage.removeItem;
Meteor._localStorage.removeItem = function removeItem(key) {
  if (key === 'Meteor.loginToken') {
    Meteor.defer(initToken);
  }
  originalRemoveItem.call(Meteor._localStorage, key);
};
<|endoftext|>


<commit_before>import WebMiddle, { evaluate, createContext, isResource } from 'webmiddle';
import superagent from 'superagent';

async function requestServer(url, data = {}) {
  return new Promise((resolve, reject) => {
    superagent
      .post(url)
      .send(data)
      .end((err, res) => {
        if (err) reject(err);
        resolve(res.body);
      });
  });
}

async function requestServicePaths(serverUrl) {
  const servicePathsUrl = serverUrl + (serverUrl.endsWith('/') ? '' : '/') + 'services/';
  const jsonResource = await requestServer(servicePathsUrl);
  return jsonResource.content;
}

async function requestSettingPaths(serverUrl) {
  const settingPathsUrl = serverUrl + (serverUrl.endsWith('/') ? '' : '/') + 'settings/';
  const jsonResource = await requestServer(settingPathsUrl);
  return jsonResource.content;
}

async function createServices(serverUrl) {
  const servicePaths = await requestServicePaths(serverUrl);
  const services = {};
  servicePaths.forEach(path => {
    const serviceUrl = serverUrl + (serverUrl.endsWith('/') ? '' : '/') + 'services/' + path;
    const service = (props, context) => requestServer(serviceUrl, {
      props,
      options: context.options,
    });
    services[path] = service;
  });
  return services;
}

async function createSettings(serverUrl) {
  // TODO
}

export default async function webmiddleClient(serverUrl) {
  return new WebMiddle({
    services: await createServices(serverUrl),
    settings: await createSettings(serverUrl),
  });
}
<commit_msg>Replace . in path with /<commit_after>import WebMiddle, { evaluate, createContext, isResource } from 'webmiddle';
import superagent from 'superagent';

async function requestServer(url, data = {}) {
  return new Promise((resolve, reject) => {
    superagent
      .post(url)
      .send(data)
      .end((err, res) => {
        if (err) reject(err);
        resolve(res.body);
      });
  });
}

async function requestServicePaths(serverUrl) {
  const servicePathsUrl = serverUrl + (serverUrl.endsWith('/') ? '' : '/') + 'services/';
  const jsonResource = await requestServer(servicePathsUrl);
  return jsonResource.content;
}

async function requestSettingPaths(serverUrl) {
  const settingPathsUrl = serverUrl + (serverUrl.endsWith('/') ? '' : '/') + 'settings/';
  const jsonResource = await requestServer(settingPathsUrl);
  return jsonResource.content;
}

async function createServices(serverUrl) {
  const servicePaths = await requestServicePaths(serverUrl);
  const services = {};
  servicePaths.forEach(path => {
    const serviceUrl = serverUrl +
      (serverUrl.endsWith('/') ? '' : '/') + 'services/' +
      path.replace(/\\./g, '/');

    const service = (props, context) => requestServer(serviceUrl, {
      props,
      options: context.options,
    });
    services[path] = service;
  });
  return services;
}

async function createSettings(serverUrl) {
  // TODO
}

export default async function webmiddleClient(serverUrl) {
  return new WebMiddle({
    services: await createServices(serverUrl),
    settings: await createSettings(serverUrl),
  });
}
<|endoftext|>


<commit_before>module.exports = function (grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
      demo: {
        files: {
          './examples/browserify/example.js': ['./examples/browserify/index.js']
        },
        options: {
          browserifyOptions: {
            debug: true
          }
        }
      }
    },
    concurrent: {
      tasks: ['watch','nodemon'],
      options: {
        logConcurrentOutput: true
      }
    },
    copy: {
      raw: {
        expand: true,
        flatten: true,
        src: [
          './angular.hammer.js',
          './node_modules/hammerjs/hammer.js',
          './node_modules/angular/angular.js'
        ],
        dest: './examples/raw/'
      },
      rawmin: {
        expand: true,
        flatten: true,
        src: [
          './angular.hammer.min.js',
          './angular.hammer.min.js.map',
          './node_modules/angular/angular.min.js',
          './node_modules/angular/angular.min.js.map',
          './node_modules/hammerjs/hammer.min.js',
          './node_modules/hammerjs/hammer.min.js.map'
        ],
        dest: './examples/raw/'
      }
    },
    jsdoc : {
      dist : {
        src: ['./angular.hammer.js'],
        dest: './doc',
        options: {
          configure: 'jsdoc.json'
        }
      }
    },
    nodemon: {
      demo: {
        script:'server.js',
        options: {
          watch: ['./examples']
        }
      }
    },
    requirejs: {
    },
    uglify: {
      dist: {
        options: {
          sourceMap: true,
          sourceMapName: './angular.hammer.min.js.map',
          mangle: true,
          preserveComments: require('uglify-save-license')
        },
        './angular.hammer.min.js': ['./angular.hammer.js']
      },
      browserify: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/browserify/example.min.js.map',
          mangle: true
        },
        './examples/browserify/example.js': ['./examples/browserify/example.js']
      },
      requirejs: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/requirejs/example.min.js.map',
          mangle: true
        },
        './examples/requirejs/example.js': ['./examples/requirejs/example.js']
      },
      webpack: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/webpack/example.min.js.map',
          mangle: true
        },
        './examples/webpack/example.js': ['./examples/webpack/example.js']
      }
    },
    watch: {
      js:  {
        files: ['./angular.hammer.js'],
        tasks: ['browserify:dev']
      },
      raw: {
        files: ['./angular.hammer.js'],
        tasks: ['browserify:dev']
      }
    },
    webpack: {
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-webpack');

  grunt.registerTask('build', ['uglify:dist', 'jsdoc:dist']);
  grunt.registerTask('default', ['copy', 'browserify', 'requirejs', 'webpack', 'concurrent']);
  grunt.registerTask('demo-browserify', ['browserify', 'nodemon']);
  grunt.registerTask('demo-browserify-min', ['browserify', 'uglify:browserify', 'nodemon']);
  grunt.registerTask('demo-raw', ['copy:raw', 'nodemon']);
  grunt.registerTask('demo-raw-min', ['copy:rawmin', 'nodemon']);
}<commit_msg>Updated gruntfile to adjust build and demo process<commit_after>module.exports = function (grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
      demo: {
        files: {
          './examples/browserify/example.js': ['./examples/browserify/index.js']
        },
        options: {
          browserifyOptions: {
            debug: true
          }
        }
      }
    },
    concurrent: {
      tasks: ['watch','nodemon'],
      options: {
        logConcurrentOutput: true
      }
    },
    copy: {
      raw: {
        expand: true,
        flatten: true,
        src: [
          './angular.hammer.js',
          './node_modules/hammerjs/hammer.js',
          './node_modules/angular/angular.js'
        ],
        dest: './examples/raw/'
      },
      rawmin: {
        expand: true,
        flatten: true,
        src: [
          './angular.hammer.min.js',
          './angular.hammer.min.js.map',
          './node_modules/angular/angular.min.js',
          './node_modules/angular/angular.min.js.map',
          './node_modules/hammerjs/hammer.min.js',
          './node_modules/hammerjs/hammer.min.js.map'
        ],
        dest: './examples/raw/'
      }
    },
    jsdoc : {
      dist : {
        src: ['./angular.hammer.js'],
        dest: './doc',
        options: {
          configure: 'jsdoc.json'
        }
      }
    },
    nodemon: {
      demo: {
        script:'server.js',
        options: {
          watch: ['./examples']
        }
      }
    },
    requirejs: {
    },
    uglify: {
      dist: {
        options: {
          sourceMap: true,
          sourceMapName: './angular.hammer.min.js.map',
          mangle: true,
          preserveComments: require('uglify-save-license')
        },
        './angular.hammer.min.js': ['./angular.hammer.js']
      },
      browserify: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/browserify/example.min.js.map',
          mangle: true
        },
        './examples/browserify/example.js': ['./examples/browserify/example.js']
      },
      requirejs: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/requirejs/example.min.js.map',
          mangle: true
        },
        './examples/requirejs/example.js': ['./examples/requirejs/example.js']
      },
      webpack: {
        options: {
          sourceMap: true,
          sourceMapName: './examples/webpack/example.min.js.map',
          mangle: true
        },
        './examples/webpack/example.js': ['./examples/webpack/example.js']
      }
    },
    watch: {
      js:  {
        files: ['./angular.hammer.js'],
        tasks: ['copy', 'browserify']
      },
      raw: {
        files: [
          './angular.hammer.js',
          './angular.hammer.min.js'
        ],
        tasks: ['copy']
      }
    },
    webpack: {
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-webpack');

  grunt.registerTask('build', ['uglify:dist', 'jsdoc:dist']);
  grunt.registerTask('default', ['copy', 'browserify', 'requirejs', 'webpack', 'concurrent']);
  grunt.registerTask('demo-browserify', ['browserify', 'nodemon']);
  grunt.registerTask('demo-browserify-min', ['browserify', 'uglify:browserify', 'nodemon']);
  grunt.registerTask('demo-raw', ['copy:raw', 'nodemon']);
  grunt.registerTask('demo-raw-min', ['copy:rawmin', 'nodemon']);
}<|endoftext|>


<commit_before>module.exports = function(grunt) {

  var package = grunt.file.readJSON('package.json');

  grunt.initConfig ({
    pkg: package,

    sass: {
      docs: {
        options:{/*outputStyle: 'compressed'*/ /* cssmin will do this for us */},
        files: {'docs.css' : 'docs/docs.scss'}
      },
    },

    // ---------------------

    cssmin: {
      docs: {
        options: {
          expand: false,
          processImport: true,
          banner: '/* <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %> */',
        },
        files: {'docs.css': ["docs.css"]}
      }
    },

    // ---------------------

    jade: {
      docs: {
        options: {
          data: {
            pkg: package,
            debug: false,
            timestamp: "<%= pkg.name + ' '+ (new Date().getTime()) %>"
          }
        },
        files: {"docs.html": ["docs/docs.jade"]}
      }
    },

    // ---------------------

    uglify: {
      options: {
        banner: '/* <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %> */',
        compress: {} /*{drop_console: true}*/,
        mangle: true /*{except: ['jQuery','fwx']}*/
      },
      dist: {
        options: {},
        files: {'jQuery.MultiFile.min.js': 'jQuery.MultiFile.js'}
      }
    },

    // ---------------------

    shell: {
      beep_twice: {
        command: 'echo  echo ',
        options: {stdout: true}
      }
    },

    // ---------------------

    gitcommit: {
      local: {
        options: {
          branch: 'dev',
          message: 'Auto commit <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %>'
        }
      },
    },
    gitpush: {
      remote: {
        options: {
          branch: 'dev',
          message: 'Auto deply <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %>'
        }
      },
    },

    // ---------------------

    watch: {
      options:{
        reload: true
      },
      jade: { files: ['package.json','docs/**/*.jade','docs/*.html'], tasks: ['jade:docs','beep'], options: {} },
      scss: { files: ['docs/*.scss'], tasks: ['sass:docs','beep'], options: {} },
      css: { files: ['*.css'], tasks: ['cssmin:docs','beep'], options: {} },
      js: { files: ['jquery.MultiFile.js'], tasks: ['uglify:dist','beep'], options: {} }
    }

  });

  // ---------------------

  // Load required plugins
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-git');

  // ---------------------

  // Register common tasks and aliases
  grunt.registerTask('default', ['uglify:dist']);
  grunt.registerTask('build', ['uglify:dist']);
  grunt.registerTask('min', ['uglify:dist']);
  grunt.registerTask('css', ['sass:docs cssmin:docs']);
  grunt.registerTask('doc', ['jade:docs sass:docs cssmin:docs']);
  grunt.registerTask('all', ['uglify:dist jade:docs sass:docs cssmin:docs']);
  grunt.registerTask('beep', ['shell:beep_twice']);
  grunt.registerTask('deploy', ['gitpush:remote']);

  // ---------------------

  // Custom test tasks
  grunt.registerTask('test', function() {
    grunt.log.write('Unit tests will go here'+'\n').ok();
  });

  // ---------------------

  // Watch for file changes and run tasks automatically
  grunt.event.on('watch', function(action, filepath, target) {
    grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
  });

  // ---------------------

};
<commit_msg>fix task definition, enabling successful doc build at least<commit_after>module.exports = function(grunt) {

  var package = grunt.file.readJSON('package.json');

  grunt.initConfig ({
    pkg: package,

    sass: {
      docs: {
        options:{/*outputStyle: 'compressed'*/ /* cssmin will do this for us */},
        files: {'docs.css' : 'docs/docs.scss'}
      },
    },

    // ---------------------

    cssmin: {
      docs: {
        options: {
          expand: false,
          processImport: true,
          banner: '/* <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %> */',
        },
        files: {'docs.css': ["docs.css"]}
      }
    },

    // ---------------------

    jade: {
      docs: {
        options: {
          data: {
            pkg: package,
            debug: false,
            timestamp: "<%= pkg.name + ' '+ (new Date().getTime()) %>"
          }
        },
        files: {"docs.html": ["docs/docs.jade"]}
      }
    },

    // ---------------------

    uglify: {
      options: {
        banner: '/* <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %> */',
        compress: {} /*{drop_console: true}*/,
        mangle: true /*{except: ['jQuery','fwx']}*/
      },
      dist: {
        options: {},
        files: {'jQuery.MultiFile.min.js': 'jQuery.MultiFile.js'}
      }
    },

    // ---------------------

    shell: {
      beep_twice: {
        command: 'echo  echo ',
        options: {stdout: true}
      }
    },

    // ---------------------

    gitcommit: {
      local: {
        options: {
          branch: 'dev',
          message: 'Auto commit <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %>'
        }
      },
    },
    gitpush: {
      remote: {
        options: {
          branch: 'dev',
          message: 'Auto deply <%= pkg.name %> v<%= pkg.version %> @ <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %>'
        }
      },
    },

    // ---------------------

    watch: {
      options:{
        reload: true
      },
      jade: { files: ['package.json','docs/**/*.jade','docs/*.html'], tasks: ['jade:docs','beep'], options: {} },
      scss: { files: ['docs/*.scss'], tasks: ['sass:docs','beep'], options: {} },
      css: { files: ['*.css'], tasks: ['cssmin:docs','beep'], options: {} },
      js: { files: ['jquery.MultiFile.js'], tasks: ['uglify:dist','beep'], options: {} }
    }

  });

  // ---------------------

  // Load required plugins
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-git');

  // ---------------------

  // Register common tasks and aliases
  grunt.registerTask('default', ['uglify:dist']);
  grunt.registerTask('build', ['uglify:dist']);
  grunt.registerTask('min', ['uglify:dist']);
  grunt.registerTask('css', ['sass:docs', 'cssmin:docs']);
  grunt.registerTask('doc', ['jade:docs', 'sass:docs', 'cssmin:docs']);
  grunt.registerTask('all', ['uglify:dist', 'jade:docs', 'sass:docs', 'cssmin:docs']);
  grunt.registerTask('beep', ['shell:beep_twice']);
  grunt.registerTask('deploy', ['gitpush:remote']);

  // ---------------------

  // Custom test tasks
  grunt.registerTask('test', function() {
    grunt.log.write('Unit tests will go here'+'\n').ok();
  });

  // ---------------------

  // Watch for file changes and run tasks automatically
  grunt.event.on('watch', function(action, filepath, target) {
    grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
  });

  // ---------------------

};
<|endoftext|>


<commit_before>/**
 * Created by Samuel on 6/5/2016.
 */

function loadTasks(grunt) {
    grunt.loadNpmTasks('grunt-simple-mocha');
    grunt.loadNpmTasks('grunt-mocha-istanbul');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-uglify');
}

function registerTasks(grunt) {

    grunt.registerTask('default',
        ['mocha_istanbul']);

    grunt.registerTask('test',
        ['simplemocha']);

    grunt.registerTask('cover',
        ['mocha_istanbul']);

    grunt.registerTask('build',
        ['mkdir','browserify','uglify']);
}

function getMkdirData() {
    return {
        all: {
            options: {
                create: ['dist']
            }
        }
    };
}

function getBrowserifyData() {
    return {
        "dist/short-uuid.js": ["index.js"],
        options: {
            browserifyOptions: {
                builtins: false,
                commondir: false,
                detectGlobals: false,
                insertGlobalVars: ['__filename', '__dirname'],
                'standalone' : 'ShortUUID'
            }
        }
    };
}

function getMochaIstanbulData() {
    return {
        coverage: {
            src: 'test', // a folder works nicely
            options: {
                mask: '*.js'
            }
        }
    };
}

function getSimpleMochaData() {
    return {
        options: {
            globals: ['expect'],
            timeout: 3000,
            ignoreLeaks: false,
            ui: 'bdd',
            reporter: 'tap'
        },
        all: { src: ['test/*.js'] }
    };
}

function getUglifyData() {
    return {
        options: {
            banner: '/*! <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        },
        my_target: {
            files: {
                'dist/short-uuid.min.js': ['dist/short-uuid.js']
            }
        }
    };
}
module.exports = function(grunt) {
    var banner = '/*\n<%= pkg.name %> <%= pkg.version %>';
    banner += '- <%= pkg.description %>\n<%= pkg.repository.url %>\n';
    banner += 'Built on <%= grunt.template.today("yyyy-mm-dd") %>\n*/\n';

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        browserify: getBrowserifyData(),
        mkdir: getMkdirData(),
        mocha_istanbul: getMochaIstanbulData(),
        simplemocha: getSimpleMochaData(),
        uglify: getUglifyData()
    });

    loadTasks(grunt);
    registerTasks(grunt);
};<commit_msg>Add Missing linebreak<commit_after>/**
 * Created by Samuel on 6/5/2016.
 */

function loadTasks(grunt) {
    grunt.loadNpmTasks('grunt-simple-mocha');
    grunt.loadNpmTasks('grunt-mocha-istanbul');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-uglify');
}

function registerTasks(grunt) {

    grunt.registerTask('default',
        ['mocha_istanbul']);

    grunt.registerTask('test',
        ['simplemocha']);

    grunt.registerTask('cover',
        ['mocha_istanbul']);

    grunt.registerTask('build',
        ['mkdir','browserify','uglify']);
}

function getMkdirData() {
    return {
        all: {
            options: {
                create: ['dist']
            }
        }
    };
}

function getBrowserifyData() {
    return {
        "dist/short-uuid.js": ["index.js"],
        options: {
            browserifyOptions: {
                builtins: false,
                commondir: false,
                detectGlobals: false,
                insertGlobalVars: ['__filename', '__dirname'],
                'standalone' : 'ShortUUID'
            }
        }
    };
}

function getMochaIstanbulData() {
    return {
        coverage: {
            src: 'test', // a folder works nicely
            options: {
                mask: '*.js'
            }
        }
    };
}

function getSimpleMochaData() {
    return {
        options: {
            globals: ['expect'],
            timeout: 3000,
            ignoreLeaks: false,
            ui: 'bdd',
            reporter: 'tap'
        },
        all: { src: ['test/*.js'] }
    };
}

function getUglifyData() {
    return {
        options: {
            banner: '/*! <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        },
        my_target: {
            files: {
                'dist/short-uuid.min.js': ['dist/short-uuid.js']
            }
        }
    };
}
module.exports = function(grunt) {
    var banner = '/*\n<%= pkg.name %> <%= pkg.version %>';
    banner += '- <%= pkg.description %>\n<%= pkg.repository.url %>\n';
    banner += 'Built on <%= grunt.template.today("yyyy-mm-dd") %>\n*/\n';

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        browserify: getBrowserifyData(),
        mkdir: getMkdirData(),
        mocha_istanbul: getMochaIstanbulData(),
        simplemocha: getSimpleMochaData(),
        uglify: getUglifyData()
    });

    loadTasks(grunt);
    registerTasks(grunt);
};
<|endoftext|>


<commit_before>var shell = require("shelljs");

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
      jshint: {
        gruntfile: ['gruntfile.js'],
        scripts: ['scripts/**/*.js'],
        js: {
          options: {
            node: true,
            browser: true,
            browserify: true,
            globals: {
              '$': true,
              'jQuery': true,
              'tinymce': true
            }
          },
          files: {
            src: ['src/**/*.js']
          }
        }
      },
      browserify: {
        dist: {
          src: 'index.js',
          dest: 'plugin.js'
        }
      },
      uglify: {
        dist: {
          files: {
            'plugin.min.js': ['plugin.js']
          }
        }
      },
      watch: {
        gruntfile: {
          files: 'Gruntfile.js',
          tasks: ['jshint:gruntfile'],
        },
        js: {
          files: ['src/**/*.js'],
          tasks: ['jshint:js','browserify','watch'],
        }
      },
      bump: {
        options: {
          files: ['package.json','bower.json'],
          updateConfigs: [],
          commit: true,
          commitMessage: 'Release v%VERSION%',
          commitFiles: ['package.json','bower.json'],
          createTag: true,
          tagName: 'v%VERSION%',
          tagMessage: 'Version %VERSION%',
          push: true,
          pushTo: 'gh-sirap-group',
          gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
          globalReplace: false,
          prereleaseName: false,
          regExp: false
        }
      },
    });

    grunt.registerTask('jsdoc', function(){
      shell.exec('npm run jsdoc');
    });

    grunt.registerTask('build', ['jshint', 'browserify', 'uglify', 'jsdoc']);

    grunt.registerTask('dev', ['jshint', 'browserify', 'watch']);

    grunt.registerTask('default', ['dev']);
};
<commit_msg>replace jshint by standard and format gruntfile<commit_after>var shell = require('shelljs')

module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt)

  grunt.initConfig({
    standard: {
      options: { format: true },
      gruntfile: { src: ['gruntfile.js'] },
      scripts: { src: 'scripts/**/*.js' },
      js: { src: 'src/**/*.js' }
    },
    browserify: {
      dist: { src: 'index.js', dest: 'plugin.js' }
    },
    uglify: {
      dist: { files: { 'plugin.min.js': ['plugin.js'] } }
    },
    watch: {
      gruntfile: {
        files: 'Gruntfile.js',
        tasks: ['standard:gruntfile']
      },
      js: {
        files: ['src/**/*.js'],
        tasks: ['standard:js', 'browserify', 'watch']
      }
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: [],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['package.json', 'bower.json'],
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'gh-sirap-group',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
        globalReplace: false,
        prereleaseName: false,
        regExp: false
      }
    }
  })

  grunt.registerTask('jsdoc', function () {
    shell.exec('npm run jsdoc')
  })

  grunt.registerTask('build', ['standard', 'browserify', 'uglify', 'jsdoc'])

  grunt.registerTask('dev', ['standard', 'browserify', 'watch'])

  grunt.registerTask('default', ['dev'])
}
<|endoftext|>


<commit_before>module.exports = function(grunt){
  "use strict";

  grunt.initConfig({
    browserify: {
      dev: {
        options: {
            plugin: [
              [ "licensify"],
            ],
            debug: true,
            transform: [["babelify", { "stage": 0 }]],
            browserifyOptions: {
              extensions: ['.jsx']
            }
        },
        files: {
            'dist/app.js': 'src/**/*.jsx',
        }
      }
    },
    uglify: {
      my_target: {
        files: {
          'dist/static.js': [
              './node_modules/jquery/dist/jquery.min.js',
              './jquery.qtip.js',
              './node_modules/cytoscape/dist/cytoscape.js',
              './node_modules/cytoscape-qtip/cytoscape-qtip.js',
              './node_modules/bootstrap/dist/js/bootstrap.min.js',
              './node_modules/babel-core/browser-polyfill.min.js',
              './node_modules/cytoscape/lib/dagre.js'
          ]
        }
      }
    },
    cssmin: {
      options: {
        shorthandCompacting: false,
        roundingPrecision: -1
      },
      target: {
        files: {
          'dist/app.css': [
            './node_modules/bootstrap/dist/css/bootstrap.css',
            './node_modules/codemirror/lib/codemirror.css',
            './node_modules/react-treeview/react-treeview.css'
          ]
        }
      }
    },
    watch: {
      browserify: {
        files: ['src/**/*.jsx', 'src/**/*.js'],
        tasks: ['browserify:dev']
      },
      options: {
        nospawn: true
      }
    },
    compress: {
      main: {
        options: {
          archive: 'demo.tgz',
        },
        files: [
          {src: ['dist/**','projects/**','index.html', 'server.py'], dest: 'demo/', filter: 'isFile', expand: true}, // includes files in path and its subdirs
        ]
      }
    }
  })

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.registerTask('default', ['watch']);
//grunt.registerTask('build', ['env:build', 'browserify:build']);
};
<commit_msg>lint gruntfile<commit_after>module.exports = function(grunt){
  "use strict";

  grunt.initConfig({
    browserify: {
      dev: {
        options: {
          plugin: [
            [ "licensify"]
          ],
          debug: true,
          transform: [["babelify", { "stage": 0 }]],
          browserifyOptions: {
            extensions: [".jsx"]
          }
        },
        files: {
          "dist/app.js": "src/**/*.jsx"
        }
      }
    },
    uglify: {
      my_target: {
        files: {
          "dist/static.js": [
            "./node_modules/jquery/dist/jquery.min.js",
            "./jquery.qtip.js",
            "./node_modules/bootstrap/dist/js/bootstrap.min.js",
            "./node_modules/babel-core/browser-polyfill.min.js",
            "./node_modules/cytoscape/lib/dagre.js"
          ]
        }
      }
    },
    cssmin: {
      options: {
        shorthandCompacting: false,
        roundingPrecision: -1
      },
      target: {
        files: {
          "dist/app.css": [
            "./node_modules/bootstrap/dist/css/bootstrap.css",
            "./node_modules/codemirror/lib/codemirror.css",
            "./node_modules/react-treeview/react-treeview.css"
          ]
        }
      }
    },
    watch: {
      browserify: {
        files: ["src/**/*.jsx", "src/**/*.js"],
        tasks: ["browserify:dev"]
      },
      options: {
        nospawn: true
      }
    },
    compress: {
      main: {
        options: {
          archive: "demo.tgz"
        },
        files: [
          {src: ["dist/**","projects/**","index.html", "server.py"], dest: "demo/", filter: "isFile", expand: true} // includes files in path and its subdirs
        ]
      }
    }
  });

  grunt.loadNpmTasks("grunt-contrib-watch");
  grunt.loadNpmTasks("grunt-browserify");
  grunt.loadNpmTasks("grunt-contrib-cssmin");
  grunt.loadNpmTasks("grunt-contrib-uglify");
  grunt.loadNpmTasks("grunt-contrib-compress");
  grunt.registerTask("default", ["watch"]);
  //grunt.registerTask('build', ['env:build', 'browserify:build']);
};
<|endoftext|>


<commit_before>/*global module:true*/
(function() {
	"use strict";

	var pkg;

	module.exports = function(grunt) {

		// Project configuration.
		grunt.initConfig({
			// Metadata.
			pkg: pkg = grunt.file.readJSON("picturefill.json"),
			banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
			"<%= grunt.template.today('yyyy-mm-dd') %>\n" +
			"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
			"* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
			" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n",
			// Task configuration.
			clean: {
				files: [ "dist" ]
			},
			copy: {
				plugins: {
					files: [
						{
							expand: true,
							cwd: "src/plugins/",
							src: [ "**/*.js" ],
							dest: "dist/plugins/"
						}
					]
				}
			},

			uglify: {
				options: {
					banner: "<%= banner %>",
					compress: {
						global_defs: {
							"PFDEBUG": false
						},
						dead_code: true
					}
				},
				distfull: {
					options: {
						beautify: true,
						mangle: false
					},
					src: [ "src/picturefill.js" ],
					dest: "dist/picturefill.js"
				},
				distmin: {
					src: [ "src/picturefill.js" ],
					dest: "dist/picturefill.min.js"
				},
				plugins: {
					files: [ {
						expand: true,
						cwd: "src/plugins/",
						src: [ "**/*.js", "!*.min.js", "!**/*.min.js" ],
						dest: "dist/plugins/",
						ext: ".min.js",
						extDot: "last"
					} ]
				}
			},
			qunit: {
				files: [ "tests/*.html", "!tests/index-functional.html" ]
			},
			jshint: {
				all: {
					options: {
						jshintrc: true
					},
					src: [ "Gruntfile.js", "src/*.js" ]
				}
			},
			jscs: {
				all: {
					src: "<%= jshint.all.src %>"
				}
			},
			watch: {
				gruntfile: {
					files: [ "Gruntfile.js", "src/*.js", "tests/*.js" ],
					tasks: [ "default" ]
				}
			},
			bytesize: {
				all: {
					src: [ "dist/picturefill.min.js" ]
				}
			},
			maxFilesize: {
				options: {
					// Task-specific options go here.
				},
				minified: {
					options: {
						maxBytes: 10000
					},
					src: [ "src/picturefill.min.js" ]
				}
			}
		});

		// because the compress plugin is insane
		grunt.task.registerTask("compress", "compress the dist folder", function() {
			var childProc = require("child_process");
			var done = this.async();

			childProc.exec("zip -r dist-" + pkg.version + ".zip dist", function() {
				done();
			});
		});

		// These plugins provide necessary tasks.
		grunt.loadNpmTasks("grunt-contrib-clean");
		grunt.loadNpmTasks("grunt-contrib-copy");
		grunt.loadNpmTasks("grunt-contrib-jshint");
		grunt.loadNpmTasks("grunt-contrib-qunit");
		grunt.loadNpmTasks("grunt-contrib-uglify");
		grunt.loadNpmTasks("grunt-contrib-watch");
		grunt.loadNpmTasks("grunt-jscs");
		grunt.loadNpmTasks("grunt-bytesize");
		grunt.loadNpmTasks("grunt-max-filesize");

		// Default task.
		grunt.registerTask("default", [ "test", "clean", "copy", "uglify", "bytesize", "maxFilesize" ]);
		grunt.registerTask("test", [ "jshint", "qunit" ]); //"jscs",
	};
})();
<commit_msg>Updated Gruntfile with release task (and all the whitespace)<commit_after>/*global module:true*/
(function() {
  "use strict";

  var pkg, toConcat = [ "src/external/matchmedia.js", "src/picturefill.js" ], supportTypes = "";
  module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
      // Metadata.
      pkg: pkg = grunt.file.readJSON("picturefill.json"),
      banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
        "<%= grunt.template.today('yyyy-mm-dd') %>\n" +
        "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
        "* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
        " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n",
      // Task configuration.
      clean: {
        files: [ "dist" ]
      },
      concat: {

        dist: {
          options: {
            banner: "<%= banner %>",
            stripBanners: true
          },
          src: toConcat,
          dest: "dist/picturefill.js"
        }
      },
      uglify: {
        options: {
          banner: "<%= banner %>"
        },
        dist: {
          src: [ "<%= concat.dist.src %>" ],
          dest: "dist/picturefill.min.js"
        }
      },

      qunit: {
        files: [ "tests/**/*.html" ]
      },
      jshint: {
        all: {
          options: {
            jshintrc: true
          },
          src: [ "Gruntfile.js", "src/*.js", "src/includes/*.js", "tests/*.js" ]
        }
      },
      jscs: {
        all: {
          src: "<%= jshint.all.src %>"
        }
      },
      "gh-pages": {
        options: {
          base: '.'
        },
        src: ["**/*", "!node_modules/**/*", "!test/**/*", "!src/**/*"]
      },
      release: {
        options: {
          additionalFiles: ["bower.json"],
          commitMessage: "Picturefill <%= version %>",
          tagMessage: "Picturefill <%= version %>",
          afterRelease: ["gh-pages"]
        }
      },
      watch: {
        gruntfile: {
          files: [ "Gruntfile.js", "src/*.js", "src/includes/*.js", "tests/*.js" ],
          tasks: [ "support-types" +  supportTypes, "default" ],
          options: {
            spawn: false
          }
        }
      }
    });

    // because the compress plugin is insane
    grunt.task.registerTask( "compress", "compress the dist folder", function() {
      var childProc = require("child_process");
      var done = this.async();

      childProc.exec( "zip -r dist-" + pkg.version + ".zip dist", function() {
        done();
      });
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-qunit");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-jscs-checker");
    grunt.loadNpmTasks("grunt-gh-pages");
    grunt.loadNpmTasks("grunt-release");

    grunt.task.registerTask("support-types", "insert support for image types dev wants to include", function() {
      var supportTypes = "";
      for (var i = 0; i < arguments.length; i++) {
        var arg = arguments[i];

        switch ( arg ) {
          case "webp":
          case "svg":
          case "jxr":
          case "jp2":
          case "apng":

            toConcat.push("src/includes/" + arg + ".js");
        }

        supportTypes += ":" + arg;

      }

      if (!supportTypes) {
        supportTypes = supportTypes;
      }
      grunt.task.run("default");
      console.log("files to concatenate", toConcat);
    } );

	// Default task.
    grunt.registerTask("default", [ "jscs", "test", "clean", "concat", "uglify" ]);
    grunt.registerTask("test", [ "jscs", "jshint", "qunit" ]);
    grunt.registerTask("publish", [ "gh-pages" ]);
  };
})();
<|endoftext|>


<commit_before><commit_msg>Updating the grunt file to push template items.<commit_after><|endoftext|>


<commit_before>module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      file: {
        src: [
          'gruntfile.js',
          'js/**/*.js',
          'test/**/*.js'
        ]
      },
      options: {
        multistr: true,
        esnext: true,
        jshintrc: '.jshintrc'
      }
    },
    concat: {
      dist: {
        // the files to concatenate
        src: ['js/**/*.js'],
        // the location of the resulting JS file
        dest: 'dist/js/<%= pkg.name %>.js'
      },
      options: {
        // define a string to put between each file in the concatenated output
        separator: ';',
        // Setup a source map for easier debugging
        sourceMap: true
      }
    },
    uglify: {
      dist: {
        files: {
          'dist/js/<%= pkg.name %>.min.js': '<%= concat.dist.dest %>'
        },
        options: {
          sourceMap: true,
          sourceMapIn: '<%= concat.dist.dest %>.map'
        }
      }
    },
    browserify: {
      dist: {
        files: {
          'dist/js/index.js': [
            'js/**/*.js',
            '!js/main.js'
          ]
        }
      },
      dev: {
        files: {
          'dist/js/index.js': [
            'js/**/*.js',
            '!js/main.js'
          ]
        },
        option: {
          browserifyOptions: {
            debug: true
          }
        }
      }
    },
    requirejs: {
      dist: {
        options: {
          baseUrl: '.',
          out: 'dist/js/app.js',
          include: 'js/logofr',
          name: 'node_modules/almond/almond',
          inlineText: true,
          findNestedDependencies: true,
          optimize: 'ulgify'
        }
      }
    },
    karma: {
      unit: {
        configFile: 'test/karma.conf.js'
      }
    },
    watch: {
      files: ['<%= jshint.file.src %>'],
      tasks: ['jshint']
    },
    clean: { dist: [
      'dist',
    ]}
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-browserify');

  grunt.registerTask('default', ['clean', 'jshint']);
  //grunt.registerTask('default', ['jshint', 'requirejs']);
  grunt.registerTask('test', ['clean', 'jshint', 'browserify:dev', 'karma']);
};
<commit_msg>Remove browserify.<commit_after>module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      file: {
        src: [
          'gruntfile.js',
          'js/**/*.js',
          'test/**/*.js'
        ]
      },
      options: {
        multistr: true,
        esnext: true,
        jshintrc: '.jshintrc'
      }
    },
    concat: {
      dist: {
        // the files to concatenate
        src: ['js/**/*.js'],
        // the location of the resulting JS file
        dest: 'dist/js/<%= pkg.name %>.js'
      },
      options: {
        // define a string to put between each file in the concatenated output
        separator: ';',
        // Setup a source map for easier debugging
        sourceMap: true
      }
    },
    uglify: {
      dist: {
        files: {
          'dist/js/<%= pkg.name %>.min.js': '<%= concat.dist.dest %>'
        },
        options: {
          sourceMap: true,
          sourceMapIn: '<%= concat.dist.dest %>.map'
        }
      }
    },
//    browserify: {
//      dist: {
//        files: {
//          'dist/js/index.js': [
//            'js/**/*.js',
//            '!js/main.js'
//          ]
//        }
//      },
//      dev: {
//        files: {
//          'dist/js/index.js': [
//            'js/**/*.js',
//            '!js/main.js'
//          ]
//        },
//        option: {
//          browserifyOptions: {
//            debug: true
//          }
//        }
//      }
//    },
    requirejs: {
      dist: {
        options: {
          baseUrl: '.',
          out: 'dist/js/app.js',
          include: 'js/logofr',
          name: 'node_modules/almond/almond',
          inlineText: true,
          findNestedDependencies: true,
          optimize: 'ulgify'
        }
      }
    },
    karma: {
      unit: {
        configFile: 'test/karma.conf.js'
      }
    },
    watch: {
      files: ['<%= jshint.file.src %>'],
      tasks: ['jshint']
    },
    clean: { dist: [
      'dist',
    ]}
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-browserify');

  grunt.registerTask('default', ['clean', 'jshint']);
  //grunt.registerTask('default', ['jshint', 'requirejs']);
  grunt.registerTask('test', ['clean', 'jshint', 'karma']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		typescript: {
			base: {
				src: ['src/main/ts/**/*.ts', 'node_modules/test-grunt-dependency-a/src/main/ts/**/*.ts', 'node_modules/test-grunt-dependency-a/node_modules/test-grunt-dependency-b/src/main/ts/**/*.ts'],
				dest: 'target/application.js',
				options: {
					module: 'amd', //or commonjs
					target: 'es5', //or es3
					base_path: 'src/main/ts',
					sourcemap: true,
					fullSourceMapPath: true,
					declaration: true
				}
			}
		},
		uglify: {
			my_target: {
				options: {
					sourceMapPrefix: 1,
					preserveComments: false,
					sourceMap: 'target/application.min.js.map',
					sourceMapRoot: '.', // the location to find your original source
					sourceMapIn: 'target/application.js.map' // input sourcemap from a previous compilation
				},
				files: {
					'target/application.min.js': ['target/application.js']
				}
			}
		}

	});

	grunt.loadNpmTasks('grunt-typescript');
	grunt.loadNpmTasks('grunt-contrib-uglify');

	grunt.registerTask('default', ['typescript',  'uglify']);

};<commit_msg>Adde grunt bump<commit_after>module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		typescript: {
			base: {
				src: ['src/main/ts/**/*.ts', 'node_modules/test-grunt-dependency-a/src/main/ts/**/*.ts', 'node_modules/test-grunt-dependency-a/node_modules/test-grunt-dependency-b/src/main/ts/**/*.ts'],
				dest: 'target/application.js',
				options: {
					module: 'amd', //or commonjs
					target: 'es5', //or es3
					base_path: 'src/main/ts',
					sourcemap: true,
					fullSourceMapPath: true,
					declaration: true
				}
			}
		},
		uglify: {
			my_target: {
				options: {
					sourceMapPrefix: 1,
					preserveComments: false,
					sourceMap: 'target/application.min.js.map',
					sourceMapRoot: '.', // the location to find your original source
					sourceMapIn: 'target/application.js.map' // input sourcemap from a previous compilation
				},
				files: {
					'target/application.min.js': ['target/application.js']
				}
			}
		}

	});

	grunt.loadNpmTasks('grunt-typescript');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-bump');

	grunt.registerTask('default', ['typescript',  'uglify']);

};<|endoftext|>


<commit_before>module.exports = function (grunt) {
    var outDirectoryFirefox = "app-firefox";
    var outDirectoryChrome = "app-chrome";

    grunt.initConfig({
        clean: {
            chrome: [outDirectoryChrome],
            firefox: [outDirectoryFirefox]
        },
        ts: {
            options: {
                "target": "es6",
                "module": "es6",
                "noImplicitAny": true,
                "removeComments": true,
                "preserveConstEnums": true,
                "sourceMap": true
            },
            firefox: {
                src: ["src/**/*.ts", "!src/UI/Settings/**/*.ts", "!node_modules/**/*.ts", "!typings/**/*.ts"],
                outDir: [outDirectoryFirefox]
            },
            chrome: {
                src: ["src/**/*.ts", "!src/UI/Settings/**/*.ts", "!node_modules/**/*.ts", "!typings/**/*.ts"],
                outDir: [outDirectoryChrome]
            }
        },
        "merge-json": {
            "en-firefox": {
                src: ["src/**/*-en.json"],
                dest: outDirectoryFirefox + "/_locales/en/messages.json"
            },
            "de-firefox": {
                src: ["src/**/*-de.json"],
                dest: outDirectoryFirefox + "/_locales/de/messages.json"
            },
            "en-chrome": {
                src: ["src/**/*-en.json"],
                dest: outDirectoryChrome + "/_locales/en/messages.json"
            },
            "de-chrome": {
                src: ["src/**/*-de.json"],
                dest: outDirectoryChrome + "/_locales/de/messages.json"
            },
            "manifest-chrome": {
                src: ["configurations/manifest-base.json"],
                dest: outDirectoryChrome + "/manifest.json"
            },
            "manifest-firefox": {
                src: ["configurations/manifest-base.json", "configurations/manifest-firefox.json"],
                dest: outDirectoryFirefox + "/manifest.json"
            }
        },
        processhtml: {
            chrome: {
                src: ['src/UI/Settings/index.html',
                    'src/UI/Settings/app.js'],
                dest: outDirectoryChrome + '/UI/Settings/index.html'
            },
            firefox: {
                src: ['src/UI/Settings/index.html',
                    'src/UI/Settings/app.js'],
                dest: outDirectoryFirefox + '/UI/Settings'
            }
        },
        copy: {
            chrome: {
                files: [
                    // includes files within path
                    { expand: true, cwd: 'src/UI/Settings/', src: ['**'], dest: outDirectoryChrome + '/UI/Settings' }
                ],
            },
            firefox: {
                files: [
                    // includes files within path
                    { expand: true, cwd: 'src/UI/Settings/', src: ['**'], dest: outDirectoryFirefox + '/UI/Settings' }
                ],
            }
        },
        bowercopy: {
            options: {
                srcPrefix: 'bower_components'
            },
            "scripts-chrome": {
                options: {
                    destPrefix: outDirectoryChrome + '/scripts'
                },
                files: {
                    'angular.js': 'angular/angular.js',
                    'angular-route.js': 'angular-route/angular-route.js',
                    'jquery.js': 'jquery/dist/jquery.js',
                    'require.js': 'requirejs/require.js'
                }
            },
            "styles-chrome": {
                options: {
                    destPrefix: outDirectoryChrome + '/styles'
                },
                files: {
                    'semantic.css': 'semantic/dist/semantic.css',
                    'bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css'
                }
            },
            "scripts-firefox": {
                options: {
                    destPrefix: outDirectoryFirefox + '/scripts'
                },
                files: {
                    'angular.js': 'angular/angular.js',
                    'angular-route.js': 'angular-route/angular-route.js',
                    'jquery.js': 'jquery/dist/jquery.js',
                    'require.js': 'requirejs/require.js'
                }
            },
            "styles-firefox": {
                options: {
                    destPrefix: outDirectoryFirefox + '/styles'
                },
                files: {
                    'semantic.css': 'semantic/dist/semantic.css',
                    'bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css'
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks("grunt-ts");
    grunt.loadNpmTasks("grunt-merge-json");
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-bowercopy');

    grunt.registerTask("chrome", [
        "clean:chrome",
        "ts:chrome",
        "merge-json:en-chrome",
        "merge-json:de-chrome",
        "merge-json:manifest-chrome",
        "copy:chrome",
        "bowercopy:scripts-chrome",
        "bowercopy:styles-chrome"]);
    grunt.registerTask("firefox", [
        "clean:firefox",
        "ts:firefox",
        "merge-json:en-firefox",
        "merge-json:de-firefox",
        "merge-json:manifest-firefox",
        "copy:firefox",
        "bowercopy:scripts-firefox",
        "bowercopy:styles-firefox"]);
    grunt.registerTask("default", [
        "chrome",
        "firefox"]);
};<commit_msg>- changed TypeScript settings; - removed old 'ProcessHtml' section; - adjusted copy section to only copy *.html files<commit_after>module.exports = function (grunt) {
    var outDirectoryFirefox = "app-firefox";
    var outDirectoryChrome = "app-chrome";

    grunt.initConfig({
        clean: {
            chrome: [outDirectoryChrome],
            firefox: [outDirectoryFirefox]
        },
        ts: {
            options: {
                "target": "es5",
                "module": "es5",
                "noImplicitAny": true,
                "removeComments": true,
                "preserveConstEnums": true,
                "sourceMap": true
            },

            chrome: {
                src: ["src/**/*.ts", "!node_modules/**/*.ts", "!typings/**/*.ts"],
                outDir: [outDirectoryChrome]
            },
            firefox: {
                src: ["src/**/*.ts", "!node_modules/**/*.ts", "!typings/**/*.ts"],
                outDir: [outDirectoryFirefox]
            }
        },
        "merge-json": {
            "en-chrome": {
                src: ["src/**/*-en.json"],
                dest: outDirectoryChrome + "/_locales/en/messages.json"
            },
            "de-chrome": {
                src: ["src/**/*-de.json"],
                dest: outDirectoryChrome + "/_locales/de/messages.json"
            },
            "en-firefox": {
                src: ["src/**/*-en.json"],
                dest: outDirectoryFirefox + "/_locales/en/messages.json"
            },
            "de-firefox": {
                src: ["src/**/*-de.json"],
                dest: outDirectoryFirefox + "/_locales/de/messages.json"
            },
            "manifest-chrome": {
                src: ["configurations/manifest-base.json"],
                dest: outDirectoryChrome + "/manifest.json"
            },
            "manifest-firefox": {
                src: ["configurations/manifest-base.json", "configurations/manifest-firefox.json"],
                dest: outDirectoryFirefox + "/manifest.json"
            }
        },
        copy: {
            chrome: {
                files: [
                    // includes files within path
                    { expand: true, cwd: 'src/UI/Settings/', src: ['**/*.html'], dest: outDirectoryChrome + '/UI/Settings' }
                ],
            },
            firefox: {
                files: [
                    // includes files within path
                    { expand: true, cwd: 'src/UI/Settings/', src: ['**'], dest: outDirectoryFirefox + '/UI/Settings' }
                ],
            }
        },
        bowercopy: {
            options: {
                srcPrefix: 'bower_components'
            },
            "scripts-chrome": {
                options: {
                    destPrefix: outDirectoryChrome + '/scripts'
                },
                files: {
                    'angular.js': 'angular/angular.js',
                    'angular-route.js': 'angular-route/angular-route.js',
                    'jquery.js': 'jquery/dist/jquery.js',
                    'require.js': 'requirejs/require.js'
                }
            },
            "styles-chrome": {
                options: {
                    destPrefix: outDirectoryChrome + '/styles'
                },
                files: {
                    'semantic.css': 'semantic/dist/semantic.css',
                    'bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css'
                }
            },
            "scripts-firefox": {
                options: {
                    destPrefix: outDirectoryFirefox + '/scripts'
                },
                files: {
                    'angular.js': 'angular/angular.js',
                    'angular-route.js': 'angular-route/angular-route.js',
                    'jquery.js': 'jquery/dist/jquery.js',
                    'require.js': 'requirejs/require.js'
                }
            },
            "styles-firefox": {
                options: {
                    destPrefix: outDirectoryFirefox + '/styles'
                },
                files: {
                    'semantic.css': 'semantic/dist/semantic.css',
                    'bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css'
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks("grunt-ts");
    grunt.loadNpmTasks("grunt-merge-json");
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-bowercopy');

    grunt.registerTask("chrome", [
        "clean:chrome",
        "ts:chrome",
        "merge-json:en-chrome",
        "merge-json:de-chrome",
        "merge-json:manifest-chrome",
        "copy:chrome",
        "bowercopy:scripts-chrome",
        "bowercopy:styles-chrome"]);
    grunt.registerTask("firefox", [
        "clean:firefox",
        "ts:firefox",
        "merge-json:en-firefox",
        "merge-json:de-firefox",
        "merge-json:manifest-firefox",
        "copy:firefox",
        "bowercopy:scripts-firefox",
        "bowercopy:styles-firefox"]);
    grunt.registerTask("default", [
        "chrome",
        "firefox"]);
};<|endoftext|>


<commit_before>// Define Task for 'REV'
var gulp       = require('gulp');
var watch      = require('gulp-watch');
var config     = require('../gulp.config')();
var jshint     = require('gulp-jshint');
var karma      = require('gulp-karma');
var mocha      = require('gulp-mocha');
var istanbul   = require('gulp-istanbul');

gulp.task('before-server-test', function () {
    return gulp.src(config.serverSource)
        .pipe(istanbul(config.istanbul.start))
        .pipe(istanbul.hookRequire());  // Force `require` to return covered files
});

gulp.task('server-test', ['before-server-test'], function () {
    gulp.src(config.serverSpecs)
        .pipe(mocha(config.mocha))
        .on('error', function (err) {
            // Make sure failed tests cause gulp to exit non-zero
            console.log(err);
            this.emit('end'); //instead of erroring the stream, end it
        })
        .pipe(istanbul.writeReports(config.istanbul.report));
});

gulp.task('client-test', ['lint'], function () {
    // Be sure to return the stream
    // NOTE: Using the fake './foobar' so as to run the files
    // listed in karma.conf.js INSTEAD of what was passed to
    // gulp.src !
    return gulp.src('./foobar')
        .pipe(karma({
            configFile: 'karma.conf.js',
            action: 'run'
        }))
        .on('error', function (err) {
            // Make sure failed tests cause gulp to exit non-zero
            console.log(err);
            this.emit('end'); //instead of erroring the stream, end it
        });
});

gulp.task('test', ['client-test', 'server-test']);

gulp.task('autotest', ['client-test', 'server-test'], function () {
    watch(config.clientSource, function () {
        gulp.start('client-test');
    });

    watch(config.serverSource, function() {
        gulp.start('server-test')
    })
});<commit_msg>add missing semi-colon<commit_after>// Define Task for 'REV'
var gulp       = require('gulp');
var watch      = require('gulp-watch');
var config     = require('../gulp.config')();
var jshint     = require('gulp-jshint');
var karma      = require('gulp-karma');
var mocha      = require('gulp-mocha');
var istanbul   = require('gulp-istanbul');

gulp.task('before-server-test', function () {
    return gulp.src(config.serverSource)
        .pipe(istanbul(config.istanbul.start))
        .pipe(istanbul.hookRequire());  // Force `require` to return covered files
});

gulp.task('server-test', ['before-server-test'], function () {
    gulp.src(config.serverSpecs)
        .pipe(mocha(config.mocha))
        .on('error', function (err) {
            // Make sure failed tests cause gulp to exit non-zero
            console.log(err);
            this.emit('end'); //instead of erroring the stream, end it
        })
        .pipe(istanbul.writeReports(config.istanbul.report));
});

gulp.task('client-test', ['lint'], function () {
    // Be sure to return the stream
    // NOTE: Using the fake './foobar' so as to run the files
    // listed in karma.conf.js INSTEAD of what was passed to
    // gulp.src !
    return gulp.src('./foobar')
        .pipe(karma({
            configFile: 'karma.conf.js',
            action: 'run'
        }))
        .on('error', function (err) {
            // Make sure failed tests cause gulp to exit non-zero
            console.log(err);
            this.emit('end'); //instead of erroring the stream, end it
        });
});

gulp.task('test', ['client-test', 'server-test']);

gulp.task('autotest', ['client-test', 'server-test'], function () {
    watch(config.clientSource, function () {
        gulp.start('client-test');
    });

    watch(config.serverSource, function() {
        gulp.start('server-test');
    })
});<|endoftext|>


<commit_before>var HARjson =
<?php
if ( array_key_exists('u', $_GET) ) {
	$target = $_GET['u'];
	echo file_get_contents($target) . ";\n";
}
else if ( array_key_exists('f', $_GET) ) {
	// TODO - remove this - not used since March 24, 2011
	require_once("utils.inc");
	$target = $_GET['f'];
	echo getHarFileContents($target) . ";\n";
}
?>

<commit_msg>nit<commit_after>var HARjson =
<?php
if ( array_key_exists('u', $_GET) ) {
	$target = $_GET["u"];
	echo file_get_contents($target) . ";\n";
}
else if ( array_key_exists('f', $_GET) ) {
	// TODO - remove this - not used since March 24, 2011
	require_once("utils.inc");
	$target = $_GET["f"];
	echo getHarFileContents($target) . ";\n";
}
?>

<|endoftext|>


<commit_before>function handleApiError(response) {

  if(!response || response.status === 200)
    return;

  if(response.status === 403) {
    logout();
  }
  else {
    console.log('Error: ' + response.responseText);
    alert(response.responseText);
  }
}
<commit_msg>Handle 401 api errors and logout.<commit_after>function handleApiError(response) {

  if(!response || response.status === 200)
    return;

  if(response.status === 403 || response.status === 401) {
    logout();
  }
  else {
    console.log('Error: ' + response.responseText);
    alert(response.responseText);
  }
}
<|endoftext|>