<commit_before>var app = angular.module('app', ['notification', 'storage', 'profile', 'favorites', 'video', 'angularMoment', 'ngSanitize']);
app.controller('controller', function($scope, $rootScope, $notification, $storage, $profile, $favorites, $video, $timeout, $http, $log) {
  $('.ui.search')
    .search({
      minCharacters: 3,
      onSelect(result, response) {
        if (result.playlistId) {
          $scope.addPlaylist(result.playlistId)
            .then(() => {
              $('.ui.search input').val('');
            });
        } else {
          $scope.readd(result.key)
            .then(() => {
              $('.ui.search input').val('');
            });
        }
      },
      apiSettings: {
        onResponse(videos) {
          return {
            results: $.map(videos, (v) => {
              v.title = v.title + ' (' + (v.playlistId ? v.playlistItems + ' videos' : moment.duration(v.duration).format('H:mm:ss')) + ')';
              v.image = v.thumbnail;
              return v;
            })
          };
        },
        url: 'api/search?query={query}&maxResults=10'
      }
    });

    $scope.updateTheme = function(theme) {
      $rootScope.profile.theme = theme;
    };

    $rootScope.title = 'JukeBot';
    $scope.initTime = new Date().getTime();
    $scope.autoplay = false;
    $scope.listeners = {};
    $scope.newChat = '';

    /*************
     * Favorites *
     *************/
    $scope.likeCurrentVideo = function() {
      let video = $video.current();
      $favorites.likeVideo(video);
      if ($scope.likesCurrentVideo()) {
        $scope.$emit('likeVideo', {
          video
        });
      }
    };

    $scope.likesCurrentVideo = function() {
      return $favorites.likesVideo($video.current().key);
    };

    $scope.likeVideo = function(video) {
      return $favorites.likeVideo(video);
    };

    $scope.getFavorites = function() {
      return $rootScope.favorites.filter(favorite => !$scope.favoriteFilter || favorite.title.toLowerCase().indexOf($scope.favoriteFilter.toLowerCase()) !== -1);
    };

    $scope.clearFavoritesFilter = function() {
      $scope.favoriteFilter = '';
    };
    /*****************
     * End Favorites *
     *****************/

    /**************************
     * Video Service Passthru *
     **************************/
    $scope.currentVideo = function() {
      return $video.current();
    };

    $scope.addVideo = function() {
      if ($scope.link) {
        $video
          .add(link, user)
          .success(() => $scope.link = '')
          .error((e) => {
            $scope.link = '';
            sweetAlert('Error', e, 'error');
          });
      }
    };

    $scope.readd = function(key) {
      return $video.addByKey($rootScope.profile.username, key);
    };

    $scope.addPlaylist = function(key) {
      return $video.addPlaylistById($rootScope.profile.username, key);
    };

    $scope.skip = function() {
      return $video.skip($rootScope.profile.username);
    };

    $scope.findVideoById = function(id) {
      return $video.findById(id);
    };

    $scope.videoInUpcoming = function(key) {
      return $video.videoInUpcoming(key);
    };
    /******************************
     * End Video Service Passthru *
     ******************************/

    $scope.startTime = function() {
      let video = $video.current();

      return video ? Math.max(Math.floor(($scope.initTime - new Date(video.startTime).getTime()) / 1000), 0) : 0;
    };

    $scope.$watch($video.current, function(currentVideo) {
      $rootScope.title = currentVideo ? currentVideo.title : 'JukeBot';
      if (currentVideo && $scope.startTime() === 0 && $rootScope.notifications) {
        $notification(currentVideo.title, {
          icon: currentVideo.thumbnail,
          delay: 4000,
          focusWindowOnClick: true
        });
      }
      setTimeout(function() {
        $('.ui.embed').embed({
          url: currentVideo ? `//www.youtube.com/embed/${currentVideo.key}` : '',
          autoplay: true,
          parameters: {
            start: $scope.startTime()
          }
        });
        $('.ui.dropdown').dropdown();

        let $playing = $('#video-list .yellow').closest('playlistitem');

        if ($playing.length) {
          $playing[0].scrollIntoView({
            behavior: 'smooth'
          });
        }
        $scope.popupVideo();
      }, 0);
    }, true);

    $scope.popupVideo = function() {
      $('.playing span[data-content]').popup({
        variation: 'inverted',
        position: 'top center'
      });
    };

    $rootScope.$watch('profile.username', function() {
      io.socket._raw.emit('username', $rootScope.profile.username);
    });

    io.socket.get('/api/subscribeUsers', {
      username: $rootScope.profile.username
    });

    /************
     * Autoplay *
     ************/
    io.socket.on('autoplay', function(obj) {
      $scope.autoplay = obj.autoplay;
      $scope.$digest();
    });

    io.socket.get('/api/autoplay');

    $scope.toggleAutoplay = function() {
      io.socket._raw.emit('autoplay', $scope.autoplay);
    };
    /****************
     * End Autoplay *
     ****************/

    /***************
     * Chrome Flag *
     ***************/
    $scope.canShowChromeFlag = function() {
      return !$storage.get('chromeFlag');
    };

    $scope.hideChromeFlag = function() {
      $storage.set('chromeFlag', 'true');
    };
    /*******************
     * End Chrome Flag *
     *******************/

    /*************
     * Listeners *
     *************/
     io.socket.on('listening', function(obj) {
       $scope.listeners = obj.users;
       $scope.$digest();
       setTimeout($scope.popupListeners);
     });

    $scope.toggleListeners = function() {
      $('.listeners').toggle();
    };

    $scope.listenerUsernames = function() {
      return Object.values($scope.listeners);
    };

    $scope.listenerCount = function() {
      return Object.keys($scope.listeners).length;
    };

    $scope.popupListeners = function() {
      $('.listeners span[data-content]').popup({
        variation: 'inverted',
        position: 'top center'
      });
    };
    /*****************
     * End Listeners *
     *****************/
}).config(function($sceProvider) {
    $sceProvider.enabled(false);
}).directive('enterPress', function () {
  return function (scope, element, attrs) {
    element.bind('keydown keypress', function (event) {
      if(event.which === 13) {
        scope.$apply(function (){
          scope.$eval(attrs.enterPress);
        });
        event.preventDefault();
      }
    });
  };
});
<commit_msg>Update embedded url to be `autoplay=1`<commit_after>var app = angular.module('app', ['notification', 'storage', 'profile', 'favorites', 'video', 'angularMoment', 'ngSanitize']);
app.controller('controller', function($scope, $rootScope, $notification, $storage, $profile, $favorites, $video, $timeout, $http, $log) {
  $('.ui.search')
    .search({
      minCharacters: 3,
      onSelect(result, response) {
        if (result.playlistId) {
          $scope.addPlaylist(result.playlistId)
            .then(() => {
              $('.ui.search input').val('');
            });
        } else {
          $scope.readd(result.key)
            .then(() => {
              $('.ui.search input').val('');
            });
        }
      },
      apiSettings: {
        onResponse(videos) {
          return {
            results: $.map(videos, (v) => {
              v.title = v.title + ' (' + (v.playlistId ? v.playlistItems + ' videos' : moment.duration(v.duration).format('H:mm:ss')) + ')';
              v.image = v.thumbnail;
              return v;
            })
          };
        },
        url: 'api/search?query={query}&maxResults=10'
      }
    });

    $scope.updateTheme = function(theme) {
      $rootScope.profile.theme = theme;
    };

    $rootScope.title = 'JukeBot';
    $scope.initTime = new Date().getTime();
    $scope.autoplay = false;
    $scope.listeners = {};
    $scope.newChat = '';

    /*************
     * Favorites *
     *************/
    $scope.likeCurrentVideo = function() {
      let video = $video.current();
      $favorites.likeVideo(video);
      if ($scope.likesCurrentVideo()) {
        $scope.$emit('likeVideo', {
          video
        });
      }
    };

    $scope.likesCurrentVideo = function() {
      return $favorites.likesVideo($video.current().key);
    };

    $scope.likeVideo = function(video) {
      return $favorites.likeVideo(video);
    };

    $scope.getFavorites = function() {
      return $rootScope.favorites.filter(favorite => !$scope.favoriteFilter || favorite.title.toLowerCase().indexOf($scope.favoriteFilter.toLowerCase()) !== -1);
    };

    $scope.clearFavoritesFilter = function() {
      $scope.favoriteFilter = '';
    };
    /*****************
     * End Favorites *
     *****************/

    /**************************
     * Video Service Passthru *
     **************************/
    $scope.currentVideo = function() {
      return $video.current();
    };

    $scope.addVideo = function() {
      if ($scope.link) {
        $video
          .add(link, user)
          .success(() => $scope.link = '')
          .error((e) => {
            $scope.link = '';
            sweetAlert('Error', e, 'error');
          });
      }
    };

    $scope.readd = function(key) {
      return $video.addByKey($rootScope.profile.username, key);
    };

    $scope.addPlaylist = function(key) {
      return $video.addPlaylistById($rootScope.profile.username, key);
    };

    $scope.skip = function() {
      return $video.skip($rootScope.profile.username);
    };

    $scope.findVideoById = function(id) {
      return $video.findById(id);
    };

    $scope.videoInUpcoming = function(key) {
      return $video.videoInUpcoming(key);
    };
    /******************************
     * End Video Service Passthru *
     ******************************/

    $scope.startTime = function() {
      let video = $video.current();

      return video ? Math.max(Math.floor(($scope.initTime - new Date(video.startTime).getTime()) / 1000), 0) : 0;
    };

    $scope.$watch($video.current, function(currentVideo) {
      $rootScope.title = currentVideo ? currentVideo.title : 'JukeBot';
      if (currentVideo && $scope.startTime() === 0 && $rootScope.notifications) {
        $notification(currentVideo.title, {
          icon: currentVideo.thumbnail,
          delay: 4000,
          focusWindowOnClick: true
        });
      }
      setTimeout(function() {
        $('.ui.embed').embed({
          url: currentVideo ? `//www.youtube.com/embed/${currentVideo.key}` : '',
          autoplay: 1,
          parameters: {
            start: $scope.startTime()
          }
        });
        $('.ui.dropdown').dropdown();

        let $playing = $('#video-list .yellow').closest('playlistitem');

        if ($playing.length) {
          $playing[0].scrollIntoView({
            behavior: 'smooth'
          });
        }
        $scope.popupVideo();
      }, 0);
    }, true);

    $scope.popupVideo = function() {
      $('.playing span[data-content]').popup({
        variation: 'inverted',
        position: 'top center'
      });
    };

    $rootScope.$watch('profile.username', function() {
      io.socket._raw.emit('username', $rootScope.profile.username);
    });

    io.socket.get('/api/subscribeUsers', {
      username: $rootScope.profile.username
    });

    /************
     * Autoplay *
     ************/
    io.socket.on('autoplay', function(obj) {
      $scope.autoplay = obj.autoplay;
      $scope.$digest();
    });

    io.socket.get('/api/autoplay');

    $scope.toggleAutoplay = function() {
      io.socket._raw.emit('autoplay', $scope.autoplay);
    };
    /****************
     * End Autoplay *
     ****************/

    /***************
     * Chrome Flag *
     ***************/
    $scope.canShowChromeFlag = function() {
      return !$storage.get('chromeFlag');
    };

    $scope.hideChromeFlag = function() {
      $storage.set('chromeFlag', 'true');
    };
    /*******************
     * End Chrome Flag *
     *******************/

    /*************
     * Listeners *
     *************/
     io.socket.on('listening', function(obj) {
       $scope.listeners = obj.users;
       $scope.$digest();
       setTimeout($scope.popupListeners);
     });

    $scope.toggleListeners = function() {
      $('.listeners').toggle();
    };

    $scope.listenerUsernames = function() {
      return Object.values($scope.listeners);
    };

    $scope.listenerCount = function() {
      return Object.keys($scope.listeners).length;
    };

    $scope.popupListeners = function() {
      $('.listeners span[data-content]').popup({
        variation: 'inverted',
        position: 'top center'
      });
    };
    /*****************
     * End Listeners *
     *****************/
}).config(function($sceProvider) {
    $sceProvider.enabled(false);
}).directive('enterPress', function () {
  return function (scope, element, attrs) {
    element.bind('keydown keypress', function (event) {
      if(event.which === 13) {
        scope.$apply(function (){
          scope.$eval(attrs.enterPress);
        });
        event.preventDefault();
      }
    });
  };
});
<|endoftext|>


