<commit_before>define(["dojo/_base/lang", "dojo/_base/declare", "dojo/Deferred", "dojo/when", "require", "dojo/has", "dojo/_base/config", "dojo/on", "dojo/ready", "dojo/_base/window", "dojo/dom-construct", "./model", "./View", "./controllers/Load", "./controllers/Transition", "./controllers/Layout", "dojo/_base/loader", "dojo/store/Memory"],
function(lang, declare, Deferred, when, require, has, config, on, ready, baseWindow, dom, Model, View, LoadController, TransitionController, LayoutController){
	dojo.experimental("dojox.app");

	has.add("app-log-api", (config["app"] || {}).debugApp);

	var Application = declare(null, {
		constructor: function(params, node){
			lang.mixin(this, params);
			this.params = params;
			this.id = params.id;
			this.defaultView = params.defaultView;
			this.widgetId = params.id;
			this.controllers = [];
			this.children = {};
			this.loadedModels = {};

			// Create a new domNode and append to body
			// Need to bind startTransition event on application domNode,
			// Because dojox.mobile.ViewController bind startTransition event on document.body
			// Make application's root domNode id unique because this id can be visited by window namespace on Chrome 18.
			this.domNode = dom.create("div", {
				id: this.id+"_Root",
				style: "width:100%; height:100%; overflow-y:hidden; overflow-x:hidden;"
			});
			node.appendChild(this.domNode);
		},

		createDataStore: function(params){
			// summary:
			//		Create data store instance
			//
			// params: Object
			//		data stores configuration.

			if(params.stores){
				//create stores in the configuration.
				for(var item in params.stores){
					if(item.charAt(0) !== "_"){//skip the private properties
						var type = params.stores[item].type ? params.stores[item].type : "dojo.store.Memory";
						var config = {};
						if(params.stores[item].params){
							lang.mixin(config, params.stores[item].params);
						}
						var storeCtor = lang.getObject(type);
						if(config.data && lang.isString(config.data)){
							//get the object specified by string value of data property
							//cannot assign object literal or reference to data property
							//because json.ref will generate __parent to point to its parent
							//and will cause infinitive loop when creating StatefulModel.
							config.data = lang.getObject(config.data);
						}
						params.stores[item].store = new storeCtor(config);
					}
				}
			}
		},

		createControllers: function(controllers){
			// summary:
			//		Create controller instance
			//
			// parent: Array
			//		controller configuration array.
			// returns:
			//		controllerDeferred object

			if(controllers){
				var requireItems = [];
				for(var i = 0; i < controllers.length; i++){
					requireItems.push(controllers[i]);
				}

				var def = new Deferred();
				var requireSignal;
				try{
					requireSignal = require.on("error", function(error){
						if(def.isResolved() || def.isRejected()){
							return;
						}
						def.reject("load controllers error.");
						requireSignal.remove();
					});
					require(requireItems, function(){
						def.resolve.call(def, arguments);
						requireSignal.remove();
					});
				}catch(ex){
					def.reject("load controllers error.");
					requireSignal.remove();
				}

				var controllerDef = new Deferred();
				when(def, lang.hitch(this, function(){
					for(var i = 0; i < arguments[0].length; i++){
						// Store Application object on each controller.
						this.controllers.push(new arguments[0][i](this));
					}
					controllerDef.resolve(this);
				}), function(){
					//require def error, reject loadChildDeferred
					controllerDef.reject("load controllers error.");
				});
				return controllerDef;
			}
		},

		trigger: function(event, params){
			// summary:
			//		trigger an event
			//
			// event: String
			//		event name. The event is binded by controller.bind() method.
			// params: Object
			//		event parameters.
			on.emit(this.domNode, event, params);
		},

		// setup default view and Controllers and startup the default view
		start: function(){
			//create application level data store
			this.createDataStore(this.params);

			// create application level data model
			var loadModelLoaderDeferred = new Deferred();
			var createPromise;
			try{
				createPromise = Model(this.params.models, this);
			}catch(ex){
				loadModelLoaderDeferred.reject("load model error.");
				return loadModelLoaderDeferred.promise;
			}
			if(createPromise.then){
				when(createPromise, lang.hitch(this, function(newModel){
					this.loadedModels = newModel;
					this.setupAppView();
				}), function(){
					loadModelLoaderDeferred.reject("load model error.")
				});
			}else{
				this.loadedModels = createPromise;
				this.setupAppView();
			}
		},

		setupAppView: function(){
			//create application level view
			if(this.template){
				this.view = new View({
					app: this,  // pass the app into the View so it can have easy access to app
					name: this.name,
					parent: this,
					templateString: this.templateString,
					definition: this.definition
				});
				when(this.view.start(), lang.hitch(this, function(){
					this.domNode = this.view.domNode;
					this.setupControllers();
					this.startup();
				}));
			}else{
				this.setupControllers();
				this.startup();
			}
		},

		setupControllers: function(){
			// create application controller instance
			new LoadController(this);
			new TransitionController(this);
			new LayoutController(this);

			// move set _startView operation from history module to application
			var hash = window.location.hash;
			this._startView = ((hash && hash.charAt(0) == "#") ? hash.substr(1) : hash) || this.defaultView;
		},

		startup: function(){
			// load controllers in configuration file
			var controllers = this.createControllers(this.params.controllers);
			when(controllers, lang.hitch(this, function(result){
				// emit load event and let controller to load view.
				this.trigger("load", {
					"viewId": this.defaultView,
					"callback": lang.hitch(this, function(){
						var selectId = this.defaultView.split(",");
						selectId = selectId.shift();
						this.selectedChild = this.children[this.id + '_' + selectId];
						// transition to startView. If startView==defaultView, that means initial the default view.
						this.trigger("transition", {
							"viewId": this._startView
						});
						this.setStatus(this.lifecycle.STARTED);
					})
				});
			}));
		}
	});

	function generateApp(config, node, appSchema, validate){
		// Register application module path
		var path = window.location.pathname;
		if(path.charAt(path.length) != "/"){
			path = path.split("/");
			path.pop();
			path = path.join("/");
		}
		dojo.registerModulePath("app", path);

		if(!config.modules){
			config.modules = [];
		}
		// add dojox.app lifecycle module by default
		config.modules.push("dojox/app/module/lifecycle");
		var modules = config.modules.concat(config.dependencies);

		if(config.template){
			modules.push("dojo/text!" + "app/" + config.template);
		}

		require(modules, function(){
			var modules = [Application];
			for(var i = 0; i < config.modules.length; i++){
				modules.push(arguments[i]);
			}

			if(config.template){
				var ext = {
					templateString: arguments[arguments.length - 1]
				}
			}
			App = declare(modules, ext);

			ready(function(){
				var app = App(config, node || baseWindow.body());

				if(has("app-log-api")){
					app.log = function(){
						// summary:
						//		If config is set to turn on app logging, then log msg to the console
						//
						// arguments:
						//		the message to be logged,
						//		all but the last argument will be treated as Strings and be concatenated together,
						//      the last argument can be an object it will be added as an argument to the console.log
						var msg = "";
						try{
							for(var i = 0; i < arguments.length-1; i++){
								msg = msg + arguments[i];
							}
							console.log(msg,arguments[arguments.length-1]);
						}catch(e){}
					};
				}else{
					app.log = function(){}; // noop
				}

				app.setStatus(app.lifecycle.STARTING);
				app.start();
				// Create global namespace for application.
				// The global name is application id. For example: modelApp
				var globalAppName = app.id;
				if(window[globalAppName]){
					lang.mixin(app, window[globalAppName]);
				}
				window[globalAppName] = app;
			});
		});
	}

	return function(config, node){
		if(!config){
			throw Error("App Config Missing");
		}

		if(config.validate){
			require(["dojox/json/schema", "dojox/json/ref", "dojo/text!dojox/application/schema/application.json"], function(schema, appSchema){
				schema = dojox.json.ref.resolveJson(schema);
				if(schema.validate(config, appSchema)){
					generateApp(config, node);
				}
			});
		}else{
			generateApp(config, node);
		}
	}
});
<commit_msg>make sure the dojo loader can be configured from the config file<commit_after>define(["dojo/_base/kernel",  "require", "dojo/_base/lang", "dojo/_base/declare", "dojo/Deferred", "dojo/when", "require", "dojo/has", "dojo/_base/config",
	"dojo/on", "dojo/ready", "dojo/_base/window", "dojo/dom-construct", "./model", "./View", "./controllers/Load", "./controllers/Transition",
	"./controllers/Layout"],
function(kernel, require, lang, declare, Deferred, when, require, has, config, on, ready, baseWindow, dom, Model, View,
		 LoadController, TransitionController, LayoutController){
	kernel.experimental("dojox.app");

	has.add("app-log-api", (config["app"] || {}).debugApp);

	var Application = declare(null, {
		constructor: function(params, node){
			lang.mixin(this, params);
			this.params = params;
			this.id = params.id;
			this.defaultView = params.defaultView;
			this.widgetId = params.id;
			this.controllers = [];
			this.children = {};
			this.loadedModels = {};

			// Create a new domNode and append to body
			// Need to bind startTransition event on application domNode,
			// Because dojox.mobile.ViewController bind startTransition event on document.body
			// Make application's root domNode id unique because this id can be visited by window namespace on Chrome 18.
			this.domNode = dom.create("div", {
				id: this.id+"_Root",
				style: "width:100%; height:100%; overflow-y:hidden; overflow-x:hidden;"
			});
			node.appendChild(this.domNode);
		},

		createDataStore: function(params){
			// summary:
			//		Create data store instance
			//
			// params: Object
			//		data stores configuration.

			if(params.stores){
				//create stores in the configuration.
				for(var item in params.stores){
					if(item.charAt(0) !== "_"){//skip the private properties
						var type = params.stores[item].type ? params.stores[item].type : "dojo.store.Memory";
						var config = {};
						if(params.stores[item].params){
							lang.mixin(config, params.stores[item].params);
						}
						var storeCtor = lang.getObject(type);
						if(config.data && lang.isString(config.data)){
							//get the object specified by string value of data property
							//cannot assign object literal or reference to data property
							//because json.ref will generate __parent to point to its parent
							//and will cause infinitive loop when creating StatefulModel.
							config.data = lang.getObject(config.data);
						}
						params.stores[item].store = new storeCtor(config);
					}
				}
			}
		},

		createControllers: function(controllers){
			// summary:
			//		Create controller instance
			//
			// parent: Array
			//		controller configuration array.
			// returns:
			//		controllerDeferred object

			if(controllers){
				var requireItems = [];
				for(var i = 0; i < controllers.length; i++){
					requireItems.push(controllers[i]);
				}

				var def = new Deferred();
				var requireSignal;
				try{
					requireSignal = require.on("error", function(error){
						if(def.isResolved() || def.isRejected()){
							return;
						}
						def.reject("load controllers error.");
						requireSignal.remove();
					});
					require(requireItems, function(){
						def.resolve.call(def, arguments);
						requireSignal.remove();
					});
				}catch(ex){
					def.reject("load controllers error.");
					requireSignal.remove();
				}

				var controllerDef = new Deferred();
				when(def, lang.hitch(this, function(){
					for(var i = 0; i < arguments[0].length; i++){
						// Store Application object on each controller.
						this.controllers.push(new arguments[0][i](this));
					}
					controllerDef.resolve(this);
				}), function(){
					//require def error, reject loadChildDeferred
					controllerDef.reject("load controllers error.");
				});
				return controllerDef;
			}
		},

		trigger: function(event, params){
			// summary:
			//		trigger an event
			//
			// event: String
			//		event name. The event is binded by controller.bind() method.
			// params: Object
			//		event parameters.
			on.emit(this.domNode, event, params);
		},

		// setup default view and Controllers and startup the default view
		start: function(){
			//create application level data store
			this.createDataStore(this.params);

			// create application level data model
			var loadModelLoaderDeferred = new Deferred();
			var createPromise;
			try{
				createPromise = Model(this.params.models, this);
			}catch(ex){
				loadModelLoaderDeferred.reject("load model error.");
				return loadModelLoaderDeferred.promise;
			}
			if(createPromise.then){
				when(createPromise, lang.hitch(this, function(newModel){
					this.loadedModels = newModel;
					this.setupAppView();
				}), function(){
					loadModelLoaderDeferred.reject("load model error.")
				});
			}else{
				this.loadedModels = createPromise;
				this.setupAppView();
			}
		},

		setupAppView: function(){
			//create application level view
			if(this.template){
				this.view = new View({
					app: this,  // pass the app into the View so it can have easy access to app
					name: this.name,
					parent: this,
					templateString: this.templateString,
					definition: this.definition
				});
				when(this.view.start(), lang.hitch(this, function(){
					this.domNode = this.view.domNode;
					this.setupControllers();
					this.startup();
				}));
			}else{
				this.setupControllers();
				this.startup();
			}
		},

		setupControllers: function(){
			// create application controller instance
			new LoadController(this);
			new TransitionController(this);
			new LayoutController(this);

			// move set _startView operation from history module to application
			var hash = window.location.hash;
			this._startView = ((hash && hash.charAt(0) == "#") ? hash.substr(1) : hash) || this.defaultView;
		},

		startup: function(){
			// load controllers in configuration file
			var controllers = this.createControllers(this.params.controllers);
			when(controllers, lang.hitch(this, function(result){
				// emit load event and let controller to load view.
				this.trigger("load", {
					"viewId": this.defaultView,
					"callback": lang.hitch(this, function(){
						var selectId = this.defaultView.split(",");
						selectId = selectId.shift();
						this.selectedChild = this.children[this.id + '_' + selectId];
						// transition to startView. If startView==defaultView, that means initial the default view.
						this.trigger("transition", {
							"viewId": this._startView
						});
						this.setStatus(this.lifecycle.STARTED);
					})
				});
			}));
		}
	});

	function generateApp(config, node, appSchema, validate){
		if(!config.loaderConfig){
			config.loaderConfig = {};
		}
		if(!config.loaderConfig.paths){
			config.loaderConfig.paths = {};
		}
		if(!config.loaderConfig.paths["app"]){
			// Register application module path
			var path = window.location.pathname;
			if(path.charAt(path.length) != "/"){
				path = path.split("/");
				path.pop();
				path = path.join("/");
			}
			config.loaderConfig.paths["app"] = path;
		}
		require(config.loaderConfig);

		if(!config.modules){
			config.modules = [];
		}
		// add dojox.app lifecycle module by default
		config.modules.push("dojox/app/module/lifecycle");
		var modules = config.modules.concat(config.dependencies);

		if(config.template){
			modules.push("dojo/text!" + "app/" + config.template);
		}

		require(modules, function(){
			var modules = [Application];
			for(var i = 0; i < config.modules.length; i++){
				modules.push(arguments[i]);
			}

			if(config.template){
				var ext = {
					templateString: arguments[arguments.length - 1]
				}
			}
			App = declare(modules, ext);

			ready(function(){
				var app = App(config, node || baseWindow.body());

				if(has("app-log-api")){
					app.log = function(){
						// summary:
						//		If config is set to turn on app logging, then log msg to the console
						//
						// arguments:
						//		the message to be logged,
						//		all but the last argument will be treated as Strings and be concatenated together,
						//      the last argument can be an object it will be added as an argument to the console.log
						var msg = "";
						try{
							for(var i = 0; i < arguments.length-1; i++){
								msg = msg + arguments[i];
							}
							console.log(msg,arguments[arguments.length-1]);
						}catch(e){}
					};
				}else{
					app.log = function(){}; // noop
				}

				app.setStatus(app.lifecycle.STARTING);
				app.start();
				// Create global namespace for application.
				// The global name is application id. For example: modelApp
				var globalAppName = app.id;
				if(window[globalAppName]){
					lang.mixin(app, window[globalAppName]);
				}
				window[globalAppName] = app;
			});
		});
	}

	return function(config, node){
		if(!config){
			throw Error("App Config Missing");
		}

		if(config.validate){
			require(["dojox/json/schema", "dojox/json/ref", "dojo/text!dojox/application/schema/application.json"], function(schema, appSchema){
				schema = dojox.json.ref.resolveJson(schema);
				if(schema.validate(config, appSchema)){
					generateApp(config, node);
				}
			});
		}else{
			generateApp(config, node);
		}
	}
});
<|endoftext|>


