<commit_before>/**
 * @author Mike Dolbow
 * Script for geojson.html
 */

var map;
var mapOptions = {
	center: [42.363,-83.093],
	zoom:10,
	maxBounds:[
		[42.0,-83.40],
		[43.0,-82.90]
		]
};
var geojsonQueryURL = 'https://services2.arcgis.com/HsXtOCMp1Nis1Ogr/arcgis/rest/services/MyMapService/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&geohash=&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=4326&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&f=pgeojson';
//var geojsonQueryURL = 'https://eerscmap.usgs.gov/arcgis/rest/services/uswtdb/uswtdbDyn/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=geometryType%3DesriGeometryEnvelope%26geometry%3D%7Bxmin%3A+-98.3%2C+ymin%3A+42.1%2C+xmax%3A+-98.2%2C+ymax%3A+43.1%7D&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&f=geojson';
//var geojsonQueryURL = 'https://eerscmap.usgs.gov/arcgis/rest/services/uswtdb/uswtdbDyn/MapServer/0/query?where=&text=Storm+Lake&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&having=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&historicMoment=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentOnly=false&datumTransformation=&parameterValues=&rangeValues=&quantizationParameters=&f=geojson';
function initgeojsonmap() {
		map = L.map('map', mapOptions);
		var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
			attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
		});
		/*var basemapTileLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
				maxZoom: 17,
				type: 'map',
				ext: 'jpg',
				subdomains: '1234',
				attribution: 'Esri, HERE, DeLorme, Intermap, increment P Corp., GEBCO, USGS, FAO, NPS, NRCAN, GeoBase, IGN, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), swisstopo, MapmyIndia, © OpenStreetMap contributors, and the GIS User Community'
			});*/
		map.addLayer(Esri_WorldImagery);

		//var geojsonLayer = new L.GeoJSON.AJAX(geojsonQueryURL, {onEachFeature:popUp});
		//console.log("GeoJSON layer added");
		var geojsonLayer = $.getJSON(geojsonQueryURL, function(){})
		.done(function(data){
			L.geoJSON(data, {onEachFeature:popUp
			}).addTo(map);
		});

}

  function popUp(feature, layer) {
    layer.bindPopup("Name: "+feature.properties.NAME);
  }
<commit_msg>Update geojson.js<commit_after>/**
 * @author Mike Dolbow
 * Script for geojson.html
 */

var map;
var mapOptions = {
	center: [42.363,-83.093],
	zoom:10,
	maxBounds:[
		[42.0,-83.50],
		[43.0,-82.50]
		]
};
var geojsonQueryURL = 'https://services2.arcgis.com/HsXtOCMp1Nis1Ogr/arcgis/rest/services/MyMapService/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&geohash=&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=4326&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&f=pgeojson';
//var geojsonQueryURL = 'https://eerscmap.usgs.gov/arcgis/rest/services/uswtdb/uswtdbDyn/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=geometryType%3DesriGeometryEnvelope%26geometry%3D%7Bxmin%3A+-98.3%2C+ymin%3A+42.1%2C+xmax%3A+-98.2%2C+ymax%3A+43.1%7D&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&f=geojson';
//var geojsonQueryURL = 'https://eerscmap.usgs.gov/arcgis/rest/services/uswtdb/uswtdbDyn/MapServer/0/query?where=&text=Storm+Lake&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=&returnGeometry=true&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&having=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&historicMoment=&returnDistinctValues=false&resultOffset=&resultRecordCount=&queryByDistance=&returnExtentOnly=false&datumTransformation=&parameterValues=&rangeValues=&quantizationParameters=&f=geojson';
function initgeojsonmap() {
		map = L.map('map', mapOptions);
		var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
			attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
		});
		/*var basemapTileLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
				maxZoom: 17,
				type: 'map',
				ext: 'jpg',
				subdomains: '1234',
				attribution: 'Esri, HERE, DeLorme, Intermap, increment P Corp., GEBCO, USGS, FAO, NPS, NRCAN, GeoBase, IGN, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), swisstopo, MapmyIndia, © OpenStreetMap contributors, and the GIS User Community'
			});*/
		map.addLayer(Esri_WorldImagery);

		//var geojsonLayer = new L.GeoJSON.AJAX(geojsonQueryURL, {onEachFeature:popUp});
		//console.log("GeoJSON layer added");
		var geojsonLayer = $.getJSON(geojsonQueryURL, function(){})
		.done(function(data){
			L.geoJSON(data, {onEachFeature:popUp
			}).addTo(map);
		});

}

  function popUp(feature, layer) {
    layer.bindPopup("Name: "+feature.properties.NAME);
  }
<|endoftext|>


<commit_before>'use strict';

const process = require('process');
const webpack = require('webpack');
const path = require('path');
const buildPath = path.resolve(__dirname, 'static');
const nodeModulesPath = path.resolve(__dirname, 'node_modules');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TransferWebpackPlugin = require('transfer-webpack-plugin'); // dev-server only

var devtool = 'source-map'; // Render source-map file for final build
var plugins = [
  new CopyWebpackPlugin([
    { context: 'frontend', from: '**/*.css' },
    { context: 'frontend', from: '**/*.html' },
    { context: 'frontend', from: '**/*.png' },
    { context: 'frontend', from: '**/*.jpg' },
    { context: 'frontend', from: '**/*.svg' },
    { context: nodeModulesPath, from: 'bootstrap/dist/**', to: 'lib' },
    { context: nodeModulesPath, from: 'bootswatch/**', to: 'lib' },
    { context: nodeModulesPath, from: 'jquery/dist/**', to: 'lib' },
    { context: nodeModulesPath, from: 'react/umd/**', to: 'lib' },
    { context: nodeModulesPath, from: 'react-dom/umd/**', to: 'lib' },
  ])
];

if (process.env.WEBPACK_DEV_SERVER === 'true') {
  console.log('WEBPACK_DEV_SERVER is true');
  devtool = 'eval';
  plugins.push(
    new TransferWebpackPlugin([
      {from: 'css'},
      {from: 'html'},
      {from: 'image'},
      {from: nodeModulesPath + "/bootstrap", to: 'lib'},
      {from: nodeModulesPath + "/bootswatch", to: 'lib'},
      {from: nodeModulesPath + "/jquery", to: 'lib'},
      {from: nodeModulesPath + "/react", to: 'lib'},
      {from: nodeModulesPath + "/react-dom", to: 'lib'},
    ], path.resolve(__dirname, "frontend"))
  );
}

const config = {
  mode: process.env.MINIFY === 'true' ? 'production' : 'development',
  entry: {
    main: './frontend/js/main.js',
    setting: './frontend/js/setting.js',
  },
  resolve: {
    //When require, do not have to add these extensions to file's name
    extensions: ['.js', '.jsx', '.json', '.css'],
    //node_modules: ["web_modules", "node_modules"]  (Default Settings)
  },
  output: {
    path: path.join(buildPath, process.env.VERSION_HASH),
    publicPath: path.join('/static', process.env.VERSION_HASH),
    filename: "js/[name].bundle.js",
    chunkFilename: "js/[name].chunk.js"
  },
  externals: {
    'jquery': 'jQuery',
    'react': 'React',
    'react-dom': 'ReactDOM',
    'bootstrap': 'bootstrap',
    'bootswatch': 'bootswatch',
  },
  optimization: {
    runtimeChunk: {
      name: 'vendor'
    },
    splitChunks: {
      name: 'vendor',
      chunks: 'initial',
    }
  },
  plugins: plugins,
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        //include: paths.appSrc,
        loader: require.resolve('babel-loader'),
        options: {
          // This is a feature of `babel-loader` for Webpack (not Babel itself).
          // It enables caching results in ./node_modules/.cache/babel-loader/
          // directory for faster rebuilds.
          cacheDirectory: true,
          //plugins: ['react-hot-loader/babel'],
        },
      },
      {
        test: /\.css$/,
        loader: "style-loader!css-loader"
      },
      {
        test: /\.png$/,
        loader: "url-loader?limit=100000"
      },
      {
        test: /\.jpg$/,
        loader: "file-loader"
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'file'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=image/svg+xml'
      }
    ],
  },
  // Dev server Configuration options
  devServer: {
    contentBase: 'frontend',  // Relative directory for base of server
    hot: true,        // Live-reload
    inline: true,
    port: 4000,
    host: '0.0.0.0',  // Change to '0.0.0.0' for external facing server
    proxy: {
      '*': {
        target: 'http://localhost:4001',
        secure: false,
        // bypass: function (req, res, proxyOptions) {
        //     const accept = req.headers.accept
        //     console.log(accept);
        //     //if (accept.indexOf('html') !== -1 || accept.indexOf('js') !== -1 || accept.indexOf('css') !== -1) {
        //         console.log('Skipping proxy for browser request.');
        //         return false;
        //     //}
        // }
      }
    },
  },
};