<commit_before>// TODO: transfer Save, Print, Close functions from older forms. *needs server access
app.service('$eea', ['$http', '$compile', function($http, $compile) {
	return {
		test: function($scope) {
			return 'test' + $scope;
		},
		init: function($scope) {
			$scope.field = {};
			$scope.multipleIndex = 1;
			$scope.ValidationDisabled = false;
			$scope.selectedLanguage = "en";
			$scope.groups = groups;
		},
		group: {
			addRow: function(frm, group, $scope) {
				$scope.multipleIndex = $scope.groups[frm][group].length;
				var id = ++$scope.multipleIndex;
				$scope.groups[frm][group].push(id);
				setTimeout(function() {
					$scope.$apply();
					$('#group-area-' + $scope.multipleIndex + '-' + group).prepend($compile('
<button type="button"  title="{{\'deleterow\' | translate}}"class="deleterowbutton" ng-click="deleteRow(\'' + frm + '\', \'' + group + '\', ' + id + ')"></button>
')($scope));
				}, 10);
			},
			deleteRow: function(frm, group, id, $scope) {
				$scope.groups[frm][group][$scope.groups[frm][group].indexOf(id)] = -1;
				$("#group-area-" + id + "-" + group).html("");
			}
		},
		form: {
			save : function ($scope) {
				$("form.eeaform").each(function(index, form){
					console.log("Testing form - Valid:", $scope[form.name].$valid);
					//TODO: Maybe a DB status flag (same Table or Lookup for activity logging? or Status in main table and Activity Table for action/date/user logging)
					//(i.e. 0 created/saved, 1 edited (+dateedited? extra field), 2 commited - leave it "open" for future statuses). In order to be Commited it needs to be valid. It can be saved without all elements completed but not commited.
					// Maybe an extra Commit button appearing in case server respond to last edit/save (and on form loading with saved data from server) that data are accepted and checked.
					// Is it possible to autogenerate the DB and REST services based on the XSD (or the other way around) so front-end and back-end automatch/autofunctioning together since they are constructed based on the same XSD file?
					// A kind of enviromental behaviour to tasks. If it can not be automated and just coexists transparently together with the other processes, then it doesn't do. Extra work and tickets every time.
					if (!$scope[form.name].$valid) {
						$("#" + form.name + " .ng-invalid").first().focus();
					}
				});
			},
			submit : function (frm, test, $scope) {

				for (var form in $scope.field) {
					if (frm) {
						if (frm.$name !== form) continue;
					}

					if (test) return false;

					var frmObj = $scope.field[form];
					var postContent = '';
					for (var element in frmObj) {
						postContent += "&" + encodeURIComponent(element) + "=" + encodeURIComponent(frmObj[element]);
					}

					$http({
						method: 'POST',
						url: $("#" + form).attr("eea-action"),
						headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
						data: postContent
					}).then(
						function(response) {
							console.log("response", response.status);
						},
						function(error) {
							console.log("error", error.status);
						});

				}

				return false;
			}
		}
	};
}]);<commit_msg>Updated EEA Form Validation Component<commit_after>// TODO: transfer Save, Print, Close functions from older forms. *needs server access
app.service('$eea', ['$http', '$compile', function($http, $compile) {
	return {
		test: function($scope) {
			return 'test' + $scope;
		},
		init: function($scope) {
			$scope.field = {};
			$scope.multipleIndex = 1;
			$scope.ValidationDisabled = false;
			$scope.selectedLanguage = "en";
			$scope.groups = groups;
		},
		group: {
			addRow: function(frm, group, $scope) {
				$scope.multipleIndex = $scope.groups[frm][group].length;
				var id = ++$scope.multipleIndex;
				$scope.groups[frm][group].push(id);
				setTimeout(function() {
					$scope.$apply();
					$('#group-area-' + $scope.multipleIndex + '-' + group).prepend($compile('
<button type="button"  title="{{\'deleterow\' | translate}}"class="deleterowbutton" ng-click="deleteRow(\'' + frm + '\', \'' + group + '\', ' + id + ')"></button>
')($scope));
					$scope.$apply();
				}, 10);
			},
			deleteRow: function(frm, group, id, $scope) {
				$scope.groups[frm][group][$scope.groups[frm][group].indexOf(id)] = -1;
				$("#group-area-" + id + "-" + group).html("");
			}
		},
		form: {
			save : function ($scope) {
				$("form.eeaform").each(function(index, form){
					console.log("Testing form - Valid:", $scope[form.name].$valid);
					//TODO: Maybe a DB status flag (same Table or Lookup for activity logging? or Status in main table and Activity Table for action/date/user logging)
					//(i.e. 0 created/saved, 1 edited (+dateedited? extra field), 2 commited - leave it "open" for future statuses). In order to be Commited it needs to be valid. It can be saved without all elements completed but not commited.
					// Maybe an extra Commit button appearing in case server respond to last edit/save (and on form loading with saved data from server) that data are accepted and checked.
					// Is it possible to autogenerate the DB and REST services based on the XSD (or the other way around) so front-end and back-end automatch/autofunctioning together since they are constructed based on the same XSD file?
					// A kind of enviromental behaviour to tasks. If it can not be automated and just coexists transparently together with the other processes, then it doesn't do. Extra work and tickets every time.
					if (!$scope[form.name].$valid) {
						$("#" + form.name + " .ng-invalid").first().focus();
					}
				});
			},
			submit : function (frm, test, $scope) {

				for (var form in $scope.field) {
					if (frm) {
						if (frm.$name !== form) continue;
					}

					if (test) return false;

					var frmObj = $scope.field[form];
					var postContent = '';
					for (var element in frmObj) {
						postContent += "&" + encodeURIComponent(element) + "=" + encodeURIComponent(frmObj[element]);
					}

					$http({
						method: 'POST',
						url: $("#" + form).attr("eea-action"),
						headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
						data: postContent
					}).then(
						function(response) {
							console.log("response", response.status);
						},
						function(error) {
							console.log("error", error.status);
						});

				}

				return false;
			}
		}
	};
}]);<|endoftext|>


<commit_before>
((module) => {
	'use strict';

	var createClassFromSuper = require('simple-class-utils').createClass.super;
	var Root = require('./root.js').class;

	var _key_iterator = Symbol.iterator;

	module.exports = createClass;

	function createClass(Super, ...args) {

		class XIterable extends (typeof Super === 'function' ? Super : createClass.default) {

			constructor(...args) {
				super(...args);
			}

			forEach(callback) {
				for (let element of this) {
					callback(element, this);
				}
			}

			map(callback) {
				var result = new this.Array();
				this.forEach((element) => result.push(callback(element, this)));
				return result;
			}

			some(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return true;
					}
				}
				return false;
			}

			every(callback) {
				return !this.every((element) => !callback(element, this));
			}

			filter(callback) {
				var result = new this.Array();
				this.forEach((element) => callback(element, this) && result.push(element));
				return result;
			}

			most(callback, init) {
				for (let element of this) {
					if (callback(element, init)) {
						init = element;
					}
				}
				return init;
			}

			get min() {
				return this.most((challenger, champion) => challenger < champion, +Infinity);
			}

			get max() {
				return this.most((challenger, champion) => challenger > champion, -Infinity);
			}

		}

		((proto) => {
			proto.Array = Array;
		})(XIterable.prototype);

		return createClassFromSuper(XIterable, ...args);

	}

	createClass.default = Root.IterableBased;

	createClass.fromGenerator = (gen, ...args) => {

		var _key_args = Symbol('args');

		return createClass(class extends createClass.fromGenerator.Root {

			constructor(...args) {
				super();
				this[_key_args] = args;
			}

			* [_key_iterator]() {
				yield * gen.call(this, ...this[_key_args]);
			}

		}, ...args);

	}

	createClass.fromGenerator.Root = createClassFromSuper(Root);

})(module);
<commit_msg>something is unnecessary<commit_after>
((module) => {
	'use strict';

	var createClassFromSuper = require('simple-class-utils').createClass.super;
	var Root = require('./root.js').class;

	var _key_iterator = Symbol.iterator;

	module.exports = createClass;

	function createClass(Super, ...args) {

		class XIterable extends (typeof Super === 'function' ? Super : createClass.default) {

			forEach(callback) {
				for (let element of this) {
					callback(element, this);
				}
			}

			map(callback) {
				var result = new this.Array();
				this.forEach((element) => result.push(callback(element, this)));
				return result;
			}

			some(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return true;
					}
				}
				return false;
			}

			every(callback) {
				return !this.every((element) => !callback(element, this));
			}

			filter(callback) {
				var result = new this.Array();
				this.forEach((element) => callback(element, this) && result.push(element));
				return result;
			}

			most(callback, init) {
				for (let element of this) {
					if (callback(element, init)) {
						init = element;
					}
				}
				return init;
			}

			get min() {
				return this.most((challenger, champion) => challenger < champion, +Infinity);
			}

			get max() {
				return this.most((challenger, champion) => challenger > champion, -Infinity);
			}

		}

		((proto) => {
			proto.Array = Array;
		})(XIterable.prototype);

		return createClassFromSuper(XIterable, ...args);

	}

	createClass.default = Root.IterableBased;

	createClass.fromGenerator = (gen, ...args) => {

		var _key_args = Symbol('args');

		return createClass(class extends createClass.fromGenerator.Root {

			constructor(...args) {
				super();
				this[_key_args] = args;
			}

			* [_key_iterator]() {
				yield * gen.call(this, ...this[_key_args]);
			}

		}, ...args);

	}

	createClass.fromGenerator.Root = createClassFromSuper(Root);

})(module);
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2009
 * Ingo Kitzmann, Christoph Koenig
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **/

