<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var EXPORTED_SYMBOLS = ["MouseGestureObserver"];

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/Services.jsm")
Cu.import("resource://gesticulate/log.jsm");

const platform = Cc["@mozilla.org/system-info;1"]
                   .getService(Ci.nsIPropertyBag2).getProperty("name");

/**
 * Map a button bitmask containing only one set bit to a button index
 * (effectively, Event.buttons => Event.button).
 *
 * @param x A button bitmask
 * @return The mapped button index
 */
function fromButtons(x) {
  switch (x) {
  case 1:  return 0;
  case 2:  return 2;
  case 4:  return 1;
  case 8:  return 3;
  case 16: return 4;
  default: return undefined;
  }
}

/**
 * Map a button index to a button bitmask (effectively, Event.button =>
 * Event.buttons).
 *
 * @param x A button index
 * @return The mapped button bitmask
 */
function toButtons(x) {
  switch (x) {
  case 0:  return 1;
  case 1:  return 4;
  case 2:  return 2;
  case 3:  return 8;
  case 4:  return 16;
  default: return undefined;
  }
}

/**
 * Create a new mouse gesture observer.
 *
 * @param window The window to observe gestures for
 */
function MouseGestureObserver(window) {
  this._window = window;

  this._bound = new Map();
  for (var i of ["mousedown", "mouseup", "click", "contextmenu", "wheel"]) {
    var bound = this[i].bind(this);
    this._bound.set(i, bound);
    this._window.addEventListener(i, bound, true);
  }
}