module.exports = config;
<commit_msg>Copy only yeti to static dir<commit_after>'use strict';

const process = require('process');
const webpack = require('webpack');
const path = require('path');
const buildPath = path.resolve(__dirname, 'static');
const nodeModulesPath = path.resolve(__dirname, 'node_modules');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TransferWebpackPlugin = require('transfer-webpack-plugin'); // dev-server only

var devtool = 'source-map'; // Render source-map file for final build
var plugins = [
  new CopyWebpackPlugin([
    { context: 'frontend', from: '**/*.css' },
    { context: 'frontend', from: '**/*.html' },
    { context: 'frontend', from: '**/*.png' },
    { context: 'frontend', from: '**/*.jpg' },
    { context: 'frontend', from: '**/*.svg' },
    { context: nodeModulesPath, from: 'bootstrap/dist/**', to: 'lib' },
    { context: nodeModulesPath, from: 'bootswatch/dist/yeti/**', to: 'lib' },
    { context: nodeModulesPath, from: 'jquery/dist/**', to: 'lib' },
    { context: nodeModulesPath, from: 'react/umd/**', to: 'lib' },
    { context: nodeModulesPath, from: 'react-dom/umd/**', to: 'lib' },
  ])
];

if (process.env.WEBPACK_DEV_SERVER === 'true') {
  console.log('WEBPACK_DEV_SERVER is true');
  devtool = 'eval';
  plugins.push(
    new TransferWebpackPlugin([
      {from: 'css'},
      {from: 'html'},
      {from: 'image'},
      {from: nodeModulesPath + "/bootstrap", to: 'lib'},
      {from: nodeModulesPath + "/bootswatch", to: 'lib'},
      {from: nodeModulesPath + "/jquery", to: 'lib'},
      {from: nodeModulesPath + "/react", to: 'lib'},
      {from: nodeModulesPath + "/react-dom", to: 'lib'},
    ], path.resolve(__dirname, "frontend"))
  );
}

const config = {
  mode: process.env.MINIFY === 'true' ? 'production' : 'development',
  entry: {
    main: './frontend/js/main.js',
    setting: './frontend/js/setting.js',
  },
  resolve: {
    //When require, do not have to add these extensions to file's name
    extensions: ['.js', '.jsx', '.json', '.css'],
    //node_modules: ["web_modules", "node_modules"]  (Default Settings)
  },
  output: {
    path: path.join(buildPath, process.env.VERSION_HASH),
    publicPath: path.join('/static', process.env.VERSION_HASH),
    filename: "js/[name].bundle.js",
    chunkFilename: "js/[name].chunk.js"
  },
  externals: {
    'jquery': 'jQuery',
    'react': 'React',
    'react-dom': 'ReactDOM',
    'bootstrap': 'bootstrap',
    'bootswatch': 'bootswatch',
  },
  optimization: {
    runtimeChunk: {
      name: 'vendor'
    },
    splitChunks: {
      name: 'vendor',
      chunks: 'initial',
    }
  },
  plugins: plugins,
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        //include: paths.appSrc,
        loader: require.resolve('babel-loader'),
        options: {
          // This is a feature of `babel-loader` for Webpack (not Babel itself).
          // It enables caching results in ./node_modules/.cache/babel-loader/
          // directory for faster rebuilds.
          cacheDirectory: true,
          //plugins: ['react-hot-loader/babel'],
        },
      },
      {
        test: /\.css$/,
        loader: "style-loader!css-loader"
      },
      {
        test: /\.png$/,
        loader: "url-loader?limit=100000"
      },
      {
        test: /\.jpg$/,
        loader: "file-loader"
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'file'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url?limit=10000&mimetype=image/svg+xml'
      }
    ],
  },
  // Dev server Configuration options
  devServer: {
    contentBase: 'frontend',  // Relative directory for base of server
    hot: true,        // Live-reload
    inline: true,
    port: 4000,
    host: '0.0.0.0',  // Change to '0.0.0.0' for external facing server
    proxy: {
      '*': {
        target: 'http://localhost:4001',
        secure: false,
        // bypass: function (req, res, proxyOptions) {
        //     const accept = req.headers.accept
        //     console.log(accept);
        //     //if (accept.indexOf('html') !== -1 || accept.indexOf('js') !== -1 || accept.indexOf('css') !== -1) {
        //         console.log('Skipping proxy for browser request.');
        //         return false;
        //     //}
        // }
      }
    },
  },
};

module.exports = config;
<|endoftext|>


<commit_before>// Copyright 2002-2014, University of Colorado