if (!ORYX)
	ORYX = new Object();
if (!ORYX.Plugins)
	ORYX.Plugins = new Object();

ORYX.Plugins.BpmnLayouter = ORYX.Plugins.AbstractPlugin.extend({
	facade: undefined,
	construct: function(facade){
		this.facade = facade;
		this.facade.offer({
			'name' : "Layout-BPMN",
			'description' : "Layout BPMN Model",
			'functionality' : this.layout.bind(this),
			'group' : "Layout",
			'icon' : ORYX.PATH + "images/auto_layout.png",
			'index' : 1,
			'minShape' : 0,
			'maxShape' : 0
		});
	},
	layout: function(){

		this.facade.raiseEvent({
            type: ORYX.CONFIG.EVENT_LOADING_ENABLE,
			text: ORYX.I18N.Layouting.doing
        });

		new Ajax.Request(ORYX.CONFIG.BPMN_LAYOUTER, {
			method : 'POST',
			asynchronous : false,
			parameters : {
				data: this.facade.getSerializedJSON(),
				output: "coordinatesonly"
			},
			onFailure: function(request){
				Ext.Msg.alert("Layouting Error", "Error while layouting:!\n" + request.responseText);
            	this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_LOADING_DISABLE});
			},
			onSuccess: function(request){

				/*Ext.Msg.alert("Oryx", "New Layout arrived:!\n" + request.responseText);*/
				var resp = request.responseText.evalJSON();

				if(resp instanceof Array && resp.size() > 0){
					resp.each(function(elem){
						var shape = this.facade.getCanvas().getChildShapeByResourceId(elem.id);
						var bound = elem.bounds.split(" ");
						shape.bounds.set(bound[0],bound[1],bound[2],bound[3]);

						if(elem.dockers != null){
							this.setDockersBad(shape,elem.dockers);
						}

						shape.update();
					}.bind(this));

					this.facade.getCanvas().update();
					this.facade.updateSelection();
				}

            	this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_LOADING_DISABLE});
			}.bind(this)
		})
	},
	setDockersBad: function(shape, dockers){
		var dockersString = "";
		dockers.each(function(p){
			dockersString += p.x + " " + p.y + " ";
		});
		dockersString += " # ";
		shape.deserialize([{
								prefix: 'oryx',
								name: 'dockers',
								value: dockersString
							}]);
	},
	setDockersGood: function(shape, dockers){
		if(elem.dockers.length == 1){
			/* docked event */

		}else{

			/* clear all except of the first and last dockers */
			var dockers = shape.getDockers().slice(1,-1);
			dockers.each(function(docker){
				shape.removeDocker(docker);
			});

			/* set first and last docker */
			var firstDocker = shape.getDockers()[0];
			if (firstDocker.getDockedShape()) {
				firstDocker.setReferencePoint(elem.dockers[0]);
			}
			else {
				firstDocker.bounds.moveTo(elem.dockers[0].x,elem.dockers[0].y);
			}
			firstDocker.refresh();

			var lastDocker = shape.getDockers()[1];
			if (lastDocker.getDockedShape()) {
				lastDocker.setReferencePoint(elem.dockers[elem.dockers.length - 1]);
			}
			else {
				lastDocker.bounds.moveTo(elem.dockers[elem.dockers.length - 1].x, elem.dockers[elem.dockers.length - 1].y);
			}
			lastDocker.refresh();

			/* add new dockers except of the first and last */
			var dockersToAdd = elem.dockers.slice(1,-1);
			dockersToAdd.each(function(dockerPoint){
				var newDocker = shape.createDocker();
				newDocker.parent = shape;
				newDocker.bounds.centerMoveTo(dockerPoint.x, dockerPoint.y);
				/*newDocker.setReferencePoint(dockerPoint);*/
				newDocker.update();
			});
		}
	}
});
<commit_msg>[bpmnlayouter] partly undo/redo (undo only for bounds)<commit_after>/**
 * Copyright (c) 2009
 * Ingo Kitzmann, Christoph Koenig
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **/

if (!ORYX)
	ORYX = new Object();
if (!ORYX.Plugins)
	ORYX.Plugins = new Object();

ORYX.Plugins.BpmnLayouter = ORYX.Plugins.AbstractPlugin.extend({
	facade: undefined,
	construct: function(facade){
		this.facade = facade;
		this.facade.offer({
			'name' : "Layout-BPMN",
			'description' : "Layout BPMN Model",
			'functionality' : this.layout.bind(this),
			'group' : "Layout",
			'icon' : ORYX.PATH + "images/auto_layout.png",
			'index' : 1,
			'minShape' : 0,
			'maxShape' : 0
		});
	},
	layout: function(){

		this.facade.raiseEvent({
            type: ORYX.CONFIG.EVENT_LOADING_ENABLE,
			text: ORYX.I18N.Layouting.doing
        });

		new Ajax.Request(ORYX.CONFIG.BPMN_LAYOUTER, {
			method : 'POST',
			asynchronous : false,
			parameters : {
				data: this.facade.getSerializedJSON(),
				output: "coordinatesonly"
			},
			onFailure: function(request){
				Ext.Msg.alert("Layouting Error", "Error while layouting:!\n" + request.responseText);
            	this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_LOADING_DISABLE});
			},
			onSuccess: function(request){

				/*Ext.Msg.alert("Oryx", "New Layout arrived:!\n" + request.responseText);*/

				var setLayoutCommandClass = ORYX.Core.Command.extend({
					construct: function(layoutArray, plugin){
						this.layoutArray = layoutArray;
						this.plugin = plugin;
						this.oldLayoutArray = [];
					},
					execute: function(){
						this.layoutArray.each(function(elem){
							/* get shape */
							var shape = this.plugin.facade.getCanvas().getChildShapeByResourceId(elem.id);

							/* save old layout for undo*/
							var oldLayout = {
								id : elem.id,
								bounds : shape.bounds.clone()
							};
							this.oldLayoutArray.push(oldLayout);

							/* set new bounds */
							var bound = elem.bounds.split(" ");
							shape.bounds.set(bound[0],bound[1],bound[2],bound[3]);

							/* set new dockers */
							if(elem.dockers != null){
								this.plugin.setDockersBad(shape,elem.dockers);
							}

							shape.update();
						}.bind(this));

						this.plugin.facade.getCanvas().update();
						this.plugin.facade.updateSelection();

					},
					rollback: function(){
						this.oldLayoutArray.each(function(elem){
							var shape = this.plugin.facade.getCanvas().getChildShapeByResourceId(elem.id);
							shape.bounds.set(elem.bounds);
							shape.update();
						}.bind(this));

						this.plugin.facade.getCanvas().update();
						this.plugin.facade.updateSelection();
					}
				});

				var resp = request.responseText.evalJSON();
				if (resp instanceof Array && resp.size() > 0) {
					/* create command */
					var command = new setLayoutCommandClass(resp, this);
					/* execute command */
					this.facade.executeCommands([command]);
				}
            	this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_LOADING_DISABLE});
			}.bind(this)
		})
	},
	setDockersBad: function(shape, dockers){
		var dockersString = "";
		dockers.each(function(p){
			dockersString += p.x + " " + p.y + " ";
		});
		dockersString += " # ";
		shape.deserialize([{
								prefix: 'oryx',
								name: 'dockers',
								value: dockersString
							}]);
	},
	setDockersGood: function(shape, dockers){
		if(elem.dockers.length == 1){
			/* docked event */

		}else{

			/* clear all except of the first and last dockers */
			var dockers = shape.getDockers().slice(1,-1);
			dockers.each(function(docker){
				shape.removeDocker(docker);
			});

			/* set first and last docker */
			var firstDocker = shape.getDockers()[0];
			if (firstDocker.getDockedShape()) {
				firstDocker.setReferencePoint(elem.dockers[0]);
			}
			else {
				firstDocker.bounds.moveTo(elem.dockers[0].x,elem.dockers[0].y);
			}
			firstDocker.refresh();

			var lastDocker = shape.getDockers()[1];
			if (lastDocker.getDockedShape()) {
				lastDocker.setReferencePoint(elem.dockers[elem.dockers.length - 1]);
			}
			else {
				lastDocker.bounds.moveTo(elem.dockers[elem.dockers.length - 1].x, elem.dockers[elem.dockers.length - 1].y);
			}
			lastDocker.refresh();

			/* add new dockers except of the first and last */
			var dockersToAdd = elem.dockers.slice(1,-1);
			dockersToAdd.each(function(dockerPoint){
				var newDocker = shape.createDocker();
				newDocker.parent = shape;
				newDocker.bounds.centerMoveTo(dockerPoint.x, dockerPoint.y);
				/*newDocker.setReferencePoint(dockerPoint);*/
				newDocker.update();
			});
		}
	}
});
<|endoftext|>


