<commit_before>// Copyright 2013-2020, University of Colorado Boulder

/**
 * The view portion of a Screen, specifies the layout strategy for the visual view.
 *
 * For the PDOM view, this type creates  the three organizing elements associated with each screen:
 * - The `ScreenSummaryNode` is introductory description that outlines the screen and sets the scene for the user.
 * - The `PlayAreaNode` holds content that is considered the main interaction and pedigogy to be learned from the screen.
 * - The `ControlAreaNode` houses controls and other content that is secondary to the main interaction. Ideally the user
 *       would encounter this after exploring the PlayAreaNode.
 * The screenSummaryNode instance is not available on the ScreenView, instead content can be added to it via a constructor
 * option or `ScreenView.setScreenSummaryContent`. This is because some accessible descriptions in the screen summary
 * are the same throughout all simulations. The playAreaNode and controlAreaNode instances are public, read-only Nodes
 * that are meant to have their accessibleOrder and children set to achieve the proper PDOM structure. Do not set
 * `accessibleOrder` directly on the ScreenView, as ScreenView set's its own accessibleOrder
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */

import Property from '../../axon/js/Property.js';
import Bounds2 from '../../dot/js/Bounds2.js';
import inherit from '../../phet-core/js/inherit.js';
import merge from '../../phet-core/js/merge.js';
import ControlAreaNode from '../../scenery-phet/js/accessibility/nodes/ControlAreaNode.js';
import PlayAreaNode from '../../scenery-phet/js/accessibility/nodes/PlayAreaNode.js';
import ScreenSummaryNode from '../../scenery-phet/js/accessibility/nodes/ScreenSummaryNode.js';
import Node from '../../scenery/js/nodes/Node.js';
import Tandem from '../../tandem/js/Tandem.js';
import joist from './joist.js';

/*
 * Default width and height for iPad2, iPad3, iPad4 running Safari with default tabs and decorations
 * These bounds were added in Sep 2014 and are based on a screenshot from a non-Retina iPad, in Safari, iOS7.
 * It therefore accounts for the nav bar on the bottom and the space consumed by the browser on the top.
 * As of this writing, this is the resolution being used by PhET's sim designers for their mockups.
 * For more information see https://github.com/phetsims/joist/issues/126
 */
const DEFAULT_LAYOUT_BOUNDS = new Bounds2( 0, 0, 1024, 618 );

function ScreenView( options ) {

  options = merge( {

    // {Bounds2} the bounds that are safe to draw in on all supported platforms
    layoutBounds: DEFAULT_LAYOUT_BOUNDS.copy(),

    // Node options
    layerSplit: true, // so we're not in the same layer as the navbar, etc.
    excludeInvisible: true, // so we don't keep invisible screens in the SVG tree

    // phet-io options
    tandem: Tandem.OPTIONAL,

    // a11y options
    containerTagName: 'article',
    tagName: 'div',
    labelTagName: 'h1',

    // {Node|null} the Node with screen summary content to be added to the ScreenSummaryNode, and into PDOM above
    // the Play Area. This Node is added as a child to the ScreenSummaryNode.
    screenSummaryContent: null

  }, options );

  // @public (read-only) {Bounds2} - the bounds the confine the layout of the view.
  assert && assert( options.layoutBounds instanceof Bounds2, 'invalid layoutBounds' );
  this.layoutBounds = options.layoutBounds;

  Node.call( this, options );

  // The visible bounds of the ScreenView in ScreenView coordinates.  This includes top/bottom or left/right margins
  // depending on the aspect ratio of the screen.
  // Initialize to defaults, then update as soon as layout() is called, which is before the ScreenView is displayed
  // @public (read-only)
  this.visibleBoundsProperty = new Property( options.layoutBounds );

  // @public (read-only) - add children and set accessible order to these to organize and structure the PDOM.
  this.pdomPlayAreaNode = new PlayAreaNode();
  this.pdomControlAreaNode = new ControlAreaNode();

  // @private
  // a11y - this Node is suffixed "container" because it is added to with sim specific screen summary content, often
  // called {Sim}ScreenSummaryNode. This container has the intro "{sim} is an interactive sim, it changes as you . . ."
  this.pdomScreenSummaryNode = new ScreenSummaryNode();

  // @private {Node|null} - keep track of the content added to the summary Node, so that if it is set more than once,
  // the previous one can be removed.
  this.screenSummaryContent = null;

  // at the Node from options in the same way that can be done at any time
  options.screenSummaryContent && this.setScreenSummaryContent( options.screenSummaryContent );

  // @private
  this.pdomParent = new Node( {
    children: [
      this.pdomScreenSummaryNode,
      this.pdomPlayAreaNode,
      this.pdomControlAreaNode
    ]
  } );
  this.addChild( this.pdomParent );
}

joist.register( 'ScreenView', ScreenView );

export default inherit( Node, ScreenView, {

    /**
     * Override to make sure that setting children doesn't blow away Nodes set by ScreenView.
     * @override
     * @param {Node[]} children
     */
    setChildren( children ) {
      Node.prototype.setChildren.call( this, children );
      if ( !this.hasChild( this.pdomParent ) ) {
        this.addChild( this.pdomParent );
        this.pdomParent.moveToBack();
      }
    },

    /**
     * Get the scale to use for laying out the sim components and the navigation bar, so its size will track
     * with the sim size
     * @param {number} width
     * @param {number} height
     * @returns {number}
     * @public (joist-internal)
     */
    getLayoutScale: function( width, height ) {
      return Math.min( width / this.layoutBounds.width, height / this.layoutBounds.height );
    },

    /**
     * Default layout function uses the layoutWidth and layoutHeight to scale the content (based on whichever is more limiting: width or height)
     * and centers the content in the screen vertically and horizontally
     * This function can be replaced by subclasses that wish to perform their own custom layout.
     * @param {number} width
     * @param {number} height
     * @public (joist-internal)
     */
    layout: function( width, height ) {
      this.resetTransform();

      const scale = this.getLayoutScale( width, height );
      this.setScaleMagnitude( scale );

      let dx = 0;
      let dy = 0;

      //center vertically
      if ( scale === width / this.layoutBounds.width ) {
        dy = ( height / scale - this.layoutBounds.height ) / 2;
      }

      //center horizontally
      else if ( scale === height / this.layoutBounds.height ) {
        dx = ( width / scale - this.layoutBounds.width ) / 2;
      }

      this.translate( dx, dy );

      this.visibleBoundsProperty.set( new Bounds2( -dx, -dy, width / scale - dx, height / scale - dy ) );
    },

    /**
     * Make screen view eligible for garbage collection.
     * @public
     */
    dispose: function() {
      Node.prototype.dispose.call( this );
      this.disposeScreenView();
    },

    /**
     * Set the screen summary Node for the PDOM of this Screen View. Prefer passing in a screen summary Node via
     * constructor options, but this method can be used directly when necessary.
     * @param {Node} node
     * @public
     */
    setScreenSummaryContent: function( node ) {
      assert && assert( node instanceof Node );
      assert && assert( node !== this.screenSummaryContent, 'this is already the screen summary node content' );

      this.screenSummaryContent && this.pdomScreenSummaryNode.removeChild( this.screenSummaryContent );

      this.screenSummaryContent = node;
      this.pdomScreenSummaryNode.addChild( node );
    },

    /**
     * Set the screen summary Node intro string
     * @param {string} simName
     * @param {number} numberOfScreens
     * @public (joist-internal)
     */
    setScreenSummaryIntroString: function( simName, numberOfScreens ) {
      this.pdomScreenSummaryNode.setIntroString( simName, numberOfScreens );
    },

    set accessibleOrder( order ) { throw new Error( 'should not need to set accessible order on the screen view' ); }
  },

  //statics
  {
    // @public
    DEFAULT_LAYOUT_BOUNDS: DEFAULT_LAYOUT_BOUNDS
  }
);<commit_msg>exclude ScreenView.visibleProperty from phetioState, https://github.com/phetsims/studio/issues/109<commit_after>// Copyright 2013-2020, University of Colorado Boulder

/**
 * The view portion of a Screen, specifies the layout strategy for the visual view.
 *
 * For the PDOM view, this type creates  the three organizing elements associated with each screen:
 * - The `ScreenSummaryNode` is introductory description that outlines the screen and sets the scene for the user.
 * - The `PlayAreaNode` holds content that is considered the main interaction and pedigogy to be learned from the screen.
 * - The `ControlAreaNode` houses controls and other content that is secondary to the main interaction. Ideally the user
 *       would encounter this after exploring the PlayAreaNode.
 * The screenSummaryNode instance is not available on the ScreenView, instead content can be added to it via a constructor
 * option or `ScreenView.setScreenSummaryContent`. This is because some accessible descriptions in the screen summary
 * are the same throughout all simulations. The playAreaNode and controlAreaNode instances are public, read-only Nodes
 * that are meant to have their accessibleOrder and children set to achieve the proper PDOM structure. Do not set
 * `accessibleOrder` directly on the ScreenView, as ScreenView set's its own accessibleOrder
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */

import Property from '../../axon/js/Property.js';
import Bounds2 from '../../dot/js/Bounds2.js';
import inherit from '../../phet-core/js/inherit.js';
import merge from '../../phet-core/js/merge.js';
import ControlAreaNode from '../../scenery-phet/js/accessibility/nodes/ControlAreaNode.js';
import PlayAreaNode from '../../scenery-phet/js/accessibility/nodes/PlayAreaNode.js';
import ScreenSummaryNode from '../../scenery-phet/js/accessibility/nodes/ScreenSummaryNode.js';
import Node from '../../scenery/js/nodes/Node.js';
import PhetioObject from '../../tandem/js/PhetioObject.js';
import Tandem from '../../tandem/js/Tandem.js';
import joist from './joist.js';

/*
 * Default width and height for iPad2, iPad3, iPad4 running Safari with default tabs and decorations
 * These bounds were added in Sep 2014 and are based on a screenshot from a non-Retina iPad, in Safari, iOS7.
 * It therefore accounts for the nav bar on the bottom and the space consumed by the browser on the top.
 * As of this writing, this is the resolution being used by PhET's sim designers for their mockups.
 * For more information see https://github.com/phetsims/joist/issues/126
 */
const DEFAULT_LAYOUT_BOUNDS = new Bounds2( 0, 0, 1024, 618 );

function ScreenView( options ) {

  options = merge( {

    // {Bounds2} the bounds that are safe to draw in on all supported platforms
    layoutBounds: DEFAULT_LAYOUT_BOUNDS.copy(),

    // Node options
    layerSplit: true, // so we're not in the same layer as the navbar, etc.
    excludeInvisible: true, // so we don't keep invisible screens in the SVG tree

    // phet-io options
    tandem: Tandem.OPTIONAL,

    // a11y options
    containerTagName: 'article',
    tagName: 'div',
    labelTagName: 'h1',

    // {Node|null} the Node with screen summary content to be added to the ScreenSummaryNode, and into PDOM above
    // the Play Area. This Node is added as a child to the ScreenSummaryNode.
    screenSummaryContent: null

  }, options );

  // @public (read-only) {Bounds2} - the bounds the confine the layout of the view.
  assert && assert( options.layoutBounds instanceof Bounds2, 'invalid layoutBounds' );
  this.layoutBounds = options.layoutBounds;

  PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioState: false } }, options );

  Node.call( this, options );

  // The visible bounds of the ScreenView in ScreenView coordinates.  This includes top/bottom or left/right margins
  // depending on the aspect ratio of the screen.
  // Initialize to defaults, then update as soon as layout() is called, which is before the ScreenView is displayed
  // @public (read-only)
  this.visibleBoundsProperty = new Property( options.layoutBounds );

  // @public (read-only) - add children and set accessible order to these to organize and structure the PDOM.
  this.pdomPlayAreaNode = new PlayAreaNode();
  this.pdomControlAreaNode = new ControlAreaNode();

  // @private
  // a11y - this Node is suffixed "container" because it is added to with sim specific screen summary content, often
  // called {Sim}ScreenSummaryNode. This container has the intro "{sim} is an interactive sim, it changes as you . . ."
  this.pdomScreenSummaryNode = new ScreenSummaryNode();

  // @private {Node|null} - keep track of the content added to the summary Node, so that if it is set more than once,
  // the previous one can be removed.
  this.screenSummaryContent = null;

  // at the Node from options in the same way that can be done at any time
  options.screenSummaryContent && this.setScreenSummaryContent( options.screenSummaryContent );

  // @private
  this.pdomParent = new Node( {
    children: [
      this.pdomScreenSummaryNode,
      this.pdomPlayAreaNode,
      this.pdomControlAreaNode
    ]
  } );
  this.addChild( this.pdomParent );
}

joist.register( 'ScreenView', ScreenView );

export default inherit( Node, ScreenView, {

    /**
     * Override to make sure that setting children doesn't blow away Nodes set by ScreenView.
     * @override
     * @param {Node[]} children
     */
    setChildren( children ) {
      Node.prototype.setChildren.call( this, children );
      if ( !this.hasChild( this.pdomParent ) ) {
        this.addChild( this.pdomParent );
        this.pdomParent.moveToBack();
      }
    },

    /**
     * Get the scale to use for laying out the sim components and the navigation bar, so its size will track
     * with the sim size
     * @param {number} width
     * @param {number} height
     * @returns {number}
     * @public (joist-internal)
     */
    getLayoutScale: function( width, height ) {
      return Math.min( width / this.layoutBounds.width, height / this.layoutBounds.height );
    },

    /**
     * Default layout function uses the layoutWidth and layoutHeight to scale the content (based on whichever is more limiting: width or height)
     * and centers the content in the screen vertically and horizontally
     * This function can be replaced by subclasses that wish to perform their own custom layout.
     * @param {number} width
     * @param {number} height
     * @public (joist-internal)
     */
    layout: function( width, height ) {
      this.resetTransform();

      const scale = this.getLayoutScale( width, height );
      this.setScaleMagnitude( scale );

      let dx = 0;
      let dy = 0;

      //center vertically
      if ( scale === width / this.layoutBounds.width ) {
        dy = ( height / scale - this.layoutBounds.height ) / 2;
      }

      //center horizontally
      else if ( scale === height / this.layoutBounds.height ) {
        dx = ( width / scale - this.layoutBounds.width ) / 2;
      }

      this.translate( dx, dy );

      this.visibleBoundsProperty.set( new Bounds2( -dx, -dy, width / scale - dx, height / scale - dy ) );
    },

    /**
     * Make screen view eligible for garbage collection.
     * @public
     */
    dispose: function() {
      Node.prototype.dispose.call( this );
      this.disposeScreenView();
    },

    /**
     * Set the screen summary Node for the PDOM of this Screen View. Prefer passing in a screen summary Node via
     * constructor options, but this method can be used directly when necessary.
     * @param {Node} node
     * @public
     */
    setScreenSummaryContent: function( node ) {
      assert && assert( node instanceof Node );
      assert && assert( node !== this.screenSummaryContent, 'this is already the screen summary node content' );

      this.screenSummaryContent && this.pdomScreenSummaryNode.removeChild( this.screenSummaryContent );

      this.screenSummaryContent = node;
      this.pdomScreenSummaryNode.addChild( node );
    },

    /**
     * Set the screen summary Node intro string
     * @param {string} simName
     * @param {number} numberOfScreens
     * @public (joist-internal)
     */
    setScreenSummaryIntroString: function( simName, numberOfScreens ) {
      this.pdomScreenSummaryNode.setIntroString( simName, numberOfScreens );
    },

    set accessibleOrder( order ) { throw new Error( 'should not need to set accessible order on the screen view' ); }
  },

  //statics
  {
    // @public
    DEFAULT_LAYOUT_BOUNDS: DEFAULT_LAYOUT_BOUNDS
  }
);<|endoftext|>


<commit_before>/**
 * Created by soheil on 02/08/2016.
 */

WebService = Class.create({

	initialize: function () {
		this._settings = new Settings();
		this._baseURL = this._settings.getSetting('codingDefinitionServiceEndpoint');
	},

	getOmimLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/OMIMLookupService?";
	},

	getIcd10LookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/ICDLookupService?";
	},

	getSnomedCTLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/SNOMEDCTLookupService?";
	},

	getGELLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/DiseaseList?";
	},

	getEthnicityLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/Ethnicity?";
	},

	getHPOLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/OntologyService/LookupService?";
	},

	getDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath =  _this.getUrlParameter("accessPath", true);
				return accessPath;
				break;
			case "openclinica":
				var eventCRFId = this.getUrlParameter("eventCRFId");
				var status = this.getUrlParameter("status");
				var participantId = this.getUrlParameter("participantId");
				return "/openclinica/pedigree/get?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	saveDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath    = _this.getUrlParameter("accessPath");
				var participantId = _this.getParticipantIdFromURL();
				return "???";
				break;
			case "openclinica":
				var _this = this;
				var eventCRFId = _this.getUrlParameter("eventCRFId");
				var status = _this.getUrlParameter("status");
				var participantId = _this.getUrlParameter("participantId");
				return "/openclinica/pedigree/update?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getUrlParameter: function getUrlParameter(sParam, doNotDecode) {

		var sPageURL = decodeURIComponent(window.location.search.substring(1));
		if(doNotDecode && doNotDecode == true){
			sPageURL = window.location.search.substring(1);
		}

		var	sURLVariables = sPageURL.split('&')
		var	sParameterName;
		var	i;

		for (i = 0; i < sURLVariables.length; i++) {
			sParameterName = sURLVariables[i].split('=');

			if (sParameterName[0] === sParam) {
				return sParameterName[1] === undefined ? true : sParameterName[1];
			}
		}
	},

	getParticipantIdFromURL: function(){
		var index =  window.location.pathname.length;
		if(index > 1) {
			return window.location.pathname[index - 1];
		}
		return "";
	}

});<commit_msg>Add a method to get path to js files on server through the URL<commit_after>/**
 * Created by soheil on 02/08/2016.
 */