/**
 * Poolable wrapper for SVG <group> elements. We store state and add listeners directly to the corresponding Node, so that we can set dirty flags and
 * smartly update only things that have changed. This takes a load off of SVGBlock.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  var Poolable = require( 'PHET_CORE/Poolable' );
  var cleanArray = require( 'PHET_CORE/cleanArray' );
  var scenery = require( 'SCENERY/scenery' );

  scenery.SVGGroup = function SVGGroup( block, instance, parent ) {
    this.initialize( block, instance, parent );
  };
  var SVGGroup = scenery.SVGGroup;

  SVGGroup.prototype = {
    constructor: SVGGroup,

    initialize: function( block, instance, parent ) {
      //OHTWO TODO: add collapsing groups! they can't have self drawables, transforms, filters, etc., and we probably shouldn't de-collapse groups

      this.block = block;
      this.instance = instance;
      this.node = instance.trail.lastNode();
      this.parent = parent;
      this.children = cleanArray( this.children );
      this.hasSelfDrawable = false;

      sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'initializing ' + this.toString() );

      // general dirty flag (triggered on any other dirty event)
      this.dirty = true;

      // we won't listen for transform changes (or even want to set a transform) if our node is beneath a transform root
      this.willApplyTransforms = this.block.transformRootInstance.trail.nodes.length < this.instance.trail.nodes.length;

      // we won't listen for filter changes (or set filters, like opacity or visibility) if our node is beneath a filter root
      this.willApplyFilters = this.block.filterRootInstance.trail.nodes.length < this.instance.trail.nodes.length;

      // transform handling
      this.transformDirty = true;
      this.hasTransform = this.hasTransform !== undefined ? this.hasTransform : false; // persists across disposal
      this.transformDirtyListener = this.transformDirtyListener || this.markTransformDirty.bind( this );
      if ( this.willApplyTransforms ) {
        this.node.onStatic( 'transform', this.transformDirtyListener );
      }

      // filter handling
      this.opacityDirty = true;
      this.visibilityDirty = true;
      this.clipDirty = true;
      this.hasOpacity = this.hasOpacity !== undefined ? this.hasOpacity : false; // persists across disposal
      this.clipDefinition = this.clipDefinition !== undefined ? this.clipDefinition : null; // persists across disposal
      this.clipPath = this.clipPath !== undefined ? this.clipPath : null; // persists across disposal
      this.opacityDirtyListener = this.opacityDirtyListener || this.markOpacityDirty.bind( this );
      this.visibilityDirtyListener = this.visibilityDirtyListener || this.markVisibilityDirty.bind( this );
      this.clipDirtyListener = this.clipDirtyListener || this.markClipDirty.bind( this );
      if ( this.willApplyFilters ) {
        this.node.onStatic( 'opacity', this.opacityDirtyListener );
        this.node.onStatic( 'visibility', this.visibilityDirtyListener );
        this.node.onStatic( 'clip', this.clipDirtyListener );
      }

      // for tracking the order of child groups, we use a flag and update (reorder) once per updateDisplay if necessary.
      this.orderDirty = true;
      this.orderDirtyListener = this.orderDirtyListener || this.markOrderDirty.bind( this );
      this.node.onStatic( 'childInserted', this.orderDirtyListener );
      this.node.onStatic( 'childRemoved', this.orderDirtyListener );

      if ( !this.svgGroup ) {
        this.svgGroup = document.createElementNS( scenery.svgns, 'g' );
      }

      this.instance.addSVGGroup( this );

      this.block.markDirtyGroup( this ); // so we are marked and updated properly

      return this;
    },

    addSelfDrawable: function( drawable ) {
      this.svgGroup.insertBefore( drawable.svgElement, this.children.length ? this.children[0].svgBlock : null );
      this.hasSelfDrawable = true;
    },

    removeSelfDrawable: function( drawable ) {
      this.hasSelfDrawable = false;
      this.svgGroup.removeChild( drawable.svgElement );
    },

    addChildGroup: function( group ) {
      this.markOrderDirty();

      group.parent = this;
      this.children.push( group );
      this.svgGroup.appendChild( group.svgGroup );
    },

    removeChildGroup: function( group ) {
      this.markOrderDirty();

      group.parent = null;
      this.children.splice( _.indexOf( this.children, group ), 1 );
      this.svgGroup.removeChild( group.svgGroup );
    },

    markDirty: function() {
      if ( !this.dirty ) {
        this.dirty = true;

        this.block.markDirtyGroup( this );
      }
    },

    /*---------------------------------------------------------------------------*
    * TODO: reduce filesize by creating these methods programatically. not done yet since I want to ensure correctness and make refactoring easier right now.
    *----------------------------------------------------------------------------*/

    markOrderDirty: function() {
      if ( !this.orderDirty ) {
        this.orderDirty = true;
        this.markDirty();
      }
    },

    markTransformDirty: function() {
      if ( !this.transformDirty ) {
        this.transformDirty = true;
        this.markDirty();
      }
    },

    markOpacityDirty: function() {
      if ( !this.opacityDirty ) {
        this.opacityDirty = true;
        this.markDirty();
      }
    },

    markVisibilityDirty: function() {
      if ( !this.visibilityDirty ) {
        this.visibilityDirty = true;
        this.markDirty();
      }
    },

    markClipDirty: function() {
      if ( !this.clipDirty ) {
        this.clipDirty = true;
        this.markDirty();
      }
    },

    update: function() {
      // we may have been disposed since being marked dirty on our block. we won't have a reference if we are disposed
      if ( !this.block ) {
        return;
      }

      var svgGroup = this.svgGroup;

      this.dirty = false;

      if ( this.transformDirty ) {
        this.transformDirty = false;

        if ( this.willApplyTransforms ) {

          var isIdentity = this.node.transform.isIdentity();

          if ( !isIdentity ) {
            this.hasTransform = true;
            svgGroup.setAttribute( 'transform', this.node.transform.getMatrix().getSVGTransform() );
          } else if ( this.hasTransform ) {
            this.hasTransform = false;
            svgGroup.removeAttribute( 'transform' );
          }
        } else {
          // we want no transforms if we won't be applying transforms
          if ( this.hasTransform ) {
            this.hasTransform = false;
            svgGroup.removeAttribute( 'transform' );
          }
        }
      }

      if ( this.visibilityDirty ) {
        this.visibilityDirty = false;

        svgGroup.style.display = ( this.willApplyFilters && !this.node.isVisible() ) ? 'none' : '';
      }

      if ( this.opacityDirty ) {
        this.opacityDirty = false;

        if ( this.willApplyFilters && this.node.opacity !== 1 ) {
          this.hasOpacity = true;
          svgGroup.setAttribute( 'opacity', this.node.opacity );
        } else if ( this.hasOpacity ) {
          this.hasOpacity = false;
          svgGroup.removeAttribute( 'opacity' );
        }
      }

      if ( this.clipDirty ) {
        this.clipDirty = false;

        if ( this.willApplyFilters && this.node._clipArea ) {
          if ( !this.clipDefinition ) {
            var clipId = 'clip' + this.node.getId();

            this.clipDefinition = document.createElementNS( scenery.svgns, 'clipPath' );
            this.clipDefinition.setAttribute( 'id', clipId );
            this.clipDefinition.setAttribute( 'clipPathUnits', 'userSpaceOnUse' );
            this.block.defs.appendChild( this.clipDefinition ); // TODO: method? evaluate with future usage of defs (not done yet)

            this.clipPath = document.createElementNS( scenery.svgns, 'path' );
            this.clipDefinition.appendChild( this.clipPath );

            svgGroup.setAttribute( 'clip-path', 'url(#' + clipId + ')' );
          }

          this.clipPath.setAttribute( 'd', this.node._clipArea.getSVGPath() );
        } else if ( this.clipDefinition ) {
          svgGroup.removeAttribute( 'clip-path' );
          this.block.defs.removeChild( this.clipDefinition ); // TODO: method? evaluate with future usage of defs (not done yet)

          // TODO: consider pooling these?
          this.clipDefinition = null;
          this.clipPath = null;
        }
      }

      if ( this.orderDirty ) {
        this.orderDirty = false;

        // our instance should have the proper order of children. we check that way.
        var idx = 0;
        var instanceChildren = this.instance.children;
        for ( var i = 0; i < instanceChildren.length; i++ ) {
          var group = instanceChildren[i].lookupSVGGroup( this.block );
          if ( group ) {
            // ensure that the spot in our array (and in the DOM) at [idx] is correct
            if ( this.children[idx] !== group ) {
              // out of order, rearrange

              // in the DOM first (since we reference the children array to know what to insertBefore)
              svgGroup.insertBefore( group.svgGroup, idx + 1 >= this.children.length ? null : this.children[idx+1].svgGroup ); // see http://stackoverflow.com/questions/9732624/how-to-swap-dom-child-nodes-in-javascript

              // then in our children array
              var oldIndex = _.indexOf( this.children, group );
              assert && assert( oldIndex > idx, 'The item we are moving forward to location [idx] should not have an index less than that' );
              this.children.splice( oldIndex, 1 );
              this.children.splice( idx, 0, group );
            }

            // if there was a group for that instance, we move on to the next spot
            idx++;
          }
        }
      }
    },

    isReleasable: function() {
      // if we have no parent, we are the rootGroup (the block is responsible for disposing that one)
      return !this.hasSelfDrawable && !this.children.length && this.parent;
    },

    dispose: function() {
      sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'dispose ' + this.toString() );

      assert && assert( this.children.length === 0, 'Should be empty by now' );

      if ( this.willApplyTransforms ) {
        this.node.offStatic( 'transform', this.transformDirtyListener );
      }
      if ( this.willApplyFilters ) {
        this.node.offStatic( 'opacity', this.opacityDirtyListener );
        this.node.offStatic( 'visibility', this.visibilityDirtyListener );
        this.node.offStatic( 'clip', this.clipDirtyListener );
      }
      this.node.offStatic( 'childInserted', this.orderDirtyListener );
      this.node.offStatic( 'childRemoved', this.orderDirtyListener );

      this.instance.removeSVGGroup( this );

      // clear references
      this.parent = null;
      this.block = null;
      this.instance = null;
      this.node = null;
      this.clipDefinition = null;
      this.clipPath = null;
      cleanArray( this.children );

      // for now
      this.freeToPool();
    },

    toString: function() {
      return 'SVGGroup:' + this.block.toString() + '_' + this.instance.toString();
    }
  };

  // @public
  SVGGroup.addDrawable = function( block, drawable ) {
    assert && assert( drawable.instance, 'Instance is required for a drawable to be grouped correctly in SVG' );

    var group = SVGGroup.ensureGroupsToInstance( block, drawable.instance );
    group.addSelfDrawable( drawable );
  };

  // @public
  SVGGroup.removeDrawable = function( block, drawable ) {
    drawable.instance.lookupSVGGroup( block ).removeSelfDrawable( drawable );

    SVGGroup.releaseGroupsToInstance( block, drawable.instance );
  };

  // @private
  SVGGroup.ensureGroupsToInstance = function( block, instance ) {
    // TODO: assertions here

    var group = instance.lookupSVGGroup( block );

    if ( !group ) {
      assert && assert( instance !== block.rootGroup.instance, 'Making sure we do not walk past our rootGroup' );

      var parentGroup = SVGGroup.ensureGroupsToInstance( block, instance.parent );

      group = SVGGroup.createFromPool( block, instance, parentGroup );
      parentGroup.addChildGroup( group );
    }

    return group;
  };

  // @private
  SVGGroup.releaseGroupsToInstance = function( block, instance ) {
    var group = instance.lookupSVGGroup( block );

    if ( group.isReleasable() ) {
      group.parent.removeChildGroup( group );

      SVGGroup.releaseGroupsToInstance( block, instance.parent );

      group.dispose();
    }
  };

  /* jshint -W064 */
  Poolable( SVGGroup, {
    constructorDuplicateFactory: function( pool ) {
      return function( block, instance, parent ) {
        if ( pool.length ) {
          sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'new from pool' );
          return pool.pop().initialize( block, instance, parent );
        } else {
          sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'new from constructor' );
          return new SVGGroup( block, instance, parent );
        }
      };
    }
  } );

  return SVGGroup;
} );
<commit_msg>SVGGroup bugfix - don't rely on instance tree during disposal<commit_after>// Copyright 2002-2014, University of Colorado