<commit_before>/*#ifndef(UMD)*/
"use strict";
/*global _gpfAlpha*/ // Letters (lowercase)
/*global _gpfALPHA*/ // Letters (uppercase)
/*global _gpfDigit*/ // Digits
/*global _gpfMax31*/ // Max value on 31 bits
/*global _gpfMax32*/ // Max value on 32 bits
/*#endif*/

var
    _gpfB64 = _gpfALPHA + _gpfAlpha + _gpfDigit + "+/",
    _gpfB16 = "0123456789ABCDEF",
    _gpfBinZ = 987654321,
    _gpfBinW = (new Date()).getTime() & _gpfMax32;

        result = [],
    var result = [],
        bits,
        mask,
        digit;
    if (undefined === length) {
        bits = 32;
    } else {
        bits = length * pow;
    }
    mask = (1 << (bits - pow)) - 1;
    bits = (1 << pow) - 1;
    while (0 !== value) {
        digit = value & bits;
        result.unshift(base.charAt(digit));
        value = (value >> pow) & mask;
    }
    return result;
}

        result = [],
        baseLength = base.length,
        digit;
    while (0 !== value) {
        digit = value % baseLength;
        result.unshift(base.charAt(digit));
        value = (value - digit) / baseLength;
    }
    return result;
}

    if (-1 < pow && (undefined === length || length * pow <= 32)) {
        // Good conditions to use bits masking & shifting, will work with negative values and will be faster
    }
}

/**
 * Encodes the value within the specified base.
 * Result string length can be defined (formattingOptions.length) and missing characters will be added from
 * formattingOptions.pad
 *
 * @param {String} base values
 * @param {Number} value to encode
 * @param {Object} formattingOptions
 * - {Number} [length=undefined] length of encoding
 * - {String} [pad="0"] pad
 * @return {String}
 */
function _gpfToBaseANY (base, value, formattingOptions) {
    if (undefined === formattingOptions) {
        formattingOptions = {};
    }
    var length = formattingOptions.length,
        pad = formattingOptions.pad,
        result = _gpfToBaseAnyEncode({
            base: base,
            value: value
        }, length);
    // Padding
    if (undefined !== length) {
        if (undefined === pad) {
            pad = base.charAt(0);
        }
        while (result.length < length) {
            result.unshift(pad.charAt(result.length % pad.length));
        }
    } else if (0 === result.length) {
        result = [base.charAt(0)]; // 0
    }
    return result.join("");
}

/**
 * Decodes the text value using the specified base.
 *
 * @param {String} base
 * @param {String} text
 * @param {String} [pad=base.charAt(0)] pad
 * @return {Number}
 */
function _gpfFromBaseANY (base, text, pad) {
    var
        baseLength = base.length,
        result = 0,
        idx = 0;
    if (undefined === pad) {
        pad = base.charAt(0);
    }
    while (idx < text.length) {
        if (-1 === pad.indexOf(text.charAt(idx))) {
            break;
        } else {
            ++idx;
        }
    }
    while (idx < text.length) {
        result = baseLength * result + base.indexOf(text.charAt(idx++));
    }
    return result;
}

gpf.bin = {

    /**
     * Computes the power of 2
     *
     * @param {Number} n the power to compute
     * @return {Number}
     */
    pow2: function (n) {
        if (31 === n) {
            return _gpfMax31 + 1;
        }
        if (32 === n) {
            return _gpfMax32 + 1;
        }
        if (31 > n) {
            return 1 << n;
        }
        var result = _gpfMax32 + 1;
        n -= 31;
        while (--n) {
            result *= 2;
        }
        return result;
    },

    /**
     * Check if the given value is a power of 2
     *
     * @param {Number} value the value to check
     * @return {Number} the power of 2 or -1
     */
    isPow2: function (value) {
        // http://en.wikipedia.org/wiki/Power_of_two
        if (0 < value && (0 === (value & (value - 1)))) {
            var result = 0;
            while (1 < value) {
                ++result;
                value /= 2;
            }
            return result;
        } else {
            return -1;
        }
    },

    /**
     * Returns the hexadecimal encoding of value.
     *
     * @param {Number} value
     * @param {Number} length of encoding
     * @param {String} [pad="0"] pad
     * @return {String}
     */
    toHexa: function (value, length, pad) {
        return _gpfToBaseANY(_gpfB16, value, {
            length: length,
            pad: pad
        });
    },

    /**
     * Decodes the hexadecimal text value.
     *
     * @param {String} text
     * @param {String} [pad="0"] pad
     * @return {Number}
     */
    fromHexa: function (text, pad) {
        return _gpfFromBaseANY(_gpfB16, text, pad);
    },

    /**
     * Returns the base 64 encoding of value.
     *
     * @param {Number} value
     * @param {Number} length of encoding
     * @param {String} [pad="0"] pad
     * @return {String}
     */
    toBase64: function (value, length, pad) {
        return _gpfToBaseANY(_gpfB64, value, {
            length: length,
            pad: pad
        });
    },

    /**
     * Decodes the hexadecimal text value.
     *
     * @param {String} text
     * @param {String} [pad="0"] pad
     * @return {Number}
     */
    fromBase64: function (text, pad) {
        return _gpfFromBaseANY(_gpfB64, text, pad);
    },

    /**
     * Test if the value contains the bitmask.
     *
     * @param {Number} value
     * @param {Number} bitmask
     * @return {Boolean}
     */
    test: function /*gpf:inline*/ (value, bitmask) {
        return (value & bitmask) === bitmask;
    },

    /**
     * Clear the bitmask inside the value
     *
     * @param {Number} value
     * @param {Number} bitmask
     * @return {Number}
     */
    clear: function /*gpf:inline*/ (value, bitmask) {
        return value & ~bitmask;
    },

    /**
     * Generate a random number between 0 inclusive and pow2(32) exclusive
     *
     * @return {Number}
     * Based on:
     * http://en.wikipedia.org/wiki/Random_number_generation
     * http://stackoverflow.com/questions/521295/javascript-random-seeds
     */
    random: function () {
        _gpfBinZ = (36969 * (_gpfBinZ & 65535) + (_gpfBinZ >> 16)) & _gpfMax32;
        _gpfBinW = (18000 * (_gpfBinW & 65535) + (_gpfBinW >> 16)) & _gpfMax32;
        return (((_gpfBinZ << 16) + _gpfBinW) & _gpfMax32) + _gpfMax31;
    }

};
<commit_msg>Fixed JSHint errors (and Git 'wrong' commit)<commit_after>/*#ifndef(UMD)*/
"use strict";
/*global _gpfAlpha*/ // Letters (lowercase)
/*global _gpfALPHA*/ // Letters (uppercase)
/*global _gpfDigit*/ // Digits
/*global _gpfMax31*/ // Max value on 31 bits
/*global _gpfMax32*/ // Max value on 32 bits
/*#endif*/

var
    _gpfB64 = _gpfALPHA + _gpfAlpha + _gpfDigit + "+/",
    _gpfB16 = "0123456789ABCDEF",
    _gpfBinZ = 987654321,
    _gpfBinW = (new Date()).getTime() & _gpfMax32;

function _gpfToBaseAnyEncodeUsingBitShifting (baseAndValue, pow, length) {
    var base = baseAndValue.base,
        value = baseAndValue.value,
        result = [],
        bits,
        mask,
        digit;
    if (undefined === length) {
        bits = 32;
    } else {
        bits = length * pow;
    }
    mask = (1 << (bits - pow)) - 1;
    bits = (1 << pow) - 1;
    while (0 !== value) {
        digit = value & bits;
        result.unshift(base.charAt(digit));
        value = (value >> pow) & mask;
    }
    return result;
}

function _gpfToBaseAnyEncodeUsingModulo (baseAndValue) {
    var base = baseAndValue.base,
        value = baseAndValue.value,
        result = [],
        baseLength = base.length,
        digit;
    while (0 !== value) {
        digit = value % baseLength;
        result.unshift(base.charAt(digit));
        value = (value - digit) / baseLength;
    }
    return result;
}