MouseGestureObserver.prototype = {
  // True if we're performing a gesture; this lets us know when to suppress
  // mouse events.
  _performingGesture: false,

  // True if the browser tried to open a context menu and we want to delay it
  // until the corresponding click event.
  _wantContextMenu: false,

  /**
   * Clean up the mouse gesture observer, detaching all event listeners.
   */
  cleanup: function() {
    for (var [k, v] of this._bound.entries()) {
      this._window.removeEventListener(k, v, true);
    }
  },

  /**
   * Determine if the context menu's popup should be delayed. This is necessary
   * on non-Windows platforms because it pops up on mousedown, which can
   * visually interrupt a rocker gesture.
   */
  get _delayContextMenu() {
    return platform !== "Windows_NT" && Services.prefs.getBoolPref(
      "extensions.gesticulate.delay_context_menu"
    );
  },

  /**
   * Get the button to use for mouse gestures.
   */
  get _gestureButton() {
    return Services.prefs.getIntPref("extensions.gesticulate.gesture_button");
  },

  /**
   * Reset the internal state to the default if we were performing a gesture.
   * This is necessary because Firefox swallows pending events during page
   * unloads.
   */
  _resetState: function() {
    // We only reset when we know we were already performing a gesture because
    // recent Firefox builds on Linux fire the contextmenu event *before* the
    // mousedown event. If we don't do this, we'll forget that we had a context
    // menu queued up.
    if (this._performingGesture) {
      this._performingGesture = false;
      this._wantContextMenu = false;
    }
  },

  /**
   * Handle the mousedown event. Currently, we consider something to be a rocker
   * gesture if a single button was pressed before this event, and now two
   * buttons are pressed.
   *
   * Note: This does mean that it's possible to change the "base" of the rocker
   * gesture (e.g hold RMB, hold LMB ("go back") release RMB, hold RMB ("go
   * forward")). I'm not convinced this is really a problem, though.
   *
   * @param event The event to handle
   */
  mousedown: function(event) {
    if (!event.isTrusted)
      return;

    let buttons = event.buttons;
    let oldState = buttons - toButtons(event.button);
    debug(this._window, "mousedown", oldState, event.buttons, buttons,
          toButtons(event.button), event);

    if (oldState === 0) {
      // Firefox swallows pending events during page unloads; make sure we're
      // in the proper state if we exited the gesture.
      this._resetState();
    } else if (fromButtons(oldState) !== undefined) {
      event.target.dispatchEvent(new this._window.CustomEvent(
        "gesture", { detail: {
          subtype: "rocker",
          firstButton: fromButtons(oldState),
          secondButton: event.button,
          id: "rocker:" + fromButtons(oldState) + "," + event.button
        }}
      ));
      this._performingGesture = true;

      event.preventDefault();
      event.stopPropagation();
    }
  },

  /**
   * Handle the mouseup event. Once no buttons are being pressed, we consider
   * the rocker gesture to be over.
   *
   * @param event The event to handle
   */
  mouseup: function(event) {
    if (!event.isTrusted)
      return;

    debug(this._window, "mouseup", event);

    if (this._performingGesture) {
      if (event.buttons === 0) {
        // Delay exiting the gesture so that we can suppress the last click
        // event generated from this mouseup.
        this._window.setTimeout(() => {
          debug(this._window, "gesture exited");
          this._performingGesture = false;
        }, 0);
      }

      event.preventDefault();
      event.stopPropagation();
    }
  },

  /**
   * Handle the click event. This is necessary for two reasons: 1) to suppress
   * clicks that happened during a gesture, and 2) to synthesize a contextmenu
   * event for Linux/OS X(?), since they pop up their context menus on
   * mousedown, which disrupts the UI of rocker gestures.
   *
   * @param event The event to handle
   */
  click: function(event) {
    if (event.mozInputSource !== Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    let wantedContextMenu = this._wantContextMenu;
    this._wantContextMenu = false;

    if (this._performingGesture) {
      debug(this._window, "suppressed click");

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "click", event);
    if (wantedContextMenu) {
      // This doesn't trigger our contextmenu handler below, so we don't need to
      // worry about it being supressed.
      event.target.dispatchEvent(new this._window.MouseEvent(
        "contextmenu", event
      ));
    }
  },

  /**
   * Handle the contextmenu event. This is needed on Linux/OS X(?), since they
   * pop up their context menus on mousedown, which disrupts the UI of rocker
   * gestures.
   *
   * @param event The event to handle
   */
  contextmenu: function(event) {
    if (event.mozInputSource !== Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    if (this._performingGesture || this._delayContextMenu) {
      debug(this._window, "suppressed contextmenu");
      if (this._delayContextMenu)
        this._wantContextMenu = true;

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "contextmenu", event);
  },

  /**
   * Handle the wheel event. If the middle mouse button is being pressed, this
   * is a wheel gesture.
   *
   * @param event The event to handle
   */
  wheel: function(event) {
    if (event.mozInputSource !== Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    if (event.buttons === 0) {
      // Firefox swallows pending events during page unloads; make sure we're
      // in the proper state if we exited the gesture.
      this._resetState();
    } else if (fromButtons(event.buttons) === this._gestureButton) {
      let dir = event.deltaY > 0 ? 1 : -1;
      event.target.dispatchEvent(new this._window.CustomEvent(
        "gesture", { detail: {
          subtype: "wheel",
          direction: dir,
          id: "wheel:" + dir
        }}
      ));
      this._performingGesture = true;

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "wheel", event);
  },
};
<commit_msg>Remove one instance of Components.interfaces usage<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var EXPORTED_SYMBOLS = ["MouseGestureObserver"];

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/Services.jsm")
Cu.import("resource://gesticulate/log.jsm");

const platform = Cc["@mozilla.org/system-info;1"]
                   .getService(Ci.nsIPropertyBag2).getProperty("name");

/**
 * Map a button bitmask containing only one set bit to a button index
 * (effectively, Event.buttons => Event.button).
 *
 * @param x A button bitmask
 * @return The mapped button index
 */
function fromButtons(x) {
  switch (x) {
  case 1:  return 0;
  case 2:  return 2;
  case 4:  return 1;
  case 8:  return 3;
  case 16: return 4;
  default: return undefined;
  }
}

/**
 * Map a button index to a button bitmask (effectively, Event.button =>
 * Event.buttons).
 *
 * @param x A button index
 * @return The mapped button bitmask
 */
function toButtons(x) {
  switch (x) {
  case 0:  return 1;
  case 1:  return 4;
  case 2:  return 2;
  case 3:  return 8;
  case 4:  return 16;
  default: return undefined;
  }
}

/**
 * Create a new mouse gesture observer.
 *
 * @param window The window to observe gestures for
 */
function MouseGestureObserver(window) {
  this._window = window;

  this._bound = new Map();
  for (var i of ["mousedown", "mouseup", "click", "contextmenu", "wheel"]) {
    var bound = this[i].bind(this);
    this._bound.set(i, bound);
    this._window.addEventListener(i, bound, true);
  }
}

MouseGestureObserver.prototype = {
  // True if we're performing a gesture; this lets us know when to suppress
  // mouse events.
  _performingGesture: false,

  // True if the browser tried to open a context menu and we want to delay it
  // until the corresponding click event.
  _wantContextMenu: false,

  /**
   * Clean up the mouse gesture observer, detaching all event listeners.
   */
  cleanup: function() {
    for (var [k, v] of this._bound.entries()) {
      this._window.removeEventListener(k, v, true);
    }
  },

  /**
   * Determine if the context menu's popup should be delayed. This is necessary
   * on non-Windows platforms because it pops up on mousedown, which can
   * visually interrupt a rocker gesture.
   */
  get _delayContextMenu() {
    return platform !== "Windows_NT" && Services.prefs.getBoolPref(
      "extensions.gesticulate.delay_context_menu"
    );
  },

  /**
   * Get the button to use for mouse gestures.
   */
  get _gestureButton() {
    return Services.prefs.getIntPref("extensions.gesticulate.gesture_button");
  },

  /**
   * Reset the internal state to the default if we were performing a gesture.
   * This is necessary because Firefox swallows pending events during page
   * unloads.
   */
  _resetState: function() {
    // We only reset when we know we were already performing a gesture because
    // recent Firefox builds on Linux fire the contextmenu event *before* the
    // mousedown event. If we don't do this, we'll forget that we had a context
    // menu queued up.
    if (this._performingGesture) {
      this._performingGesture = false;
      this._wantContextMenu = false;
    }
  },

  /**
   * Handle the mousedown event. Currently, we consider something to be a rocker
   * gesture if a single button was pressed before this event, and now two
   * buttons are pressed.
   *
   * Note: This does mean that it's possible to change the "base" of the rocker
   * gesture (e.g hold RMB, hold LMB ("go back") release RMB, hold RMB ("go
   * forward")). I'm not convinced this is really a problem, though.
   *
   * @param event The event to handle
   */
  mousedown: function(event) {
    if (!event.isTrusted)
      return;

    let buttons = event.buttons;
    let oldState = buttons - toButtons(event.button);
    debug(this._window, "mousedown", oldState, event.buttons, buttons,
          toButtons(event.button), event);

    if (oldState === 0) {
      // Firefox swallows pending events during page unloads; make sure we're
      // in the proper state if we exited the gesture.
      this._resetState();
    } else if (fromButtons(oldState) !== undefined) {
      event.target.dispatchEvent(new this._window.CustomEvent(
        "gesture", { detail: {
          subtype: "rocker",
          firstButton: fromButtons(oldState),
          secondButton: event.button,
          id: "rocker:" + fromButtons(oldState) + "," + event.button
        }}
      ));
      this._performingGesture = true;

      event.preventDefault();
      event.stopPropagation();
    }
  },

  /**
   * Handle the mouseup event. Once no buttons are being pressed, we consider
   * the rocker gesture to be over.
   *
   * @param event The event to handle
   */
  mouseup: function(event) {
    if (!event.isTrusted)
      return;

    debug(this._window, "mouseup", event);

    if (this._performingGesture) {
      if (event.buttons === 0) {
        // Delay exiting the gesture so that we can suppress the last click
        // event generated from this mouseup.
        this._window.setTimeout(() => {
          debug(this._window, "gesture exited");
          this._performingGesture = false;
        }, 0);
      }

      event.preventDefault();
      event.stopPropagation();
    }
  },

  /**
   * Handle the click event. This is necessary for two reasons: 1) to suppress
   * clicks that happened during a gesture, and 2) to synthesize a contextmenu
   * event for Linux/OS X(?), since they pop up their context menus on
   * mousedown, which disrupts the UI of rocker gestures.
   *
   * @param event The event to handle
   */
  click: function(event) {
    if (event.mozInputSource !== MouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    let wantedContextMenu = this._wantContextMenu;
    this._wantContextMenu = false;

    if (this._performingGesture) {
      debug(this._window, "suppressed click");

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "click", event);
    if (wantedContextMenu) {
      // This doesn't trigger our contextmenu handler below, so we don't need to
      // worry about it being supressed.
      event.target.dispatchEvent(new this._window.MouseEvent(
        "contextmenu", event
      ));
    }
  },

  /**
   * Handle the contextmenu event. This is needed on Linux/OS X(?), since they
   * pop up their context menus on mousedown, which disrupts the UI of rocker
   * gestures.
   *
   * @param event The event to handle
   */
  contextmenu: function(event) {
    if (event.mozInputSource !== MouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    if (this._performingGesture || this._delayContextMenu) {
      debug(this._window, "suppressed contextmenu");
      if (this._delayContextMenu)
        this._wantContextMenu = true;

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "contextmenu", event);
  },

  /**
   * Handle the wheel event. If the middle mouse button is being pressed, this
   * is a wheel gesture.
   *
   * @param event The event to handle
   */
  wheel: function(event) {
    if (event.mozInputSource !== MouseEvent.MOZ_SOURCE_MOUSE ||
        !event.isTrusted)
      return;

    if (event.buttons === 0) {
      // Firefox swallows pending events during page unloads; make sure we're
      // in the proper state if we exited the gesture.
      this._resetState();
    } else if (fromButtons(event.buttons) === this._gestureButton) {
      let dir = event.deltaY > 0 ? 1 : -1;
      event.target.dispatchEvent(new this._window.CustomEvent(
        "gesture", { detail: {
          subtype: "wheel",
          direction: dir,
          id: "wheel:" + dir
        }}
      ));
      this._performingGesture = true;

      event.preventDefault();
      event.stopPropagation();
      return;
    }

    debug(this._window, "wheel", event);
  },
};
<|endoftext|>


<commit_before>/**
	_onyx.TimePicker_ is a group of onyx.Picker
	controls displaying the current time. The user may change the hour, minute,
	and AM/PM values.

	By default, _TimePicker_ tries to determine the current locale and use its
	rules to format the time (including AM/PM). In order to do this
	successfully, the _g11n_ library must be loaded; if it is not loaded, the
	control defaults to using standard U.S. time format.
 */
enyo.kind({
	name: "onyx.TimePicker",
	classes: "onyx-toolbar-inline",
	published: {
		disabled: false,
		/**
			Current locale used for formatting. Can be set after control
			creation, in which case the control will be updated to reflect the
			new value.
		*/
		locale: null,
		//* If true, 24-hour time is used. This is reset when locale is changed.
		is24HrMode: null,
		/**
			The current Date object. When a Date object is passed to _setValue_,
			the control is updated to reflect the new value. _getValue_ returns
			a Date object.
		*/
		value: null
	},
	events: {
		/**
			Fires when one of the TimePicker's fields is selected.

			_inEvent.name_ contains the name of the TimePicker that generated
			the event.

			_inEvent.value_ contains the current Date value of the control.
		*/
		onSelect: ""
	},
	create: function() {
		this.inherited(arguments);
		if (!this.locale){
			try {
				this.locale = enyo.g11n.currentLocale().getLocale();
			}
			catch(err) {
				this.locale = "en_us";
			}
		}
		this.initDefaults();
	},
	initDefaults: function() {
		var am, pm;
		//Attempt to use the g11n lib (ie assume it is loaded)
		try {
			this._tf = new enyo.g11n.Fmts({locale:this.locale});
			am = this._tf.getAmCaption();
			pm = this._tf.getPmCaption();

			if (this.is24HrMode == null) {
				this.is24HrMode = !this._tf.isAmPm();
			}
		}
		catch(err) {
			//fall back to en_us as default
			am = "AM";
			pm = "PM";
			this.is24HrMode = false;
		}

		this.setupPickers(this._tf ? this._tf.getTimeFieldOrder() : 'hma');

		var d = this.value = this.value || new Date();

		// create hours
		var i;
		if (!this.is24HrMode){
			var h = d.getHours();
			h = (h === 0) ? 12 : h;
			for (i=1; i<=12; i++) {
				this.$.hourPicker.createComponent({content: i, value:i, active: (i == (h>12 ? h%12 : h))});
			}
		} else {
			for (i=0; i<24; i++) {
				this.$.hourPicker.createComponent({content: i, value:i, active: (i == d.getHours())});
			}
		}

		// create minutes
		for (i=0; i<=59; i++) {
			this.$.minutePicker.createComponent({content: (i < 10) ? ("0"+i):i, value:i, active: i == d.getMinutes()});
		}

		// create am/pm
		if (d.getHours() >= 12) {
			this.$.ampmPicker.createComponents([{content: am},{content:pm, active: true}]);
		}
		else {
			this.$.ampmPicker.createComponents([{content: am, active: true},{content:pm}]);
		}
		this.$.ampmPicker.getParent().setShowing(!this.is24HrMode);
	},
	setupPickers: function(ordering) {
		var orderingArr = ordering.split("");
		var o,f,l;
		for(f = 0, l = orderingArr.length; f < l; f++) {
			o = orderingArr[f];
			switch (o){
				case 'h': this.createHour();
				break;
				case 'm': this.createMinute();
				break;
				case 'a': this.createAmPm();
				break;
				default: break;
			}
		}
	},
	createHour: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateHour", components: [
				{classes:"onyx-timepicker-hour", name: "hourPickerButton", disabled: this.disabled},
				{name: "hourPicker", kind: "onyx.Picker"}
			]}
		);
	},
	createMinute: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateMinute", components: [
				{classes:"onyx-timepicker-minute", name: "minutePickerButton", disabled: this.disabled},
				{name: "minutePicker", kind: "onyx.Picker"}
			]}
		);
	},
	createAmPm: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateAmPm", components: [
				{classes:"onyx-timepicker-ampm", name: "secondPickerButton", disabled: this.disabled},
				{name: "ampmPicker", kind: "onyx.Picker"}
			]}
		);
	},
	disabledChanged: function() {
		this.hourPickerButton.setDisabled(this.disabled);
		this.minutePickerButton.setDisabled(this.disabled);
		this.secondPickerButton.setDisabled(this.disabled);
	},
	localeChanged: function() {
		//reset 24 hour mode when changing locales
		this.is24HrMode = null;
		this.refresh();
	},
	is24HrModeChanged: function() {
		this.refresh();
	},
	valueChanged: function(){
		this.refresh();
	},
	updateHour: function(inSender, inEvent){
		var h = inEvent.selected.value;
		if (!this.is24HrMode){
			var ampm = this.$.ampmPicker.getParent().controlAtIndex(0).content;
			h = h + (h == 12 ? -12 : 0) + (this.isAm(ampm) ? 0 : 12);
		}
		this.value = this.calcTime(h, this.value.getMinutes());
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	updateMinute: function(inSender, inEvent){
		this.value = this.calcTime(this.value.getHours(), inEvent.selected.value);
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	updateAmPm: function(inSender, inEvent){
		var h = this.value.getHours();
		if (!this.is24HrMode){
			h = h + (h > 11 ? (this.isAm(inEvent.content) ? -12 : 0) : (this.isAm(inEvent.content) ? 0 : 12));
		}
		this.value = this.calcTime(h, this.value.getMinutes());
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	calcTime: function(hour, minute){
		return new Date(this.value.getFullYear(),
						this.value.getMonth(),
						this.value.getDate(),
						hour, minute,
						this.value.getSeconds(),
						this.value.getMilliseconds());
	},
	isAm: function(value){
		var am, pm, isAm;
		//Workaround for pickers not having directly retrievable active item. Using it to find whether
		//picker is on AM or PM (& have to check localized spelling as well)
		try {
			am = this._tf.getAmCaption();
			pm = this._tf.getPmCaption();
		} catch (err) {
			am = "AM";
			pm = "PM";
		}

		if (value == am){
			return true;
		} else {
			return false;
		}
	},
	refresh: function(){
		this.destroyClientControls();
		this.initDefaults();
		this.render();
	}
});<commit_msg>Added "disabled" explanation<commit_after>/**
	_onyx.TimePicker_ is a group of onyx.Picker
	controls displaying the current time. The user may change the hour, minute,
	and AM/PM values.

	By default, _TimePicker_ tries to determine the current locale and use its
	rules to format the time (including AM/PM). In order to do this
	successfully, the _g11n_ library must be loaded; if it is not loaded, the
	control defaults to using standard U.S. time format.
 */
enyo.kind({
	name: "onyx.TimePicker",
	classes: "onyx-toolbar-inline",
	published: {
		//* If true, control is shown as disabled, and user can't select new values
		disabled: false,
		/**
			Current locale used for formatting. Can be set after control
			creation, in which case the control will be updated to reflect the
			new value.
		*/
		locale: null,
		//* If true, 24-hour time is used. This is reset when locale is changed.
		is24HrMode: null,
		/**
			The current Date object. When a Date object is passed to _setValue_,
			the control is updated to reflect the new value. _getValue_ returns
			a Date object.
		*/
		value: null
	},
	events: {
		/**
			Fires when one of the TimePicker's fields is selected.

			_inEvent.name_ contains the name of the TimePicker that generated
			the event.

			_inEvent.value_ contains the current Date value of the control.
		*/
		onSelect: ""
	},
	create: function() {
		this.inherited(arguments);
		if (!this.locale){
			try {
				this.locale = enyo.g11n.currentLocale().getLocale();
			}
			catch(err) {
				this.locale = "en_us";
			}
		}
		this.initDefaults();
	},
	initDefaults: function() {
		var am, pm;
		//Attempt to use the g11n lib (ie assume it is loaded)
		try {
			this._tf = new enyo.g11n.Fmts({locale:this.locale});
			am = this._tf.getAmCaption();
			pm = this._tf.getPmCaption();

			if (this.is24HrMode == null) {
				this.is24HrMode = !this._tf.isAmPm();
			}
		}
		catch(err) {
			//fall back to en_us as default
			am = "AM";
			pm = "PM";
			this.is24HrMode = false;
		}

		this.setupPickers(this._tf ? this._tf.getTimeFieldOrder() : 'hma');

		var d = this.value = this.value || new Date();

		// create hours
		var i;
		if (!this.is24HrMode){
			var h = d.getHours();
			h = (h === 0) ? 12 : h;
			for (i=1; i<=12; i++) {
				this.$.hourPicker.createComponent({content: i, value:i, active: (i == (h>12 ? h%12 : h))});
			}
		} else {
			for (i=0; i<24; i++) {
				this.$.hourPicker.createComponent({content: i, value:i, active: (i == d.getHours())});
			}
		}

		// create minutes
		for (i=0; i<=59; i++) {
			this.$.minutePicker.createComponent({content: (i < 10) ? ("0"+i):i, value:i, active: i == d.getMinutes()});
		}

		// create am/pm
		if (d.getHours() >= 12) {
			this.$.ampmPicker.createComponents([{content: am},{content:pm, active: true}]);
		}
		else {
			this.$.ampmPicker.createComponents([{content: am, active: true},{content:pm}]);
		}
		this.$.ampmPicker.getParent().setShowing(!this.is24HrMode);
	},
	setupPickers: function(ordering) {
		var orderingArr = ordering.split("");
		var o,f,l;
		for(f = 0, l = orderingArr.length; f < l; f++) {
			o = orderingArr[f];
			switch (o){
				case 'h': this.createHour();
				break;
				case 'm': this.createMinute();
				break;
				case 'a': this.createAmPm();
				break;
				default: break;
			}
		}
	},
	createHour: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateHour", components: [
				{classes:"onyx-timepicker-hour", name: "hourPickerButton", disabled: this.disabled},
				{name: "hourPicker", kind: "onyx.Picker"}
			]}
		);
	},
	createMinute: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateMinute", components: [
				{classes:"onyx-timepicker-minute", name: "minutePickerButton", disabled: this.disabled},
				{name: "minutePicker", kind: "onyx.Picker"}
			]}
		);
	},
	createAmPm: function() {
		this.createComponent(
			{kind: "onyx.PickerDecorator", onSelect: "updateAmPm", components: [
				{classes:"onyx-timepicker-ampm", name: "secondPickerButton", disabled: this.disabled},
				{name: "ampmPicker", kind: "onyx.Picker"}
			]}
		);
	},
	disabledChanged: function() {
		this.hourPickerButton.setDisabled(this.disabled);
		this.minutePickerButton.setDisabled(this.disabled);
		this.secondPickerButton.setDisabled(this.disabled);
	},
	localeChanged: function() {
		//reset 24 hour mode when changing locales
		this.is24HrMode = null;
		this.refresh();
	},
	is24HrModeChanged: function() {
		this.refresh();
	},
	valueChanged: function(){
		this.refresh();
	},
	updateHour: function(inSender, inEvent){
		var h = inEvent.selected.value;
		if (!this.is24HrMode){
			var ampm = this.$.ampmPicker.getParent().controlAtIndex(0).content;
			h = h + (h == 12 ? -12 : 0) + (this.isAm(ampm) ? 0 : 12);
		}
		this.value = this.calcTime(h, this.value.getMinutes());
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	updateMinute: function(inSender, inEvent){
		this.value = this.calcTime(this.value.getHours(), inEvent.selected.value);
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	updateAmPm: function(inSender, inEvent){
		var h = this.value.getHours();
		if (!this.is24HrMode){
			h = h + (h > 11 ? (this.isAm(inEvent.content) ? -12 : 0) : (this.isAm(inEvent.content) ? 0 : 12));
		}
		this.value = this.calcTime(h, this.value.getMinutes());
		this.doSelect({name:this.name, value:this.value});
		return true;
	},
	calcTime: function(hour, minute){
		return new Date(this.value.getFullYear(),
						this.value.getMonth(),
						this.value.getDate(),
						hour, minute,
						this.value.getSeconds(),
						this.value.getMilliseconds());
	},
	isAm: function(value){
		var am, pm, isAm;
		//Workaround for pickers not having directly retrievable active item. Using it to find whether
		//picker is on AM or PM (& have to check localized spelling as well)
		try {
			am = this._tf.getAmCaption();
			pm = this._tf.getPmCaption();
		} catch (err) {
			am = "AM";
			pm = "PM";
		}

		if (value == am){
			return true;
		} else {
			return false;
		}
	},
	refresh: function(){
		this.destroyClientControls();
		this.initDefaults();
		this.render();
	}
});<|endoftext|>