WebService = Class.create({

	initialize: function () {
		this._settings = new Settings();
		this._baseURL = this._settings.getSetting('codingDefinitionServiceEndpoint');
	},

	getOmimLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/OMIMLookupService?";
	},

	getIcd10LookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/ICDLookupService?";
	},

	getSnomedCTLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/SNOMEDCTLookupService?";
	},

	getGELLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/DiseaseList?";
	},

	getEthnicityLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/lookupServices/Ethnicity?";
	},

	getHPOLookupPath: function(){
		var endpoint = this._baseURL ? this._baseURL : this._settings.getSetting('codingDefinitionServiceEndpoint');
		return endpoint + "/OntologyService/LookupService?";
	},

	getDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath =  _this.getUrlParameter("accessPath", true);
				return accessPath;
				break;
			case "openclinica":
				var eventCRFId = this.getUrlParameter("eventCRFId");
				var status = this.getUrlParameter("status");
				var participantId = this.getUrlParameter("participantId");
				return "/openclinica/pedigree/get?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getPathToEditorFiles: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				return "";
				break;
			case "openclinica":
				//get path to pedigree directory like :
				//"http://localhost:8083/openclinica/includes/pedigreeEditor/" or
				//"https://gmc.genomicsengland.nhs.uk/rarediseases/demo/includes/pedigreeEditor/"
				return Helpers.getSiteURL() + "/includes/pedigreeEditor/";
			case "local":
				return Helpers.getSiteURL() + "/";
		}
	},

	saveDiagramEndpointPath: function(){
		var config = this._settings.getSetting('diagramEndpoint');
		switch(config.service){
			case "mercury":
				var _this = this;
				var accessPath    = _this.getUrlParameter("accessPath");
				var participantId = _this.getParticipantIdFromURL();
				return "???";
				break;
			case "openclinica":
				var _this = this;
				var eventCRFId = _this.getUrlParameter("eventCRFId");
				var status = _this.getUrlParameter("status");
				var participantId = _this.getUrlParameter("participantId");
				return "/openclinica/pedigree/update?eventCRFId=" + eventCRFId + "&status=" + status + "&participantId=" + participantId;
			case "local":
				return null;
		}
	},

	getUrlParameter: function getUrlParameter(sParam, doNotDecode) {

		var sPageURL = decodeURIComponent(window.location.search.substring(1));
		if(doNotDecode && doNotDecode == true){
			sPageURL = window.location.search.substring(1);
		}

		var	sURLVariables = sPageURL.split('&')
		var	sParameterName;
		var	i;

		for (i = 0; i < sURLVariables.length; i++) {
			sParameterName = sURLVariables[i].split('=');

			if (sParameterName[0] === sParam) {
				return sParameterName[1] === undefined ? true : sParameterName[1];
			}
		}
	},

	getParticipantIdFromURL: function(){
		var index =  window.location.pathname.length;
		if(index > 1) {
			return window.location.pathname[index - 1];
		}
		return "";
	}

});<|endoftext|>


<commit_before>$(document).ready(
  function() {
    console.log('ready');

    $('#evaluations-popup').popup({history: false});

    var model = new AppModel();
    var handModel = model.handModel;
    var $tbody = $("table#evaluations tbody")
    var $shapeRow = $tbody.find('tr.shape');
    var $totalRow = $tbody.find('tr.total');
    var $suitRow = {}
    handModel.suits().forEach(
        function(suit) {
            $suitRow[suit.short]=$tbody.find('tr.suit'+suit.short);
        }
    );

    var focusSpades = function() {
	$('input.holding#spades').focus();
    }

    var submitButton =  $('form#handentry input[type="submit"]');

    var setButtonLabel = function(buttonElement,label) {
	buttonElement.val(label)
	buttonElement.button('refresh')
    }

    var errorDiv = $('form#handentry .error');
    var setErrorState = function(label) {
	if (label == null) {
	    errorDiv.hide(0);
        } else {
	    errorDiv.text(label);
	    errorDiv.show(0);
	}
    }

    var disableSubmit= function(label) {
	submitButton.button('disable');
	setErrorState(label);
    };

    var clearModel = function(e) {
          handModel.clear();
          $('input.holding').val('');
          $('input.holding').removeClass('invalid');
	  disableSubmit(null);
	  focusSpades();
    };

    $('input.holding').bind("propertychange change click keyup input paste",
       function(event) {
         var $input = $(this);
         var $form = $(this.form)
         suitLabel = $input.data('suit');
         hString = $input.val().toUpperCase();
         if (hString != $input.val()) {
             $input.val(hString);
         }

         // if the string ends with 1, treat it as ending with 10, except when
         // exiting field, for purposes of validating entry inline
         if (hString.slice(-1)=='1' && event.type !='change' && event.type!='propertychange') {
             hString = hString+'0';
             appended = true;
         } else {
             appended = false;
         }

         var valid = handModel.setHolding(suitLabel,hString);
         if (!valid) {
           $input.addClass('invalid');
         } else {
           $input.removeClass('invalid');
         }

         if (handModel.isComplete() && !appended) {
	     submitButton.button('enable');
	     setErrorState(null);
         } else {
	     if (handModel.length<0) {
		 disableSubmit('Invalid');
	     } else if (appended) {
                 disableSubmit('Incomplete 10');
	     } else if (handModel.length==0) {
		 disableSubmit('Evaluate');
             } else {
		 disableSubmit(handModel.length.toString() + " cards");
	     }
         }
       }
    );

    var pageHandHash = function() {
        hash = window.location.hash;
        if (hash==null) {
            return hash;
        }
	return hash.split('&')[0]
    }

    window.onpopstate = function(event) {
        stateHash = handModel.urlHash()
        pageHash = pageHandHash()
	console.log(pageHash);
        if (stateHash==null) {
            if (pageHash != '') {
                initializeHash();
            }
        } else if (pageHash != '#' + stateHash) {
	    initializeHash();
        }
	return false;
    }
    var formPanel = $('#handForm');

    var handleSubmit = function() {
	formPanel.panel('close');
	var container = $('#evaluationscontainer');
	container.hide(250);

	window.location.hash = handModel.urlHash()
	var shape = handModel.shape();
	$shapeRow.find('.key').text(shape.short);
	handModel.suits().forEach(
            function (suit) {
		$suitRow[suit.short].find('.holding').text(handModel.text(suit));
	    }
        );

        var evaluations = model.evaluate();
        var toText = function(val) {
            if (val == null) {
                return "n/a";
            } else {
                return val;
            }
        }

        evaluations.forEach(
            function (evaluation) {
                var evalClass = '.' + evaluation['name'];
                var update = function(row,value) {
                    row.find(evalClass).html(toText(value));
                }

                update($shapeRow,evaluation.shape);
                update($totalRow,evaluation.total);
                handModel.suits().forEach(
                    function(suit) {
                        update($suitRow[suit.short],evaluation[suit.short])
                    }
                );
            }
         );

         container.finish();
         container.show('fast');
         jQuery.mobile.silentScroll(0);
     }

     var initializeHash=function() {
         hash = pageHandHash();
         clearModel();
         if (hash != '' && hash!='#' || hash!=null) {
            hStrings = hash.substring(1).split(',',4);
            map = {'S':'','H':'','D':'','C':'' }
            for (i=0; i<hStrings.length; i++) {
                suit = handModel.suits().entry(i).short;
                map[suit] = hStrings[i];
            }
            $('input.holding').each(
               function(index,entry) {
                   var $entry = $(entry);
                   $entry.val(map[$entry.data('suit')]);
                   $entry.triggerHandler('change');
               }
            );
            if (handModel.isComplete()) {
                handleSubmit();
		return;
            }
	 }
	 $('#handForm').panel('open');
	 $('#evaluationscontainer').hide(500);

     }

     initializeHash();

    $('#handentry').submit(
      function(e) {
        e.preventDefault();
        handleSubmit();
      }
    );

    $('input#clear').click(
       function (e) {
          clearModel();
       }
    );

    focusSpades();
  }
);