function _gpfToBaseAnyEncode (baseAndValue, length) {
    var pow = gpf.bin.isPow2(baseAndValue.base.length);
    if (-1 < pow && (undefined === length || length * pow <= 32)) {
        // Good conditions to use bits masking & shifting, will work with negative values and will be faster
        return _gpfToBaseAnyEncodeUsingBitShifting(baseAndValue, pow, length);
    }
    return _gpfToBaseAnyEncodeUsingModulo(baseAndValue);
}

/**
 * Encodes the value within the specified base.
 * Result string length can be defined (formattingOptions.length) and missing characters will be added from
 * formattingOptions.pad
 *
 * @param {String} base values
 * @param {Number} value to encode
 * @param {Object} formattingOptions
 * - {Number} [length=undefined] length of encoding
 * - {String} [pad="0"] pad
 * @return {String}
 */
function _gpfToBaseANY (base, value, formattingOptions) {
    if (undefined === formattingOptions) {
        formattingOptions = {};
    }
    var length = formattingOptions.length,
        pad = formattingOptions.pad,
        result = _gpfToBaseAnyEncode({
            base: base,
            value: value
        }, length);
    // Padding
    if (undefined !== length) {
        if (undefined === pad) {
            pad = base.charAt(0);
        }
        while (result.length < length) {
            result.unshift(pad.charAt(result.length % pad.length));
        }
    } else if (0 === result.length) {
        result = [base.charAt(0)]; // 0
    }
    return result.join("");
}

/**
 * Decodes the text value using the specified base.
 *
 * @param {String} base
 * @param {String} text
 * @param {String} [pad=base.charAt(0)] pad
 * @return {Number}
 */
function _gpfFromBaseANY (base, text, pad) {
    var
        baseLength = base.length,
        result = 0,
        idx = 0;
    if (undefined === pad) {
        pad = base.charAt(0);
    }
    while (idx < text.length) {
        if (-1 === pad.indexOf(text.charAt(idx))) {
            break;
        } else {
            ++idx;
        }
    }
    while (idx < text.length) {
        result = baseLength * result + base.indexOf(text.charAt(idx++));
    }
    return result;
}

gpf.bin = {

    /**
     * Computes the power of 2
     *
     * @param {Number} n the power to compute
     * @return {Number}
     */
    pow2: function (n) {
        if (31 === n) {
            return _gpfMax31 + 1;
        }
        if (32 === n) {
            return _gpfMax32 + 1;
        }
        if (31 > n) {
            return 1 << n;
        }
        var result = _gpfMax32 + 1;
        n -= 31;
        while (--n) {
            result *= 2;
        }
        return result;
    },

    /**
     * Check if the given value is a power of 2
     *
     * @param {Number} value the value to check
     * @return {Number} the power of 2 or -1
     */
    isPow2: function (value) {
        // http://en.wikipedia.org/wiki/Power_of_two
        if (0 < value && (0 === (value & (value - 1)))) {
            var result = 0;
            while (1 < value) {
                ++result;
                value /= 2;
            }
            return result;
        } else {
            return -1;
        }
    },

    /**
     * Returns the hexadecimal encoding of value.
     *
     * @param {Number} value
     * @param {Number} length of encoding
     * @param {String} [pad="0"] pad
     * @return {String}
     */
    toHexa: function (value, length, pad) {
        return _gpfToBaseANY(_gpfB16, value, {
            length: length,
            pad: pad
        });
    },

    /**
     * Decodes the hexadecimal text value.
     *
     * @param {String} text
     * @param {String} [pad="0"] pad
     * @return {Number}
     */
    fromHexa: function (text, pad) {
        return _gpfFromBaseANY(_gpfB16, text, pad);
    },

    /**
     * Returns the base 64 encoding of value.
     *
     * @param {Number} value
     * @param {Number} length of encoding
     * @param {String} [pad="0"] pad
     * @return {String}
     */
    toBase64: function (value, length, pad) {
        return _gpfToBaseANY(_gpfB64, value, {
            length: length,
            pad: pad
        });
    },

    /**
     * Decodes the hexadecimal text value.
     *
     * @param {String} text
     * @param {String} [pad="0"] pad
     * @return {Number}
     */
    fromBase64: function (text, pad) {
        return _gpfFromBaseANY(_gpfB64, text, pad);
    },

    /**
     * Test if the value contains the bitmask.
     *
     * @param {Number} value
     * @param {Number} bitmask
     * @return {Boolean}
     */
    test: function /*gpf:inline*/ (value, bitmask) {
        return (value & bitmask) === bitmask;
    },

    /**
     * Clear the bitmask inside the value
     *
     * @param {Number} value
     * @param {Number} bitmask
     * @return {Number}
     */
    clear: function /*gpf:inline*/ (value, bitmask) {
        return value & ~bitmask;
    },

    /**
     * Generate a random number between 0 inclusive and pow2(32) exclusive
     *
     * @return {Number}
     * Based on:
     * http://en.wikipedia.org/wiki/Random_number_generation
     * http://stackoverflow.com/questions/521295/javascript-random-seeds
     */
    random: function () {
        _gpfBinZ = (36969 * (_gpfBinZ & 65535) + (_gpfBinZ >> 16)) & _gpfMax32;
        _gpfBinW = (18000 * (_gpfBinW & 65535) + (_gpfBinW >> 16)) & _gpfMax32;
        return (((_gpfBinZ << 16) + _gpfBinW) & _gpfMax32) + _gpfMax31;
    }

};
<|endoftext|>


<commit_before>
((module) => {
	'use strict';

	var createClassFromSuper = require('simple-class-utils').createClass.super;
	var Root = require('./root.js').class;

	var _key_iterator = Symbol.iterator;

	module.exports = createClass;

	function createClass(Super, ...args) {

		class XIterable extends (typeof Super === 'function' ? Super : createClass.default) {

			* transformGenerator(callback) {
				for (let element of this) {
					yield callback(element, this);
				}
			}

			transformOnce(callback) {
				return new createClass.Yield(this.transformGenerator(callback));
			}

			transform(callback) {
				return new createClass.Yield(
					new createClass.AssignIterator(() => this.transformGenerator(callback))
				);
			}

			runthrough() {
				for (let element of this);
			}

			forEach(callback) {
				for (let element of this) {
					callback(element, this);
				}
			}

			map(callback) {
				return this.Array.from(this.transformOnce(callback));
			}

			some(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return true;
					}
				}
				return false;
			}

			every(callback) {
				return !this.every((element) => !callback(element, this));
			}

			filter(callback) {
				var result = new this.Array();
				this.forEach((element) => callback(element, this) && result.push(element));
				return result;
			}

			reduce(callback, init) {
				this.forEach((element) => {init = callback(init, element, this)});
				return init;
			}

			spread(callback) {
				if (typeof callback !== 'function') {
					callback = this.spread.DEFAULT_CALLBACK;
				}
				var Result = this.Array;
				return this.reduce((prev, now) => new Result(...prev, ...callback(now, this)), new Result());
			}

			get sumAsNum() {
				return this.reduce((prev, now) => prev + Number(now), 0);
			}

			get productAsNum() {
				return this.reduce((prev, now) => prev * Number(now), 1);
			}

			get sumAsStr() {
				return this.reduce((prev, now) => prev + String(now), '');
			}

			get sumAsReservedStr() {
				return this.reduce((prev, now) => String(now) + prev, '');
			}

			most(callback, init) {
				for (let element of this) {
					if (callback(element, init, this)) {
						init = element;
					}
				}
				return init;
			}

			get min() {
				return this.most((challenger, champion) => challenger < champion, +Infinity);
			}

			get max() {
				return this.most((challenger, champion) => challenger > champion, -Infinity);
			}

			toArray() {
				return this.Array.from(this);
			}

			find(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return element;
					}
				}
			}

			search(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return new this.search.Result(element, this);
					}
				}
			}

		}

		((proto) => {

			proto.Array = Array;

			proto.search.Result = class extends Root {
				constructor(value, object) {
					this.value = value;
					this.object = object;
				}
			};

			proto.spread.ITERABLES = (element, self) => new self.Array(...element);
			proto.spread.DEFAULT_CALLBACK = proto.spread.ITERABLES;

			var superproto = Object.getPrototypeOf(proto);

			makeMethodExists('join', function (...args) {
				return this.toArray().join(...args);
			});

			function makeMethodExists(fname, func) {
				if (typeof superproto[fname] !== 'function') {
					proto[fname] = func;
				}
			}

		})(XIterable.prototype);

		return createClassFromSuper(XIterable, ...args);

	}

	createClass.default = Root.IterableBased;

	createClass.fromGenerator = (gen, ...args) =>
		createClass(class extends createClass.fromGenerator.Root {
			constructor(...args) {
				super();
				this[_key_iterator] = (...rest) => gen.call(this, ...args, ...rest);
			}
		}, ...args);

	createClass.fromGenerator.Root = createClassFromSuper(Root);

	createClass.Yield = createClass.fromGenerator(function * (base) {
		yield * base;
	});

	createClass.AssignIterator = createClass(class extends Root {
		constructor(iterate) {
			super();
			this[_key_iterator] = iterate;
		}
	});

})(module);
<commit_msg>improve runthrough<commit_after>
((module) => {
	'use strict';

	var createClassFromSuper = require('simple-class-utils').createClass.super;
	var Root = require('./root.js').class;

	var _key_iterator = Symbol.iterator;

	module.exports = createClass;

	function createClass(Super, ...args) {

		class XIterable extends (typeof Super === 'function' ? Super : createClass.default) {

			* transformGenerator(callback) {
				for (let element of this) {
					yield callback(element, this);
				}
			}

			transformOnce(callback) {
				return new createClass.Yield(this.transformGenerator(callback));
			}

			transform(callback) {
				return new createClass.Yield(
					new createClass.AssignIterator(() => this.transformGenerator(callback))
				);
			}

			runthrough() {
				for (let gen = this[_key_iterator](); !gen.next().done; );
			}

			forEach(callback) {
				for (let element of this) {
					callback(element, this);
				}
			}

			map(callback) {
				return this.Array.from(this.transformOnce(callback));
			}

			some(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return true;
					}
				}
				return false;
			}

			every(callback) {
				return !this.every((element) => !callback(element, this));
			}

			filter(callback) {
				var result = new this.Array();
				this.forEach((element) => callback(element, this) && result.push(element));
				return result;
			}

			reduce(callback, init) {
				this.forEach((element) => {init = callback(init, element, this)});
				return init;
			}

			spread(callback) {
				if (typeof callback !== 'function') {
					callback = this.spread.DEFAULT_CALLBACK;
				}
				var Result = this.Array;
				return this.reduce((prev, now) => new Result(...prev, ...callback(now, this)), new Result());
			}

			get sumAsNum() {
				return this.reduce((prev, now) => prev + Number(now), 0);
			}

			get productAsNum() {
				return this.reduce((prev, now) => prev * Number(now), 1);
			}

			get sumAsStr() {
				return this.reduce((prev, now) => prev + String(now), '');
			}

			get sumAsReservedStr() {
				return this.reduce((prev, now) => String(now) + prev, '');
			}

			most(callback, init) {
				for (let element of this) {
					if (callback(element, init, this)) {
						init = element;
					}
				}
				return init;
			}

			get min() {
				return this.most((challenger, champion) => challenger < champion, +Infinity);
			}

			get max() {
				return this.most((challenger, champion) => challenger > champion, -Infinity);
			}

			toArray() {
				return this.Array.from(this);
			}

			find(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return element;
					}
				}
			}

			search(callback) {
				for (let element of this) {
					if (callback(element, this)) {
						return new this.search.Result(element, this);
					}
				}
			}

		}

		((proto) => {

			proto.Array = Array;

			proto.search.Result = class extends Root {
				constructor(value, object) {
					this.value = value;
					this.object = object;
				}
			};

			proto.spread.ITERABLES = (element, self) => new self.Array(...element);
			proto.spread.DEFAULT_CALLBACK = proto.spread.ITERABLES;

			var superproto = Object.getPrototypeOf(proto);

			makeMethodExists('join', function (...args) {
				return this.toArray().join(...args);
			});

			function makeMethodExists(fname, func) {
				if (typeof superproto[fname] !== 'function') {
					proto[fname] = func;
				}
			}

		})(XIterable.prototype);

		return createClassFromSuper(XIterable, ...args);

	}

	createClass.default = Root.IterableBased;

	createClass.fromGenerator = (gen, ...args) =>
		createClass(class extends createClass.fromGenerator.Root {
			constructor(...args) {
				super();
				this[_key_iterator] = (...rest) => gen.call(this, ...args, ...rest);
			}
		}, ...args);

	createClass.fromGenerator.Root = createClassFromSuper(Root);

	createClass.Yield = createClass.fromGenerator(function * (base) {
		yield * base;
	});

	createClass.AssignIterator = createClass(class extends Root {
		constructor(iterate) {
			super();
			this[_key_iterator] = iterate;
		}
	});

})(module);
<|endoftext|>