<commit_before>$(document).ready(function () {

    var apiHost = "http://cmsapi.seven49.net";
    //var apiHost = "http://localhost.cmsadmin.seven49.net";

    docCookies.removeItem("SessionGuid","/"); // log out

    $(".Login .Button").click(function () {

        var redirectUrl = getQueryStringParameterByName("redirecturl");
        var origin = window.location.href;
        if (origin.indexOf("?") > 0) {
            origin = origin.substring(0, origin.indexOf("?"));
        }
        var url = apiHost + "/Login?username=" + encodeURIComponent($('#LoginUserName').val()) + "&password=" + encodeURIComponent($('#LoginPassword').val()) + "&redirecturl=" + encodeURIComponent(redirectUrl) + "&sessionguid=" + docCookies.getItem("SessionGuid") + "&origin=" + encodeURIComponent(origin);
        console.log(url);
        console.log("Cookie: " + document.cookie);

        $.ajax({
            dataType: "json",
            url: url,
            async: true
        }).done(function (data) {
            console.log(data);
            docCookies.setItem("SessionGuid", data.SessionGuid, 86400, "/"); // 24 hours = 86400 seconds
            console.log("Cookie: " + document.cookie);
            if (data.RedirectUrl == "") {
                window.location = "/";
            }
            else {
                window.location = data.RedirectUrl;
            }
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log("error getting " + url);
            var jsonResponse = $.parseJSON(jqXHR.responseText);
            var message;
            if (jsonResponse.Message) {
                console.log("Error message: " + jsonResponse.Message);
                message = jsonResponse.Message;
            }
            else {
                message = "Login failed";
            }
            insertSystemMessageAfter(".Login .Button", message, "loginSystemMessage");
        });
    });

    $('.PasswordRecovery .Button').click(function () {

        var username = $('#PasswordRecoveryUsername').val();
        if (!username) {
            console.log('Username is missing');
            return;
        }
        var origin = window.location.href;
        if (origin.indexOf("?") > 0) {
            origin = origin.substring(0, origin.indexOf("?"));
        }
        console.log('Recovering password for ' + username);
        var url = apiHost + "/LostPassword/?username=" + username + "&origin=" + origin

        console.log(url);
        $.getJSON(url, function (data) {
            console.log(data);
            insertSystemMessageAfter(".PasswordRecovery .Button", data.Message, "passwordRecoverySystemMessage");
            $('#LoginUserName').val(username);
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log("error getting " + url);
            var jsonResponse = $.parseJSON(jqXHR.responseText);
            var message;
            if (jsonResponse.Message) {
                console.log("Error message: " + jsonResponse.Message);
                message = jsonResponse.Message;
            }
            else {
                message = "Password recovery failed";
            }
            insertSystemMessageAfter(".PasswordRecovery .Button", message, "passwordRecoverySystemMessage");
        });
    });

    function getQueryStringParameterByName(name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }

    function insertSystemMessageAfter(selector, message, id) {
        $("#" + id).remove();
        $("
" + message + "
").insertAfter(selector);
    }

});<commit_msg>Cookie<commit_after>$(document).ready(function () {

    var apiHost = "http://cmsapi.seven49.net";
    //var apiHost = "http://localhost.cmsadmin.seven49.net";

    docCookies.removeItem("SessionGuid","/"); // log out

    $(".Login .Button").click(function () {

        var redirectUrl = getQueryStringParameterByName("redirecturl");
        var origin = window.location.href;
        if (origin.indexOf("?") > 0) {
            origin = origin.substring(0, origin.indexOf("?"));
        }
        var url = apiHost + "/Login?username=" + encodeURIComponent($('#LoginUserName').val()) + "&password=" + encodeURIComponent($('#LoginPassword').val()) + "&redirecturl=" + encodeURIComponent(redirectUrl) + "&sessionguid=" + docCookies.getItem("SessionGuid") + "&origin=" + encodeURIComponent(origin);
        console.log(url);
        console.log("Cookie: " + document.cookie);

        $.ajax({
            dataType: "json",
            url: url,
            async: true
        }).done(function (data) {
            console.log(data);
            docCookies.setItem("SessionGuid", data.SessionGuid, 7776000, "/"); // 24 hours = 86400 seconds, 90 days = 7776000 seconds
            console.log("Cookie: " + document.cookie);
            if (data.RedirectUrl == "") {
                window.location = "/";
            }
            else {
                window.location = data.RedirectUrl;
            }
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log("error getting " + url);
            var jsonResponse = $.parseJSON(jqXHR.responseText);
            var message;
            if (jsonResponse.Message) {
                console.log("Error message: " + jsonResponse.Message);
                message = jsonResponse.Message;
            }
            else {
                message = "Login failed";
            }
            insertSystemMessageAfter(".Login .Button", message, "loginSystemMessage");
        });
    });

    $('.PasswordRecovery .Button').click(function () {

        var username = $('#PasswordRecoveryUsername').val();
        if (!username) {
            console.log('Username is missing');
            return;
        }
        var origin = window.location.href;
        if (origin.indexOf("?") > 0) {
            origin = origin.substring(0, origin.indexOf("?"));
        }
        console.log('Recovering password for ' + username);
        var url = apiHost + "/LostPassword/?username=" + username + "&origin=" + origin

        console.log(url);
        $.getJSON(url, function (data) {
            console.log(data);
            insertSystemMessageAfter(".PasswordRecovery .Button", data.Message, "passwordRecoverySystemMessage");
            $('#LoginUserName').val(username);
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log("error getting " + url);
            var jsonResponse = $.parseJSON(jqXHR.responseText);
            var message;
            if (jsonResponse.Message) {
                console.log("Error message: " + jsonResponse.Message);
                message = jsonResponse.Message;
            }
            else {
                message = "Password recovery failed";
            }
            insertSystemMessageAfter(".PasswordRecovery .Button", message, "passwordRecoverySystemMessage");
        });
    });

    function getQueryStringParameterByName(name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }

    function insertSystemMessageAfter(selector, message, id) {
        $("#" + id).remove();
        $("
" + message + "
").insertAfter(selector);
    }

});<|endoftext|>


<commit_before>import { LitElement, html } from 'lit-element';

import {MDCDataTable} from '@material/data-table';

import Node from '../../../src/nOrg.js';

function __expandCell(node) {
  if (node.$childHead) {
    const icon = node.$collapsed ? 'expand_more' : 'expand_less';
    return html`
      <mwc-icon-button icon="${icon}">
      </mwc-icon-button>
    `
  }
  return null;
}

export class NorgNodesTable extends LitElement {
  static get properties() {
    return {
      parentNode: { type: Node },
      firstNode: { type: Node },
     };
  }

  render() {
    return html`
      <link
           href="node_modules/@material/data-table/dist/mdc.data-table.css"
           rel="stylesheet" type="text/css" />

                  <input
                        type="checkbox"
                        class="mdc-checkbox__native-control"
                        aria-label="Select/unselect al children"/>

                <mwc-icon-button icon="unfold_more">
                </mwc-icon-button>

                State

                Subject

            ${this.__iterateNodes()}

    `;
  }

  updated() {
    // eslint-disable-next-line no-new
    new MDCDataTable(this.shadowRoot.querySelector('.mdc-data-table'));
  }

  * __iterateNodes() {
    let node = this.firstNode;
    while (node) {
      yield html`

              <input type="checkbox" class="mdc-checkbox__native-control"
                     aria-labelledby="${node['Message-ID']}"/>

            ${__expandCell(node)}

          ${node["Node-State"]}

            ${node.Subject}

      `
      node = node.$nextSibling
    }
  }

}
<commit_msg>[ui] Indicate the depth of the node with bullets<commit_after>import { LitElement, html } from 'lit-element';

import {MDCDataTable} from '@material/data-table';

import Node from '../../../src/nOrg.js';

function __expandCell(node) {
  if (node.$childHead) {
    const icon = node.$collapsed ? 'expand_more' : 'expand_less';
    return html`
      <mwc-icon-button icon="${icon}">
      </mwc-icon-button>
    `
  }
  return null;
}

export class NorgNodesTable extends LitElement {
  static get properties() {
    return {
      parentNode: { type: Node },
      firstNode: { type: Node },
     };
  }

  render() {
    return html`
      <link
           href="node_modules/@material/data-table/dist/mdc.data-table.css"
           rel="stylesheet" type="text/css" />

                  <input
                        type="checkbox"
                        class="mdc-checkbox__native-control"
                        aria-label="Select/unselect al children"/>

                <mwc-icon-button icon="unfold_more">
                </mwc-icon-button>

                State

                Subject

            ${this.__iterateNodes()}

    `;
  }

  updated() {
    // eslint-disable-next-line no-new
    new MDCDataTable(this.shadowRoot.querySelector('.mdc-data-table'));
  }

  * __iterateNodes() {
    let node = this.firstNode;
    while (node) {
      const depth = node.depth(this.parentNode);
      yield html`

              <input type="checkbox" class="mdc-checkbox__native-control"
                     aria-labelledby="${node['Message-ID']}"/>

            ${__expandCell(node)}

          ${node["Node-State"]}

            ${Array.from(Array(depth)).map(() => html`•`)}
            ${node.Subject}

      `
      if (node.$childHead && !node.$collapsed) {
        node = node.$childHead;
      } else if (node.$nextSibling) {
        node = node.$nextSibling;
      } else if (node.$parent !== this.parentNode) {
        node = node.$parent.$nextSibling;
      } else {
        node = null;
      }
    }
  }

}
<|endoftext|>


<commit_before>/* eslint-env node */

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary')
  ]).then((urls) => {
    return {
  useYarn: true,
  scenarios: [
    {
      name: 'ember-2.4-stack',
      npm: {
        devDependencies: {
          'ember-data': '2.4.3',
          'ember-inflector': '^1.9.4',
          'ember-source': null,
          'ember-cli-shims': null
        }
      },
      bower: {
        dependencies: {
          'ember': '2.4.6',
          'ember-cli-shims': '0.1.1'
        }
      }
    },
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8',
          'ember-cli-shims': '0.1.1'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-data': '2.8.1',
          'ember-inflector': '^1.9.4',
          'ember-source': null,
          'ember-cli-shims': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-data': '2.12.2',
          'ember-inflector': '^1.9.4',
          'ember-source': '2.12.2',
          'ember-cli-shims': '^1.1.0'
        }
      }
    },
    {
      name: 'ember-2.14-stack',
      npm: {
        devDependencies: {
          'ember-data': '~2.14.0',
          'ember-source': '~2.14.0',
        }
      },
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-data': '~2.16.0',
          'ember-source': '~2.16.0',
        }
      }
    },
    {
      name: 'ember-lts-2.18',
      npm: {
        devDependencies: {
          'ember-data': '~2.18.0',
          'ember-source': '~2.18.0',
        }
      }
    },
{
      name: 'ember-lts-3.4',
      npm: {
        devDependencies: {
          'ember-source': '~3.4.0',
          'ember-data': '~3.4.0',
        }
      }
    },
    {
      name: 'ember-lts-3.8',
      npm: {
        devDependencies: {
          'ember-source': '~3.8.0',
          'ember-data': '~3.8.0',
        }
      }
    },
    {
      name: 'ember-lts-3.12',
      npm: {
        devDependencies: {
          'ember-source': '~3.12.0',
          'ember-data': '~3.12.0',
        }
      }
    },
    {
      name: 'ember-release',
      npm: {
        devDependencies: {
          'ember-data': 'latest',
          'ember-source': urls[0]
        }
      }
    },
    {
      name: 'ember-beta',
      npm: {
        devDependencies: {
          'ember-data': 'beta',
          'ember-source': urls[1]
        }
      }
    },
    {
      name: 'ember-canary',
      npm: {
        devDependencies: {
          'ember-data': 'emberjs/data#master',
          'ember-source': urls[2]
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
    };
  });
};
<commit_msg>ember-factory-for-polyfill for 2.4 and 2.8<commit_after>/* eslint-env node */

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary')
  ]).then((urls) => {
    return {
  useYarn: true,
  scenarios: [
    {
      name: 'ember-2.4-stack',
      npm: {
        devDependencies: {
          'ember-data': '2.4.3',
          'ember-inflector': '^1.9.4',
          'ember-source': null,
          'ember-cli-shims': null,
          'ember-factory-for-polyfill': '1.3.1'
        }
      },
      bower: {
        dependencies: {
          'ember': '2.4.6',
          'ember-cli-shims': '0.1.1'
        }
      }
    },
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8',
          'ember-cli-shims': '0.1.1',
          'ember-factory-for-polyfill': '1.3.1'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-data': '2.8.1',
          'ember-inflector': '^1.9.4',
          'ember-source': null,
          'ember-cli-shims': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-data': '2.12.2',
          'ember-inflector': '^1.9.4',
          'ember-source': '2.12.2',
          'ember-cli-shims': '^1.1.0'
        }
      }
    },
    {
      name: 'ember-2.14-stack',
      npm: {
        devDependencies: {
          'ember-data': '~2.14.0',
          'ember-source': '~2.14.0',
        }
      },
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-data': '~2.16.0',
          'ember-source': '~2.16.0',
        }
      }
    },
    {
      name: 'ember-lts-2.18',
      npm: {
        devDependencies: {
          'ember-data': '~2.18.0',
          'ember-source': '~2.18.0',
        }
      }
    },
{
      name: 'ember-lts-3.4',
      npm: {
        devDependencies: {
          'ember-source': '~3.4.0',
          'ember-data': '~3.4.0',
        }
      }
    },
    {
      name: 'ember-lts-3.8',
      npm: {
        devDependencies: {
          'ember-source': '~3.8.0',
          'ember-data': '~3.8.0',
        }
      }
    },
    {
      name: 'ember-lts-3.12',
      npm: {
        devDependencies: {
          'ember-source': '~3.12.0',
          'ember-data': '~3.12.0',
        }
      }
    },
    {
      name: 'ember-release',
      npm: {
        devDependencies: {
          'ember-data': 'latest',
          'ember-source': urls[0]
        }
      }
    },
    {
      name: 'ember-beta',
      npm: {
        devDependencies: {
          'ember-data': 'beta',
          'ember-source': urls[1]
        }
      }
    },
    {
      name: 'ember-canary',
      npm: {
        devDependencies: {
          'ember-data': 'emberjs/data#master',
          'ember-source': urls[2]
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
    };
  });
};
<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = {
  scenarios: [
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-source': '~2.16.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<commit_msg>use yarn with ember-try<commit_after>/* eslint-env node */
module.exports = {
  useYarn: true,
  scenarios: [
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-source': '~2.16.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<|endoftext|>


<commit_before>/*eslint-env node*/
module.exports = {
    {
      name: 'ember-1.13',
      bower: {
        dependencies: {
          'ember': '~1.13.0'
        },
        resolutions: {
          'ember': '~1.13.0'
        }
      }
    },
    {
      name: 'ember-lts-2.4',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-4'
        },
        resolutions: {
          'ember': 'lts-2-4'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      }
    }
  ]
};
<commit_msg>un-broke ember-try config file.<commit_after>/*eslint-env node*/
module.exports = {
  scenarios: [
    {
      name: 'ember-1.13',
      bower: {
        dependencies: {
          'ember': '~1.13.0'
        },
        resolutions: {
          'ember': '~1.13.0'
        }
      }
    },
    {
      name: 'ember-lts-2.4',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-4'
        },
        resolutions: {
          'ember': 'lts-2-4'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      }
    }
  ]
};
<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = {
  scenarios: [
    {
      name: 'ember-2.10',
      bower: {
        dependencies: {
          ember: '~2.10.0'
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-source': '~2.16.0'
        }
      }
    },
    {
      name: 'ember-lts-2.18',
      npm: {
        devDependencies: {
          'ember-source': '~2.18.0'
        }
      }
    },
    {
      name: 'ember-3.0.x',
      npm: {
        devDependencies: {
          'ember-source': '~3.0.0'
        }
      }
    },
    {

      name: 'ember-3.1.x',
      npm: {
        devDependencies: {
          'ember-source': '~3.1.0'
        }
      }
    }
  ]
};
<commit_msg>Adding emberjs 1.13.x to ember-try.<commit_after>/* eslint-env node */
module.exports = {
  scenarios: [
    {
      name: 'ember-1.13',
      bower: {
        dependencies: {
          ember: '~1.13.0'
        }
      }
    },
    {
      name: 'ember-2.10',
      bower: {
        dependencies: {
          ember: '~2.10.0'
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-lts-2.16',
      npm: {
        devDependencies: {
          'ember-source': '~2.16.0'
        }
      }
    },
    {
      name: 'ember-lts-2.18',
      npm: {
        devDependencies: {
          'ember-source': '~2.18.0'
        }
      }
    },
    {
      name: 'ember-3.0.x',
      npm: {
        devDependencies: {
          'ember-source': '~3.0.0'
        }
      }
    },
    {
      name: 'ember-3.1.x',
      npm: {
        devDependencies: {
          'ember-source': '~3.1.0'
        }
      }
    }
  ]
};
<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary')
  ]).then((urls) => {
    const [releaseUrl, betaUrl, canaryUrl] = urls;

    return {
      useYarn: true,
      scenarios: [
      {
        name: 'ember-3.5.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.5',
            'ember-data': '~3.5'
          }
        }
      },
      {
        name: 'ember-3.6.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.6',
            'ember-data': '~3.6'
          }
        }
      },
      {
        name: 'ember-3.7.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.7',
            'ember-data': '~3.7'
          }
        }
      },
      {
        name: 'ember-3.8.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.8',
            'ember-data': '~3.8'
          }
        }
      },
      {
        name: 'ember-3.9.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.9',
            'ember-data': '~3.9'
          }
        }
      },
      {
        name: 'ember-3.10.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.10',
            'ember-data': '~3.10'
          }
        }
      },
      {
        name: 'ember-3.11.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.11',
            'ember-data': '~3.11'
          }
        }
      },
      {
        name: 'ember-3.12.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.12',
            'ember-data': '~3.12'
          }
        }
      },
      {
        name: 'ember-3.13.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.13',
            'ember-data': '~3.13'
          }
        }
      },
      {
        name: 'ember-3.14.0',
        npm: {
          devDependencies: {
            'ember-source': '~3.14',
            'ember-data': '~3.14'
          }
        }
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': releaseUrl,
            'ember-data': 'latest',
          }
        }
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': betaUrl,
            'ember-data': 'beta',
          }
        }
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': canaryUrl,
            'ember-data': 'canary',
          }
        }
      },
      {
        name: 'ember-default',
        npm: {
          devDependencies: {}
        }
      }]
    };
  });
};
<commit_msg>fix code style<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary')
  ])
    .then((urls) => {
      const [releaseUrl, betaUrl, canaryUrl] = urls;

      return {
        useYarn: true,
        scenarios: [
          {
            name: 'ember-3.5.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.5',
                'ember-data': '~3.5'
              }
            }
          },
          {
            name: 'ember-3.6.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.6',
                'ember-data': '~3.6'
              }
            }
          },
          {
            name: 'ember-3.7.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.7',
                'ember-data': '~3.7'
              }
            }
          },
          {
            name: 'ember-3.8.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.8',
                'ember-data': '~3.8'
              }
            }
          },
          {
            name: 'ember-3.9.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.9',
                'ember-data': '~3.9'
              }
            }
          },
          {
            name: 'ember-3.10.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.10',
                'ember-data': '~3.10'
              }
            }
          },
          {
            name: 'ember-3.11.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.11',
                'ember-data': '~3.11'
              }
            }
          },
          {
            name: 'ember-3.12.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.12',
                'ember-data': '~3.12'
              }
            }
          },
          {
            name: 'ember-3.13.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.13',
                'ember-data': '~3.13'
              }
            }
          },
          {
            name: 'ember-3.14.0',
            npm: {
              devDependencies: {
                'ember-source': '~3.14',
                'ember-data': '~3.14'
              }
            }
          },
          {
            name: 'ember-release',
            npm: {
              devDependencies: {
                'ember-source': releaseUrl,
                'ember-data': 'latest'
              }
            }
          },
          {
            name: 'ember-beta',
            npm: {
              devDependencies: {
                'ember-source': betaUrl,
                'ember-data': 'beta'
              }
            }
          },
          {
            name: 'ember-canary',
            npm: {
              devDependencies: {
                'ember-source': canaryUrl,
                'ember-data': 'canary'
              }
            }
          },
          {
            name: 'ember-default',
            npm: {
              devDependencies: {}
            }
          }]
      };
    });
};
<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary'),
  ]).then(urls => {
    let env = {
      EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': false }),
    };

    return {
      useYarn: true,
      scenarios: [
        {
          name: 'ember-2.0',
          env,
          bower: {
            dependencies: {
              ember: '~2.0.0',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.4',
          env,
          bower: {
            dependencies: {
              ember: 'components/ember#lts-2-4',
            },
            resolutions: {
              ember: 'lts-2-4',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.8',
          env,
          bower: {
            dependencies: {
              ember: 'components/ember#lts-2-8',
            },
            resolutions: {
              ember: 'lts-2-8',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.12',
          env,
          npm: {
            devDependencies: {
              'ember-source': '~2.12.0',
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.16',
          env,
          npm: {
            devDependencies: {
              'ember-source': '~2.16.0-beta.1',
              'ember-native-dom-event-dispatcher': '^0.6.4',
            },
          },
        },
        {
          name: 'ember-release',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[0],
            },
          },
        },
        {
          name: 'ember-beta',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[1],
            },
          },
        },
        {
          name: 'ember-canary',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[2],
            },
          },
        },
        {
          name: 'ember-without-application-wrapper',
          env: Object.assign({}, env, {
            EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'application-template-wrapper': false }),
          }),
          npm: {
            devDependencies: {
              'ember-source': urls[2],
            },
          },
        },
        {
          name: 'ember-default-with-jquery',
          env: Object.assign({}, env, {
            EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }),
          }),
          npm: {
            devDependencies: {
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-default',
          env,
          npm: {
            devDependencies: {},
          },
        },
      ],
    };
  });
};
<commit_msg>Fix dependencies for some older scenarios<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
  return Promise.all([
    getChannelURL('release'),
    getChannelURL('beta'),
    getChannelURL('canary'),
  ]).then(urls => {
    let env = {
      EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': false }),
    };

    return {
      useYarn: true,
      scenarios: [
        {
          name: 'ember-2.0',
          env,
          bower: {
            dependencies: {
              ember: '~2.0.0',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
              'ember-data': '~3.1.0',
            },
          },
        },
        {
          name: 'ember-lts-2.4',
          env,
          bower: {
            dependencies: {
              ember: 'components/ember#lts-2-4',
            },
            resolutions: {
              ember: 'lts-2-4',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.8',
          env,
          bower: {
            dependencies: {
              ember: 'components/ember#lts-2-8',
            },
            resolutions: {
              ember: 'lts-2-8',
            },
          },
          npm: {
            devDependencies: {
              'ember-source': null,
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.12',
          env,
          npm: {
            devDependencies: {
              '@ember/jquery': '^0.5.2',
              'ember-source': '~2.12.0',
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-lts-2.16',
          env,
          npm: {
            devDependencies: {
              'ember-source': '~2.16.0-beta.1',
              'ember-native-dom-event-dispatcher': '^0.6.4',
            },
          },
        },
        {
          name: 'ember-release',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[0],
            },
          },
        },
        {
          name: 'ember-beta',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[1],
            },
          },
        },
        {
          name: 'ember-canary',
          env,
          npm: {
            devDependencies: {
              'ember-source': urls[2],
            },
          },
        },
        {
          name: 'ember-without-application-wrapper',
          env: Object.assign({}, env, {
            EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'application-template-wrapper': false }),
          }),
          npm: {
            devDependencies: {
              'ember-source': urls[2],
            },
          },
        },
        {
          name: 'ember-default-with-jquery',
          env: Object.assign({}, env, {
            EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }),
          }),
          npm: {
            devDependencies: {
              'ember-fetch': null,
            },
          },
        },
        {
          name: 'ember-default',
          env,
          npm: {
            devDependencies: {},
          },
        },
      ],
    };
  });
};
<|endoftext|>