<commit_msg>Exit entry field when form is submitted to close keyboard<commit_after>$(document).ready(
  function() {
    console.log('ready');

    $('#evaluations-popup').popup({history: false});

    var model = new AppModel();
    var handModel = model.handModel;
    var $tbody = $("table#evaluations tbody")
    var $shapeRow = $tbody.find('tr.shape');
    var $totalRow = $tbody.find('tr.total');
    var $suitRow = {}
    handModel.suits().forEach(
        function(suit) {
            $suitRow[suit.short]=$tbody.find('tr.suit'+suit.short);
        }
    );

    var focusSpades = function() {
	$('input.holding#spades').focus();
    }

    var submitButton =  $('form#handentry input[type="submit"]');

    var setButtonLabel = function(buttonElement,label) {
	buttonElement.val(label)
	buttonElement.button('refresh')
    }

    var errorDiv = $('form#handentry .error');
    var setErrorState = function(label) {
	if (label == null) {
	    errorDiv.hide(0);
        } else {
	    errorDiv.text(label);
	    errorDiv.show(0);
	}
    }

    var disableSubmit= function(label) {
	submitButton.button('disable');
	setErrorState(label);
    };

    var clearModel = function(e) {
          handModel.clear();
          $('input.holding').val('');
          $('input.holding').removeClass('invalid');
	  disableSubmit(null);
	  focusSpades();
    };

    $('input.holding').bind("propertychange change click keyup input paste",
       function(event) {
         var $input = $(this);
         var $form = $(this.form)
         suitLabel = $input.data('suit');
         hString = $input.val().toUpperCase();
         if (hString != $input.val()) {
             $input.val(hString);
         }

         // if the string ends with 1, treat it as ending with 10, except when
         // exiting field, for purposes of validating entry inline
         if (hString.slice(-1)=='1' && event.type !='change' && event.type!='propertychange') {
             hString = hString+'0';
             appended = true;
         } else {
             appended = false;
         }

         var valid = handModel.setHolding(suitLabel,hString);
         if (!valid) {
           $input.addClass('invalid');
         } else {
           $input.removeClass('invalid');
         }

         if (handModel.isComplete() && !appended) {
	     submitButton.button('enable');
	     setErrorState(null);
         } else {
	     if (handModel.length<0) {
		 disableSubmit('Invalid');
	     } else if (appended) {
                 disableSubmit('Incomplete 10');
	     } else if (handModel.length==0) {
		 disableSubmit('Evaluate');
             } else {
		 disableSubmit(handModel.length.toString() + " cards");
	     }
         }
       }
    );

    var pageHandHash = function() {
        hash = window.location.hash;
        if (hash==null) {
            return hash;
        }
	return hash.split('&')[0]
    }

    window.onpopstate = function(event) {
        stateHash = handModel.urlHash()
        pageHash = pageHandHash()
	console.log(pageHash);
        if (stateHash==null) {
            if (pageHash != '') {
                initializeHash();
            }
        } else if (pageHash != '#' + stateHash) {
	    initializeHash();
        }
	return false;
    }
    var formPanel = $('#handForm');

    var handleSubmit = function() {
	$( document.activeElement ).blur();
	formPanel.panel('close');
	var container = $('#evaluationscontainer');
	container.hide(250);

	window.location.hash = handModel.urlHash()
	var shape = handModel.shape();
	$shapeRow.find('.key').text(shape.short);
	handModel.suits().forEach(
            function (suit) {
		$suitRow[suit.short].find('.holding').text(handModel.text(suit));
	    }
        );

        var evaluations = model.evaluate();
        var toText = function(val) {
            if (val == null) {
                return "n/a";
            } else {
                return val;
            }
        }

        evaluations.forEach(
            function (evaluation) {
                var evalClass = '.' + evaluation['name'];
                var update = function(row,value) {
                    row.find(evalClass).html(toText(value));
                }

                update($shapeRow,evaluation.shape);
                update($totalRow,evaluation.total);
                handModel.suits().forEach(
                    function(suit) {
                        update($suitRow[suit.short],evaluation[suit.short])
                    }
                );
            }
         );

         container.finish();
         container.show('fast');
         jQuery.mobile.silentScroll(0);
     }

     var initializeHash=function() {
         hash = pageHandHash();
         clearModel();
         if (hash != '' && hash!='#' || hash!=null) {
            hStrings = hash.substring(1).split(',',4);
            map = {'S':'','H':'','D':'','C':'' }
            for (i=0; i<hStrings.length; i++) {
                suit = handModel.suits().entry(i).short;
                map[suit] = hStrings[i];
            }
            $('input.holding').each(
               function(index,entry) {
                   var $entry = $(entry);
                   $entry.val(map[$entry.data('suit')]);
                   $entry.triggerHandler('change');
               }
            );
            if (handModel.isComplete()) {
                handleSubmit();
		return;
            }
	 }
	 $('#handForm').panel('open');
	 $('#evaluationscontainer').hide(500);

     }

     initializeHash();

    $('#handentry').submit(
      function(e) {
        e.preventDefault();
        handleSubmit();
      }
    );

    $('input#clear').click(
       function (e) {
          clearModel();
       }
    );

    focusSpades();
  }
);

<|endoftext|>


<commit_before>/**
 * Models for the Legislature Tracker app.
 */

(function($, w, undefined) {

  /**
   * Base Model for Open States items
   */
  LT.OSModel = Backbone.Model.extend({
    urlBase: function() {
      return 'http://openstates.org/api/v1/';
    },

    urlEnd: function() {
      return '/?apikey=' + encodeURI(this.options.apiKey) + '&callback=?';
    },

    url: function() {
      return this.urlBase() + '/' + encodeURI(this.osType) + '/' +
        encodeURI(this.id) + this.urlEnd();
    },

    initialize: function(attr, options) {
      this.options = options;

      this.on('sync', function(model, resp, options) {
        // Mark as fetched so we can use some caching
        model.set('fetched', true);
      });
    }
  });

  /**
   * Model for Open States Bill
   */
  LT.OSStateModel = LT.OSModel.extend({
    url: function() {
      return this.urlBase() + '/metadata/'  + encodeURI(this.options.state) +
        this.urlEnd();
    }
  });

  /**
   * Model for Open States Bill
   */
  LT.OSBillModel = LT.OSModel.extend({
    url: function() {
      if (!_.isUndefined(this.id)) {
        return this.urlBase() + '/bills/'  + this.id + this.urlEnd();
      }
      else {
        return this.urlBase() + '/bills/'  + encodeURI(this.options.state) + '/' +
          encodeURI(this.options.session) + '/' +
          encodeURI(this.get('bill_id')) + this.urlEnd();
      }
    }
  });

  /**
   * Model for Open States Legislator
   */
  LT.OSLegislatorModel = LT.OSModel.extend({
    osType: 'legislators'
  });

  /**
   * Model for Open States Committee
   */
  LT.OSCommitteeModel = LT.OSModel.extend({
    osType: 'committees'
  });

  /**
   * Model Legislature Tracker category
   */
  LT.CategoryModel = Backbone.Model.extend({
    initialize: function(attr, options) {
      this.options = options;
    },

    bills: function() {
      var thisModel = this;
      var bills = [];

      _.each(this.get('bills'), function(b) {
        bills.push(LT.utils.getModel('OSBillModel', 'bill_id', b, thisModel.options));
      });
      return bills;
    }
  });

})(jQuery, window);<commit_msg>Minor update to URL making.<commit_after>/**
 * Models for the Legislature Tracker app.
 */

(function($, w, undefined) {

  /**
   * Base Model for Open States items
   */
  LT.OSModel = Backbone.Model.extend({
    urlBase: function() {
      return 'http://openstates.org/api/v1/';
    },

    urlEnd: function() {
      return '/?apikey=' + encodeURI(this.options.apiKey) + '&callback=?';
    },

    url: function() {
      return this.urlBase() + encodeURI(this.osType) + '/' +
        encodeURI(this.id) + this.urlEnd();
    },

    initialize: function(attr, options) {
      this.options = options;

      this.on('sync', function(model, resp, options) {
        // Mark as fetched so we can use some caching
        model.set('fetched', true);
      });
    }
  });

  /**
   * Model for Open States Bill
   */
  LT.OSStateModel = LT.OSModel.extend({
    url: function() {
      return this.urlBase() + 'metadata/'  + encodeURI(this.options.state) +
        this.urlEnd();
    }
  });

  /**
   * Model for Open States Bill
   */
  LT.OSBillModel = LT.OSModel.extend({
    url: function() {
      if (!_.isUndefined(this.id)) {
        return this.urlBase() + 'bills/'  + this.id + this.urlEnd();
      }
      else {
        return this.urlBase() + 'bills/'  + encodeURI(this.options.state) + '/' +
          encodeURI(this.options.session) + '/' +
          encodeURI(this.get('bill_id')) + this.urlEnd();
      }
    }
  });

  /**
   * Model for Open States Legislator
   */
  LT.OSLegislatorModel = LT.OSModel.extend({
    osType: 'legislators'
  });

  /**
   * Model for Open States Committee
   */
  LT.OSCommitteeModel = LT.OSModel.extend({
    osType: 'committees'
  });

  /**
   * Model Legislature Tracker category
   */
  LT.CategoryModel = Backbone.Model.extend({
    initialize: function(attr, options) {
      this.options = options;
    },

    bills: function() {
      var thisModel = this;
      var bills = [];

      _.each(this.get('bills'), function(b) {
        bills.push(LT.utils.getModel('OSBillModel', 'bill_id', b, thisModel.options));
      });
      return bills;
    }
  });

})(jQuery, window);<|endoftext|>


<commit_before>function startupInject() {
	chrome.tabs.query({
		url: "*://www.rcgroups.com/aircraft-electric-multirotor-fs-w-733/"
		},
		function(tabs) {
			chrome.windows.getCurrent(function(window) {
				if(!tabs[0].active || !window.focused) {
					chrome.tabs.reload(tabs[0].id);
					chrome.tabs.executeScript(tabs[0].id, {file: "js/monitor.js"});
				}
			});
		}
	);
}

function alertUser(message) {
	var notifOptions = {
		type: "basic",
		title: message.itemTitle,
		message: message.itemPrice + " + " + message.itemShipping,
		iconUrl: message.picUrl
	};
	if(notifOptions.iconUrl.length === 3)
		notifOptions.iconUrl = "white.png";
	if(message.itemPrice == "" && message.itemShipping == "")
		notifOptions.message = "";
	chrome.notifications.onClicked.addListener(function(notfid) {
		chrome.tabs.create({
			url: message.itemUrl,
			active: true
		});
	})
	chrome.notifications.clear("userAlert", function(notifId){});
	chrome.notifications.create("userAlert", notifOptions, function(notifId){});
}

chrome.runtime.onMessage.addListener(function(message, sender) {
	alertUser(message);
})