<commit_before>import $ from 'blingblingjs'
import hotkeys from 'hotkeys-js'
import { getStyle, showHideSelected } from './utils.js'

const key_events = 'up,down,left,right'
  .split(',')
  .reduce((events, event) =>
    `${events},${event},shift+${event}`
  , '')
  .substring(1)

const command_events = 'cmd+up,cmd+down'

export function Font(selector) {
  hotkeys(key_events, (e, handler) => {
    e.preventDefault()

    let selectedNodes = $(selector)
      , keys = handler.key.split('+')

    if (keys.includes('left') || keys.includes('right'))
      keys.includes('shift')
        ? changeKerning(selectedNodes, handler.key)
        : changeAlignment(selectedNodes, handler.key)
    else
      keys.includes('shift')
        ? changeLeading(selectedNodes, handler.key)
        : changeFontSize(selectedNodes, handler.key)
  })

  hotkeys(command_events, (e, handler) => {
    e.preventDefault()
    let keys = handler.key.split('+')
    changeFontWeight($(selector), keys.includes('up') ? 'up' : 'down')
  })

  return () => {
    hotkeys.unbind(key_events)
    hotkeys.unbind(command_events)
    hotkeys.unbind('up,down,left,right')
  }
}

export function changeLeading(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'lineHeight',
      current:  parseInt(getStyle(el, 'lineHeight')),
      amount:   1,
      negative: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        current: payload.current == 'normal' || isNaN(payload.current)
          ? 1.14 * parseInt(getStyle(payload.el, 'fontSize')) // document this choice
          : payload.current
      }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = `${value}px`)
}

export function changeKerning(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'letterSpacing',
      current:  parseFloat(getStyle(el, 'letterSpacing')),
      amount:   .1,
      negative: direction.split('+').includes('left'),
    }))
    .map(payload =>
      Object.assign(payload, {
        current: payload.current == 'normal' || isNaN(payload.current)
          ? 0
          : payload.current
      }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = `${value <= -2 ? -2 : value}px`)
}

export function changeFontSize(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'fontSize',
      current:  parseInt(getStyle(el, 'fontSize')),
      amount:   direction.split('+').includes('shift') ? 10 : 1,
      negative: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        font_size: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, font_size}) =>
      el.style[style] = `${font_size <= 6 ? 6 : font_size}px`)
}

const weightMap = {
  normal: 2,
  bold:   5,
  light:  0,
  "": 2,
  "100":0,"200":1,"300":2,"400":3,"500":4,"600":5,"700":6,"800":7,"900":8
}
const weightOptions = [100,200,300,400,500,600,700,800,900]

export function changeFontWeight(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'fontWeight',
      current:  getStyle(el, 'fontWeight'),
      direction: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.direction
          ? weightMap[payload.current] - 1
          : weightMap[payload.current] + 1
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = weightOptions[value < 0 ? 0 : value >= weightOptions.length
        ? weightOptions.length
        : value
      ])
}

const alignMap = {
  start: 0,
  left: 0,
  center: 1,
  right: 2,
}
const alignOptions = ['left','center','right']

export function changeAlignment(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'textAlign',
      current:  getStyle(el, 'textAlign'),
      direction: direction.split('+').includes('left'),
    }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.direction
          ? alignMap[payload.current] - 1
          : alignMap[payload.current] + 1
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = alignOptions[value < 0 ? 0 : value >= 2 ? 2: value])
}
<commit_msg>quick italic/bold when font tool is selected<commit_after>import $ from 'blingblingjs'
import hotkeys from 'hotkeys-js'
import { getStyle, showHideSelected } from './utils.js'

const key_events = 'up,down,left,right'
  .split(',')
  .reduce((events, event) =>
    `${events},${event},shift+${event}`
  , '')
  .substring(1)

const command_events = 'cmd+up,cmd+down'

export function Font(selector) {
  hotkeys(key_events, (e, handler) => {
    e.preventDefault()

    let selectedNodes = $(selector)
      , keys = handler.key.split('+')

    if (keys.includes('left') || keys.includes('right'))
      keys.includes('shift')
        ? changeKerning(selectedNodes, handler.key)
        : changeAlignment(selectedNodes, handler.key)
    else
      keys.includes('shift')
        ? changeLeading(selectedNodes, handler.key)
        : changeFontSize(selectedNodes, handler.key)
  })

  hotkeys(command_events, (e, handler) => {
    e.preventDefault()
    let keys = handler.key.split('+')
    changeFontWeight($(selector), keys.includes('up') ? 'up' : 'down')
  })

  hotkeys('cmd+b', e => {
    $(selector).forEach(el =>
      el.style.fontWeight = 'bold')
  })

  hotkeys('cmd+i', e => {
    $(selector).forEach(el =>
      el.style.fontStyle = 'italic')
  })

  return () => {
    hotkeys.unbind(key_events)
    hotkeys.unbind(command_events)
    hotkeys.unbind('cmd+b,cmd+i')
    hotkeys.unbind('up,down,left,right')
  }
}

export function changeLeading(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'lineHeight',
      current:  parseInt(getStyle(el, 'lineHeight')),
      amount:   1,
      negative: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        current: payload.current == 'normal' || isNaN(payload.current)
          ? 1.14 * parseInt(getStyle(payload.el, 'fontSize')) // document this choice
          : payload.current
      }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = `${value}px`)
}

export function changeKerning(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'letterSpacing',
      current:  parseFloat(getStyle(el, 'letterSpacing')),
      amount:   .1,
      negative: direction.split('+').includes('left'),
    }))
    .map(payload =>
      Object.assign(payload, {
        current: payload.current == 'normal' || isNaN(payload.current)
          ? 0
          : payload.current
      }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = `${value <= -2 ? -2 : value}px`)
}

export function changeFontSize(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'fontSize',
      current:  parseInt(getStyle(el, 'fontSize')),
      amount:   direction.split('+').includes('shift') ? 10 : 1,
      negative: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        font_size: payload.negative
          ? payload.current - payload.amount
          : payload.current + payload.amount
      }))
    .forEach(({el, style, font_size}) =>
      el.style[style] = `${font_size <= 6 ? 6 : font_size}px`)
}

const weightMap = {
  normal: 2,
  bold:   5,
  light:  0,
  "": 2,
  "100":0,"200":1,"300":2,"400":3,"500":4,"600":5,"700":6,"800":7,"900":8
}
const weightOptions = [100,200,300,400,500,600,700,800,900]