/**
 * Poolable wrapper for SVG <group> elements. We store state and add listeners directly to the corresponding Node, so that we can set dirty flags and
 * smartly update only things that have changed. This takes a load off of SVGBlock.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  var Poolable = require( 'PHET_CORE/Poolable' );
  var cleanArray = require( 'PHET_CORE/cleanArray' );
  var scenery = require( 'SCENERY/scenery' );

  scenery.SVGGroup = function SVGGroup( block, instance, parent ) {
    this.initialize( block, instance, parent );
  };
  var SVGGroup = scenery.SVGGroup;

  SVGGroup.prototype = {
    constructor: SVGGroup,

    initialize: function( block, instance, parent ) {
      //OHTWO TODO: add collapsing groups! they can't have self drawables, transforms, filters, etc., and we probably shouldn't de-collapse groups

      this.block = block;
      this.instance = instance;
      this.node = instance.trail.lastNode();
      this.parent = parent;
      this.children = cleanArray( this.children );
      this.hasSelfDrawable = false;

      sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'initializing ' + this.toString() );

      // general dirty flag (triggered on any other dirty event)
      this.dirty = true;

      // we won't listen for transform changes (or even want to set a transform) if our node is beneath a transform root
      this.willApplyTransforms = this.block.transformRootInstance.trail.nodes.length < this.instance.trail.nodes.length;

      // we won't listen for filter changes (or set filters, like opacity or visibility) if our node is beneath a filter root
      this.willApplyFilters = this.block.filterRootInstance.trail.nodes.length < this.instance.trail.nodes.length;

      // transform handling
      this.transformDirty = true;
      this.hasTransform = this.hasTransform !== undefined ? this.hasTransform : false; // persists across disposal
      this.transformDirtyListener = this.transformDirtyListener || this.markTransformDirty.bind( this );
      if ( this.willApplyTransforms ) {
        this.node.onStatic( 'transform', this.transformDirtyListener );
      }

      // filter handling
      this.opacityDirty = true;
      this.visibilityDirty = true;
      this.clipDirty = true;
      this.hasOpacity = this.hasOpacity !== undefined ? this.hasOpacity : false; // persists across disposal
      this.clipDefinition = this.clipDefinition !== undefined ? this.clipDefinition : null; // persists across disposal
      this.clipPath = this.clipPath !== undefined ? this.clipPath : null; // persists across disposal
      this.opacityDirtyListener = this.opacityDirtyListener || this.markOpacityDirty.bind( this );
      this.visibilityDirtyListener = this.visibilityDirtyListener || this.markVisibilityDirty.bind( this );
      this.clipDirtyListener = this.clipDirtyListener || this.markClipDirty.bind( this );
      if ( this.willApplyFilters ) {
        this.node.onStatic( 'opacity', this.opacityDirtyListener );
        this.node.onStatic( 'visibility', this.visibilityDirtyListener );
        this.node.onStatic( 'clip', this.clipDirtyListener );
      }

      // for tracking the order of child groups, we use a flag and update (reorder) once per updateDisplay if necessary.
      this.orderDirty = true;
      this.orderDirtyListener = this.orderDirtyListener || this.markOrderDirty.bind( this );
      this.node.onStatic( 'childInserted', this.orderDirtyListener );
      this.node.onStatic( 'childRemoved', this.orderDirtyListener );

      if ( !this.svgGroup ) {
        this.svgGroup = document.createElementNS( scenery.svgns, 'g' );
      }

      this.instance.addSVGGroup( this );

      this.block.markDirtyGroup( this ); // so we are marked and updated properly

      return this;
    },

    addSelfDrawable: function( drawable ) {
      this.svgGroup.insertBefore( drawable.svgElement, this.children.length ? this.children[0].svgBlock : null );
      this.hasSelfDrawable = true;
    },

    removeSelfDrawable: function( drawable ) {
      this.hasSelfDrawable = false;
      this.svgGroup.removeChild( drawable.svgElement );
    },

    addChildGroup: function( group ) {
      this.markOrderDirty();

      group.parent = this;
      this.children.push( group );
      this.svgGroup.appendChild( group.svgGroup );
    },

    removeChildGroup: function( group ) {
      this.markOrderDirty();

      group.parent = null;
      this.children.splice( _.indexOf( this.children, group ), 1 );
      this.svgGroup.removeChild( group.svgGroup );
    },

    markDirty: function() {
      if ( !this.dirty ) {
        this.dirty = true;

        this.block.markDirtyGroup( this );
      }
    },

    /*---------------------------------------------------------------------------*
    * TODO: reduce filesize by creating these methods programatically. not done yet since I want to ensure correctness and make refactoring easier right now.
    *----------------------------------------------------------------------------*/

    markOrderDirty: function() {
      if ( !this.orderDirty ) {
        this.orderDirty = true;
        this.markDirty();
      }
    },

    markTransformDirty: function() {
      if ( !this.transformDirty ) {
        this.transformDirty = true;
        this.markDirty();
      }
    },

    markOpacityDirty: function() {
      if ( !this.opacityDirty ) {
        this.opacityDirty = true;
        this.markDirty();
      }
    },

    markVisibilityDirty: function() {
      if ( !this.visibilityDirty ) {
        this.visibilityDirty = true;
        this.markDirty();
      }
    },

    markClipDirty: function() {
      if ( !this.clipDirty ) {
        this.clipDirty = true;
        this.markDirty();
      }
    },

    update: function() {
      // we may have been disposed since being marked dirty on our block. we won't have a reference if we are disposed
      if ( !this.block ) {
        return;
      }

      var svgGroup = this.svgGroup;

      this.dirty = false;

      if ( this.transformDirty ) {
        this.transformDirty = false;

        if ( this.willApplyTransforms ) {

          var isIdentity = this.node.transform.isIdentity();

          if ( !isIdentity ) {
            this.hasTransform = true;
            svgGroup.setAttribute( 'transform', this.node.transform.getMatrix().getSVGTransform() );
          } else if ( this.hasTransform ) {
            this.hasTransform = false;
            svgGroup.removeAttribute( 'transform' );
          }
        } else {
          // we want no transforms if we won't be applying transforms
          if ( this.hasTransform ) {
            this.hasTransform = false;
            svgGroup.removeAttribute( 'transform' );
          }
        }
      }

      if ( this.visibilityDirty ) {
        this.visibilityDirty = false;

        svgGroup.style.display = ( this.willApplyFilters && !this.node.isVisible() ) ? 'none' : '';
      }

      if ( this.opacityDirty ) {
        this.opacityDirty = false;

        if ( this.willApplyFilters && this.node.opacity !== 1 ) {
          this.hasOpacity = true;
          svgGroup.setAttribute( 'opacity', this.node.opacity );
        } else if ( this.hasOpacity ) {
          this.hasOpacity = false;
          svgGroup.removeAttribute( 'opacity' );
        }
      }

      if ( this.clipDirty ) {
        this.clipDirty = false;

        if ( this.willApplyFilters && this.node._clipArea ) {
          if ( !this.clipDefinition ) {
            var clipId = 'clip' + this.node.getId();

            this.clipDefinition = document.createElementNS( scenery.svgns, 'clipPath' );
            this.clipDefinition.setAttribute( 'id', clipId );
            this.clipDefinition.setAttribute( 'clipPathUnits', 'userSpaceOnUse' );
            this.block.defs.appendChild( this.clipDefinition ); // TODO: method? evaluate with future usage of defs (not done yet)

            this.clipPath = document.createElementNS( scenery.svgns, 'path' );
            this.clipDefinition.appendChild( this.clipPath );

            svgGroup.setAttribute( 'clip-path', 'url(#' + clipId + ')' );
          }

          this.clipPath.setAttribute( 'd', this.node._clipArea.getSVGPath() );
        } else if ( this.clipDefinition ) {
          svgGroup.removeAttribute( 'clip-path' );
          this.block.defs.removeChild( this.clipDefinition ); // TODO: method? evaluate with future usage of defs (not done yet)

          // TODO: consider pooling these?
          this.clipDefinition = null;
          this.clipPath = null;
        }
      }

      if ( this.orderDirty ) {
        this.orderDirty = false;

        // our instance should have the proper order of children. we check that way.
        var idx = 0;
        var instanceChildren = this.instance.children;
        for ( var i = 0; i < instanceChildren.length; i++ ) {
          var group = instanceChildren[i].lookupSVGGroup( this.block );
          if ( group ) {
            // ensure that the spot in our array (and in the DOM) at [idx] is correct
            if ( this.children[idx] !== group ) {
              // out of order, rearrange

              // in the DOM first (since we reference the children array to know what to insertBefore)
              svgGroup.insertBefore( group.svgGroup, idx + 1 >= this.children.length ? null : this.children[idx+1].svgGroup ); // see http://stackoverflow.com/questions/9732624/how-to-swap-dom-child-nodes-in-javascript

              // then in our children array
              var oldIndex = _.indexOf( this.children, group );
              assert && assert( oldIndex > idx, 'The item we are moving forward to location [idx] should not have an index less than that' );
              this.children.splice( oldIndex, 1 );
              this.children.splice( idx, 0, group );
            }

            // if there was a group for that instance, we move on to the next spot
            idx++;
          }
        }
      }
    },

    isReleasable: function() {
      // if we have no parent, we are the rootGroup (the block is responsible for disposing that one)
      return !this.hasSelfDrawable && !this.children.length && this.parent;
    },

    dispose: function() {
      sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'dispose ' + this.toString() );

      assert && assert( this.children.length === 0, 'Should be empty by now' );

      if ( this.willApplyTransforms ) {
        this.node.offStatic( 'transform', this.transformDirtyListener );
      }
      if ( this.willApplyFilters ) {
        this.node.offStatic( 'opacity', this.opacityDirtyListener );
        this.node.offStatic( 'visibility', this.visibilityDirtyListener );
        this.node.offStatic( 'clip', this.clipDirtyListener );
      }
      this.node.offStatic( 'childInserted', this.orderDirtyListener );
      this.node.offStatic( 'childRemoved', this.orderDirtyListener );

      this.instance.removeSVGGroup( this );

      // clear references
      this.parent = null;
      this.block = null;
      this.instance = null;
      this.node = null;
      this.clipDefinition = null;
      this.clipPath = null;
      cleanArray( this.children );

      // for now
      this.freeToPool();
    },

    toString: function() {
      return 'SVGGroup:' + this.block.toString() + '_' + this.instance.toString();
    }
  };

  // @public
  SVGGroup.addDrawable = function( block, drawable ) {
    assert && assert( drawable.instance, 'Instance is required for a drawable to be grouped correctly in SVG' );

    var group = SVGGroup.ensureGroupsToInstance( block, drawable.instance );
    group.addSelfDrawable( drawable );
  };

  // @public
  SVGGroup.removeDrawable = function( block, drawable ) {
    drawable.instance.lookupSVGGroup( block ).removeSelfDrawable( drawable );

    SVGGroup.releaseGroupsToInstance( block, drawable.instance );
  };

  // @private
  SVGGroup.ensureGroupsToInstance = function( block, instance ) {
    // TODO: assertions here

    var group = instance.lookupSVGGroup( block );

    if ( !group ) {
      assert && assert( instance !== block.rootGroup.instance, 'Making sure we do not walk past our rootGroup' );

      var parentGroup = SVGGroup.ensureGroupsToInstance( block, instance.parent );

      group = SVGGroup.createFromPool( block, instance, parentGroup );
      parentGroup.addChildGroup( group );
    }

    return group;
  };

  // @private
  SVGGroup.releaseGroupsToInstance = function( block, instance ) {
    var group = instance.lookupSVGGroup( block );

    if ( group.isReleasable() ) {
      var parentGroup = group.parent;
      parentGroup.removeChildGroup( group );

      SVGGroup.releaseGroupsToInstance( block, parentGroup.instance );

      group.dispose();
    }
  };

  /* jshint -W064 */
  Poolable( SVGGroup, {
    constructorDuplicateFactory: function( pool ) {
      return function( block, instance, parent ) {
        if ( pool.length ) {
          sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'new from pool' );
          return pool.pop().initialize( block, instance, parent );
        } else {
          sceneryLayerLog && sceneryLayerLog.SVGGroup && sceneryLayerLog.SVGGroup( 'new from constructor' );
          return new SVGGroup( block, instance, parent );
        }
      };
    }
  } );

  return SVGGroup;
} );
<|endoftext|>