localStorage["firstobject"] = "";
var poll_interval = 5;
setInterval(function() {
	startupInject();
}, poll_interval * 1000);
<commit_msg>change poll interval to 30 seconds<commit_after>function startupInject() {
	chrome.tabs.query({
		url: "*://www.rcgroups.com/aircraft-electric-multirotor-fs-w-733/"
		},
		function(tabs) {
			chrome.windows.getCurrent(function(window) {
				if(!tabs[0].active || !window.focused) {
					chrome.tabs.reload(tabs[0].id);
					chrome.tabs.executeScript(tabs[0].id, {file: "js/monitor.js"});
				}
			});
		}
	);
}

function alertUser(message) {
	var notifOptions = {
		type: "basic",
		title: message.itemTitle,
		message: message.itemPrice + " + " + message.itemShipping,
		iconUrl: message.picUrl
	};
	if(notifOptions.iconUrl.length === 3)
		notifOptions.iconUrl = "white.png";
	if(message.itemPrice == "" && message.itemShipping == "")
		notifOptions.message = "";
	chrome.notifications.onClicked.addListener(function(notfid) {
		chrome.tabs.create({
			url: message.itemUrl,
			active: true
		});
	})
	chrome.notifications.clear("userAlert", function(notifId){});
	chrome.notifications.create("userAlert", notifOptions, function(notifId){});
}

chrome.runtime.onMessage.addListener(function(message, sender) {
	alertUser(message);
})

localStorage["firstobject"] = "";
var poll_interval = 30;
setInterval(function() {
	startupInject();
}, poll_interval * 1000);
<|endoftext|>


<commit_before>/*!
 * CARIS oscar - Open Spatial Component ARchitecture
 *
 * Copyright 2012 CARIS <http://www.caris.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

(function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,i){var j=b(a),l=j.autoCallback;j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2})))}function i(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var j,l,m=this.yepnope.loader;if(e(a))g(a,0,m,0);else if(w(a))for(j=0;j<a.length;j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);else Object(a)===a&&i(a,m)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);

var $_oscarcssdependencies = [
    "../jquery/jquery/css/smoothness/jquery-ui-1.10.0.custom.min.css"
    ,"theme/default/style.css"
    ,"../yui/build/fonts/fonts-min.css"
    ,"../yui/build/button/assets/skins/sam/button.css"
    ,"../yui/build/autocomplete/assets/skins/sam/autocomplete.css"
    ,"../yui/build/container/assets/skins/sam/container.css"
    ,"../yui/build/paginator/assets/skins/sam/paginator.css"
    ,"../yui/build/datatable/assets/skins/sam/datatable.css"
    ,"../yui/build/datatable/assets/skins/sam/datatable-skin.css"
    ,"../yui/build/layout/assets/skins/sam/layout.css"
    ,"../yui/build/resize/assets/skins/sam/resize.css"
    ,"../yui/build/tabview/assets/skins/sam/tabview.css"
];

var $_oscarscripts = [
    "../jquery/jquery/js/jquery-1.9.0.js"
    ,"../jquery/jquery/js/jquery-ui-1.10.0.custom.min.js"
	,"../jquery/plugins/stalker/jquery.stalker.js"
	,"../jquery/plugins/layout/js/jquery.layout-latest.min.js"
    ,"../proj4js/lib/proj4js.js"
    ,"../openlayers/OpenLayers.js"
    ,"../jsts/lib/javascript.util.js"
    ,"../jsts/lib/jsts.js"
];

var $_oscaryuiscripts = [
    "../yui/build/yahoo-dom-event/yahoo-dom-event.js",
    "../yui/build/element/element-min.js",
    "../yui/build/button/button-min.js",
    "../yui/build/container/container-min.js",
    "../yui/build/datasource/datasource.js",
    "../yui/build/json/json.js",
    "../yui/build/dragdrop/dragdrop.js",
    "../yui/build/treeview/treeview.js",
    "../yui/build/animation/animation.js",
    "../yui/build/autocomplete/autocomplete.js",
    "../yui/build/connection/connection.js",
    "../yui/build/datatable/datatable.js",
    "../yui/build/paginator/paginator-min.js",
    "../yui/build/resize/resize.js",
    "../yui/build/layout/layout-min.js",
    "../yui/build/connection/connection.js",
    "../yui/build/resize/resize-min.js",
    "../yui/build/tabview/tabview-min.js"
];

$_oscarscriptdependencies = $_oscarscripts.concat($_oscaryuiscripts);

$_oscarscriptdependencies.push("oscar.js");
$_oscarscriptdependencies.push("yuiDependencies.js");

window["oscar"] = {
    injectJs:yepnope.injectJs,
    injectCss:yepnope.injectCss,
    readyCallbacks:[]
};

/**
 * Method: _isReady Internal function call to begin performing call backs
 */
oscar._isReady = function() {
    var scope = this;
    $$(document).ready(function() {

        var cb = null;
        while((cb = scope.readyCallbacks.shift()) != null) {
            cb.call(scope);
        }
    });
};

/**
 * APIMethod: getScriptLocation Returns the relative path to the oscar script
 * directory
 */
oscar.getScriptLocation = function() {
	return oscar._scriptLocation;
}

/**
 * APIMethod: oscar.onReady Called when all dependencies have been loaded and
 * oscar is ready to be used.
 */
oscar.onReady = function(fn) {

    this.readyCallbacks.push(fn);
};

(function() {
        var loadUtility = {};
        var scripts = document.getElementsByTagName('script');
        for ( var i = 0, len = scripts.length; i < len; i++) {
            var src = scripts[i].getAttribute('src');
            if (src) {
                var index = src.indexOf("Loader.js");
                loadUtility.host = oscar._scriptLocation = src.substring(0, index);
                break;
            }
        }
        loadUtility.loadScript = function() {
            var scriptToLoad = $_oscarscriptdependencies.shift();
            var scope = this;
            if(scriptToLoad!=null) {
                var s = scriptToLoad;
                if(scriptToLoad.indexOf("http")== -1) {
                    scriptToLoad=this.host + scriptToLoad;
                }
                oscar.injectJs(scriptToLoad,function(){scope.loadScript()});
            } else {
                setTimeout("oscar._isReady()",0);
                }
        }
        var css =null;
        while((css = $_oscarcssdependencies.shift())!= null) {
            oscar.injectCss(loadUtility.host + css);
        }
        loadUtility.loadScript();
})();
<commit_msg>OSCAR-0<commit_after>/*!
 * CARIS oscar - Open Spatial Component ARchitecture
 *
 * Copyright 2012 CARIS <http://www.caris.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

(function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,i){var j=b(a),l=j.autoCallback;j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2})))}function i(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var j,l,m=this.yepnope.loader;if(e(a))g(a,0,m,0);else if(w(a))for(j=0;j<a.length;j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);else Object(a)===a&&i(a,m)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);

var $_oscarcssdependencies = [
    "../jquery/jquery/css/smoothness/jquery-ui-1.10.0.custom.min.css"
    ,"theme/default/style.css"
    ,"../yui/build/fonts/fonts-min.css"
    ,"../yui/build/button/assets/skins/sam/button.css"
    ,"../yui/build/autocomplete/assets/skins/sam/autocomplete.css"
    ,"../yui/build/container/assets/skins/sam/container.css"
    ,"../yui/build/paginator/assets/skins/sam/paginator.css"
    ,"../yui/build/datatable/assets/skins/sam/datatable.css"
    ,"../yui/build/datatable/assets/skins/sam/datatable-skin.css"
    ,"../yui/build/layout/assets/skins/sam/layout.css"
    ,"../yui/build/resize/assets/skins/sam/resize.css"
    ,"../yui/build/tabview/assets/skins/sam/tabview.css"
];

var $_oscarscripts = [
    "../jquery/jquery/js/jquery-1.9.0.js"
    ,"../jquery/jquery/js/jquery-ui-1.10.0.custom.min.js"
	,"../jquery/plugins/stalker/jquery.stalker.js"
	,"../jquery/plugins/layout/js/jquery.layout-latest.min.js"
    ,"../jquery/plugins/slimScroll/jquery.slimscroll.js"
    ,"../proj4js/lib/proj4js.js"
    ,"../openlayers/OpenLayers.js"
    ,"../jsts/lib/javascript.util.js"
    ,"../jsts/lib/jsts.js"
];

var $_oscaryuiscripts = [
    "../yui/build/yahoo-dom-event/yahoo-dom-event.js",
    "../yui/build/element/element-min.js",
    "../yui/build/button/button-min.js",
    "../yui/build/container/container-min.js",
    "../yui/build/datasource/datasource.js",
    "../yui/build/json/json.js",
    "../yui/build/dragdrop/dragdrop.js",
    "../yui/build/treeview/treeview.js",
    "../yui/build/animation/animation.js",
    "../yui/build/autocomplete/autocomplete.js",
    "../yui/build/connection/connection.js",
    "../yui/build/datatable/datatable.js",
    "../yui/build/paginator/paginator-min.js",
    "../yui/build/resize/resize.js",
    "../yui/build/layout/layout-min.js",
    "../yui/build/connection/connection.js",
    "../yui/build/resize/resize-min.js",
    "../yui/build/tabview/tabview-min.js"
];

$_oscarscriptdependencies = $_oscarscripts.concat($_oscaryuiscripts);

$_oscarscriptdependencies.push("oscar.js");
$_oscarscriptdependencies.push("yuiDependencies.js");

window["oscar"] = {
    injectJs:yepnope.injectJs,
    injectCss:yepnope.injectCss,
    readyCallbacks:[]
};

/**
 * Method: _isReady Internal function call to begin performing call backs
 */