export function changeFontWeight(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'fontWeight',
      current:  getStyle(el, 'fontWeight'),
      direction: direction.split('+').includes('down'),
    }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.direction
          ? weightMap[payload.current] - 1
          : weightMap[payload.current] + 1
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = weightOptions[value < 0 ? 0 : value >= weightOptions.length
        ? weightOptions.length
        : value
      ])
}

const alignMap = {
  start: 0,
  left: 0,
  center: 1,
  right: 2,
}
const alignOptions = ['left','center','right']

export function changeAlignment(els, direction) {
  els
    .map(el => showHideSelected(el))
    .map(el => ({
      el,
      style:    'textAlign',
      current:  getStyle(el, 'textAlign'),
      direction: direction.split('+').includes('left'),
    }))
    .map(payload =>
      Object.assign(payload, {
        value: payload.direction
          ? alignMap[payload.current] - 1
          : alignMap[payload.current] + 1
      }))
    .forEach(({el, style, value}) =>
      el.style[style] = alignOptions[value < 0 ? 0 : value >= 2 ? 2: value])
}
<|endoftext|>


<commit_before>import framework from 'framework'
import utils from 'utils'
import config from 'config'
import events from 'dom-event'
import classes from 'dom-classes'
import strftime from 'strftime'

class App {

  constructor(opt = {}) {

    this.onSubmit = this.onSubmit.bind(this)
    this.onKeyPress = this.onKeyPress.bind(this)
    this.updateDisplay = this.updateDisplay.bind(this)
    this.addSpaceToDisplay = this.addSpaceToDisplay.bind(this)

    this.init()
  }

  init() {

    this.addEvents()
    framework.init()
    const currentDatetime = strftime('Last login: %a %b %-d %X on ttys000')
    config.dom.header.innerHTML += `<span class="datetime">${currentDatetime}</span>`

    config.dom.input.focus()
  }

  addEvents() {

    // listen to submit event
    events.on(config.body, 'click', _ => config.dom.input.focus())
    events.on(config.dom.form, 'submit', this.onSubmit)
    events.on(config.dom.input, 'keydown', this.onKeyPress)
    events.on(config.dom.input, 'keyup', this.addSpaceToDisplay)
    events.on(config.dom.input, 'input', this.updateDisplay)
  }

  onSubmit(e) {

    e.preventDefault()

    const userInput = config.dom.input.value.trim()
    userInput.length !== 0 ? config.hist.push(userInput) : null

    config.dom.input.value = ''
    config.dom.display.innerText = ''
    config.dom.input.focus()

    this.index = config.hist.length

    this.handleUserInput(userInput)
  }

  handleUserInput(userInput) {

    const { commands } = window._data
    const command = commands.hasOwnProperty(userInput) ? commands[userInput] : userInput.length === 0 ? commands.blank : commands.error

    switch(command.type) {
      case 'route':
        framework.go(command.data)
        break

      case 'static':
        const output = command.data[0].href ? command.data.map(this.toAnchor) : command.data
        this.render(this.commandTemplate(userInput, output))
        break

      case 'function':
        !command.template ? this[command.data]() : this.render(this[command.data]())
        break

      default:
        this.render(this.errorTemplate(userInput, commands.error))
    }
  }

  toAnchor(link) {
    return `<a target="_blank" href="${link.href}">${link.text}</a>`
  }

  render(template) {
    config.dom.commands.innerHTML += template
  }

  blankTemplate() {
    return `

`
  }

  commandTemplate(userInput, output) {
    return `

${userInput}

            ${output.map(item => `<li class="command__output--list-item">${item}</li>`).join('')}

`
  }

  errorTemplate(userInput, output) {
    return `

${userInput}

            ${output.map(item => `<li class="command__output--list-item">-oops '${userInput}': ${item}</li>`).join('')}

`
  }

  clearDisplay() {
    config.dom.commands.innerHTML = ''
  }

  updateDisplay() {
    config.dom.display.innerHTML = config.dom.input.value
  }

  addSpaceToDisplay(e) {
    if (e.keyCode !== App.SPACE) return

    config.dom.display.innerHTML += ''
  }

  onKeyPress(e) {

    switch(e.keyCode) {
      case App.KEY_UP:
        if (this.index > 0 && this.index <= config.hist.length) {
          this.index -= 1
          config.dom.input.value = config.hist[this.index]
          this.updateDisplay()
        }
        break

      case App.KEY_DOWN:
        if (this.index >= 0 && this.index < config.hist.length) {
          this.index += 1
          config.dom.input.value = this.index === config.hist.length ? '' : config.dom.input.value = config.hist[this.index]
          this.updateDisplay()
        }
        break

      case App.KEY_LEFT:
        return false
        break

      case App.KEY_RIGHT:
        return false
        break

      case App.TAB:
        return false
        break

      default: break
    }
  }

  static get KEY_LEFT() {
    return 37
  }

  static get KEY_UP() {
    return 38
  }

  static get KEY_RIGHT() {
    return 39
  }

  static get KEY_DOWN() {
    return 40
  }

  static get TAB() {
    return 9
  }

  static get SPACE() {
    return 32
  }
}

module.exports = App
<commit_msg>change the span tags to p tags<commit_after>import framework from 'framework'
import utils from 'utils'
import config from 'config'
import events from 'dom-event'
import classes from 'dom-classes'
import strftime from 'strftime'

class App {

  constructor(opt = {}) {

    this.onSubmit = this.onSubmit.bind(this)
    this.onKeyPress = this.onKeyPress.bind(this)
    this.updateDisplay = this.updateDisplay.bind(this)
    this.addSpaceToDisplay = this.addSpaceToDisplay.bind(this)

    this.init()
  }

  init() {

    this.addEvents()
    framework.init()
    const currentDatetime = strftime('Last login: %a %b %-d %X on ttys000')
    config.dom.header.innerHTML += `<p>${currentDatetime}</p>`
    config.dom.input.focus()
  }

  addEvents() {

    // listen to submit event
    events.on(config.body, 'click', _ => config.dom.input.focus())
    events.on(config.dom.form, 'submit', this.onSubmit)
    events.on(config.dom.input, 'keydown', this.onKeyPress)
    events.on(config.dom.input, 'keyup', this.addSpaceToDisplay)
    events.on(config.dom.input, 'input', this.updateDisplay)
  }

  onSubmit(e) {

    e.preventDefault()

    const userInput = config.dom.input.value.trim()
    userInput.length !== 0 ? config.hist.push(userInput) : null

    config.dom.input.value = ''
    config.dom.display.innerText = ''
    config.dom.input.focus()

    this.index = config.hist.length

    this.handleUserInput(userInput)
  }

  handleUserInput(userInput) {

    const { commands } = window._data
    const command = commands.hasOwnProperty(userInput) ? commands[userInput] : userInput.length === 0 ? commands.blank : commands.error

    switch(command.type) {
      case 'route':
        framework.go(command.data)
        break

      case 'static':
        const output = command.data[0].href ? command.data.map(this.toAnchor) : command.data
        this.render(this.commandTemplate(userInput, output))
        break

      case 'function':
        !command.template ? this[command.data]() : this.render(this[command.data]())
        break

      default:
        this.render(this.errorTemplate(userInput, commands.error))
    }
  }

  toAnchor(link) {
    return `<a target="_blank" href="${link.href}">${link.text}</a>`
  }

  render(template) {
    config.dom.commands.innerHTML += template
  }

  blankTemplate() {
    return `

`
  }

  commandTemplate(userInput, output) {
    return `

${userInput}

            ${output.map(item => `<li class="command__output--list-item">${item}</li>`).join('')}

`
  }

  errorTemplate(userInput, output) {
    return `

${userInput}

            ${output.map(item => `<li class="command__output--list-item">-oops '${userInput}': ${item}</li>`).join('')}

`
  }

  clearDisplay() {
    config.dom.commands.innerHTML = ''
  }

  updateDisplay() {
    config.dom.display.innerHTML = config.dom.input.value
  }

  addSpaceToDisplay(e) {
    if (e.keyCode !== App.SPACE) return

    config.dom.display.innerHTML += ''
  }

  onKeyPress(e) {

    switch(e.keyCode) {
      case App.KEY_UP:
        if (this.index > 0 && this.index <= config.hist.length) {
          this.index -= 1
          config.dom.input.value = config.hist[this.index]
          this.updateDisplay()
        }
        break

      case App.KEY_DOWN:
        if (this.index >= 0 && this.index < config.hist.length) {
          this.index += 1
          config.dom.input.value = this.index === config.hist.length ? '' : config.dom.input.value = config.hist[this.index]
          this.updateDisplay()
        }
        break

      case App.KEY_LEFT:
        return false
        break

      case App.KEY_RIGHT:
        return false
        break

      case App.TAB:
        return false
        break

      default: break
    }
  }

  static get KEY_LEFT() {
    return 37
  }

  static get KEY_UP() {
    return 38
  }

  static get KEY_RIGHT() {
    return 39
  }

  static get KEY_DOWN() {
    return 40
  }

  static get TAB() {
    return 9
  }

  static get SPACE() {
    return 32
  }
}

module.exports = App
<|endoftext|>


<commit_before>/*eslint ava/max-asserts: ["error", 3]*/
import test from 'ava'
import check from '../helpers/check'

test('using unknown modifiers is bad', t => {
  const code = `
import test from 'ava'
test('bad test', t => {
  t.foo()
  t.bar()
  t.lol()
})
`
  t.is(check(code).errors, 3)
})