<commit_before>let motivos = [
	'No começo era legal, mas agora eu quero matar todo mundo'
	, 'Uma capivara me disse pra fazer isso'
	, 'Papai quer que eu faça medicina'
	, 'Acabou o café'
	, 'Acabou o leite do café'
	, 'Acabou o açucar do café'
	, 'Nunca posso nada nessa p****!'
	, 'Demissão não se pede se ganha!'
	, 'A empresa usa Sybase'
	, 'O comercial vendeu uma feature que não existe no sistema'
	, 'Agendaram a homologação do sistema para às 18h de sexta'
	, 'Meu trabalho esta  matando a minha criatividade'
	, 'Patch de correção para um problema que foi criado por um patch anterior'
	, 'Deixaram pra contratar a consultoria quando começou a dar merda'
	, 'O planejamento do projeto se resume a fazer tudo no tempo'
	, 'Não entendi a change, mas os totais voltaram a bater'
	, 'A empresa está contratando programador PHP'
	, 'A empresa usa SVN'
];

document.getElementById('motivo').firstChild.innerText = motivos[Math.trunc(Math.random() * motivos.length)];
<commit_msg>Casos comuns em algumas empresas (#10)<commit_after>let motivos = [
	'No começo era legal, mas agora eu quero matar todo mundo'
	, 'Uma capivara me disse pra fazer isso'
	, 'Papai quer que eu faça medicina'
	, 'Acabou o café'
	, 'Acabou o leite do café'
	, 'Acabou o açucar do café'
	, 'Nunca posso nada nessa p****!'
	, 'Demissão não se pede se ganha!'
	, 'A empresa usa Sybase'
	, 'O comercial vendeu uma feature que não existe no sistema'
	, 'Agendaram a homologação do sistema para às 18h de sexta'
	, 'Meu trabalho esta  matando a minha criatividade'
	, 'Patch de correção para um problema que foi criado por um patch anterior'
	, 'Deixaram pra contratar a consultoria quando começou a dar merda'
	, 'O planejamento do projeto se resume a fazer tudo no tempo'
	, 'Não entendi a change, mas os totais voltaram a bater'
	, 'A empresa está contratando programador PHP'
	, 'A empresa usa SVN'
	, 'O código fonte é cheio de números mágicos'
	, 'Usando SQL para registrar log'
];