<commit_before>/**
 * gettext.js ( http://code.google.com/p/gettext-js/ )
 *
 * @author     Maxime Haineault, 2007 (max@centdessin.com)
 * @version    0.1.0
 * @licence    M.I.T
 * @example:
 *
 *   Gettext.lang = 'de';
 *   Gettext.gettext('hello %s','world');
 *   _('hello %s','world');
 *
 */

var jsGettext = Class.create();
jsGettext.prototype = {

	initialize: function(lang) {
		this.lang         = lang || 'en';
		this.debug        = true;
		this.LCmessages   = {};
		this.links        = [];
		this.linksPointer = 0;
		this.currentFetch = false;
		this.init();

		new PeriodicalExecuter(function(pe) {
  			if (Gettext.linksPointer == Gettext.links.length) pe.stop();
  			else {
  				Gettext.include.apply(Gettext, Gettext.links[Gettext.linksPointer])
  				Gettext.linksPointer++;
  			}
		}, 0.5);
	},

	init: function() {
		this.links = $$('link').map(function(link){
			if (link.rel == 'gettext' && link.href && link.lang) return [link.lang, link.href];
		});
	},

	log: function() {
		if (typeof console != 'undefined' && console.log && this.debug) {
			console.log.apply(this,arguments);
		}
	},

	include: function(lang, href) {
		if (arguments[1].substring(0,7) == 'http://') {
			onCompleteCallback = this.include_complete.bind(this);
			this.currentFetch  = lang;
			new Ajax.Request(arguments[1], {
				onComplete: onCompleteCallback
			});
		}
		else {
			this.LCmessages[lang] = new jsGettext.Parse(str);
			Gettext.log('Loading language: ', lang.toUpperCase(), ' (',str,')');
		}
		this.log('Loading language: ', lang.toUpperCase(), ' (',href,')');
	},

	include_complete: function (t) {
			this.log('Fetched language: ', this.currentFetch.toUpperCase(), ' ('+ t.responseText.length +' bytes)');
			this.LCmessages[this.currentFetch] = this.parse(t.responseText);
			this.log(_('Parsed: %d msgids, %d msgids-plurals, %d msgstrs, %d obsoletes, %d contexts, %d references %d flags, %d previous untranslateds, %d previous untranslated-plurals',[
				this.LCmessages[this.currentFetch].msgid.length,
				this.LCmessages[this.currentFetch].msgidplurals.length,
				this.LCmessages[this.currentFetch].msgstr.length,
				this.LCmessages[this.currentFetch].obsoletes.length,
				this.LCmessages[this.currentFetch].contexts.length,
				this.LCmessages[this.currentFetch].references.length,
				this.LCmessages[this.currentFetch].flags.length,
				this.LCmessages[this.currentFetch].previousUntranslateds.length,
				this.LCmessages[this.currentFetch].previousUntranslatedsPlurals.length]));
			this.currentFetch = false;
	},

	// This function based on public domain code. Feel free to take a look the original function at http://jan.moesen.nu/
	// ---
	// Changes made by Maxime Haineault (2007):
	// - The function is now extended to Strings instead (using prototype)
	// - The function now accept arrays as arguments, much easier to handle (using prototype)
	// - The function throw error if argument lenght doesn't equal matches count (as specified in gettex file format documentation)
	// - Translations lookups
	// Reference: http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files

	gettext: function() {
		if (!arguments || arguments.length < 1 || !RegExp) return;
		var str      = arguments[0];
		arguments[0] = null;
		arguments    = $A(arguments).compact();

		if (arguments.length == 1 && typeof arguments[0] == 'object') {
			arguments = $A(arguments[0]);
		}

		if (str.match('%','g').length != arguments.length) {
			Gettext.log('Gettext error: Arguments count ('+ arguments.length +') does not match replacement token count ('+ str.match('%','g').length +').');
			return;
		}

		// Try to find translated string
		if (Gettext.LCmessages[Gettext.lang] && Gettext.LCmessages[Gettext.lang].msgid.indexOf(str) != -1) {
			str = Gettext.LCmessages[Gettext.lang].msgstr[Gettext.LCmessages[Gettext.lang].msgid.indexOf(str)];
		}

		var re  = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; //'
		var a   = b = [], i = 0, numMatches = 0;
		while (a = re.exec(str)) {
			var leftpart   = a[1], pPad  = a[2], pJustify  = a[3], pMinLength = a[4];
			var pPrecision = a[5], pType = a[6], rightPart = a[7];
			numMatches++;
			if (pType == '%') subst = '%';
			else {
				var param = arguments[i];
				var pad   = '';
				if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
				else if (pPad) pad = pPad;
				var justifyRight = true;
				if (pJustify && pJustify === "-") justifyRight = false;
				var minLength = -1;
				if (pMinLength) minLength = parseInt(pMinLength);
				var precision = -1;
				if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
				var subst = param;
				if (pType == 'b')      subst = parseInt(param).toString(2);
				else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
				else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
				else if (pType == 'u') subst = Math.abs(param);
				else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
				else if (pType == 'o') subst = parseInt(param).toString(8);
				else if (pType == 's') subst = param;
				else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
				else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
			}
			str = leftpart + subst + rightPart;
			i++;
		}
		return str;
	},

	parse: function(str) {
		// #  translator-comments
		// #. extracted-comments
		// #: reference...
		// #, flag...
		// #| msgid previous-untranslated-string
		// msgid untranslated-string
		// msgstr translated-string

		rgx_msg   = new RegExp(/((^#[\:\.,~|\s]\s?)?|(msgid\s"|msgstr\s")?)?("$)?/g);
		function clean(str) {
			return str.replace(rgx_msg,'').replace(/\\"/g,'"');
		}

		po        = str.split("\n");
		head      = [];
		msgids    = [];
		strings   = [];
		obs       = [];
		tpls      = [];
		curMsgid  = -1;
		output    = { header: [], contexts: [], msgid: [], msgidplurals: [], references: [], flags: [], msgstr: [], obsoletes: [], previousUntranslateds: [], previousUntranslatedsPlurals: [] };

		for(x=0, cnt=po.length; x<cnt; ++x) {
			if (po[x].substring(0,1) == '#') {
				switch (po[x].substring(1,2)) {
					// translator-comments
					case ' ':
					// top comments
					if (curMsgid == 0) output.header.push(po[x]);
					break;

					// references
					case ':':
					if(typeof output.references[curMsgid] == 'undefined') output.references[curMsgid] = [];
					output.references[curMsgid].push(clean(po[x]));
					break;

					// msgid previous-untranslated-string
					case '|':
					if(typeof output.previousUntranslateds[curMsgid] == 'undefined') output.previousUntranslateds[curMsgid] = [];
					// previous-untranslated-string-plural
					if (po[x].substring(3,15) == 'msgid_plural') {
						output.previousUntranslateds[curMsgid].push(clean(po[x]));
					}
					else {
						output.previousUntranslatedsPlurals[curMsgid].push(clean(po[x]));
					}
					break;

					// flags
					case ',':
					if(typeof output.flags[curMsgid] == 'undefined') output.flags[curMsgid] = [];
					output.flags[curMsgid].push(clean(po[x]));
					break;

					// obsoletes
					case '~':
					if (po[x].substring(3,9) == 'msgid ') {
						curMsgid++;
						if(typeof output.msgid[curMsgid] == 'undefined') output.msgid[curMsgid] = [];
						output.msgid[curMsgid].push(clean(po[x]));
						output.obsoletes.push(curMsgid);
					}
					else if (po[x].substring(3,10) == 'msgstr ') {
						if(typeof output.msgstr[curMsgid] == 'undefined')    output.msgstr[curMsgid] = [];
						output.msgstr[curMsgid].push(clean(po[x]));
					}
					break;
				}
			}
			else {
				// untranslated-string
				if (po[x].substring(0,6) == 'msgid ') {
					if (po[x].substring(6,8) != '""')  {
						curMsgid++;
						if(typeof output.msgid[curMsgid] != 'object') output.msgid[curMsgid] = [];
						output.msgid[curMsgid].push(clean(po[x]));
					}
				}

				// untranslated-string-plural
				if (po[x].substring(0,13) == 'msgid_plural ') {
					if (!output.msgidplurals[curMsgid]) output.msgidplurals[curMsgid] = [];
					output.msgidplurals[curMsgid].push(clean(po[x]));
				}

				// translated-string
				if (po[x].substring(0,6) == 'msgstr') {
					if (po[x].substring(8,10) != '""')  {
						// translated-string-case-n
						if (po[x].substring(6,7) == '[') {}
						else {
							if (!output.msgstr[curMsgid]) output.msgstr[curMsgid] = [];
							output.msgstr[curMsgid].push(clean(po[x]));
						}
					}
				}

				// context
				if (po[x].substring(0,7) == 'msgctxt ') {
					if (!output.contexts[curMsgid]) output.contexts[curMsgid] = [];
					output.contexts[curMsgid].push(clean(po[x]));
				}
			}
		}
		return output;
	}
}
Gettext = new jsGettext();
function _() { return Gettext.gettext.apply(this,arguments); }<commit_msg>- code cleanup<commit_after>/**
 * gettext.js ( http://code.google.com/p/gettext-js/ )
 *
 * @author     Maxime Haineault, 2007 (max@centdessin.com)
 * @version    0.1.0
 * @licence    M.I.T
 * @example:
 *
 *   Gettext.lang = 'de';
 *   Gettext.gettext('hello %s','world');
 *   _('hello %s','world');
 *
 */

var jsGettext = Class.create();
jsGettext.prototype = {

	initialize: function(lang) {
		this.lang         = lang || 'en';
		this.debug        = true;
		this.LCmessages   = {};
		this.links        = [];
		this.linksPointer = 0;
		this.currentFetch = false;
		this.links        = $$('link').map(function(link){
			if (link.rel == 'gettext' && link.href && link.lang) return [link.lang, link.href];
		});

		new PeriodicalExecuter(function(pe) {
  			if (Gettext.linksPointer == Gettext.links.length) pe.stop();
  			else {
  				Gettext.include.apply(Gettext, Gettext.links[Gettext.linksPointer])
  				Gettext.linksPointer++;
  			}
		}, 0.5);
	},

	log: function() {
		if (typeof console != 'undefined' && console.log && this.debug) {
			console.log.apply(this,arguments);
		}
	},

	include: function(lang, href) {
		if (arguments[1].substring(0,7) == 'http://') {
			onCompleteCallback = this.include_complete.bind(this);
			this.currentFetch  = lang;
			new Ajax.Request(arguments[1], {
				onComplete: onCompleteCallback
			});
		}
		else {
			this.LCmessages[lang] = new jsGettext.Parse(str);
			Gettext.log('Loading language: ', lang.toUpperCase(), ' (',str,')');
		}
		this.log('Loading language: ', lang.toUpperCase(), ' (',href,')');
	},

	include_complete: function (t) {
			this.log('Fetched language: ', this.currentFetch.toUpperCase(), ' ('+ t.responseText.length +' bytes)');
			this.LCmessages[this.currentFetch] = this.parse(t.responseText);
			this.log(_('Parsed: %d msgids, %d msgids-plurals, %d msgstrs, %d obsoletes, %d contexts, %d references %d flags, %d previous untranslateds, %d previous untranslated-plurals',[
				this.LCmessages[this.currentFetch].msgid.length,
				this.LCmessages[this.currentFetch].msgidplurals.length,
				this.LCmessages[this.currentFetch].msgstr.length,
				this.LCmessages[this.currentFetch].obsoletes.length,
				this.LCmessages[this.currentFetch].contexts.length,
				this.LCmessages[this.currentFetch].references.length,
				this.LCmessages[this.currentFetch].flags.length,
				this.LCmessages[this.currentFetch].previousUntranslateds.length,
				this.LCmessages[this.currentFetch].previousUntranslatedsPlurals.length]));
			this.currentFetch = false;
	},

	// This function based on public domain code. Feel free to take a look the original function at http://jan.moesen.nu/
	// ---
	// Changes made by Maxime Haineault (2007):
	// - The function is now extended to Strings instead (using prototype)
	// - The function now accept arrays as arguments, much easier to handle (using prototype)
	// - The function throw error if argument lenght doesn't equal matches count (as specified in gettex file format documentation)
	// - Translations lookups
	// Reference: http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files

	gettext: function() {
		if (!arguments || arguments.length < 1 || !RegExp) return;
		var str      = arguments[0];
		arguments[0] = null;
		arguments    = $A(arguments).compact();

		if (arguments.length == 1 && typeof arguments[0] == 'object') {
			arguments = $A(arguments[0]);
		}

		if (str.match('%','g').length != arguments.length) {
			Gettext.log('Gettext error: Arguments count ('+ arguments.length +') does not match replacement token count ('+ str.match('%','g').length +').');
			return;
		}

		// Try to find translated string
		if (Gettext.LCmessages[Gettext.lang] && Gettext.LCmessages[Gettext.lang].msgid.indexOf(str) != -1) {
			str = Gettext.LCmessages[Gettext.lang].msgstr[Gettext.LCmessages[Gettext.lang].msgid.indexOf(str)];
		}

		var re  = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; //'
		var a   = b = [], i = 0, numMatches = 0;
		while (a = re.exec(str)) {
			var leftpart   = a[1], pPad  = a[2], pJustify  = a[3], pMinLength = a[4];
			var pPrecision = a[5], pType = a[6], rightPart = a[7];
			numMatches++;
			if (pType == '%') subst = '%';
			else {
				var param = arguments[i];
				var pad   = '';
				if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
				else if (pPad) pad = pPad;
				var justifyRight = true;
				if (pJustify && pJustify === "-") justifyRight = false;
				var minLength = -1;
				if (pMinLength) minLength = parseInt(pMinLength);
				var precision = -1;
				if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
				var subst = param;
				if (pType == 'b')      subst = parseInt(param).toString(2);
				else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
				else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
				else if (pType == 'u') subst = Math.abs(param);
				else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
				else if (pType == 'o') subst = parseInt(param).toString(8);
				else if (pType == 's') subst = param;
				else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
				else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
			}
			str = leftpart + subst + rightPart;
			i++;
		}
		return str;
	},

	parse: function(str) {
		// #  translator-comments
		// #. extracted-comments
		// #: reference...
		// #, flag...
		// #| msgid previous-untranslated-string
		// msgid untranslated-string
		// msgstr translated-string

		rgx_msg   = new RegExp(/((^#[\:\.,~|\s]\s?)?|(msgid\s"|msgstr\s")?)?("$)?/g);
		function clean(str) {
			return str.replace(rgx_msg,'').replace(/\\"/g,'"');
		}

		po        = str.split("\n");
		head      = [];
		msgids    = [];
		strings   = [];
		obs       = [];
		tpls      = [];
		curMsgid  = -1;
		output    = { header: [], contexts: [], msgid: [], msgidplurals: [], references: [], flags: [], msgstr: [], obsoletes: [], previousUntranslateds: [], previousUntranslatedsPlurals: [] };

		for(x=0, cnt=po.length; x<cnt; ++x) {
			if (po[x].substring(0,1) == '#') {
				switch (po[x].substring(1,2)) {
					// translator-comments
					case ' ':
					// top comments
					if (curMsgid == 0) output.header.push(po[x]);
					break;

					// references
					case ':':
					if(typeof output.references[curMsgid] == 'undefined') output.references[curMsgid] = [];
					output.references[curMsgid].push(clean(po[x]));
					break;

					// msgid previous-untranslated-string
					case '|':
					if(typeof output.previousUntranslateds[curMsgid] == 'undefined') output.previousUntranslateds[curMsgid] = [];
					// previous-untranslated-string-plural
					if (po[x].substring(3,15) == 'msgid_plural') {
						output.previousUntranslateds[curMsgid].push(clean(po[x]));
					}
					else {
						output.previousUntranslatedsPlurals[curMsgid].push(clean(po[x]));
					}
					break;

					// flags
					case ',':
					if(typeof output.flags[curMsgid] == 'undefined') output.flags[curMsgid] = [];
					output.flags[curMsgid].push(clean(po[x]));
					break;

					// obsoletes
					case '~':
					if (po[x].substring(3,9) == 'msgid ') {
						curMsgid++;
						if(typeof output.msgid[curMsgid] == 'undefined') output.msgid[curMsgid] = [];
						output.msgid[curMsgid].push(clean(po[x]));
						output.obsoletes.push(curMsgid);
					}
					else if (po[x].substring(3,10) == 'msgstr ') {
						if(typeof output.msgstr[curMsgid] == 'undefined')    output.msgstr[curMsgid] = [];
						output.msgstr[curMsgid].push(clean(po[x]));
					}
					break;
				}
			}
			else {
				// untranslated-string
				if (po[x].substring(0,6) == 'msgid ') {
					if (po[x].substring(6,8) != '""')  {
						curMsgid++;
						if(typeof output.msgid[curMsgid] != 'object') output.msgid[curMsgid] = [];
						output.msgid[curMsgid].push(clean(po[x]));
					}
				}

				// untranslated-string-plural
				if (po[x].substring(0,13) == 'msgid_plural ') {
					if (!output.msgidplurals[curMsgid]) output.msgidplurals[curMsgid] = [];
					output.msgidplurals[curMsgid].push(clean(po[x]));
				}

				// translated-string
				if (po[x].substring(0,6) == 'msgstr') {
					if (po[x].substring(8,10) != '""')  {
						// translated-string-case-n
						if (po[x].substring(6,7) == '[') {}
						else {
							if (!output.msgstr[curMsgid]) output.msgstr[curMsgid] = [];
							output.msgstr[curMsgid].push(clean(po[x]));
						}
					}
				}

				// context
				if (po[x].substring(0,7) == 'msgctxt ') {
					if (!output.contexts[curMsgid]) output.contexts[curMsgid] = [];
					output.contexts[curMsgid].push(clean(po[x]));
				}
			}
		}
		return output;
	}
}
Gettext = new jsGettext();
function _() { return Gettext.gettext.apply(this,arguments); }<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');

module.exports = {
    entry: "./src/app/index.js",
    output: {
        path: __dirname,
        filename: "src/bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015']
                }
            }
        ]
    }
}

// Need to run:
// $ npm install webpack-dev-server@1.12.1 -g<commit_msg>Updating webpack to support jsx<commit_after>var path = require('path');
var webpack = require('webpack');

module.exports = {
    entry: "./src/app/index.js",
    output: {
        path: __dirname,
        filename: "src/bundle.js"
    },
    resolve: {
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel',
                query: {
                    presets: ['react', 'es2015']
                }
            }
        ]
    }
}

// Need to run:
// $ npm install webpack-dev-server@1.12.1 -g<|endoftext|>


<commit_before>

 var duration_longue = true;
  var  duration_courte = false;
  var  enfant = false;
   var adult = true;
   var duree = "longue";

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut

    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //localStorage.numGroupe = nbDePersonnes;

  //  localStorage.duree = 'longue_adult';

  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

   //localStorage.duree = 'longue_adult';
    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
   $("#inputnb").change(function(e){
     var numpers = $("#inputnb").val();
     localStorage.numGroupe = numpers;
   });

  //Pour la durée :
    $("#dur_cou").click(function(e){

  //    localStorage.duree = 'courte';

      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";

    });
    $("#dur_lon").click(function(e){

    //  localStorage.duree = 'longue';

      duree = "longue";
      duration_longue = true;
      duration_courte = false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le public :
    $("#pub_enf").click(function(e){

      localStorage.type = 'enfant';

      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
    $("#pub_adu").click(function(e){

      localStorage.type = 'adult';

      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
     localStorage.dataset = "deux";
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      localStorage.dataset = "un";
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function generer() {

     var pdf = new jsPDF('p', 'pt', 'a4', false);

  //   alert(localStorage.duree);
groupe = 1;
    var logo = new Image();

    var numPErs =  (parseInt(localStorage.numGroupe));

          if(localStorage.duree == "longue_adult"){
            if(localStorage.dataset == "un"){
              var cont = 1;
              var logo = new Image();
              logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
              logo.onload = function(){
                 pdf.addImage(logo, 'PNG', 2, 2, 590,850);
              }
             alert("holq");
         /*     var logo = new Image();
         //     for (groupe = 1; groupe < 5; groupe++) {

                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo2 = new Image();
                 logo2.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_2.PNG";
                 logo2.onload = function(){
                    pdf.addImage(logo2, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo3 = new Image();
                 logo3.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_3.PNG";
                 logo3.onload = function(){
                    pdf.addImage(logo3, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo4 = new Image();
                 logo4.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_4.PNG";
                 logo4.onload = function(){
                    pdf.addImage(logo4, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
           //   }*/
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }
          }
          else if(localStorage.duree == "longue_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }

      }
      else if(localStorage.duree == "courte_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                }
              }
            }

          }
          else {
            if(localStorage.dataset == "un"){
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset1_"+groupe+".PNG";
                logo.onload = function(){
                  pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }

             }
            }else{
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }
             }
            }
          // var uno= 1;
          }
alert("pdfPRET");
  pdf.output("dataurlnewwindow");
}
function visualiser() {

}
<commit_msg>Update dynamic_carousel.js<commit_after>

 var duration_longue = true;
  var  duration_courte = false;
  var  enfant = false;
   var adult = true;
   var duree = "longue";

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut

    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //localStorage.numGroupe = nbDePersonnes;

  //  localStorage.duree = 'longue_adult';

  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

   //localStorage.duree = 'longue_adult';
    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
   $("#inputnb").change(function(e){
     var numpers = $("#inputnb").val();
     localStorage.numGroupe = numpers;
   });

  //Pour la durée :
    $("#dur_cou").click(function(e){

  //    localStorage.duree = 'courte';

      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";

    });
    $("#dur_lon").click(function(e){

    //  localStorage.duree = 'longue';

      duree = "longue";
      duration_longue = true;
      duration_courte = false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le public :
    $("#pub_enf").click(function(e){

      localStorage.type = 'enfant';

      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
    $("#pub_adu").click(function(e){

      localStorage.type = 'adult';

      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
     localStorage.dataset = "deux";
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      localStorage.dataset = "un";
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function generer() {

     var pdf = new jsPDF('p', 'pt', 'a4', false);

  //   alert(localStorage.duree);
groupe = 1;
    var logo = new Image();

    var numPErs =  (parseInt(localStorage.numGroupe));

          if(localStorage.duree == "longue_adult"){
            if(localStorage.dataset == "un"){
              var cont = 1;
              var logo = new Image();
              logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
              logo.onload = function(){
                 pdf.addImage(logo, 'PNG', 2, 2, 590,850);
              }

             alert("pdfPRET");
  pdf.output("dataurlnewwindow");
         /*     var logo = new Image();
         //     for (groupe = 1; groupe < 5; groupe++) {

                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo2 = new Image();
                 logo2.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_2.PNG";
                 logo2.onload = function(){
                    pdf.addImage(logo2, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo3 = new Image();
                 logo3.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_3.PNG";
                 logo3.onload = function(){
                    pdf.addImage(logo3, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo4 = new Image();
                 logo4.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_4.PNG";
                 logo4.onload = function(){
                    pdf.addImage(logo4, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
           //   }*/
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }
          }
          else if(localStorage.duree == "longue_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }

      }
      else if(localStorage.duree == "courte_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                }
              }
            }

          }
          else {
            if(localStorage.dataset == "un"){
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset1_"+groupe+".PNG";
                logo.onload = function(){
                  pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }

             }
            }else{
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }
             }
            }
          // var uno= 1;
          }

}
function visualiser() {

}
<|endoftext|>


<commit_before>const path = require('path')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')

module.exports = {
  mode: 'development',
  entry: [
    './src/index.js'
  ],
  output: {
    library: 'printJS',
    libraryTarget: 'umd',
    path: path.resolve(__dirname, 'dist'),
    filename: 'print.js',
    sourceMapFilename: 'print.map',
    libraryExport: 'default'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      },
      // TODO: Configure istanbul to interpret how webpack bundles files
      // {
      //   test: /\.js$/,
      //   use: {
      //     loader: 'istanbul-instrumenter-loader',
      //     options: { esModules: true }
      //   },
      //   enforce: 'post',
      //   exclude: /node_modules|\.spec\.js$/
      // },
      {
        test: /\.scss$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'print.css'
    })
  ],
  optimization: {
    minimizer: [
      new OptimizeCssAssetsPlugin({
        assetNameRegExp: /\.css$/g,
        canPrint: false
      }),
      new UglifyJSPlugin({
        sourceMap: true
      })
    ]
  }
}
<commit_msg>set source-map as a devtool<commit_after>const path = require('path')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')

module.exports = {
  mode: 'development',
  devtool: 'source-map',
  entry: [
    './src/index.js'
  ],
  output: {
    library: 'printJS',
    libraryTarget: 'umd',
    path: path.resolve(__dirname, 'dist'),
    filename: 'print.js',
    sourceMapFilename: 'print.map',
    libraryExport: 'default'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      },
      // TODO: Configure istanbul to interpret how webpack bundles files
      // {
      //   test: /\.js$/,
      //   use: {
      //     loader: 'istanbul-instrumenter-loader',
      //     options: { esModules: true }
      //   },
      //   enforce: 'post',
      //   exclude: /node_modules|\.spec\.js$/
      // },
      {
        test: /\.scss$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'print.css'
    })
  ],
  optimization: {
    minimizer: [
      new OptimizeCssAssetsPlugin({
        assetNameRegExp: /\.css$/g,
        canPrint: false
      }),
      new UglifyJSPlugin({
        sourceMap: true
      })
    ]
  }
}
<|endoftext|>