test('usage only known modifiers is good', t => {
  const code = `
import test from 'ava'
test('good test', t => {
  t.is()
  t.true()
  t.false()
})
`
  t.is(check(code).errors, 0)
})
<commit_msg>fix ava-no-unknown-modifiers test<commit_after>import test from 'ava'
import check from '../helpers/check'

test('using unknown modifiers is bad', t => {
  const code = `
/*eslint ava/max-asserts: ["error", 3]*/
import test from 'ava'
test('bad test', t => {
  t.foo()
  t.bar()
  t.lol()
})
`
  t.is(check(code).errors, 3)
})

test('usage only known modifiers is good', t => {
  const code = `
/*eslint ava/max-asserts: ["error", 3]*/
import test from 'ava'
test('good test', t => {
  t.is()
  t.true()
  t.false()
})
`
  t.is(check(code).errors, 0)
})
<|endoftext|>


<commit_before>'use strict';

const names = [
  [
    // Month: January
    ['Laimnesis','Solvita','Solvija'],
    ['Indulis','Ivo','Iva','Ivis'],
    ['Miervaldis','Miervalda','Ringolds'],
    ['Spodra','Ilva','Ilvita'],
    ['Sīmanis','Zintis'],
    ['Spulga','Arnita'],
    ['Rota','Zigmārs','Juliāns','Digmārs'],
    ['Gatis','Ivanda'],
    ['Kaspars','Aksels','Alta'],
    ['Tatjana','Dorisa'],
    ['Smaida','Franciska'],
    ['Reinis','Reina','Reinholds','Renāts'],
    ['Harijs','Ārijs','Āris','Aira'],
    ['Roberts','Roberta','Raitis','Raits'],
    ['Fēlikss','Felicita'],
    ['Lidija','Lida'],
    ['Tenis','Dravis'],
    ['Antons','Antis','Antonijs'],
    ['Andulis','Alnis'],
    ['Oļģerts','Orests','Aļģirds','Aļģis'],
    ['Agnese','Agnija','Agne'],
    ['Austris'],
    ['Grieta','Strauta','Rebeka'],
    ['Krišs','Ksenija','Eglons','Egle'],
    ['Zigurds','Sigurds','Sigvards'],
    ['Ansis','Agnis','Agneta'],
    ['Ilze','Ildze','Izolde'],
    ['Kārlis','Spodris'],
    ['Aivars','Valērijs','Bille'],
    ['Tīna','Valentīna','Pārsla'],
    ['Tekla','Violeta']
  ],
  [
    // Month: February
    ['Brigita','Indra','Indars','Indris'],
    ['Spīdola','Sonora'],
    ['Aīda','Ida','Vida'],
    ['Daila','Veronika','Dominiks'],
    ['Agate','Selga','Silga','Sinilga'],
    ['Dace','Dārta','Dora'],
    ['Nelda','Rihards','Ričards','Rišards'],
    ['Aldona','Česlavs'],
    ['Simona','Apolonija'],
    ['Paulīne','Paula','Jasmīna'],
    ['Laima','Laimdota'],
    ['Karlīna','Līna'],
    ['Malda','Melita'],
    ['Valentīns'],
    ['Alvils','Olafs','Aloizs','Olavs'],
    ['Jūlija','Džuljeta'],
    ['Donats','Konstance'],
    ['Kora','Kintija'],
    ['Zane','Zuzanna'],
    ['Vitauts','Smuidra','Smuidris'],
    ['Eleonora','Ariadne'],
    ['Ārija','Rigonda','Adrians','Adriāna','Adrija'],
    ['Haralds','Almants'],
    ['Diāna','Dina','Dins'],
    ['Alma','Annemarija'],
    ['Evelīna','Aurēlija','Mētra'],
    ['Līvija','Līva','Andra'],
    ['Skaidrīte','Justs','Skaidra'],
    ['–']
  ]
];
<commit_msg>Add - mar. & apr. names<commit_after>'use strict';

const names = [
  [
    // Month: January
    ['Laimnesis','Solvita','Solvija'],
    ['Indulis','Ivo','Iva','Ivis'],
    ['Miervaldis','Miervalda','Ringolds'],
    ['Spodra','Ilva','Ilvita'],
    ['Sīmanis','Zintis'],
    ['Spulga','Arnita'],
    ['Rota','Zigmārs','Juliāns','Digmārs'],
    ['Gatis','Ivanda'],
    ['Kaspars','Aksels','Alta'],
    ['Tatjana','Dorisa'],
    ['Smaida','Franciska'],
    ['Reinis','Reina','Reinholds','Renāts'],
    ['Harijs','Ārijs','Āris','Aira'],
    ['Roberts','Roberta','Raitis','Raits'],
    ['Fēlikss','Felicita'],
    ['Lidija','Lida'],
    ['Tenis','Dravis'],
    ['Antons','Antis','Antonijs'],
    ['Andulis','Alnis'],
    ['Oļģerts','Orests','Aļģirds','Aļģis'],
    ['Agnese','Agnija','Agne'],
    ['Austris'],
    ['Grieta','Strauta','Rebeka'],
    ['Krišs','Ksenija','Eglons','Egle'],
    ['Zigurds','Sigurds','Sigvards'],
    ['Ansis','Agnis','Agneta'],
    ['Ilze','Ildze','Izolde'],
    ['Kārlis','Spodris'],
    ['Aivars','Valērijs','Bille'],
    ['Tīna','Valentīna','Pārsla'],
    ['Tekla','Violeta']
  ],
  [
    // Month: February
    ['Brigita','Indra','Indars','Indris'],
    ['Spīdola','Sonora'],
    ['Aīda','Ida','Vida'],
    ['Daila','Veronika','Dominiks'],
    ['Agate','Selga','Silga','Sinilga'],
    ['Dace','Dārta','Dora'],
    ['Nelda','Rihards','Ričards','Rišards'],
    ['Aldona','Česlavs'],
    ['Simona','Apolonija'],
    ['Paulīne','Paula','Jasmīna'],
    ['Laima','Laimdota'],
    ['Karlīna','Līna'],
    ['Malda','Melita'],
    ['Valentīns'],
    ['Alvils','Olafs','Aloizs','Olavs'],
    ['Jūlija','Džuljeta'],
    ['Donats','Konstance'],
    ['Kora','Kintija'],
    ['Zane','Zuzanna'],
    ['Vitauts','Smuidra','Smuidris'],
    ['Eleonora','Ariadne'],
    ['Ārija','Rigonda','Adrians','Adriāna','Adrija'],
    ['Haralds','Almants'],
    ['Diāna','Dina','Dins'],
    ['Alma','Annemarija'],
    ['Evelīna','Aurēlija','Mētra'],
    ['Līvija','Līva','Andra'],
    ['Skaidrīte','Justs','Skaidra'],
    ['–']
  ],
  [
    // Month: March
    ['Ivars','Ilgvars'],
    ['Lavīze','Luīze','Laila'],
    ['Tālis','Tālavs','Marts'],
    ['Alise','Auce','Enija'],
    ['Austra','Aurora'],
    ['Vents','Centis','Gotfrīds'],
    ['Ella','Elmīra'],
    ['Dagmāra','Marga','Margita'],
    ['Ēvalds'],
    ['Silvija','Laimrota','Liliāna'],
    ['Konstantīns','Agita'],
    ['Aija','Aiva','Aivis'],
    ['Ernests','Balvis'],
    ['Matilde','Ulrika'],
    ['Amilda','Amalda','Imalda'],
    ['Guntis','Guntars','Guntris'],
    ['Ģertrūde','Gerda'],
    ['Ilona','Adelīna'],
    ['Jāzeps','Juzefa'],
    ['Made','Irbe'],
    ['Una','Unigunde','Dzelme','Benedikts','Benedikta'],
    ['Tamāra','Dziedra','Gabriels','Gabriela'],
    ['Mirdza','Žanete','Žanna'],
    ['Kazimirs','Izidors'],
    ['Māra','Mārīte','Marita','Mare','Ģedimins'],
    ['Eiženija','Ženija'],
    ['Gustavs','Gusts','Tālrīts','Saulis'],
    ['Gunta','Ginta','Gunda'],
    ['Aldonis','Agija'],
    ['Nanija','Ilgmārs'],
    ['Gvido','Atvars']
  ],
  [
    // Month: April
    ['Dagnis','Dagne'],
    ['Irmgarde'],
    ['Daira','Dairis','Daiva','Daivis'],
    ['Valda','Herta','Ārvalda','Ārvalds','Ārvaldis'],
    ['Vija','Vidaga','Aivija'],
    ['Zinta','Vīlips','Filips','Dzinta'],
    ['Zina','Zinaīda','Helmuts'],
    ['Edgars','Danute','Dana','Dans'],
    ['Valērija','Žubīte','Alla'],
    ['Anita','Anitra','Zīle','Annika'],
    ['Hermanis','Vilmārs'],
    ['Jūlijs','Ainis'],
    ['Egils','Egīls','Nauris'],
    ['Strauja','Gudrīte'],
    ['Aelita','Gastons'],
    ['Mintauts','Alfs','Bernadeta'],
    ['Rūdolfs','Viviāna','Rūdis'],
    ['Laura','Jadviga'],
    ['Vēsma','Fanija'],
    ['Mirta','Ziedīte'],
    ['Marģers','Anastasija'],
    ['Armands','Armanda'],
    ['Jurģis','Juris','Georgs'],
    ['Visvaldis','Nameda','Ritvaldis','Ritums'],
    ['Līksma','Bārbala'],
    ['Alīna','Sandris','Rūsiņš'],
    ['Tāle','Raimonda','Raina','Klementīne'],
    ['Gundega','Terēze'],
    ['Vilnis','Raimonds','Laine'],
    ['Lilija','Liāna']
  ]
];
<|endoftext|>