oscar._isReady = function() {
    var scope = this;
    $$(document).ready(function() {

        var cb = null;
        while((cb = scope.readyCallbacks.shift()) != null) {
            cb.call(scope);
        }
    });
};

/**
 * APIMethod: getScriptLocation Returns the relative path to the oscar script
 * directory
 */
oscar.getScriptLocation = function() {
	return oscar._scriptLocation;
}

/**
 * APIMethod: oscar.onReady Called when all dependencies have been loaded and
 * oscar is ready to be used.
 */
oscar.onReady = function(fn) {

    this.readyCallbacks.push(fn);
};

(function() {
        var loadUtility = {};
        var scripts = document.getElementsByTagName('script');
        for ( var i = 0, len = scripts.length; i < len; i++) {
            var src = scripts[i].getAttribute('src');
            if (src) {
                var index = src.indexOf("Loader.js");
                loadUtility.host = oscar._scriptLocation = src.substring(0, index);
                break;
            }
        }
        loadUtility.loadScript = function() {
            var scriptToLoad = $_oscarscriptdependencies.shift();
            var scope = this;
            if(scriptToLoad!=null) {
                var s = scriptToLoad;
                if(scriptToLoad.indexOf("http")== -1) {
                    scriptToLoad=this.host + scriptToLoad;
                }
                oscar.injectJs(scriptToLoad,function(){scope.loadScript()});
            } else {
                setTimeout("oscar._isReady()",0);
                }
        }
        var css =null;
        while((css = $_oscarcssdependencies.shift())!= null) {
            oscar.injectCss(loadUtility.host + css);
        }
        loadUtility.loadScript();
})();
<|endoftext|>


<commit_before>/* Core */
var resizeText = function(size) {
    if ($('body').css('fontSize') === "") {
        $('body').css('fontSize', '1.0em');
    }

    $('body').css('fontSize', String(size) + "pt");
};

var MARGIN = 10;

/* Bubbles */
var move_val = 40;
function Bubble(css_selector){
    this.selector = css_selector;
    this.top = parseInt($(""+this.selector).css('top'));
    this.left = parseInt($(""+this.selector).css('left'));
    this.width = parseInt($(""+this.selector).width());
    this.deltaX = move_val;
    this.deltaY = move_val;
    this.currentBorder = "none";
    this.update = function(){
        this.top = parseInt($(""+this.selector).css('top'));
        this.left = parseInt($(""+this.selector).css('left'));
    };
    this.move = function(){
        $(""+this.selector).animate({top: "+="+this.deltaY+"px", left: "+="+this.deltaX+"px"}, {duration: 900, easing: 'linear'});
    };

    this.updateMovementState = function(){
        var path = Math.floor(Math.random() * 8);

        if(this.currentBorder === "top"){
            var choiceArray = [4, 5, 6];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "bottom"){
            var choiceArray = [8, 1, 2];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "left"){
            var choiceArray = [2, 3, 4];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "right"){
            var choiceArray = [6, 7, 8];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        switch (path) {
            case 0:
                this.deltaX = 0;
                this.deltaY = -move_val;
                break;
            case 1:
                this.deltaX = move_val;
                this.deltaY = -move_val;
                break;
            case 2:
                this.deltaX = move_val;
                this.deltaY = 0;
                break;
            case 3:
                this.deltaX = move_val;
                this.deltaY = move_val;
                break;
            case 4:
                this.deltaX = 0;
                this.deltaY = move_val;
                break;
            case 5:
                this.deltaX = -move_val;
                this.deltaY = move_val;
                break;
            case 6:
                this.deltaX = -move_val;
                this.deltaY = 0;
                break;
            case 7:
                this.deltaX = -move_val;
                this.deltaY = -move_val;
                break;
        }
    };

    this.isTouchingPageElement = function(){
        this.update();
        console.log("window width: " + parseInt($(window).innerWidth()));
        console.log("bubble width: " + this.width);
        console.log("left: " + this.left);
        console.log("top: " + this.top);

        if(this.left >=
            (parseInt($(window).innerWidth()) - (this.width + MARGIN))
            ) {
            console.log("choosing right border");
            this.currentBorder = "right";
            return true;
        }

        if(this.top >= parseInt($(window).innerHeight())/2 ) {
            console.log("hit bottom");
            this.currentBorder = "bottom";
            return true;
        }

        if(this.top <= 0) {
            console.log("hit top");
            this.currentBorder = "top";
            return true;
        }

        if(this.left <= 0) {
            this.currentBorder = "left";
            return true;
        }

        this.currentBorder = "none";
        return false;
    };

    this.counter = 0;
    this.action = function(){
        if(this.isTouchingPageElement()) {
            this.updateMovementState();
        }
        if(this.counter === 15) {
            this.counter = 0;
            this.updateMovementState();
        }
        this.move();
        this.counter += 1;
    };

    /*$(''+this.selector).click(function(){
        $(''+this.selector).fadeOut(2000);
    });*/

    this.startX = parseInt( $(''+this.selector).css('left') );
    this.startY = parseInt( $(''+this.selector).css('top') );
    this.reset = function(){
        $(''+this.selector).css('left', this.startX+"px");
        $(''+this.selector).css('top', this.startY+"px");
    };
}
var bubbles = [];

$(document).ready(function(){
    /*$(document).snowfall({
        flakeCount : 300,
        maxSpeed : 10,
        maxSize: 4,
        round: true,
        collection: '#pagecontent'
    });*/
    $('#clickbubbletext').hide();

    bubbles = [ new Bubble("#b1"), new Bubble("#b2"), new Bubble("#b3"), new Bubble("#b4"), new Bubble("#b5"),
        new Bubble("#b6"), new Bubble("#b7"), new Bubble("#b8"), new Bubble("#b9") ];
    for (var i = 0; i < bubbles.length; i++) {
        bubbles[i].updateMovementState();
    }
});

//var bubble_interval;
var run = false;
function bubblefunc(){
    for (var i = 0; i < bubbles.length; i++) {
        bubbles[i].action();
    }

    if (run === true) {
        console.log("Starting again");
        setTimeout(bubblefunc, 500);
    }
}

function onSetBubblesFreeClicked() {
    $('#bubblebutton').fadeOut(1000, function(){
        $('#clickbubbletext').show();
    });
    $('.bubble').click(function(){
        $(this).effect('puff', {percent: 200}, 300, function(){
            document.getElementById("pop").play();
            $('#clickbubbletext').fadeOut(1200, 'linear');
        });
    });
    $('#resetbubblesbutton').show();

    run = true;
    bubblefunc();
    //bubble_interval = setInterval(bubblefunc, 900);
}

function onResetBubblesClicked() {
    //clearInterval(bubble_interval);
    run = false;

    $('#clickbubbletext').hide();
    $('#resetbubblesbutton').fadeOut(900, function(){
        $('#bubblebutton').show();

        for (var i = 0; i < bubbles.length; i++) {
            bubbles[i].reset();
            $(""+bubbles[i].selector).show();
        }
    });
    $('.bubble').off('click');
}<commit_msg>removing jquery animation<commit_after>/* Core */
var resizeText = function(size) {
    if ($('body').css('fontSize') === "") {
        $('body').css('fontSize', '1.0em');
    }

    $('body').css('fontSize', String(size) + "pt");
};

var MARGIN = 10;

/* Bubbles */
var move_val = 3;
function Bubble(css_selector){
    this.selector = css_selector;
    this.top = parseInt($(""+this.selector).css('top'));
    this.left = parseInt($(""+this.selector).css('left'));
    this.width = parseInt($(""+this.selector).width());
    this.deltaX = move_val;
    this.deltaY = move_val;
    this.currentBorder = "none";
    this.update = function(){
        this.top = parseInt($(""+this.selector).css('top'));
        this.left = parseInt($(""+this.selector).css('left'));
    };
    this.move = function(){
        $(""+this.selector).css('top', String(this.left + this.deltaY)+"px");
        $(""+this.selector).css('left', String(this.top + this.deltaX)+"px");
    };

    this.updateMovementState = function(){
        var path = Math.floor(Math.random() * 8);

        if(this.currentBorder === "top"){
            var choiceArray = [4, 5, 6];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "bottom"){
            var choiceArray = [8, 1, 2];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "left"){
            var choiceArray = [2, 3, 4];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        if(this.currentBorder === "right"){
            var choiceArray = [6, 7, 8];
            path = choiceArray[ Math.floor(Math.random() * 3) ];
        }

        switch (path) {
            case 0:
                this.deltaX = 0;
                this.deltaY = -move_val;
                break;
            case 1:
                this.deltaX = move_val;
                this.deltaY = -move_val;
                break;
            case 2:
                this.deltaX = move_val;
                this.deltaY = 0;
                break;
            case 3:
                this.deltaX = move_val;
                this.deltaY = move_val;
                break;
            case 4:
                this.deltaX = 0;
                this.deltaY = move_val;
                break;
            case 5:
                this.deltaX = -move_val;
                this.deltaY = move_val;
                break;
            case 6:
                this.deltaX = -move_val;
                this.deltaY = 0;
                break;
            case 7:
                this.deltaX = -move_val;
                this.deltaY = -move_val;
                break;
        }
    };

    this.isTouchingPageElement = function(){
        this.update();
        console.log("window width: " + parseInt($(window).innerWidth()));
        console.log("bubble width: " + this.width);
        console.log("left: " + this.left);
        console.log("top: " + this.top);

        if(this.left >=
            (parseInt($(window).innerWidth()) - (this.width + MARGIN))
            ) {
            console.log("choosing right border");
            this.currentBorder = "right";
            return true;
        }

        if(this.top >= parseInt($(window).innerHeight())/2 ) {
            console.log("hit bottom");
            this.currentBorder = "bottom";
            return true;
        }

        if(this.top <= 0) {
            console.log("hit top");
            this.currentBorder = "top";
            return true;
        }

        if(this.left <= 0) {
            this.currentBorder = "left";
            return true;
        }

        this.currentBorder = "none";
        return false;
    };

    this.counter = 0;
    this.action = function(){
        if(this.isTouchingPageElement()) {
            this.updateMovementState();
        }
        if(this.counter === 15) {
            this.counter = 0;
            this.updateMovementState();
        }
        this.move();
        this.counter += 1;
    };

    /*$(''+this.selector).click(function(){
        $(''+this.selector).fadeOut(2000);
    });*/

    this.startX = parseInt( $(''+this.selector).css('left') );
    this.startY = parseInt( $(''+this.selector).css('top') );
    this.reset = function(){
        $(''+this.selector).css('left', this.startX+"px");
        $(''+this.selector).css('top', this.startY+"px");
    };
}
var bubbles = [];

$(document).ready(function(){
    /*$(document).snowfall({
        flakeCount : 300,
        maxSpeed : 10,
        maxSize: 4,
        round: true,
        collection: '#pagecontent'
    });*/
    $('#clickbubbletext').hide();

    bubbles = [ new Bubble("#b1"), new Bubble("#b2"), new Bubble("#b3"), new Bubble("#b4"), new Bubble("#b5"),
        new Bubble("#b6"), new Bubble("#b7"), new Bubble("#b8"), new Bubble("#b9") ];
    for (var i = 0; i < bubbles.length; i++) {
        bubbles[i].updateMovementState();
    }
});

//var bubble_interval;
var run = false;
function bubblefunc(){
    for (var i = 0; i < bubbles.length; i++) {
        bubbles[i].action();
    }

    if (run === true) {
        console.log("Starting again");
        setTimeout(bubblefunc, 500);
    }
}

function onSetBubblesFreeClicked() {
    $('#bubblebutton').fadeOut(1000, function(){
        $('#clickbubbletext').show();
    });
    $('.bubble').click(function(){
        $(this).effect('puff', {percent: 200}, 300, function(){
            document.getElementById("pop").play();
            $('#clickbubbletext').fadeOut(1200, 'linear');
        });
    });
    $('#resetbubblesbutton').show();

    run = true;
    bubblefunc();
    //bubble_interval = setInterval(bubblefunc, 900);
}

function onResetBubblesClicked() {
    //clearInterval(bubble_interval);
    run = false;

    $('#clickbubbletext').hide();
    $('#resetbubblesbutton').fadeOut(900, function(){
        $('#bubblebutton').show();

        for (var i = 0; i < bubbles.length; i++) {
            bubbles[i].reset();
            $(""+bubbles[i].selector).show();
        }
    });
    $('.bubble').off('click');
}<|endoftext|>


<commit_before>/*!
 * Clean Blog v1.0.0 (http://startbootstrap.com)
 * Copyright 2015 Start Bootstrap
 * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE)
 */

// Tooltip Init
$(function() {
    $("[data-toggle='tooltip']").tooltip();
});

/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
    $('#success').html('');
});

    /**
     * Thanks to Jason Bunting via StackOverflow.com
     *
     * http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string#answer-359910
     * Short link: http://tinyurl.com/executeFunctionByName
     **/
    function executeFunctionByName(functionName, context /*, args*/ ) {
        var args = Array.prototype.slice.call(arguments).splice(2);
        var namespaces = functionName.split(".");
        var func = namespaces.pop();
        for (var i = 0; i < namespaces.length; i++) {
            context = context[namespaces[i]];
        }
        return context[func].apply(this, args);
    }

    $.fn.jqBootstrapValidation = function(method) {

        if (defaults.methods[method]) {
            return defaults.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return defaults.methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.jqBootstrapValidation');
            return null;
        }

    };

    $.jqBootstrapValidation = function(options) {
        $(":input").not("[type=image],[type=submit]").jqBootstrapValidation.apply(this, arguments);
    };

})(jQuery);