document.getElementById('motivo').firstChild.innerText = motivos[Math.trunc(Math.random() * motivos.length)];
<|endoftext|>


<commit_before>// http://www.quirksmode.org/js/keys.html
function ($) {
  'use strict';
  var defaults = {
      completions: function() {
          return $("#rsvp-list a.mem-name").
              map(function (i, a) { return a.text; }).sort();
      }
  };
  /**
   * options is an object which may contain one of
   * completions - a function which returns a list of completion options
   */
  $.fn.atta = function(options) {
     var self = this
      , options = options || {}
      , keys = {
          'up':38
          , 'down':40
          , 'escape':27
          , 'enter': 13
      }
      , styles = [
          '#atta-list-container { position:relative; top: 0px; left: 5px; }'
          , '#atta-list { position:relative;margin-top:18px;background:#fff;border-radius:3px;border:1px solid #ddd;box-shadow:0 0 5px rgba(0,0,0,0.1);min-width:180px;}'
          , '#atta-list ul { list-style:none;margin:0;padding:0; }'
          , '#atta-list li { padding:5px 10px;font-weight:bold;border-bottom:1px solid #eee; color:#333; }'
          , '#atta-list li.sel { background:#1DCAFF; color:#fff; }' ]
      , completions = options.completions || defaults.completions
      , newList = function (ta) {
          return $("

");
      }
      , newItem = function (name, i) {
          return '
' +
              name + '
';
      }
      , at = function (e) {
          return String.fromCharCode(e.which || e.keyCode) === "2" && e.shiftKey;
      }
      , key = function(e, alias) {
          return (e.which || e.keyCode) === keys[alias];
      }
      , cancelKey = function (e) { return key(e, 'escape'); }
      , acceptKey = function (e) { return key(e, 'enter'); }
      , upKey = function (e) { return key(e, 'up'); }
      , downKey = function (e) { return key(e, 'down'); }
      , showOptions = function (ta) {
          var current = $("#atta-list-container")
          , markup = current.length > 0 && current || newList(ta)
          , cs = (completions() || [])
          , buff = [];
          for(var i = 0, l = cs.length;i < l;i++) {
              buff.push(newItem(cs[i], i));
          }
          var l = markup.find('ul')
          l.empty().append(buff.join(''));
          $(window).on('keyup', function (e) {
              var sel = $("#atta-list li.sel")
              , kids = $(sel.parent()).children()
              , cnt = kids.length
              , index = sel.length > 0 && sel.data().index || 0;
              if (cnt) {
                  if (upKey(e)) {
                      e.preventDefault();
                      sel.removeClass('sel');
                      if (index > 0) {
                          $(kids[index-1]).addClass('sel')
                      } else if (index == 0) {
                          $(kids[cnt-1]).addClass('sel')
                      }
                      return false;
                  } else if (downKey(e)) {
                      e.preventDefault();
                      sel.removeClass('sel');
                      if (index < cnt-1) {
                          $(kids[index+1]).addClass('sel')
                      } else if (index == cnt-1) {
                          $(kids[0]).addClass('sel')
                      }
                      return false;
                  }
              }
          });
          $(ta).parent().append(markup);
      };

      // append atta styles only once
      if ($('#atta-style').length < 1) {
          $('head').append('')
      }

      // bind accept and cancelation listener
      $(window).on('keyup', function(e) {
          if (cancelKey(e)) {
              $('#atta-list-container').remove();
          } else if (acceptKey(e)) {
              var container = $('#atta-list-container');
              if (container.length > 0) {
                  e.preventDefault();
                  var name = container.find('.sel').text();
                  console.log('select ' + name);
                  return false;
              }
          }
      });

      // bind query listener
      return self.each(function() {
          $(this).live('keyup', function (e) {
              var el = $(e.target);
              if (at(e)) {
                  showOptions(e.target);
              } else {
                  var container = $("#atta-list-container");
                  if (container.length > 0) {
                      var txt = el.val(), query, matching, filteredNames;
                      if (txt.length > 0) {
                          var lastAt = txt.lastIndexOf('@');
                          if (lastAt != -1) {
                              query = txt.slice(lastAt + 1, txt.length);
                              matching = function(i, e) {
                                  return e.toLowerCase().indexOf(query.toLowerCase()) != -1;
                              }
                              filteredCompletions = (completions() || []).filter(matching);
                              console.log('filtered names matching ' + query);
                              console.log(filteredCompletions);
                          }
                      }
                  }
              }
          });
      });
  };
)(jQuery);<commit_msg>abstract the concept of an '@' and make it overrideable<commit_after>// http://www.quirksmode.org/js/keys.html
function ($) {
  'use strict';
  var defaults = {
      completions: function() {
          return $("#rsvp-list a.mem-name").
              map(function (i, a) { return a.text; }).sort();
      },
      at : {
          is: function(e){
              return  String.fromCharCode(e.which || e.keyCode) === "2" && e.shiftKey
          }
          , char : '@'
      }
  };
  /**
   * options is an object which may contain one of:
   * completions - a function which returns a list of completion options
   * at - an object representing the at trigger for tab completion.
   *      this object should contain a function, 'is', which should accept a key event
   *      and return true if the key event matches the trigger
   *      and a 'char' property which represents the display of the trigger.
   */
  $.fn.atta = function(options) {
     var self = this
      , options = options || {}
      , keys = {
          'up':38
          , 'down':40
          , 'escape':27
          , 'enter': 13
      }
      , styles = [
          '#atta-list-container { position:relative; top: 0px; left: 5px; }'
          , '#atta-list { position:relative;margin-top:18px;background:#fff;border-radius:3px;border:1px solid #ddd;box-shadow:0 0 5px rgba(0,0,0,0.1);min-width:180px;}'
          , '#atta-list ul { list-style:none;margin:0;padding:0; }'
          , '#atta-list li { padding:5px 10px;font-weight:bold;border-bottom:1px solid #eee; color:#333; }'
          , '#atta-list li.sel { background:#1DCAFF; color:#fff; }' ]
      , completions = options.completions || defaults.completions
      , at = options.at || defaults.at
      , newList = function (ta) {
          return $("

");
      }
      , newItem = function (name, i) {
          return '
' +
              name + '
';
      }
      , key = function(e, alias) {
          return (e.which || e.keyCode) === keys[alias];
      }
      , cancelKey = function (e) { return key(e, 'escape'); }
      , acceptKey = function (e) { return key(e, 'enter'); }
      , upKey = function (e) { return key(e, 'up'); }
      , downKey = function (e) { return key(e, 'down'); }
      , showOptions = function (ta) {
          var current = $("#atta-list-container")
          , markup = current.length > 0 && current || newList(ta)
          , cs = (completions() || [])
          , buff = [];
          for(var i = 0, l = cs.length;i < l;i++) {
              buff.push(newItem(cs[i], i));
          }
          var l = markup.find('ul')
          l.empty().append(buff.join(''));
          $(window).on('keyup', function (e) {
              var sel = $("#atta-list li.sel")
              , kids = $(sel.parent()).children()
              , cnt = kids.length
              , index = sel.length > 0 && sel.data().index || 0;
              if (cnt) {
                  if (upKey(e)) {
                      e.preventDefault();
                      sel.removeClass('sel');
                      if (index > 0) {
                          $(kids[index-1]).addClass('sel')
                      } else if (index == 0) {
                          $(kids[cnt-1]).addClass('sel')
                      }
                      return false;
                  } else if (downKey(e)) {
                      e.preventDefault();
                      sel.removeClass('sel');
                      if (index < cnt-1) {
                          $(kids[index+1]).addClass('sel')
                      } else if (index == cnt-1) {
                          $(kids[0]).addClass('sel')
                      }
                      return false;
                  }
              }
          });
          $(ta).parent().append(markup);
      };

      // append atta styles only once
      if ($('#atta-style').length < 1) {
          $('head').append('')
      }

      // bind accept and cancelation listener
      $(window).on('keyup', function(e) {
          if (cancelKey(e)) {
              $('#atta-list-container').remove();
          } else if (acceptKey(e)) {
              var container = $('#atta-list-container');
              if (container.length > 0) {
                  e.preventDefault();
                  var name = container.find('.sel').text();
                  console.log('select ' + name);
                  return false;
              }
          }
      });

      // bind query listener
      return self.each(function() {
          $(this).live('keyup', function (e) {
              var el = $(e.target);
              if (at.is(e)) {
                  showOptions(e.target);
              } else {
                  var container = $("#atta-list-container");
                  if (container.length > 0) {
                      var txt = el.val(), query, matching, filteredNames;
                      if (txt.length > 0) {
                          var lastAt = txt.lastIndexOf(at.char);
                          if (lastAt != -1) {
                              query = txt.slice(lastAt + 1, txt.length);
                              matching = function(i, e) {
                                  return e.toLowerCase().indexOf(query.toLowerCase()) != -1;
                              }
                              filteredCompletions = (completions() || []).filter(matching);
                              console.log('filtered names matching ' + query);
                              console.log(filteredCompletions);
                          }
                      }
                  }
              }
          });
      });
  };
)(jQuery);<|endoftext|>


<commit_before>// useful globals

var currentSuite, currentCase;

// loads common.js module
function load (test, fn) {
  module = {};
  $script('/test/' + test, function () {
    fn(module.exports);
  });
};

// load all tests
function run () {
  var tests = Array.prototype.slice.call(arguments)
    , i = 0;

  function complete () {
    $('body').append('
All suites completed
');
  };

  if (tests.length) {
    // load dom
    $('body').append('
');

    // run suites
    suite(tests[i], function check (res) {
      if (tests[++i]) {
        suite(tests[i], check);
      } else {
        complete();
      }
    });
  } else {
    complete();
  }
};

// gets keys for an object
function keys (obj) {
  if (Object.keys) return Object.keys(obj);

  var keys = [];

  for (var i in obj) {
    if (obj.hasOwnProperty(i)) {
      keys.push(i);
    }
  }

  return keys;
};

// runs a suite
function suite (file, fn) {
  var passed = {}
    , failed = {};

  // register current suite
  currentSuite = file;

  // inject test case
  var li = $('
').append(
    $('').append(
      $('').attr('href', '/test/' + file).text(file)
    )
  ).appendTo('.test-list');

  // dynamically load module
  load(file, function (suite) {
    if (!suite) return;

    var start = new Date;

    function complete () {
      var ok = !keys(failed).length
        , elapsed = Math.round((new Date - start) / 1000);

      // update dom
      li.removeClass('loading');
      li.append('•');

      if (ok) {
        li.append(' all passed');
      } else {
        li.append(' failing test');
        li.addClass('test-failure');
      }

      li.append(
        $('
')
          .html(
              'Passed: ' + keys(passed).length
            + ' — Failed: ' + keys(failed).length
            + ' — Elapsed: ' + elapsed
            + ' seconds — '
          )
          .append(
            $('Show details')
              .attr('href', '#')
              .click(function () {
                li.toggleClass('cases');
                $(this).text(
                  li.hasClass('cases')
                    ? 'Hide details'
                    : 'Show details'
                );
                return false;
              })
          )
      );

      var casesUl = $('
').appendTo(li);
      for (var i = 0, l = cases.length; i < l; i++) {
        var detail = $('
')
          .text(cases[i])
          .addClass(failed[cases[i]] ? 'failed' : '')
          .appendTo(casesUl);

        if (failed[cases[i]]) {
          if (window.console && console.log) {
            console.log(failed[cases[i]]);
          }

          detail.append($('').text(String(failed[cases[i]])));
        }
      }

      // fire callback
      fn({
          status: ok
        , passed: passed
        , failed: failed
      });
    };

    var cases = keys(suite)
      , i = 0;

    if (!cases.length) {
      return complete();
    }

    currentCase = cases[i];

    test(suite[cases[i]], function check (err) {
      if (err) {
        failed[cases[i]] = err;
      } else {
        passed[cases[i]] = true;
      }

      if (cases[++i]) {
        currentCase = cases[i];
        test(suite[cases[i]], check);
      } else {
        complete();
      }
    });
  });
};

// runs a test
function test (testcase, fn) {
  var timer;

  window.onerror = function (err) {
    complete(err);
  };

  function complete (err) {
    if (complete.run) return;
    if (timer) clearTimeout(timer);
    complete.run = true;
    window.onerror = null;
    fn(err);
  };

  try {
    if (testcase.length > 0) {
      var timer = setTimeout(function () {
        complete(new Error('Timeout'));
      }, 2000);

      testcase(complete);
    } else {
      testcase();
      complete();
    }
  } catch (e) {
    complete(e);
  }
};

// exposes a function to easily create a server for the current test

function create (nsp) {
  if (!testsPorts[currentSuite]) {
    throw new Error('No socket server defined for suite "' + currentSuite + '"');
  }

  if (!testsPorts[currentSuite][currentCase]) {
    throw new Error('No socket server defined for suite "' + currentSuite
      + '" and case "' + currentCase + '"');
  }

  return io.connect(uri() + (nsp || ''));
};

function uri () {
  return document.location.protocol + '//' + document.location.hostname
      + ':' + testsPorts[currentSuite][currentCase];
}
<commit_msg>Fixed test runner on IE6/7. Odd jquery bug<commit_after>// useful globals

var currentSuite, currentCase, testsList;

// loads common.js module
function load (test, fn) {
  module = {};
  $script('/test/' + test, function () {
    fn(module.exports);
  });
};

// load all tests
function run () {
  var tests = Array.prototype.slice.call(arguments)
    , i = 0;

  function complete () {
    $('body').append('
All suites completed
');
  };

  if (tests.length) {
    // load dom
    testsList = $('
');
    $('body').append(testsList)

    // run suites
    suite(tests[i], function check (res) {
      if (tests[++i]) {
        suite(tests[i], check);
      } else {
        complete();
      }
    });
  } else {
    complete();
  }
};

// gets keys for an object
function keys (obj) {
  if (Object.keys) return Object.keys(obj);

  var keys = [];

  for (var i in obj) {
    if (obj.hasOwnProperty(i)) {
      keys.push(i);
    }
  }

  return keys;
};

// runs a suite
function suite (file, fn) {
  var passed = {}
    , failed = {};

  // register current suite
  currentSuite = file;

  // inject test case
  var li = $('
').append(
    $('').append(
      $('').attr('href', '/test/' + file).text(file)
    )
  ).appendTo(testsList);

  // dynamically load module
  load(file, function (suite) {
    if (!suite) return;

    var start = new Date;

    function complete () {
      var ok = !keys(failed).length
        , elapsed = Math.round((new Date - start) / 1000);

      // update dom
      li.removeClass('loading');
      li.append('•');

      if (ok) {
        li.append(' all passed');
      } else {
        li.append(' failing test');
        li.addClass('test-failure');
      }

      li.append(
        $('
')
          .html(
              'Passed: ' + keys(passed).length
            + ' — Failed: ' + keys(failed).length
            + ' — Elapsed: ' + elapsed
            + ' seconds — '
          )
          .append(
            $('Show details')
              .attr('href', '#')
              .click(function () {
                li.toggleClass('cases');
                $(this).text(
                  li.hasClass('cases')
                    ? 'Hide details'
                    : 'Show details'
                );
                return false;
              })
          )
      );

      var casesUl = $('
').appendTo(li);
      for (var i = 0, l = cases.length; i < l; i++) {
        var detail = $('
')
          .text(cases[i])
          .addClass(failed[cases[i]] ? 'failed' : '')
          .appendTo(casesUl);

        if (failed[cases[i]]) {
          if (window.console && console.log) {
            console.log(failed[cases[i]]);
          }

          detail.append($('').text(String(failed[cases[i]])));
        }
      }

      // fire callback
      fn({
          status: ok
        , passed: passed
        , failed: failed
      });
    };

    var cases = keys(suite)
      , i = 0;

    if (!cases.length) {
      return complete();
    }

    currentCase = cases[i];

    test(suite[cases[i]], function check (err) {
      if (err) {
        failed[cases[i]] = err;
      } else {
        passed[cases[i]] = true;
      }

      if (cases[++i]) {
        currentCase = cases[i];
        test(suite[cases[i]], check);
      } else {
        complete();
      }
    });
  });
};

// runs a test
function test (testcase, fn) {
  var timer;

  window.onerror = function (err) {
    complete(err);
  };

  function complete (err) {
    if (complete.run) return;
    if (timer) clearTimeout(timer);
    complete.run = true;
    window.onerror = null;
    fn(err);
  };

  try {
    if (testcase.length > 0) {
      var timer = setTimeout(function () {
        complete(new Error('Timeout'));
      }, 2000);

      testcase(complete);
    } else {
      testcase();
      complete();
    }
  } catch (e) {
    complete(e);
  }
};

// exposes a function to easily create a server for the current test

function create (nsp) {
  if (!testsPorts[currentSuite]) {
    throw new Error('No socket server defined for suite "' + currentSuite + '"');
  }

  if (!testsPorts[currentSuite][currentCase]) {
    throw new Error('No socket server defined for suite "' + currentSuite
      + '" and case "' + currentCase + '"');
  }

  return io.connect(uri() + (nsp || ''));
};

function uri () {
  return document.location.protocol + '//' + document.location.hostname
      + ':' + testsPorts[currentSuite][currentCase];
}
<|endoftext|>


<commit_before>import React from 'react';
import {connect} from 'react-redux';
import {ReverseLink} from 'react-router-reverse';
import {bindActionCreators} from 'redux';

import {fetch} from '../actions/dashboard';
import AddonListing from '../components/addon';
import dashboardSelector from '../selectors/dashboard';

export class AddonDashboard extends React.Component {
  static PropTypes = {
    addons: React.PropTypes.array,
    fetch: React.PropTypes.func,
  };
  constructor(props) {
    super(props);
    this.props.fetch();
  }
  render() {
    return (

My Firefox OS Add-ons

        <AddonListing addons={this.props.addons}/>

    );
  }
};

export default connect(
  dashboardSelector,
  dispatch => bindActionCreators({
    fetch
  }, dispatch)
)(AddonDashboard);
<commit_msg>fix dashbaord<commit_after>import React from 'react';
import {connect} from 'react-redux';
import {ReverseLink} from 'react-router-reverse';
import {bindActionCreators} from 'redux';

import {fetch} from '../actions/dashboard';
import {AddonListing} from '../components/addon';
import dashboardSelector from '../selectors/dashboard';

export class AddonDashboard extends React.Component {
  static PropTypes = {
    addons: React.PropTypes.array,
    fetch: React.PropTypes.func,
  };
  constructor(props) {
    super(props);
    this.props.fetch();
  }
  render() {
    return (

My Firefox OS Add-ons

        <AddonListing addons={this.props.addons}/>

    );
  }
};

export default connect(
  dashboardSelector,
  dispatch => bindActionCreators({
    fetch
  }, dispatch)
)(AddonDashboard);
<|endoftext|>


<commit_before>/*
 * BSD 3-Clause License
 *
 * Copyright (c) 2015, Kyle Kelley and others as credited in the AUTHORS file
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors
 * may be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

/**
 * @module jupyter-paths
 *
 * @description Module `jupyter-paths` provides path helpers ported from github.com/jupyter/jupyter_core
 *
 *
 */

module.exports = {
  jupyterPath: jupyterPath,
  jupyterConfigDir: jupyterConfigDir,
  jupyterDataDir: jupyterDataDir,
  jupyterRuntimeDir: jupyterRuntimeDir,
  userHome: userHome
};

var fs = require('fs');
var path = require('path');

// Access `sys.prefix` from Python, to handle particular conda and virtualenv setups
// TODO: Think of something more sensible here, possibly doing this asynchronously elsewhere
// TODO: Provide a timeout, handle error
var child_process = require('child_process');
var response = child_process.spawnSync('python', ['-c', 'import sys; print(sys.prefix)']);
var sysPrefix = response.stdout.toString().replace(/^\s+|\s+$/g, "");

var SYSTEM_JUPYTER_PATH;

// Compute default system configurations
if (process.platform == 'win32') {
  programData = process.env.PROGRAMDATA;
  if (programData){
    SYSTEM_JUPYTER_PATH = [path.join(programData, 'jupyter')];
  }
  else {
    SYSTEM_JUPYTER_PATH = [path.join(sysPrefix, 'share', 'jupyter')];
  }
}
else {
  SYSTEM_JUPYTER_PATH = [
    "/usr/local/share/jupyter",
    "/usr/share/jupyter"
  ];
}

var ENV_JUPYTER_PATH = [path.join(sysPrefix, 'share', 'jupyter')];

// Returns the home specified by environment variable or
// node's built in path.resolve('~')
function userHome () {
  var homeDir = process.env.HOME || process.env.USERPROFILE || path.resolve('~');
  homeDir = fs.realpathSync(homeDir);
  return homeDir;
}

// Get the Jupyter config directory for this platform and user.
// Returns env[JUPYTER_CONFIG_DIR] if defined, else ~/.jupyter
function jupyterConfigDir () {
  var homeDir = userHome();
  if (process.env.JUPYTER_CONFIG_DIR) {
    return process.env.JUPYTER_CONFIG_DIR;
  }
  return path.join(homeDir, '.jupyter');
}

// Get the config directory for Jupyter data files.
//
// These are non-transient, non-configuration files.
//
// Returns process.env[JUPYTER_DATA_DIR] if defined,
// else a platform-appropriate path.
function jupyterDataDir() {
  if (process.env.JUPYTER_DATA_DIR){
    return process.env.JUPYTER_DATA_DIR;
  }
  else if (process.platform == 'win32') {
    appData = process.env.APPDATA;
    if (appData) {
      return path.join(appData, 'jupyter');
    }
    else {
      return path.join(jupyterConfigDir(), 'data');
    }
  }
  else if (process.platform == 'darwin') {
    return path.join(userHome(), 'Library', 'Jupyter');
  }
  else {
    // Linux, non-OS X Unix, AIX, etc.
    var xdg = process.env.XDG_DATA_HOME;
    if (!xdg) {
      xdg = path.join(userHome(), '.local', 'share');
    }
    return path.join(xdg, 'jupyter');
  }
}

// Returns the path for ~/.ipython
function ipythonDataDir() {
  return path.join(userHome(), '.ipython');
}

// Return the runtime dir for transient jupyter files.
//
// Returns process.env[JUPYTER_RUNTIME_DIR] if defined.
//
// Respects XDG_RUNTIME_DIR on non-OS X, non-Windows,
//   falls back on data_dir/runtime otherwise.
function jupyterRuntimeDir() {
  if (process.env.JUPYTER_RUNTIME_DIR){
    return process.env.JUPYTER_RUNTIME_DIR;
  }
  if (process.platform == 'darwin' || process.platform == 'win32'){
    return path.join(jupyterDataDir(), 'runtime');
  }
  else {
    // Linux, non-OS X Unix, AIX, etc.
    xdg = process.env.XDG_RUNTIME_DIR;
    if (xdg) {
      // Ref https://github.com/jupyter/jupyter_core/commit/176b7a9067bfc20bfa97be5dae93912e2930a427#commitcomment-11331375
      return path.join(xdg, 'jupyter');
    }
    return path.join(jupyterDataDir, 'runtime');
  }
}

/**
 * Return the list of directories to search
 * JUPYTER_PATH environment variable has highest priority.
 *
 * If subdirs are given, that subdirectory path will be added to each element.
 * Examples:
 *
 * > jupyterPath()
 * ['/Users/rgbkrk/.local/jupyter', '/usr/local/share/jupyter']
 *
 * > jupyterPath('kernels')
 * ['/Users/rgbkrk/.local/jupyter/kernels', '/usr/local/share/jupyter/kernels']
 */
function jupyterPath() {
  var subdir;
  var paths = [];
  var i;

  if (arguments) {
    subdir = path.join.apply(null, arguments);
  }

  // highest priority is env
  if (process.env.JUPYTER_PATH){
    jupyterPathEnvSplit = process.env.JUPYTER_PATH.split(path.delimiter);

    jupyterPathEnvSplit.forEach(function(p){
      // Strip off the path separator from the right
      normalizedP = p.replace(RegExp(path.sep + "+$"), "");
      paths.push(normalizedP);
    });
  }

  // Next up, user directory
  paths.push(jupyterDataDir());

  // Oh joy, it's sys.prefix
  ENV_JUPYTER_PATH.forEach(function(p) {
    if (! (p in SYSTEM_JUPYTER_PATH)) {
      paths.push(p);
    }
  });

  SYSTEM_JUPYTER_PATH.forEach(function(p){
    paths.push(p);
  });

  paths.push(ipythonDataDir());

  // Append the subdir
  if (subdir) {
    paths = paths.map(function(p){
      return path.join(p, subdir);
    });
  }

  return paths;
}
<commit_msg>Port the config path function.<commit_after>/*
 * BSD 3-Clause License
 *
 * Copyright (c) 2015, Kyle Kelley and others as credited in the AUTHORS file
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors
 * may be used to endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

/**
 * @module jupyter-paths
 *
 * @description Module `jupyter-paths` provides path helpers ported from github.com/jupyter/jupyter_core
 *
 *
 */

module.exports = {
  jupyterPath: jupyterPath,
  jupyterConfigDir: jupyterConfigDir,
  jupyterDataDir: jupyterDataDir,
  jupyterRuntimeDir: jupyterRuntimeDir,
  userHome: userHome
};

var fs = require('fs');
var path = require('path');

// Access `sys.prefix` from Python, to handle particular conda and virtualenv setups
// TODO: Think of something more sensible here, possibly doing this asynchronously elsewhere
// TODO: Provide a timeout, handle error
var child_process = require('child_process');
var response = child_process.spawnSync('python', ['-c', 'import sys; print(sys.prefix)']);
var sysPrefix = response.stdout.toString().replace(/^\s+|\s+$/g, "");

var SYSTEM_JUPYTER_PATH;

// Compute default system configurations
if (process.platform == 'win32') {
  programData = process.env.PROGRAMDATA;
  if (programData){
    SYSTEM_JUPYTER_PATH = [path.join(programData, 'jupyter')];
  }
  else {
    SYSTEM_JUPYTER_PATH = [path.join(sysPrefix, 'share', 'jupyter')];
  }
}
else {
  SYSTEM_JUPYTER_PATH = [
    "/usr/local/share/jupyter",
    "/usr/share/jupyter"
  ];
}

var ENV_JUPYTER_PATH = [path.join(sysPrefix, 'share', 'jupyter')];

// Returns the home specified by environment variable or
// node's built in path.resolve('~')
function userHome () {
  var homeDir = process.env.HOME || process.env.USERPROFILE || path.resolve('~');
  homeDir = fs.realpathSync(homeDir);
  return homeDir;
}

// Get the Jupyter config directory for this platform and user.
// Returns env[JUPYTER_CONFIG_DIR] if defined, else ~/.jupyter
function jupyterConfigDir () {
  var homeDir = userHome();
  if (process.env.JUPYTER_CONFIG_DIR) {
    return process.env.JUPYTER_CONFIG_DIR;
  }
  return path.join(homeDir, '.jupyter');
}

// Get the config directory for Jupyter data files.
//
// These are non-transient, non-configuration files.
//
// Returns process.env[JUPYTER_DATA_DIR] if defined,
// else a platform-appropriate path.
function jupyterDataDir() {
  if (process.env.JUPYTER_DATA_DIR){
    return process.env.JUPYTER_DATA_DIR;
  }
  else if (process.platform == 'win32') {
    appData = process.env.APPDATA;
    if (appData) {
      return path.join(appData, 'jupyter');
    }
    else {
      return path.join(jupyterConfigDir(), 'data');
    }
  }
  else if (process.platform == 'darwin') {
    return path.join(userHome(), 'Library', 'Jupyter');
  }
  else {
    // Linux, non-OS X Unix, AIX, etc.
    var xdg = process.env.XDG_DATA_HOME;
    if (!xdg) {
      xdg = path.join(userHome(), '.local', 'share');
    }
    return path.join(xdg, 'jupyter');
  }
}

// Returns the path for ~/.ipython
function ipythonDataDir() {
  return path.join(userHome(), '.ipython');
}

// Return the runtime dir for transient jupyter files.
//
// Returns process.env[JUPYTER_RUNTIME_DIR] if defined.
//
// Respects XDG_RUNTIME_DIR on non-OS X, non-Windows,
//   falls back on data_dir/runtime otherwise.
function jupyterRuntimeDir() {
  if (process.env.JUPYTER_RUNTIME_DIR){
    return process.env.JUPYTER_RUNTIME_DIR;
  }
  if (process.platform == 'darwin' || process.platform == 'win32'){
    return path.join(jupyterDataDir(), 'runtime');
  }
  else {
    // Linux, non-OS X Unix, AIX, etc.
    xdg = process.env.XDG_RUNTIME_DIR;
    if (xdg) {
      // Ref https://github.com/jupyter/jupyter_core/commit/176b7a9067bfc20bfa97be5dae93912e2930a427#commitcomment-11331375
      return path.join(xdg, 'jupyter');
    }
    return path.join(jupyterDataDir, 'runtime');
  }
}

/**
 * Return the list of directories to search
 * JUPYTER_PATH environment variable has highest priority.
 *
 * If subdirs are given, that subdirectory path will be added to each element.
 * Examples:
 *
 * > jupyterPath()
 * ['/Users/rgbkrk/.local/jupyter', '/usr/local/share/jupyter']
 *
 * > jupyterPath('kernels')
 * ['/Users/rgbkrk/.local/jupyter/kernels', '/usr/local/share/jupyter/kernels']
 */
function jupyterPath() {
  var subdir;
  var paths = [];
  var i;

  if (arguments) {
    subdir = path.join.apply(null, arguments);
  }

  // highest priority is env
  if (process.env.JUPYTER_PATH){
    jupyterPathEnvSplit = process.env.JUPYTER_PATH.split(path.delimiter);

    jupyterPathEnvSplit.forEach(function(p){
      // Strip off the path separator from the right
      normalizedP = p.replace(RegExp(path.sep + "+$"), "");
      paths.push(normalizedP);
    });
  }

  // Next up, user directory
  paths.push(jupyterDataDir());

  // Oh joy, it's sys.prefix
  ENV_JUPYTER_PATH.forEach(function(p) {
    if (! (p in SYSTEM_JUPYTER_PATH)) {
      paths.push(p);
    }
  });

  SYSTEM_JUPYTER_PATH.forEach(function(p){
    paths.push(p);
  });

  paths.push(ipythonDataDir());

  // Append the subdir
  if (subdir) {
    paths = paths.map(function(p){
      return path.join(p, subdir);
    });
  }

  return paths;
}

var SYSTEM_CONFIG_PATH;

if (process.platform == 'win32') {
  programData = process.env.PROGRAMDATA;
  if (programData){
    SYSTEM_CONFIG_PATH = [path.join(programData, 'jupyter')];
  } else { // PROGRAMDATA is not defined by default in XP
    SYSTEM_CONFIG_PATH = [];
  }
} else {
  SYSTEM_CONFIG_PATH = [
    "/usr/local/etc/jupyter",
    "/etc/jupyter"
  ];
}

var ENV_CONFIG_PATH = [path.join(sysPrefix, 'etc', 'jupyter')];

function jupyterConfigPath() {
  var paths = [jupyterConfigDir()];
  ENV_CONFIG_PATH.forEach(function(p){
    if (! (p in SYSTEM_CONFIG_PATH)) {
      paths.push(p);
    }
  });
  paths.push.apply(paths, SYSTEM_CONFIG_PATH);
  return paths;
}
<|endoftext|>


<commit_before>AutoForm.hooks({
    'events-form': {
        onSuccess: function (operation, result, template) {
            slidePanel.closePanel();
            Materialize.toast('Event submitted successfully!', 4000);
            Session.set("selected", result._id)
        },
        onError: function(formType, error) {
            console.error(error);
        }
    }
});
Template.eventsForm.onCreated(function() {
    this.debounce = null;
});
Template.eventsForm.helpers({
    geocodeDataSource: function(query, sync, asyncCallback) {
        var instance = Template.instance();
        if (instance.debounce) {
            Meteor.clearTimeout(instance.debounce);
        }
        const debounceDelay = 500; //wait half a second before triggering search
        instance.debounce = Meteor.setTimeout(function() {
            Meteor.call('getCoords', query, function (error, result) {
                var mapResultToDisplay = function () {
                    return result.map(function (v) {
                            var streetName = _.isNull(v.streetName) ? '' : v.streetName + ' ';
                            var streetNumber = _.isNull(v.streetNumber) ? _.isEmpty(streetName) ? '' : ', ' : +v.streetNumber + ', ';
                            var city  = _.isNull(v.city) ? '' : v.city + ', ';
                            return {
                                value: streetName + streetNumber + city + v.country,
                                lat: v.latitude,
                                lng: v.longitude
                            };
                        }
                    );
                };

                if (error != undefined) {
                    console.error(error);
                    return;
                } else {
                    asyncCallback(mapResultToDisplay());
                }
            });
        }, debounceDelay);
    },
    selectedHandler: function (event, suggestion, datasetName) {
        var dropPin = function() {
            var coordsDefined = !_.isUndefined(suggestion.lat) && !_.isUndefined(suggestion.lng);
            if (coordsDefined) {
                $('input[name="coordinates.lat"]').val(suggestion.lat);
                $('input[name="coordinates.lng"]').val(suggestion.lng);
            } else {
                throw Meteor.Error('cords-undefined', 'Coordinates are empty for the selected location');
            }
        };
        dropPin();
    },
    selectedEventDoc: function(){
        return Events.findOne(Session.get('selected'));
    }
});

Template.eventsForm.rendered = function() {
    Meteor.typeahead.inject();
    var selectedEvent = Events.findOne(Session.get('selected'));
    if (selectedEvent != null) {
        this.$('input[name="coordinates.lat"]').val(selectedEvent.coordinates.lat);
        this.$('input[name="coordinates.lng"]').val(selectedEvent.coordinates.lng);
    }
    //this is because Typeahead duplicates input and inserts it inside of a new span item which breaks Materialize
    function fixMaterializeActiveClassTrigger() {
        $('input[name=location]').detach().insertBefore('.twitter-typeahead');
        $('.twitter-typeahead').find('input[type=text]').remove();
    }
    fixMaterializeActiveClassTrigger();
};

Template.eventsForm.destroyed = function() {
    // Can do some cleanup in here
};<commit_msg>destroying typehead on slidepanel close<commit_after>AutoForm.hooks({
    'events-form': {
        onSuccess: function (operation, result, template) {
            slidePanel.closePanel();
            Materialize.toast('Event submitted successfully!', 4000);
            Session.set("selected", result._id)
        },
        onError: function(formType, error) {
            console.error(error);
        }
    }
});
Template.eventsForm.onCreated(function() {
    this.debounce = null;
});
Template.eventsForm.helpers({
    geocodeDataSource: function(query, sync, asyncCallback) {
        var instance = Template.instance();
        if (instance.debounce) {
            Meteor.clearTimeout(instance.debounce);
        }
        const debounceDelay = 500; //wait half a second before triggering search
        instance.debounce = Meteor.setTimeout(function() {
            Meteor.call('getCoords', query, function (error, result) {
                var mapResultToDisplay = function () {
                    return result.map(function (v) {
                            var streetName = _.isNull(v.streetName) ? '' : v.streetName + ' ';
                            var streetNumber = _.isNull(v.streetNumber) ? _.isEmpty(streetName) ? '' : ', ' : +v.streetNumber + ', ';
                            var city  = _.isNull(v.city) ? '' : v.city + ', ';
                            return {
                                value: streetName + streetNumber + city + v.country,
                                lat: v.latitude,
                                lng: v.longitude
                            };
                        }
                    );
                };

                if (error != undefined) {
                    console.error(error);
                    return;
                } else {
                    asyncCallback(mapResultToDisplay());
                }
            });
        }, debounceDelay);
    },
    selectedHandler: function (event, suggestion, datasetName) {
        var dropPin = function() {
            var coordsDefined = !_.isUndefined(suggestion.lat) && !_.isUndefined(suggestion.lng);
            if (coordsDefined) {
                $('input[name="coordinates.lat"]').val(suggestion.lat);
                $('input[name="coordinates.lng"]').val(suggestion.lng);
            } else {
                throw Meteor.Error('cords-undefined', 'Coordinates are empty for the selected location');
            }
        };
        dropPin();
    },
    selectedEventDoc: function(){
        return Events.findOne(Session.get('selected'));
    }
});

Template.eventsForm.rendered = function() {
    Meteor.typeahead.inject();
    var selectedEvent = Events.findOne(Session.get('selected'));
    if (selectedEvent != null) {
        this.$('input[name="coordinates.lat"]').val(selectedEvent.coordinates.lat);
        this.$('input[name="coordinates.lng"]').val(selectedEvent.coordinates.lng);
    }
    //this is because Typeahead duplicates input and inserts it inside of a new span item which breaks Materialize
    function fixMaterializeActiveClassTrigger() {
        $('input[name=location]').detach().insertBefore('.twitter-typeahead');
        $('.twitter-typeahead').find('input[type=text]').remove();
    }
    fixMaterializeActiveClassTrigger();
};

Template.eventsForm.destroyed = function() {
    $('.typeahead').typeahead('destroy');
};<|endoftext|>


<commit_before>(function ($, undefined) {

    // Contains all the buttons
    var buttons = [
        { label: 'Clear', classname: 'ss-calculator-clear ss-calculator-clearfix', action: 'clear' },
        { label: 'CE', classname: 'ss-calculator-clearentry', action: 'clearEntry' },
        { label: '*', classname: 'ss-calculator-multiply', action: 'operator' },
        { label: 7, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 8, action: 'number' },
        { label: 9, action: 'number' },
        { label: '+', classname: 'ss-calculator-plus', action: 'operator' },
        { label: 4, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 5, action: 'number' },
        { label: 6, action: 'number' },
        { label: '-', classname: 'ss-calculator-minus', action: 'operator' },
        { label: 1, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 2, action: 'number' },
        { label: 3, action: 'number' },
        { label: '/', classname: 'ss-calculator-divide', action: 'operator' },
        { label: 0, classname: 'ss-calculator-clearfix ss-calculator-wide', action: 'number' },
        { label: '.', classname: 'ss-calculator-dot', action: 'dot' },
        { label: '=', classname: 'ss-calculator-equals', action: 'equals' }
    ];

    // Defines the widget
    $.widget('ss.calculator', {

        // widget currrent version
        version: '0.0.2',

        // configurable options
        options: {
            buttons: buttons,
            show: false,
            hide: false
        },

        // Calls at the time of creation
        _create : function() {
            this.element.addClass('ss-calculator ui-widget ui-corner-all');
            this._createWrapper();
            this._createButtons();
            this._renderMarkup();

            // triggers event when any button is clicked
            this._on({
                'click button': this._clickHandler
            });

            // array showing the result
            this.currentDisplay = [];

            // array showing calculation
            this.display = [];
            this.numericalInput = false;
        },

        // Creates the wrapper
        _createWrapper: function() {
            var el = $('<div/>'), display;

            this.shell = el.clone().addClass('ss-calculator-shell ui-widget-header ui-corner-all');
            display = el.clone().addClass('ss-calculator-display ui-widget-content ui-corner-all').appendTo(this.shell);
            el.clone().addClass('ss-calculator-calculation').appendTo(display);
            el.clone().text('0').addClass('ss-calculator-result').appendTo(display);

            if(!this.options.showOnCreate) {
                this._hide(this.element, this.options.hide);
            }
        },

        // loads the buttons
        _createButtons: function() {
            var el = $('<button/>'), container = $('<div/>').addClass('ui-helper-clearfix ui-widget-content ui-corner-all'), widget = this, i;

            // iterates on the buttons array
            $.each(this.options.buttons, function(i, button) {
                if(widget._trigger('beforeAddButtons', null, button)) {
                    var btn = el.clone().text(button.label).appendTo(container).button();

                    // adds classname to buttons if defined
                    if(!!button.classname) {
                        btn.addClass(button.classname);
                    }

                    if(typeof button.action === 'string') {
                        btn.data('action', button.action);
                    }

                    // for user defined function for a button
                    else if(typeof button.action === 'function') {
                        var fName = 'custom.ss.' + i;
                        widget['_' + fName];
                        btn.data('action', fName);
                    }
                }
            });

            // updates shell
            container.appendTo(this.shell);
        },

        // joins everything together
        _renderMarkup: function() {
            this.shell.appendTo(this.element);
            this._setStyle();
        },

        // takes care of configurable options
        _setOptions: function(options) {
            this._superApply(arguments);
        },

        _setOption: function(key, val) {
            this._super(key, val);

            if(key === 'buttons') {
                this.shell.find('button').remove();
                this._createButtons();
                this._renderMarkup();
            }
            else if(key === 'disable') {
                this.shell.find('button').button('option', key, val);
            }
        },

        // for the show animation
        show: function() {
            this._show(this.element, this.options.show);
        },

        // handles the event when a button is clicked
        _clickHandler: function(e) {
            var btn = $(e.target).closest('button'), fn = btn.data('action');

            this['_' + fn](e, btn);
        },

        _clear: function(e, ui) {
            this.currentDisplay = [];
            this.display = [];
            this._updateDisplay();
            this._display();
            this.numericalInput = false;
        },

        _clearEntry: function(e, ui) {
            this.currentDisplay = [];
            this._updateDisplay();
        },

        _equals: function(e, ui) {
            this._calculate(true);
        },

        // carries on operations when an operator is clicked
        _operator: function(e, ui) {

            if(!this.display.length && !this.currentDisplay.length) {
                this.currentDisplay.push(this.element.find('.ss-calculator-result').text());
            }
            else if(this.currentDisplay.slice(0).reverse()[0] === '.') {
                this.currentDisplay.pop();
            }

            if(!this.display.length || this.numericalInput) {
                this.display.push([this.currentDisplay.join(''), ' ', ui.text(), ' '].join(''));
            }
            else if(!this.numericalInput) {
                var length = this.display.length,
                    // changes the trailing operator if any other operator is clicked
                    str = this.display[length - 1].replace(/[\*\/\+\-]/, ui.text());
                this.display.pop();
                this.display.push(str);
            }

            this._display();
            this.numericalInput = false;
            this._calculate();
        },

        _number: function(e, ui) {
            this.currentDisplay.push(ui.text());
            this._updateDisplay();
            this.numericalInput = true;
        },

        _dot: function(e, ui) {
            var dot = false, x = this.currentDisplay.length;

            if(!x) {
                this.currentDisplay.push('0');
            }

            while( --x) {
                if(this.currentDisplay[x] === '.') {
                    dot = true;
                    break;
                }
            }

            if(dot) {
                return false;
            }
            else {
                this.currentDisplay.push('.');
                this._updateDisplay();
            }
        },

        // updates the result area
        _updateDisplay: function(reset) {

            if(!this.currentDisplay.length) {
                this.element.find('.ss-calculator-result').text('0');
            }
            else if(this.currentDisplay.length < 18) {
                this.element.find('.ss-calculator-result').text(this.currentDisplay.join(''));
            }

            if(reset) {
                this.currentDisplay = [];
            }
        },

        // updates the calculation area
        _display: function() {
            this.element.find('.ss-calculator-calculation').text(this.display.join(''));
            this.currentDisplay = [];
        },

        // calculates the result
        _calculate: function(final) {

            var ops = {
                '+': function(x, y) { return x + y; },
                '-': function(x, y) { return x - y; },
                '*': function(x, y) { return x * y; },
                '/': function(x, y) { return x / y; }
            };

            // avoids javascript precedence rule for operators
            function seqCalc(str) {
                var arr = str.split(' '), left = +arr[0], x, length = arr.length;

                for(x = 1; x < length; x = x + 2) {

                    left = ops[arr[x]](left, +arr[x + 1]);

                }

                return left;
            }

            if(final) {

                var display = this.element.find('.ss-calculator-calculation').text(), current = this.element.find('.ss-calculator-result').text();

                // fills with the result
                this.currentDisplay = [seqCalc([display, current].join(''))];
                this._updateDisplay();
                this.display = [];
                this._display();
                this.numericalInput = false;

            }
            else if(this.display.length > 1) {

                var tmp = this.display.pop(),
                    // removes the trailing spaces and operator
                    trimmed = tmp.replace(/\s[\+\-\/\*]\s/, '');

                this.display.push(trimmed);
                this.currentDisplay.push(seqCalc(this.display.join('')));
                this.display.pop();
                this.display.push(tmp);
                this._updateDisplay(true);
            }
        },

        _setStyle: function() {
            $('.ss-calculator button').css('float', 'left');
            $('.ss-calculator-clearfix').css('clear', 'left');
            $('.ss-calculator-display').css('position', 'relative').css('overflow', 'hidden');
        }

    });

}(jQuery));
<commit_msg>display bug<commit_after>(function ($, undefined) {

    // Contains all the buttons
    var buttons = [
        { label: 'Clear', classname: 'ss-calculator-clear ss-calculator-clearfix', action: 'clear' },
        { label: 'CE', classname: 'ss-calculator-clearentry', action: 'clearEntry' },
        { label: '*', classname: 'ss-calculator-multiply', action: 'operator' },
        { label: 7, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 8, action: 'number' },
        { label: 9, action: 'number' },
        { label: '+', classname: 'ss-calculator-plus', action: 'operator' },
        { label: 4, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 5, action: 'number' },
        { label: 6, action: 'number' },
        { label: '-', classname: 'ss-calculator-minus', action: 'operator' },
        { label: 1, classname: 'ss-calculator-clearfix', action: 'number' },
        { label: 2, action: 'number' },
        { label: 3, action: 'number' },
        { label: '/', classname: 'ss-calculator-divide', action: 'operator' },
        { label: 0, classname: 'ss-calculator-clearfix ss-calculator-wide', action: 'number' },
        { label: '.', classname: 'ss-calculator-dot', action: 'dot' },
        { label: '=', classname: 'ss-calculator-equals', action: 'equals' }
    ];

    // Defines the widget
    $.widget('ss.calculator', {

        // widget currrent version
        version: '0.0.2',

        // configurable options
        options: {
            buttons: buttons,
            show: false,
            hide: false,
	    showOnCreate: true
        },

        // Calls at the time of creation
        _create : function() {
            this.element.addClass('ss-calculator ui-widget ui-corner-all');
            this._createWrapper();
            this._createButtons();
            this._renderMarkup();

            // triggers event when any button is clicked
            this._on({
                'click button': this._clickHandler
            });

            // array showing the result
            this.currentDisplay = [];

            // array showing calculation
            this.display = [];
            this.numericalInput = false;
        },

        // Creates the wrapper
        _createWrapper: function() {
            var el = $('<div/>'), display;

            this.shell = el.clone().addClass('ss-calculator-shell ui-widget-header ui-corner-all');
            display = el.clone().addClass('ss-calculator-display ui-widget-content ui-corner-all').appendTo(this.shell);
            el.clone().addClass('ss-calculator-calculation').appendTo(display);
            el.clone().text('0').addClass('ss-calculator-result').appendTo(display);

            if(!this.options.showOnCreate) {
                this._hide(this.element, this.options.hide);
            }
        },

        // loads the buttons
        _createButtons: function() {
            var el = $('<button/>'), container = $('<div/>').addClass('ui-helper-clearfix ui-widget-content ui-corner-all'), widget = this, i;

            // iterates on the buttons array
            $.each(this.options.buttons, function(i, button) {
                if(widget._trigger('beforeAddButtons', null, button)) {
                    var btn = el.clone().text(button.label).appendTo(container).button();

                    // adds classname to buttons if defined
                    if(!!button.classname) {
                        btn.addClass(button.classname);
                    }

                    if(typeof button.action === 'string') {
                        btn.data('action', button.action);
                    }

                    // for user defined function for a button
                    else if(typeof button.action === 'function') {
                        var fName = 'custom.ss.' + i;
                        widget['_' + fName];
                        btn.data('action', fName);
                    }
                }
            });

            // updates shell
            container.appendTo(this.shell);
        },

        // joins everything together
        _renderMarkup: function() {
            this.shell.appendTo(this.element);
            this._setStyle();
        },

        // takes care of configurable options
        _setOptions: function(options) {
            this._superApply(arguments);
        },

        _setOption: function(key, val) {
            this._super(key, val);

            if(key === 'buttons') {
                this.shell.find('button').remove();
                this._createButtons();
                this._renderMarkup();
            }
            else if(key === 'disable') {
                this.shell.find('button').button('option', key, val);
            }
        },

        // for the show animation
        show: function() {
            this._show(this.element, this.options.show);
        },

        // handles the event when a button is clicked
        _clickHandler: function(e) {
            var btn = $(e.target).closest('button'), fn = btn.data('action');

            this['_' + fn](e, btn);
        },

        _clear: function(e, ui) {
            this.currentDisplay = [];
            this.display = [];
            this._updateDisplay();
            this._display();
            this.numericalInput = false;
        },

        _clearEntry: function(e, ui) {
            this.currentDisplay = [];
            this._updateDisplay();
        },

        _equals: function(e, ui) {
            this._calculate(true);
        },

        // carries on operations when an operator is clicked
        _operator: function(e, ui) {

            if(!this.display.length && !this.currentDisplay.length) {
                this.currentDisplay.push(this.element.find('.ss-calculator-result').text());
            }
            else if(this.currentDisplay.slice(0).reverse()[0] === '.') {
                this.currentDisplay.pop();
            }

            if(!this.display.length || this.numericalInput) {
                this.display.push([this.currentDisplay.join(''), ' ', ui.text(), ' '].join(''));
            }
            else if(!this.numericalInput) {
                var length = this.display.length,
                    // changes the trailing operator if any other operator is clicked
                    str = this.display[length - 1].replace(/[\*\/\+\-]/, ui.text());
                this.display.pop();
                this.display.push(str);
            }

            this._display();
            this.numericalInput = false;
            this._calculate();
        },

        _number: function(e, ui) {
            this.currentDisplay.push(ui.text());
            this._updateDisplay();
            this.numericalInput = true;
        },

        _dot: function(e, ui) {
            var dot = false, x = this.currentDisplay.length;

            if(!x) {
                this.currentDisplay.push('0');
            }

            while( --x) {
                if(this.currentDisplay[x] === '.') {
                    dot = true;
                    break;
                }
            }

            if(dot) {
                return false;
            }
            else {
                this.currentDisplay.push('.');
                this._updateDisplay();
            }
        },

        // updates the result area
        _updateDisplay: function(reset) {

            if(!this.currentDisplay.length) {
                this.element.find('.ss-calculator-result').text('0');
            }
            else if(this.currentDisplay.length < 18) {
                this.element.find('.ss-calculator-result').text(this.currentDisplay.join(''));
            }

            if(reset) {
                this.currentDisplay = [];
            }
        },

        // updates the calculation area
        _display: function() {
            this.element.find('.ss-calculator-calculation').text(this.display.join(''));
            this.currentDisplay = [];
        },

        // calculates the result
        _calculate: function(final) {

            var ops = {
                '+': function(x, y) { return x + y; },
                '-': function(x, y) { return x - y; },
                '*': function(x, y) { return x * y; },
                '/': function(x, y) { return x / y; }
            };

            // avoids javascript precedence rule for operators
            function seqCalc(str) {
                var arr = str.split(' '), left = +arr[0], x, length = arr.length;

                for(x = 1; x < length; x = x + 2) {

                    left = ops[arr[x]](left, +arr[x + 1]);

                }

                return left;
            }

            if(final) {

                var display = this.element.find('.ss-calculator-calculation').text(), current = this.element.find('.ss-calculator-result').text();

                // fills with the result
                this.currentDisplay = [seqCalc([display, current].join(''))];
                this._updateDisplay();
                this.display = [];
                this._display();
                this.numericalInput = false;

            }
            else if(this.display.length > 1) {

                var tmp = this.display.pop(),
                    // removes the trailing spaces and operator
                    trimmed = tmp.replace(/\s[\+\-\/\*]\s/, '');

                this.display.push(trimmed);
                this.currentDisplay.push(seqCalc(this.display.join('')));
                this.display.pop();
                this.display.push(tmp);
                this._updateDisplay(true);
            }
        },

        _setStyle: function() {
            $('.ss-calculator button').css('float', 'left');
            $('.ss-calculator-clearfix').css('clear', 'left');
            $('.ss-calculator-display').css('position', 'relative').css('overflow', 'hidden');
        }

    });

}(jQuery));
<|endoftext|>