<commit_before>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = async function() {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.12',
        npm: {
          devDependencies: {
            'ember-source': '~3.12.0'
          }
        }
      },
      {
        name: 'ember-lts-3.16',
        npm: {
          devDependencies: {
            'ember-source': '~3.16.0'
          }
        }
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release')
          }
        }
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta')
          }
        }
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary')
          }
        }
      },
      // The default `.travis.yml` runs this scenario via `yarn test`,
      // not via `ember try`. It's still included here so that running
      // `ember try:each` manually or from a customized CI config will run it
      // along with all the other scenarios.
      {
        name: 'ember-default',
        npm: {
          devDependencies: {}
        }
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true
          })
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^0.5.1'
          }
        }
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false
          })
        },
        npm: {
          ember: {
            edition: 'classic'
          }
        }
      }
    ]
  };
};
<commit_msg>Test Different ember-data Versions<commit_after>'use strict';

const getChannelURL = require('ember-source-channel-url');

module.exports = async function() {
  return {
    useYarn: true,
    scenarios: [
      {
        name: 'ember-lts-3.12',
        npm: {
          devDependencies: {
            'ember-source': '~3.12.0',
            'ember-data': '~3.12.0'
          }
        }
      },
      {
        name: 'ember-lts-3.16',
        npm: {
          devDependencies: {
            'ember-source': '~3.16.0',
            'ember-data': '~3.16.0'
          }
        }
      },
      {
        name: 'ember-release',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('release'),
            'ember-data': await getChannelURL('release')
          }
        }
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta'),
            'ember-data': await getChannelURL('beta')
          }
        }
      },
      {
        name: 'ember-canary',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('canary'),
            'ember-data': await getChannelURL('canary')
          }
        }
      },
      // The default `.travis.yml` runs this scenario via `yarn test`,
      // not via `ember try`. It's still included here so that running
      // `ember try:each` manually or from a customized CI config will run it
      // along with all the other scenarios.
      {
        name: 'ember-default',
        npm: {
          devDependencies: {}
        }
      },
      {
        name: 'ember-default-with-jquery',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'jquery-integration': true
          })
        },
        npm: {
          devDependencies: {
            '@ember/jquery': '^0.5.1'
          }
        }
      },
      {
        name: 'ember-classic',
        env: {
          EMBER_OPTIONAL_FEATURES: JSON.stringify({
            'application-template-wrapper': true,
            'default-async-observers': false,
            'template-only-glimmer-components': false
          })
        },
        npm: {
          ember: {
            edition: 'classic'
          }
        }
      }
    ]
  };
};
<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = {
  scenarios: [
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<commit_msg>Use Yarn with ember-try<commit_after>/* eslint-env node */
module.exports = {
  useYarn: true,
  scenarios: [
    {
      name: 'ember-lts-2.8',
      bower: {
        dependencies: {
          'ember': 'components/ember#lts-2-8'
        },
        resolutions: {
          'ember': 'lts-2-8'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-lts-2.12',
      npm: {
        devDependencies: {
          'ember-source': '~2.12.0'
        }
      }
    },
    {
      name: 'ember-release',
      bower: {
        dependencies: {
          'ember': 'components/ember#release'
        },
        resolutions: {
          'ember': 'release'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-beta',
      bower: {
        dependencies: {
          'ember': 'components/ember#beta'
        },
        resolutions: {
          'ember': 'beta'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-canary',
      bower: {
        dependencies: {
          'ember': 'components/ember#canary'
        },
        resolutions: {
          'ember': 'canary'
        }
      },
      npm: {
        devDependencies: {
          'ember-source': null
        }
      }
    },
    {
      name: 'ember-default',
      npm: {
        devDependencies: {}
      }
    }
  ]
};
<|endoftext|>


<commit_before>var p = Ent.Project.create("vault", "external");
p.setVersion(2, 0, 0);

function getVersionString() {
    var v = p.version;
    return "set version := \"" + [v.major, v.minor, v.point, v.buildNumber].join(".") + "\"";
}

p.setConfig({
    command: ["./sbt", getVersionString, "clean", "update", "compile", "test", "package"],
    dist: "target/scala-2.9.1",
    distInclude: "*.jar"
});

<commit_msg>scala version<commit_after>var p = Ent.Project.create("vault", "external");
p.setVersion(2, 0, 0);

function getVersionString() {
    var v = p.version;
    return "set version := \"" + [v.major, v.minor, v.point, v.buildNumber].join(".") + "\"";
}

p.setConfig({
    command: ["./sbt", getVersionString, "clean", "update", "compile", "test", "package"],
    dist: "target/scala-2.9.2",
    distInclude: "*.jar"
});

<|endoftext|>


<commit_before>(function() {
  var φ = 1.618033988749895,
      ρ = 180 / Math.PI;

  var vertices = [
    [1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0],
    [0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ],
    [φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1]
  ];

  var triangles = [
    [0,1,4],  [1,9,4],  [4,9,5],  [5,9,3],  [2,3,7],
    [3,2,5],  [7,10,2], [0,8,10], [0,4,8],  [8,2,10],
    [8,4,5],  [8,5,2],  [1,0,6],  [11,1,6], [3,9,11],
    [6,10,7], [3,11,7], [11,6,7], [6,0,10], [9,1,11]
  ].map(function(triangle) {
    return triangle.map(function(i) {
      return vertices[i];
    });
  });

  d3.geodesic = {
    multipolygon: function(n) {
      return {
        type: "MultiPolygon",
        coordinates: geodesic(~~n).map(function(triangle) {
          triangle = triangle.map(project);
          triangle.push(triangle[2]);
          return [triangle];
        })
      };
    },
    polygons: function(n) {
      return geodesic(~~n).map(function(triangle) {
        triangle = triangle.map(project);
        triangle.push(triangle[2]);
        return {type: "Polygon", coordinates: [triangle]};
      });
    }
  };

  function geodesic(n) {
    return d3.merge(triangles.map(function(triangle) {
      var i01 = interpolate(triangle[0], triangle[1]),
          i02 = interpolate(triangle[0], triangle[2]),
          triangles = [];

      triangles.push([
        triangle[0],
        i01(1 / n),
        i02(1 / n)
      ]);

      for (var i = 1; i < n; ++i) {
        var i1 = interpolate(i01(i / n), i02(i / n)),
            i2 = interpolate(i01((i + 1) / n), i02((i + 1) / n));
        for (var j = 0; j <= i; ++j) {
          triangles.push([
            i1(j / i),
            i2(j / (i + 1)),
            i2((j + 1) / (i + 1))
          ]);
        }
        for (var j = 0; j < i; ++j) {
          triangles.push([
            i1(j / i),
            i1((j + 1) / i),
            i2((j + 1) / (i + 1))
          ]);
        }
      }

      return triangles;
    }));
  }

  function interpolate(p0, p1) {
    var x0 = p0[0],
        y0 = p0[1],
        z0 = p0[2],
        x1 = p1[0] - x0,
        y1 = p1[1] - y0,
        z1 = p1[2] - z0;
    return function(t) {
      return [
        x0 + t * x1,
        y0 + t * y1,
        z0 + t * z1
      ];
    };
  }

  function project(p) {
    var x = p[0],
        y = p[1],
        z = p[2];
    return [
      Math.atan2(y, x) * ρ,
      Math.acos(z / Math.sqrt(x * x + y * y + z * z)) * ρ - 90
    ];
  }
})();
<commit_msg>Add geodesic.multilinestring.<commit_after>(function() {
  var φ = 1.618033988749895,
      ρ = 180 / Math.PI;

  var vertices = [
    [1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0],
    [0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ],
    [φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1]
  ];

  var faces = [
    [0,1,4],  [1,9,4],  [4,9,5],  [5,9,3],  [2,3,7],
    [3,2,5],  [7,10,2], [0,8,10], [0,4,8],  [8,2,10],
    [8,4,5],  [8,5,2],  [1,0,6],  [11,1,6], [3,9,11],
    [6,10,7], [3,11,7], [11,6,7], [6,0,10], [9,1,11]
  ].map(function(face) {
    return face.map(function(i) {
      return vertices[i];
    });
  });

  d3.geodesic = {
    multipolygon: function(n) {
      return {
        type: "MultiPolygon",
        coordinates: subdivideFaces(~~n).map(function(face) {
          face = face.map(project);
          face.push(face[2]);
          return [face];
        })
      };
    },
    polygons: function(n) {
      return d3.geodesic.multipolygon(~~n).coordinates.map(function(face) {
        return {type: "Polygon", coordinates: face};
      });
    },
    multilinestring: function(n) {
      return {
        type: "MultiLineString",
        coordinates: subdivideEdges(~~n).map(function(edge) {
          return edge.map(project);
        })
      };
    }
  };

  function subdivideFaces(n) {
    return d3.merge(faces.map(function(face) {
      var i01 = interpolate(face[0], face[1]),
          i02 = interpolate(face[0], face[2]),
          faces = [];

      faces.push([
        face[0],
        i01(1 / n),
        i02(1 / n)
      ]);

      for (var i = 1; i < n; ++i) {
        var i1 = interpolate(i01(i / n), i02(i / n)),
            i2 = interpolate(i01((i + 1) / n), i02((i + 1) / n));
        for (var j = 0; j <= i; ++j) {
          faces.push([
            i1(j / i),
            i2(j / (i + 1)),
            i2((j + 1) / (i + 1))
          ]);
        }
        for (var j = 0; j < i; ++j) {
          faces.push([
            i1(j / i),
            i1((j + 1) / i),
            i2((j + 1) / (i + 1))
          ]);
        }
      }

      return faces;
    }));
  }

  function subdivideEdges(n) {
    var edges = {};

    subdivideFaces(n).forEach(function(face) {
      add(face[0], face[1]);
      add(face[1], face[2]);
      add(face[2], face[0]);
    });

    function add(p0, p1) {
      var t;
      if (p0[0] < p1[0] || (p0[0] == p1[0] && (p0[1] < p1[1] || (p0[1] == p1[1] && p0[2] < p1[2])))) t = p0, p0 = p1, p1 = t;
      edges[p0.map(round) + " " + p1.map(round)] = [p0, p1];
    }

    function round(d) {
      return d3.round(d, 4);
    }

    return d3.values(edges);
  }

  function interpolate(p0, p1) {
    var x0 = p0[0],
        y0 = p0[1],
        z0 = p0[2],
        x1 = p1[0] - x0,
        y1 = p1[1] - y0,
        z1 = p1[2] - z0;
    return function(t) {
      return [
        x0 + t * x1,
        y0 + t * y1,
        z0 + t * z1
      ];
    };
  }

  function project(p) {
    var x = p[0],
        y = p[1],
        z = p[2];
    return [
      Math.atan2(y, x) * ρ,
      Math.acos(z / Math.sqrt(x * x + y * y + z * z)) * ρ - 90
    ];
  }
})();
<|endoftext|>


<commit_before>// controller for start/end inputs
app.controller('inputsController', '$http', ['$scope', function($scope, $http) {
  $scope.start // start location input
  $scope.end // end location input
  $scope.submit = $http({
    method: 'POST',
    url: '/maps/submit',
    data: {
      start: $scope.start,
      end: $scope.end
    }
  })
}]);<commit_msg>client side submit button properly makes post request to server<commit_after>// controller for start/end inputs
app.controller('inputsController', ['$scope', '$http', function($scope, $http) {
  $scope.start // start location input
  $scope.end // end location input
  $scope.submit = $http({
    method: 'POST',
    url: '/maps/submit',
    data: {
      start: $scope.start,
      end: $scope.end
    }
  }).then((data) => {
    console.log('Returned data: ', data);
  }).catch((err) => {
    console.log('Error submitting: ', err);
  })
}]);<|endoftext|>