// make all images responsive
$(function() {
	$("img").addClass("img-responsive");
});

// responsive tables
$(document).ready(function() {
	$("table").wrap("

");
	$("table").addClass("table");
});

// responsive embed videos
$(document).ready(function () {
    $('iframe[src*="youtube.com"]').wrap('

');
	$('iframe[src*="youtube.com"]').addClass('embed-responsive-item');
    $('iframe[src*="vimeo.com"]').wrap('

');
	$('iframe[src*="vimeo.com"]').addClass('embed-responsive-item');
});

// Floating label headings for the contact form
$(function() {
    $("body").on("input propertychange", ".floating-label-form-group", function(e) {
        $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
    }).on("focus", ".floating-label-form-group", function() {
        $(this).addClass("floating-label-form-group-with-focus");
    }).on("blur", ".floating-label-form-group", function() {
        $(this).removeClass("floating-label-form-group-with-focus");
    });
});

// Navigation Scripts to Show Header on Scroll-Up
jQuery(document).ready(function($) {
    var MQL = 1170;

    //primary navigation slide-in effect
    if ($(window).width() > MQL) {
        var headerHeight = $('.navbar-custom').height();
        $(window).on('scroll', {
                previousTop: 0
            },
            function() {
                var currentTop = $(window).scrollTop();
                //check if user is scrolling up
                if (currentTop < this.previousTop) {
                    //if scrolling up...
                    if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) {
                        $('.navbar-custom').addClass('is-visible');
                    } else {
                        $('.navbar-custom').removeClass('is-visible is-fixed');
                    }
                } else {
                    //if scrolling down...
                    $('.navbar-custom').removeClass('is-visible');
                    if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) $('.navbar-custom').addClass('is-fixed');
                }
                this.previousTop = currentTop;
            });
    }
});
<commit_msg>Attempt 2 at fixing the contact form<commit_after>/*!
 * Clean Blog v1.0.0 (http://startbootstrap.com)
 * Copyright 2015 Start Bootstrap
 * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE)
 */

// Tooltip Init
$(function() {
    $("[data-toggle='tooltip']").tooltip();
});

/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
    $('#success').html('');
});

    /**
     * Thanks to Jason Bunting via StackOverflow.com
     *
     * http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string#answer-359910
     * Short link: http://tinyurl.com/executeFunctionByName
     **/
    function executeFunctionByName(functionName, context /*, args*/ ) {
        var args = Array.prototype.slice.call(arguments).splice(2);
        var namespaces = functionName.split(".");
        var func = namespaces.pop();
        for (var i = 0; i < namespaces.length; i++) {
            context = context[namespaces[i]];
        }
        return context[func].apply(this, args);
    }

    $.fn.jqBootstrapValidation = function(method) {

        if (defaults.methods[method]) {
            return defaults.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return defaults.methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.jqBootstrapValidation');
            return null;
        }

    };

    $.jqBootstrapValidation = function(options) {
        $(":input").not("[type=image]").jqBootstrapValidation.apply(this, arguments);
    };

})(jQuery);

// make all images responsive
$(function() {
	$("img").addClass("img-responsive");
});

// responsive tables
$(document).ready(function() {
	$("table").wrap("

");
	$("table").addClass("table");
});

// responsive embed videos
$(document).ready(function () {
    $('iframe[src*="youtube.com"]').wrap('

');
	$('iframe[src*="youtube.com"]').addClass('embed-responsive-item');
    $('iframe[src*="vimeo.com"]').wrap('

');
	$('iframe[src*="vimeo.com"]').addClass('embed-responsive-item');
});

// Floating label headings for the contact form
$(function() {
    $("body").on("input propertychange", ".floating-label-form-group", function(e) {
        $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
    }).on("focus", ".floating-label-form-group", function() {
        $(this).addClass("floating-label-form-group-with-focus");
    }).on("blur", ".floating-label-form-group", function() {
        $(this).removeClass("floating-label-form-group-with-focus");
    });
});

// Navigation Scripts to Show Header on Scroll-Up
jQuery(document).ready(function($) {
    var MQL = 1170;

    //primary navigation slide-in effect
    if ($(window).width() > MQL) {
        var headerHeight = $('.navbar-custom').height();
        $(window).on('scroll', {
                previousTop: 0
            },
            function() {
                var currentTop = $(window).scrollTop();
                //check if user is scrolling up
                if (currentTop < this.previousTop) {
                    //if scrolling up...
                    if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) {
                        $('.navbar-custom').addClass('is-visible');
                    } else {
                        $('.navbar-custom').removeClass('is-visible is-fixed');
                    }
                } else {
                    //if scrolling down...
                    $('.navbar-custom').removeClass('is-visible');
                    if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) $('.navbar-custom').addClass('is-fixed');
                }
                this.previousTop = currentTop;
            });
    }
});
<|endoftext|>


<commit_before>var curDir = "/";

$(document).ready(function() {

    $("#toggleAddStorageNode").click(function(event) {
        $("#addStorageNode").toggle();
    });

    $("button").click(function(event) {
        var actionType = $(this).attr('id');
        $.post('?action=' + actionType, {
            relativePath : curDir + "/" + $("#dirName").val()
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            if (!resp.ok) {
                alert(resp.errorMessage); // .errorMessage);
            } else {
                redrawPage('getDirList');
            }
        });
        event.preventDefault();
    });

    $("a.dirdel").live('click', function(event) {
        if (confirm('Are you sure you want to delete this directory?')) {

            var dirName = $(this).attr('id');
            $.post('?action=deleteDirectory', {
                relativePath : curDir + "/" + dirName
            }, function(data) {
                var resp = jQuery.parseJSON(data);
                if (!resp.ok) {
                    alert(resp.errorMessage); // .errorMessage);
                } else {
                    redrawPage('getDirList');
                }
            });
        }
        event.preventDefault();

    });

    $("a.filedel").live('click', function(event) {
        if (confirm('Are you sure you want to delete this file?')) {
            var dirName = $(this).attr('id');
            $.post('?action=deleteFile', {
                relativePath : curDir + "/" + dirName
            }, function(data) {
                var resp = jQuery.parseJSON(data);
                if (!resp.ok) {
                    alert(resp.errorMessage); // .errorMessage);
                } else {
                    redrawPage('getDirList');
                }
            });
        }
        event.preventDefault();
    });

    $("a.file").live('click', function(event) {
        var fileName = $(this).text();
        $.post('?action=getDownloadToken', {
            relativePath : curDir + "/" + fileName
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            window.location.href = resp.downloadLocation;
        });
        event.preventDefault();
    });

    $("a.up").live("click", function(event) {
        var lastSlash = curDir.lastIndexOf('/');
        if (lastSlash > 0) {
            curDir = curDir.substring(0, lastSlash);
            redrawPage('getDirList');
        }
        event.preventDefault();
    });

    $("a.dir").live("click", function(event) {
        var dirName = $(this).text();
        curDir = curDir + "/" + dirName;
        redrawPage('getDirList');
        event.preventDefault();
    });

    $("a.menu").live('click', function(event) {
        var actionType = $(this).attr('id');
        redrawPage(actionType);
        event.preventDefault();
    });

    $("input").change(function(event) {
        var f = this.files[0];

        var fileName = $(this).text();
        $.post('?action=getUploadToken', {
            relativePath : curDir + "/" + f.name,
            fileSize : f.size
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            if (!resp.ok) {
                alert(resp.errorMessage);
            } else {
                var uploadUrl = resp.uploadLocation;

                var xhr = new XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = Math.round(evt.loaded / evt.total * 100);
                        $("#progress").show();
                        $("#progress").text(percentComplete + "%");
                    }
                }, false);

                xhr.upload.addEventListener("load", function(evt) {
                    $("#progress").hide();
                    redrawPage('getDirList');
                }, false);

                xhr.open("PUT", uploadUrl, true);
                xhr.send(f);
                redrawPage('getDirList');
            }
        });
        event.preventDefault();
    });
    redrawPage('getDirList');
});

function redrawPage(actionType) {
    $
    .getJSON(
        '?action=' + actionType,
        {
            relativePath : curDir
        },
        function(data) {
            var items = [];

            if (actionType === 'getDirList') {
                items
                .push('
Up ('
                    + curDir + ')
');
                $
                .each(
                    data,
                    function(key, val) {
                        if (key != "ok") {

                            if (val.isDirectory) {
                                items
                                .push('
'
                                    + val.fileName
                                    + '	[DIR]	delete
');
                            } else {
                                items.push('
'
                                    + val.fileName + '	'
                                    + toHumanSize(val.fileSize)
                                    + '	delete
');
                            }
                        }
                    });
            } else {
                $.each(data,
                    function(key, val) {
                        if (key === 'availableSpace') {
                            val = toHumanSize(val);
                        }
                        items.push('
' + key + '	' + val
                            + '
>');
                    });
            }
            $("#output").html($('
', {
                'class' : 'my-new-list',
                html : items.join('')
            }));

        });
}

function toHumanSize(bytes) {
    var kilobyte = 1024;
    var megabyte = kilobyte * kilobyte;
    var gigabyte = megabyte * kilobyte;

    if (bytes >= gigabyte)
        return Math.round((bytes / gigabyte)) + "GB";
    if (bytes >= megabyte)
        return Math.round((bytes / megabyte)) + "MB";
    if (bytes >= kilobyte)
        return Math.round((bytes / kilobyte)) + "kB";
    return bytes;
}
<commit_msg>better error handling in ftc<commit_after>var curDir = "/";

$(document).ready(function() {

    $("#toggleAddStorageNode").click(function(event) {
        $("#addStorageNode").toggle();
    });

    $("button").click(function(event) {
        var actionType = $(this).attr('id');
        $.post('?action=' + actionType, {
            relativePath : curDir + "/" + $("#dirName").val()
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            if (!resp.ok) {
                alert(resp.errorMessage); // .errorMessage);
            } else {
                redrawPage('getDirList');
            }
        });
        event.preventDefault();
    });

    $("a.dirdel").live('click', function(event) {
        if (confirm('Are you sure you want to delete this directory?')) {

            var dirName = $(this).attr('id');
            $.post('?action=deleteDirectory', {
                relativePath : curDir + "/" + dirName
            }, function(data) {
                var resp = jQuery.parseJSON(data);
                if (!resp.ok) {
                    alert(resp.errorMessage); // .errorMessage);
                } else {
                    redrawPage('getDirList');
                }
            });
        }
        event.preventDefault();

    });

    $("a.filedel").live('click', function(event) {
        if (confirm('Are you sure you want to delete this file?')) {
            var dirName = $(this).attr('id');
            $.post('?action=deleteFile', {
                relativePath : curDir + "/" + dirName
            }, function(data) {
                var resp = jQuery.parseJSON(data);
                if (!resp.ok) {
                    alert(resp.errorMessage); // .errorMessage);
                } else {
                    redrawPage('getDirList');
                }
            });
        }
        event.preventDefault();
    });

    $("a.file").live('click', function(event) {
        var fileName = $(this).text();
        $.post('?action=getDownloadToken', {
            relativePath : curDir + "/" + fileName
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            window.location.href = resp.downloadLocation;
        });
        event.preventDefault();
    });

    $("a.up").live("click", function(event) {
        var lastSlash = curDir.lastIndexOf('/');
        if (lastSlash > 0) {
            curDir = curDir.substring(0, lastSlash);
            redrawPage('getDirList');
        }
        event.preventDefault();
    });

    $("a.dir").live("click", function(event) {
        var dirName = $(this).text();
        curDir = curDir + "/" + dirName;
        redrawPage('getDirList');
        event.preventDefault();
    });

    $("a.menu").live('click', function(event) {
        var actionType = $(this).attr('id');
        redrawPage(actionType);
        event.preventDefault();
    });

    $("input").change(function(event) {
        var f = this.files[0];

        var fileName = $(this).text();
        $.post('?action=getUploadToken', {
            relativePath : curDir + "/" + f.name,
            fileSize : f.size
        }, function(data) {
            var resp = jQuery.parseJSON(data);
            if (!resp.ok) {
                alert(resp.errorMessage);
            } else {
                var uploadUrl = resp.uploadLocation;

                var xhr = new XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = Math.round(evt.loaded / evt.total * 100);
                        $("#progress").show();
                        $("#progress").text(percentComplete + "%");
                    }
                }, false);

                xhr.upload.addEventListener("load", function(evt) {
                    $("#progress").hide();
                    redrawPage('getDirList');
                }, false);

                xhr.open("PUT", uploadUrl, true);
                xhr.send(f);
                redrawPage('getDirList');
            }
        });
        event.preventDefault();
    });
    redrawPage('getDirList');
});

function redrawPage(actionType) {
    $
    .getJSON(
        '?action=' + actionType,
        {
            relativePath : curDir
        },
        function(data) {
	    if(!data.ok) {
		alert(data.errorMessage);
		return;
	    }
            var items = [];

            if (actionType === 'getDirList') {
                items
                .push('
Up ('
                    + curDir + ')
');
                $
                .each(
                    data,
                    function(key, val) {
                        if (key != "ok") {

                            if (val.isDirectory) {
                                items
                                .push('
'
                                    + val.fileName
                                    + '	[DIR]	delete
');
                            } else {
                                items.push('
'
                                    + val.fileName + '	'
                                    + toHumanSize(val.fileSize)
                                    + '	delete
');
                            }
                        }
                    });
            } else {
                $.each(data,
                    function(key, val) {
                        if (key === 'availableSpace') {
                            val = toHumanSize(val);
                        }
                        items.push('
' + key + '	' + val
                            + '
>');
                    });
            }
            $("#output").html($('
', {
                'class' : 'my-new-list',
                html : items.join('')
            }));

        });
}

function toHumanSize(bytes) {
    var kilobyte = 1024;
    var megabyte = kilobyte * kilobyte;
    var gigabyte = megabyte * kilobyte;

    if (bytes >= gigabyte)
        return Math.round((bytes / gigabyte)) + "GB";
    if (bytes >= megabyte)
        return Math.round((bytes / megabyte)) + "MB";
    if (bytes >= kilobyte)
        return Math.round((bytes / kilobyte)) + "kB";
    return bytes;
}
<|endoftext|>