<commit_before>// -------------------------------------------------------------------------------------------------
// OpenSeaMap Water Depth - Web frontend for depth data handling.
//
// Written in 2012 by Dominik Fässler dfa@bezono.org
//
// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain
// worldwide. This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
// -------------------------------------------------------------------------------------------------

OSeaM.views.MapTracks = OSeaM.View.extend({
    render: function() {
        var template = OSeaM.loadTemplate('maptracks');
        var content = $(template());
        OSeaM.frontend.translate(content);
        this.$el.html(content);
        this.initOpenLayers();
        return this;
    },
    mapEventMove: function (view) {
        var fn = function(data) {
//            this.attributionControl.updateAttribution();
            this.layerBase.attribution = 'Data CC-By-SA by OpenStreetMap',
            this.layerTrackPoints10.attribution = data;
            this.layerTrackPoints.attribution = data;
            this.attributionControl.draw();
//            this.attributionControl = new OpenLayers.Control.Attribution();
            this.attributionControl.updateAttribution();
        };
        if(this.map != null) {
        var bounds = this.map.getExtent().toArray();
        var b = this.y2lat(bounds[1]).toFixed(5);
        var t = this.y2lat(bounds[3]).toFixed(5);
        var l = this.x2lon(bounds[0]).toFixed(5);
        var r = this.x2lon(bounds[2]).toFixed(5);

        jQuery.ajax({
            type: 'GET',
            url: OSeaM.apiUrl + 'license?lat1=' + b + '&lon1=' + l + '&lat2=' + t + '&lon2=' + r  ,
            dataType: 'text',
            success: jQuery.proxy(fn, this)
        });

        }

    },
    initOpenLayers: function() {

        this.projectionWGS84    = new OpenLayers.Projection('EPSG:4326');
        this.projectionMercator = new OpenLayers.Projection('EPSG:900913');
        this.maxExtent          = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
                                          this.projectionWGS84,
                                          this.projectionMercator
                                      );

        this.map = new OpenLayers.Map(this.$el.find('.oseam-map-tracks')[0], {
            projection: this.projectionMercator,
            displayProjection: this.projectionWGS84,
            maxExtent: this.maxExtent,
            numZoomLevels: 22,
            maxResolution: 156543.0399,
//        	events: {
//        		moveend     : this.mapEventMove(this),
//        		zoomend     : this.mapEventMove(this)
//        	},
            units: 'meters'
        });

        this.layerBase = new OpenLayers.Layer.XYZ('OpenStreetMap',
            'http://osm1.wtnet.de/tiles/base/${z}/${x}/${y}.png', {
                resolutions: [
                    156543.03390625, 78271.516953125, 39135.7584765625,
                    19567.87923828125, 9783.939619140625, 4891.9698095703125,
                    2445.9849047851562, 1222.9924523925781, 611.4962261962891,
                    305.74811309814453, 152.87405654907226, 76.43702827453613,
                    38.218514137268066, 19.109257068634033, 9.554628534317017,
                    4.777314267158508, 2.388657133579254, 1.194328566789627,
                    0.5971642833948135, 0.25, 0.1, 0.05
                ],
                serverResolutions: [
                    156543.03390625, 78271.516953125, 39135.7584765625,
                    19567.87923828125, 9783.939619140625, 4891.9698095703125,
                    2445.9849047851562, 1222.9924523925781, 611.4962261962891,
                    305.74811309814453, 152.87405654907226, 76.43702827453613,
                    38.218514137268066, 19.109257068634033, 9.554628534317017,
                    4.777314267158508, 2.388657133579254, 1.194328566789627,
                    0.5971642833948135
                ],
                transitionEffect: 'resize',
                sphericalMercator: true
            }
        );
        this.layerTrackPoints = new OpenLayers.Layer.WMS('100m',
            'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                layers: 'trackpoints_cor1_test_dbs,trackpoints_cor1_test,test_zoom_10_cor_1_points,test_zoom_9_cor_1_points,test_zoom_8_cor_1_points,test_zoom_7_cor_1_points,test_zoom_6_cor_1_points,test_zoom_5_cor_1_points,test_zoom_4_cor_1_points,test_zoom_3_cor_1_points,test_zoom_2_cor_1_points',
                numZoomLevels: 22,
                projection: this.projectionMercator,
                type: 'png',
                transparent: true
            },{
                isBaseLayer: false,
                tileSize: new OpenLayers.Size(1024,1024)
            }
        );
        this.layerTrackPoints10 = new OpenLayers.Layer.WMS('10m',
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                    layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
                    numZoomLevels: 22,
                    projection: this.projectionMercator,
                    type: 'png',
                    transparent: true
                },{
                    isBaseLayer: false,
                    tileSize: new OpenLayers.Size(1024,1024),
                    visibility : false
                }
            );
        this.layerTrackPoints_filter1 = new OpenLayers.Layer.WMS('100m Filter 1',
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                    layers: 'trackpoints_filter1_0,trackpoints_filter1_1',
                    numZoomLevels: 22,
                    projection: this.projectionMercator,
                    type: 'png',
                    transparent: true
                },{
                    isBaseLayer: false,
                    tileSize: new OpenLayers.Size(1024,1024)
                }
            );
//            this.layerTrackPoints10_filter1 = new OpenLayers.Layer.WMS('10m Filter 1',
//                    'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
//                        layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
//                        numZoomLevels: 22,
//                        projection: this.projectionMercator,
//                        type: 'png',
//                        transparent: true
//                    },{
//                        isBaseLayer: false,
//                        tileSize: new OpenLayers.Size(1024,1024),
//                        visibility : false
//                    }
//                );
            this.layerTrackPoints_filter2 = new OpenLayers.Layer.WMS('100m Filter 2',
                    'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                        layers: 'trackpoints_filter2_0,trackpoints_filter2_1',
                        numZoomLevels: 22,
                        projection: this.projectionMercator,
                        type: 'png',
                        transparent: true
                    },{
                        isBaseLayer: false,
                        tileSize: new OpenLayers.Size(1024,1024)
                    }
                );
//             this.layerTrackPoints10_filter2 = new OpenLayers.Layer.WMS('10m Filter 2',
//                        'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
//                            layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
//                            numZoomLevels: 22,
//                            projection: this.projectionMercator,
//                            type: 'png',
//                            transparent: true
//                        },{
//                            isBaseLayer: false,
//                            tileSize: new OpenLayers.Size(1024,1024),
//                            visibility : false
//                        }
//                    );
         this.triangulation = new OpenLayers.Layer.WMS("Triangulation",
                    "http://osm.franken.de/cgi-bin/mapserv.fcgi?", {
        	 			layers: ['triangulation'],
        	 			projection: new OpenLayers.Projection("EPSG:900913"),
        	 			type: 'png',
        	 			transparent: true
        	 		}, {
        	 			visibility: false,
        	 			isBaseLayer: false,
        	 			tileSize: new OpenLayers.Size(1024,1024)
        	 		});

         this.msl2lat = new OpenLayers.Layer.WMS("Mean Sea Level to LAT Difference",
                 "http://osm.franken.de/cgi-bin/mapserv.fcgi", {
        	 			layers: "lat",
        	 			projection: new OpenLayers.Projection("EPSG:900913"),
        	 			type: 'png',
        	 			transparent: true
        	 	  },{
        	 		  visibility: false,
        	 		  isBaseLayer: false,
        	 		  tileSize: new OpenLayers.Size(1024,1024)
        	 	  });
        this.layerContours = new OpenLayers.Layer.WMS("Contours",
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
            layers: ['contour','contour2'],
            numZoomLevels: 22,
            projection: this.projectionMercator,
            type: 'png',:w

            transparent: true
        },{
            isBaseLayer: false,
            tileSize: new OpenLayers.Size(1024,1024),
            visibility : false
        }
    );

        this.map.addLayers([
            this.layerBase,
            this.layerTrackPoints,
            this.layerTrackPoints10,
            this.layerTrackPoints_filter1,
            this.layerTrackPoints_filter2,
            this.triangulation,
            this.layerContours,
            this.msl2lat
        ]);
        this.attributionControl = new OpenLayers.Control.Attribution();
        this.map.addControls([
            this.attributionControl,
            new OpenLayers.Control.KeyboardDefaults(),
            new OpenLayers.Control.LayerSwitcher()
        ]);
        this.map.setCenter(new OpenLayers.LonLat(0.0, 40.0).transform(
            this.projectionWGS84,
            this.projectionMercator
          ), 3
        );
        this.map.events.register( 'moveend', this, this.mapEventMove);

        this.mapEventMove(this);
    },
    plusfacteur : function (a) {
        return a * (20037508.34 / 180);
    },

    moinsfacteur: function (a) {
        return a / (20037508.34 / 180);
    },

    y2lat: function (a) {
        return 180/Math.PI * (2 * Math.atan(Math.exp(this.moinsfacteur(a)*Math.PI/180)) - Math.PI/2);
    },

    lat2y: function (a) {
        return this.plusfacteur(180/Math.PI * Math.log(Math.tan(Math.PI/4+a*(Math.PI/180)/2)));
    },

    x2lon: function (a) {
        return this.moinsfacteur(a);
    },

    lon2x: function (a) {
        return this.plusfacteur(a);
    }
});
<commit_msg>F: provide additional layers for analysis<commit_after>// -------------------------------------------------------------------------------------------------
// OpenSeaMap Water Depth - Web frontend for depth data handling.
//
// Written in 2012 by Dominik Fässler dfa@bezono.org
//
// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain
// worldwide. This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
// -------------------------------------------------------------------------------------------------

OSeaM.views.MapTracks = OSeaM.View.extend({
    render: function() {
        var template = OSeaM.loadTemplate('maptracks');
        var content = $(template());
        OSeaM.frontend.translate(content);
        this.$el.html(content);
        this.initOpenLayers();
        return this;
    },
    mapEventMove: function (view) {
        var fn = function(data) {
//            this.attributionControl.updateAttribution();
            this.layerBase.attribution = 'Data CC-By-SA by OpenStreetMap',
            this.layerTrackPoints10.attribution = data;
            this.layerTrackPoints.attribution = data;
            this.attributionControl.draw();
//            this.attributionControl = new OpenLayers.Control.Attribution();
            this.attributionControl.updateAttribution();
        };
        if(this.map != null) {
        var bounds = this.map.getExtent().toArray();
        var b = this.y2lat(bounds[1]).toFixed(5);
        var t = this.y2lat(bounds[3]).toFixed(5);
        var l = this.x2lon(bounds[0]).toFixed(5);
        var r = this.x2lon(bounds[2]).toFixed(5);

        jQuery.ajax({
            type: 'GET',
            url: OSeaM.apiUrl + 'license?lat1=' + b + '&lon1=' + l + '&lat2=' + t + '&lon2=' + r  ,
            dataType: 'text',
            success: jQuery.proxy(fn, this)
        });

        }

    },
    initOpenLayers: function() {

        this.projectionWGS84    = new OpenLayers.Projection('EPSG:4326');
        this.projectionMercator = new OpenLayers.Projection('EPSG:900913');
        this.maxExtent          = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
                                          this.projectionWGS84,
                                          this.projectionMercator
                                      );

        this.map = new OpenLayers.Map(this.$el.find('.oseam-map-tracks')[0], {
            projection: this.projectionMercator,
            displayProjection: this.projectionWGS84,
            maxExtent: this.maxExtent,
            numZoomLevels: 22,
            maxResolution: 156543.0399,
//        	events: {
//        		moveend     : this.mapEventMove(this),
//        		zoomend     : this.mapEventMove(this)
//        	},
            units: 'meters'
        });

        this.layerBase = new OpenLayers.Layer.XYZ('OpenStreetMap',
            'http://osm1.wtnet.de/tiles/base/${z}/${x}/${y}.png', {
                resolutions: [
                    156543.03390625, 78271.516953125, 39135.7584765625,
                    19567.87923828125, 9783.939619140625, 4891.9698095703125,
                    2445.9849047851562, 1222.9924523925781, 611.4962261962891,
                    305.74811309814453, 152.87405654907226, 76.43702827453613,
                    38.218514137268066, 19.109257068634033, 9.554628534317017,
                    4.777314267158508, 2.388657133579254, 1.194328566789627,
                    0.5971642833948135, 0.25, 0.1, 0.05
                ],
                serverResolutions: [
                    156543.03390625, 78271.516953125, 39135.7584765625,
                    19567.87923828125, 9783.939619140625, 4891.9698095703125,
                    2445.9849047851562, 1222.9924523925781, 611.4962261962891,
                    305.74811309814453, 152.87405654907226, 76.43702827453613,
                    38.218514137268066, 19.109257068634033, 9.554628534317017,
                    4.777314267158508, 2.388657133579254, 1.194328566789627,
                    0.5971642833948135
                ],
                transitionEffect: 'resize',
                sphericalMercator: true
            }
        );
        this.layerTrackPoints = new OpenLayers.Layer.WMS('100m',
            'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                layers: 'trackpoints_cor1_test_dbs,trackpoints_cor1_test,test_zoom_10_cor_1_points,test_zoom_9_cor_1_points,test_zoom_8_cor_1_points,test_zoom_7_cor_1_points,test_zoom_6_cor_1_points,test_zoom_5_cor_1_points,test_zoom_4_cor_1_points,test_zoom_3_cor_1_points,test_zoom_2_cor_1_points',
                numZoomLevels: 22,
                projection: this.projectionMercator,
                type: 'png',
                transparent: true
            },{
                isBaseLayer: false,
                tileSize: new OpenLayers.Size(1024,1024)
            }
        );
        this.layerTrackPoints10 = new OpenLayers.Layer.WMS('10m',
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                    layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
                    numZoomLevels: 22,
                    projection: this.projectionMercator,
                    type: 'png',
                    transparent: true
                },{
                    isBaseLayer: false,
                    tileSize: new OpenLayers.Size(1024,1024),
                    visibility : false
                }
            );
        this.layerTrackPoints_filter1 = new OpenLayers.Layer.WMS('100m Filter 1',
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                    layers: 'trackpoints_filter1_0,trackpoints_filter1_1',
                    numZoomLevels: 22,
                    projection: this.projectionMercator,
                    type: 'png',
                    transparent: true
                },{
                    isBaseLayer: false,
                    tileSize: new OpenLayers.Size(1024,1024)
                }
            );
//            this.layerTrackPoints10_filter1 = new OpenLayers.Layer.WMS('10m Filter 1',
//                    'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
//                        layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
//                        numZoomLevels: 22,
//                        projection: this.projectionMercator,
//                        type: 'png',
//                        transparent: true
//                    },{
//                        isBaseLayer: false,
//                        tileSize: new OpenLayers.Size(1024,1024),
//                        visibility : false
//                    }
//                );
            this.layerTrackPoints_filter2 = new OpenLayers.Layer.WMS('100m Filter 2',
                    'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
                        layers: 'trackpoints_filter2_0,trackpoints_filter2_1',
                        numZoomLevels: 22,
                        projection: this.projectionMercator,
                        type: 'png',
                        transparent: true
                    },{
                        isBaseLayer: false,
                        tileSize: new OpenLayers.Size(1024,1024)
                    }
                );
//             this.layerTrackPoints10_filter2 = new OpenLayers.Layer.WMS('10m Filter 2',
//                        'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
//                            layers: 'trackpoints_cor1_test_dbs_10,trackpoints_cor1_test_10,test_zoom_10_cor_1_points_10,test_zoom_9_cor_1_points_10,test_zoom_8_cor_1_points_10,test_zoom_7_cor_1_points_10,test_zoom_6_cor_1_points_10,test_zoom_5_cor_1_points_10,test_zoom_4_cor_1_points_10,test_zoom_3_cor_1_points_10,test_zoom_2_cor_1_points_10',
//                            numZoomLevels: 22,
//                            projection: this.projectionMercator,
//                            type: 'png',
//                            transparent: true
//                        },{
//                            isBaseLayer: false,
//                            tileSize: new OpenLayers.Size(1024,1024),
//                            visibility : false
//                        }
//                    );
         this.triangulation = new OpenLayers.Layer.WMS("Triangulation",
                    "http://osm.franken.de/cgi-bin/mapserv.fcgi?", {
        	 			layers: ['triangulation'],
        	 			projection: new OpenLayers.Projection("EPSG:900913"),
        	 			type: 'png',
        	 			transparent: true
        	 		}, {
        	 			visibility: false,
        	 			isBaseLayer: false,
        	 			tileSize: new OpenLayers.Size(1024,1024)
        	 		});

         this.msl2lat = new OpenLayers.Layer.WMS("Mean Sea Level to LAT Difference",
                 "http://osm.franken.de/cgi-bin/mapserv.fcgi", {
        	 			layers: "lat",
        	 			projection: new OpenLayers.Projection("EPSG:900913"),
        	 			type: 'png',
        	 			transparent: true
        	 	  },{
        	 		  visibility: false,
        	 		  isBaseLayer: false,
        	 		  tileSize: new OpenLayers.Size(1024,1024)
        	 	  });
        this.layerContours = new OpenLayers.Layer.WMS("Contours",
                'http:///osm.franken.de/cgi-bin/mapserv.fcgi?', {
            layers: ['contour','contour2'],
            numZoomLevels: 22,
            projection: this.projectionMercator,
            type: 'png',

            transparent: true
        },{
            isBaseLayer: false,
            tileSize: new OpenLayers.Size(1024,1024),
            visibility : false
        }
    );

        this.map.addLayers([
            this.layerBase,
            this.layerTrackPoints,
            this.layerTrackPoints10,
            this.layerTrackPoints_filter1,
            this.layerTrackPoints_filter2,
            this.triangulation,
            this.layerContours,
            this.msl2lat
        ]);
        this.attributionControl = new OpenLayers.Control.Attribution();
        this.map.addControls([
            this.attributionControl,
            new OpenLayers.Control.KeyboardDefaults(),
            new OpenLayers.Control.LayerSwitcher()
        ]);
        this.map.setCenter(new OpenLayers.LonLat(0.0, 40.0).transform(
            this.projectionWGS84,
            this.projectionMercator
          ), 3
        );
        this.map.events.register( 'moveend', this, this.mapEventMove);

        this.mapEventMove(this);
    },
    plusfacteur : function (a) {
        return a * (20037508.34 / 180);
    },

    moinsfacteur: function (a) {
        return a / (20037508.34 / 180);
    },

    y2lat: function (a) {
        return 180/Math.PI * (2 * Math.atan(Math.exp(this.moinsfacteur(a)*Math.PI/180)) - Math.PI/2);
    },

    lat2y: function (a) {
        return this.plusfacteur(180/Math.PI * Math.log(Math.tan(Math.PI/4+a*(Math.PI/180)/2)));
    },

    x2lon: function (a) {
        return this.moinsfacteur(a);
    },

    lon2x: function (a) {
        return this.plusfacteur(a);
    }
});
<|endoftext|>


<commit_before>var autoprefixer = require('./autoprefixer.js');
var data = '';

process.stdin.on('data', function(chunk) {
    data += chunk;
});

process.stdin.on('end', function() {
    data = JSON.parse(data);
    for (var i in data.css) {
        try {
            data.css[i] = autoprefixer({ browsers: data.browsers }).process(data.css[i]).css;
        } catch (e) {
            data.css[i] = 'Error: ' + e.message;
        }
    }

    process.stdout.write(JSON.stringify(data.css));
});<commit_msg>Fixes issue 17<commit_after>var autoprefixer = require('./autoprefixer.js');
var data = '';

process.stdin.on('data', function(chunk) {
    data += chunk;
});

process.stdin.on('end', function() {
    data = JSON.parse(data);
    for (var i in data.css) {
        try {
            data.css[i] = autoprefixer.process(data.css[i], 'autoprefixer', { browsers: data.browsers }).css;
        } catch (e) {
            data.css[i] = 'Error: ' + e.message;
        }
    }

    process.stdout.write(JSON.stringify(data.css));
});
<|endoftext|>


<commit_before>var input1;
var input2;
var input3;
var answer1;
var answer2;
var answer3;
var lives;

function guessButton_Click(){
input1 = $("#num1").val();
input2 = $("#num2").val();
input3 = $("#num3").val();
console.log(input1);
console.log(input2);
console.log(input3);
//Handling the Input Boxes!
if(input1 == answer1){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput2");
} else if(input1 == answer2 || input1 == answer3){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput1");

} else if(input1 != answer1 || input1 != answer2 || input1 != answer3){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput3");
document.getElementById('lifeCounter').innerHTML = lives--
}
if(input2 == answer2){
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput2");
} else if(input2 == answer1 || input2 == answer3){
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput1");
} else if(input2 != answer1 || input2 != answer2 || input3 != answer3){
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput3");
}
document.getElementById('lifeCounter').innerHTML = lives--
if(input3 == answer3){
    $("#num3").removeClass("numInput");
    $("#num3").addClass("numInput2");
} else if(input3 == answer2 || input3 == answer1){
    $("#num3").removeClass("numInput");
    $("#num3").addClass("numInput1");
} else if(input3 != answer1 || input3 != answer2 || input3 != answer3){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput3");
}
document.getElementById('lifeCounter').innerHTML = lives--
//Win or Lose

if(document.getElementById('lifeCounter').innerHTML == 0){
    alert("You have met your fate at the 'hands' of the Ithorian!");
    location.reload();
} else if(input1 == answer1 && input2 == answer2 && input3 == answer3){
    alert("CURSE YOU ADVENTURER! I'LL GET YOU NEXT TIIIIMMMMMEEEE!!!");
}

}

function setUpGame(){
        answer1 = parseInt(Math.random() * 9);
        answer2 = parseInt(Math.random() * 9);
        answer3 = parseInt(Math.random() * 9);
        if(answer2 == answer1){
            answer2++
        }
        if(answer2 == answer1 && answer2 == 9){
            answer2--
        }
        if(answer3 == answer2 || answer3 == answer1 ){
            answer3++
        }
        if(answer3 == answer2 || answer3 == answer1 && answer3){
            answer3--
        }

    lives = 10
    document.getElementById('lifeCounter').innerHTML = lives--
    console.log("Cheater! Don't you dare enter " + answer1);
    console.log("or " + answer2);
    console.log("OR... " + answer3);

}

/*function handleGuess(){
    var guess = $("#tbxGuess").val();
    if (+guess == answer) {
        alert("You've escaped me this time!");
    } else {
        alert("You've met your fate at the 'hands' of the Ithorian");
    }
}
*/
$(function(){
    $("#guessButton").on("click", guessButton_Click)

    setUpGame();

});<commit_msg>MUCH BETTER!<commit_after>var input1;
var input2;
var input3;
var answer1;
var answer2;
var answer3;
var lives;

function guessButton_Click(){
input1 = $("#num1").val();
input2 = $("#num2").val();
input3 = $("#num3").val();
console.log(input1);
console.log(input2);
console.log(input3);
//Handling the Input Boxes!
if(input1 == answer1){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput2");
} else if(input1 == answer2 || input1 == answer3){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput1");

}
if(input2 == answer2){
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput2");
} else if(input2 == answer1 || input2 == answer3){
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput1");
}
if(input3 == answer3){
    $("#num3").removeClass("numInput");
    $("#num3").addClass("numInput2");
} else if(input3 == answer2 || input3 == answer1){
    $("#num3").removeClass("numInput");
    $("#num3").addClass("numInput1");
} else if(input1 != answer1 || input1 != answer2 || input1 != answer3 && input2 != answer1 || input2 != answer2 || input2 != answer3 && input3 != answer1 || input3 != answer2 || input3 != answer3){
    $("#num1").removeClass("numInput");
    $("#num1").addClass("numInput3");
    $("#num2").removeClass("numInput");
    $("#num2").addClass("numInput3");
    $("#num3").removeClass("numInput");
    $("#num3").addClass("numInput3");
document.getElementById('lifeCounter').innerHTML = lives--
}
//Win or Lose

if(document.getElementById('lifeCounter').innerHTML == 0){
    alert("You have met your fate at the 'hands' of the Ithorian!");
    location.reload();
} else if(input1 == answer1 && input2 == answer2 && input3 == answer3){
    alert("CURSE YOU ADVENTURER! I'LL GET YOU NEXT TIIIIMMMMMEEEE!!! OH!, by the way the numbers were...");

}

}

function setUpGame(){
        answer1 = parseInt(Math.random() * 9);
        answer2 = parseInt(Math.random() * 9);
        answer3 = parseInt(Math.random() * 9);
        if(answer2 == answer1){
            answer2++
        }
        if(answer2 == answer1 && answer2 == 9){
            answer2--
        }
        if(answer3 == answer2 || answer3 == answer1 ){
            answer3++
        }
        if(answer3 == answer2 || answer3 == answer1 && answer3){
            answer3--
        }

    lives = 10
    document.getElementById('lifeCounter').innerHTML = lives--
    console.log("Cheater! Don't you dare enter " + answer1);
    console.log("or " + answer2);
    console.log("OR... " + answer3);

}

/*function handleGuess(){
    var guess = $("#tbxGuess").val();
    if (+guess == answer) {
        alert("You've escaped me this time!");
    } else {
        alert("You've met your fate at the 'hands' of the Ithorian");
    }
}
*/
$(function(){
    $("#guessButton").on("click", guessButton_Click)

    setUpGame();

});<|endoftext|>


<commit_before><script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if(VRS.globalOptions && VRS.globalOptions.aircraftMarkers) {
            	///////////////////////
            	/* HELICOPTER - MLAT */
            	///////////////////////
            	VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-Helicopter.png',
					selectedFileName: 'M-Helicopter-Selected.png',
					size: { width: 32, height: 32 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMlat.val }
				}));

        		/////////////////////////////
		        /* WTC LIGHT 1 PROP - MLAT */
		        /////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Light-1-Prop.png',
					selectedFileName: 'M-WTC-Light-1-Prop-Selected.png',
					size: { width: 32, height: 32 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '1' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val }
				}));

				/////////////////////////////
		        /* WTC LIGHT 2 PROP - MLAT */
		        /////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Light-2-Prop.png',
					selectedFileName: 'M-WTC-Light-2-Prop-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val }
				}));

				///////////////////////////////
		        /* WTC MEDIUM 2 TURBO - MLAT */
		        ///////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Medium-2-Turbo.png',
					selectedFileName: 'M-WTC-Medium-2-Turbo-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val }
				}));

				////////////////////////////
		        /* WTC LIGHT 2 JET - MLAT */
		        ////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-Type-GLFx.png',
					selectedFileName: 'M-Type-GLFx-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val }
				}));

				/////////////////////////////
		        /* WTC MEDIUM 2 JET - MLAT */
		        /////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Medium-2-Jet.png',
					selectedFileName: 'M-WTC-Medium-2-Jet-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val }
				}));

				///////////////////////////////////////////////////////////
		        /* GALX, G200, CL30, CL35, CL60, C750, GLF2, GLF3 - MLAT */
		        ///////////////////////////////////////////////////////////
				//VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					//normalFileName: 'M-Type-GLFx.png',
					//selectedFileName: 'M-Type-GLFx-Selected.png',
					//size: { width: 40, height: 40 },
					//matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'GALX' && aircraft.modelIcao.val === 'G200' && aircraft.modelIcao.val === 'CL30' && aircraft.modelIcao.val === 'CL35' && aircraft.modelIcao.val === 'CL60' && aircraft.modelIcao.val === 'C750' && aircraft.isMlat.val }
				//}));

				///////////////////////////////////
		        /* WTC MEDIUM 4 TURBOPROP - MLAT */
		        ///////////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-4-TurboProp.png',
					selectedFileName: 'M-4-TurboProp-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val }
				}));

				///////////////////////////////////////////////////////////////////////
		        /* GLEX, GL5T, GLF4, GLF5, GLF6, F2TH, FA5X, FA7X, FA50, F900 - MLAT */
		        ///////////////////////////////////////////////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-GLEX.png',
					selectedFileName: 'M-GLEX-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'GLEX' || aircraft.modelIcao.val === 'GL5T' || aircraft.modelIcao.val === 'GLF4' || aircraft.modelIcao.val === 'GLF5' || aircraft.modelIcao.val === 'GLF6' || aircraft.modelIcao.val === 'F2TH' || aircraft.modelIcao.val === 'FA5X' || aircraft.modelIcao.val === 'FA50' || aircraft.modelIcao.val === 'F900' || aircraft.modelIcao.val === 'FA7X' && aircraft.isMlat.val }
				}));
				////////////////////////////////////////////////////////////////
		        /* GLEX, GL5T, GLF4, GLF5, GLF6, F2TH, FA5X, FA7X, FA50, F900 */
		        ////////////////////////////////////////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'GLEX.png',
					selectedFileName: 'GLEX-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'GLEX' || aircraft.modelIcao.val === 'GL5T' || aircraft.modelIcao.val === 'GLF4' || aircraft.modelIcao.val === 'GLF5' || aircraft.modelIcao.val === 'GLF6' || aircraft.modelIcao.val === 'F2TH' || aircraft.modelIcao.val === 'FA5X' || aircraft.modelIcao.val === 'FA7X' || aircraft.modelIcao.val === 'FA50' || aircraft.modelIcao.val === 'F900' }
				}));

				/////////////////////////////
		        /* E135, E35L, E145 - MLAT */
		        /////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-E135.png',
					selectedFileName: 'M-E135-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'E135' || aircraft.modelIcao.val === 'E35L' || aircraft.modelIcao.val === 'E145' && aircraft.isMlat.val}
				}));
				//////////////////////
		        /* E135, E35L, E145 */
		        //////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'E135.png',
					selectedFileName: 'E135-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'E135' || aircraft.modelIcao.val === 'E35L' || aircraft.modelIcao.val === 'E145' }
				}));

				///////////////////
		        /* KC-390 - MLAT */
		        ///////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-E39.png',
					selectedFileName: 'M-E39-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'E39' && aircraft.isMlat.val }
				}));

				////////////
		        /* KC-390 */
		        ////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'E39.png',
					selectedFileName: 'E39-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'E39' }
				}));

				/////////////////////////////
				/* WTC MEDIUM 4 JET - MLAT */
				/////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Medium-4-Jet.png',
					selectedFileName: 'M-WTC-Medium-4-Jet-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val }
				}));

				////////////////////////////
				/* WTC HEAVY 2 JET - MLAT */
				////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Heavy-2-Jet.png',
					selectedFileName: 'M-WTC-Heavy-2-Jet-Selected.png',
					size: { width: 40, height: 40 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Heavy && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val }
				}));

				////////////////////////////
				/* WTC HEAVY 4 JET - MLAT */
				////////////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
					normalFileName: 'M-WTC-Heavy-4-Jet.png',
					selectedFileName: 'M-WTC-Heavy-4-Jet-Selected.png',
					size: { width: 60, height: 60 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Heavy && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val }
				}));

				///////////////////////
				/* A340, B703 - MLAT */
				///////////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
		            normalFileName: 'M-Type-A340.png',
					selectedFileName: 'M-Type-A340-Selected.png',
					size: { width: 60, height: 60 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'A343' || aircraft.modelIcao.val === 'A345' || aircraft.modelIcao.val === 'A346' || aircraft.modelIcao.val === 'B703' && aircraft.isMlat.val }
		        }));

		        /////////////////
				/* A380 - MLAT */
				/////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
		            normalFileName: 'M-Type-A380.png',
					selectedFileName: 'M-Type-A380-Selected.png',
					size: { width: 60, height: 60 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'A124' || aircraft.modelIcao.val === 'A380' || aircraft.modelIcao.val === 'A388' && aircraft.isMlat.val }
		        }));

		        /////////////////
				/* A225 - MLAT */
				/////////////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
		            normalFileName: 'M-A225.png',
					selectedFileName: 'M-A225-Selected.png',
					size: { width: 60, height: 60 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'A225' && aircraft.isMlat.val }
		        }));

		        //////////
				/* A225 */
				//////////
				VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
		            normalFileName: 'A225.png',
					selectedFileName: 'A225-Selected.png',
					size: { width: 60, height: 60 },
					matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'A225' }
		        }));
		    }
        });
    }
</script><commit_msg>Correct Li<commit_after><script type="text/javascript">
    if (VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if (VRS.globalOptions && VRS.globalOptions.aircraftMarkers) {
                ///////////////////////
                /* HELICOPTER - MLAT */
                ///////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-Helicopter.png',
                    selectedFileName: 'M-Helicopter-Selected.png',
                    size: {
                        width: 32,
                        height: 32
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMlat.val

                    }
                }));

                /////////////////////////////
                /* WTC LIGHT 1 PROP - MLAT */
                /////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Light-1-Prop.png',
                    selectedFileName: 'M-WTC-Light-1-Prop-Selected.png',
                    size: {
                        width: 32,
                        height: 32
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '1' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val
                    }
                }));

                /////////////////////////////
                /* WTC LIGHT 2 PROP - MLAT */
                /////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Light-2-Prop.png',
                    selectedFileName: 'M-WTC-Light-2-Prop-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val
                    }
                }));

                ///////////////////////////////
                /* WTC MEDIUM 2 TURBO - MLAT */
                ///////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Medium-2-Turbo.png',
                    selectedFileName: 'M-WTC-Medium-2-Turbo-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val
                    }
                }));

                ////////////////////////////
                /* WTC LIGHT 2 JET - MLAT */
                ////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-Type-GLFx.png',
                    selectedFileName: 'M-Type-GLFx-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val
                    }
                }));

                /////////////////////////////
                /* WTC MEDIUM 2 JET - MLAT */
                /////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Medium-2-Jet.png',
                    selectedFileName: 'M-WTC-Medium-2-Jet-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val
                    }
                }));

		///////////////////////////////////////////////////////////
                /* GALX, G200, CL30, CL35, CL60, C56X, C750, GLF2, GLF3 - MLAT */
                ///////////////////////////////////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-Type-GLFx.png',
                    selectedFileName: 'M-Type-GLFx-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'GALX' || aircraft.modelIcao.val === 'G200' || aircraft.modelIcao.val === 'CL30' || aircraft.modelIcao.val === 'CL35' || aircraft.modelIcao.val === 'CL60' || aircraft.modelIcao.val === 'C750' || aircraft.modelIcao.val === 'C56X' || aircraft.modelIcao.val === 'BE40' && aircraft.isMlat.val
                    }
                }));

                ///////////////////////////////////
                /* WTC MEDIUM 4 TURBOPROP - MLAT */
                ///////////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-4-TurboProp.png',
                    selectedFileName: 'M-4-TurboProp-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.isMlat.val
                    }
                }));

                ///////////////////////////////////////////////////////////////////////
                /* GLEX, GL5T, GLF4, GLF5, GLF6, F2TH, FA5X, FA7X, FA50, F900 - MLAT */
                ///////////////////////////////////////////////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-GLEX.png',
                    selectedFileName: 'M-GLEX-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'GLEX' || aircraft.modelIcao.val === 'GL5T' || aircraft.modelIcao.val === 'GLF4' || aircraft.modelIcao.val === 'GLF5' || aircraft.modelIcao.val === 'GLF6' || aircraft.modelIcao.val === 'F2TH' || aircraft.modelIcao.val === 'FA5X' || aircraft.modelIcao.val === 'FA50' || aircraft.modelIcao.val === 'F900' || aircraft.modelIcao.val === 'FA7X' && aircraft.isMlat.val
                    }
                }));
                ////////////////////////////////////////////////////////////////
                /* GLEX, GL5T, GLF4, GLF5, GLF6, F2TH, FA5X, FA7X, FA50, F900 */
                ////////////////////////////////////////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'GLEX.png',
                    selectedFileName: 'GLEX-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'GLEX' || aircraft.modelIcao.val === 'GL5T' || aircraft.modelIcao.val === 'GLF4' || aircraft.modelIcao.val === 'GLF5' || aircraft.modelIcao.val === 'GLF6' || aircraft.modelIcao.val === 'F2TH' || aircraft.modelIcao.val === 'FA5X' || aircraft.modelIcao.val === 'FA7X' || aircraft.modelIcao.val === 'FA50' || aircraft.modelIcao.val === 'F900'
                    }
                }));

                /////////////////////////////
                /* E135, E35L, E145 - MLAT */
                /////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-E135.png',
                    selectedFileName: 'M-E135-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'E135' || aircraft.modelIcao.val === 'E35L' || aircraft.modelIcao.val === 'E145' && aircraft.isMlat.val
                    }
                }));
                //////////////////////
                /* E135, E35L, E145 */
                //////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'E135.png',
                    selectedFileName: 'E135-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'E135' || aircraft.modelIcao.val === 'E35L' || aircraft.modelIcao.val === 'E145'
                    }
                }));

                ///////////////////
                /* KC-390 - MLAT */
                ///////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-E39.png',
                    selectedFileName: 'M-E39-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'E39' && aircraft.isMlat.val
                    }
                }));

                ////////////
                /* KC-390 */
                ////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'E39.png',
                    selectedFileName: 'E39-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'E39'
                    }
                }));

                /////////////////////////////
                /* WTC MEDIUM 4 JET - MLAT */
                /////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Medium-4-Jet.png',
                    selectedFileName: 'M-WTC-Medium-4-Jet-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Medium && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val
                    }
                }));

                ////////////////////////////
                /* WTC HEAVY 2 JET - MLAT */
                ////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Heavy-2-Jet.png',
                    selectedFileName: 'M-WTC-Heavy-2-Jet-Selected.png',
                    size: {
                        width: 40,
                        height: 40
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Heavy && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val
                    }
                }));

                ////////////////////////////
                /* WTC HEAVY 4 JET - MLAT */
                ////////////////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-WTC-Heavy-4-Jet.png',
                    selectedFileName: 'M-WTC-Heavy-4-Jet-Selected.png',
                    size: {
                        width: 60,
                        height: 60
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Heavy && aircraft.countEngines.val === '4' && aircraft.engineType.val === VRS.EngineType.Jet && aircraft.isMlat.val
                    }
                }));

                ///////////////////////
                /* A340, B703 - MLAT */
                ///////////////////////
                //VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                //normalFileName: 'M-Type-A340.png',
                //selectedFileName: 'M-Type-A340-Selected.png',
                //size: { width: 60, height: 60 },
                //matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.modelIcao.val === 'A343' || aircraft.modelIcao.val === 'A345' || aircraft.modelIcao.val === 'A346' || aircraft.modelIcao.val === 'B703' && aircraft.isMlat.val
                //}
                //}));

                /////////////////
                /* A380 - MLAT */
                /////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-Type-A380.png',
                    selectedFileName: 'M-Type-A380-Selected.png',
                    size: {
                        width: 60,
                        height: 60
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'A124' || aircraft.modelIcao.val === 'A380' || aircraft.modelIcao.val === 'A388' && aircraft.isMlat.val
                    }
                }));

                /////////////////
                /* A225 - MLAT */
                /////////////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'M-A225.png',
                    selectedFileName: 'M-A225-Selected.png',
                    size: {
                        width: 60,
                        height: 60
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'A225' && aircraft.isMlat.val
                    }
                }));

                //////////
                /* A225 */
                //////////
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'A225.png',
                    selectedFileName: 'A225-Selected.png',
                    size: {
                        width: 60,
                        height: 60
                    },
                    matches: function( /** VRS.Aircraft */ aircraft) {
                        return aircraft.modelIcao.val === 'A225'
                    }
                }));
            }
        });
    }
</script><|endoftext|>


<commit_before>import * as LogManager from 'aurelia-logging';
import {Loader} from 'aurelia-loader';
import {normalize} from 'aurelia-path';
import {ViewCompiler} from './view-compiler';
import {ResourceRegistry, ViewResources} from './resource-registry';

var importSplitter = /\s*,\s*/,
    logger = LogManager.getLogger('templating');

export class ViewEngine {
  static inject() { return [Loader, ViewCompiler, ResourceRegistry]; }
	constructor(loader, viewCompiler, appResources){
		this.loader = loader;
		this.viewCompiler = viewCompiler;
    this.appResources = appResources;
    this.importedViews = {};
	}

	loadViewFactoryForModuleId(moduleId, options){
		var url = moduleId + '.html';
		return this.loadViewFactory(url, options);
	}

	loadViewFactory(url, options){
    var existing = this.importedViews[url];
    if(existing){
      return Promise.resolve(existing);
    }

    return this.loader.loadTemplate(url).then(template => {
      return this.loadTemplateResources(url, template).then(resources => {
        var viewFactory = this.viewCompiler.compile(template, resources, options);
        this.importedViews[url] = viewFactory;
        return viewFactory;
      });
    });
  }

  loadTemplateResources(templateUrl, template){
    var importIds, i, ii, j, jj, parts,
        dxImportAttribute = template.getAttribute('dx-import'),
        dxImportElements = template.content.querySelectorAll('dx-import');

    if(dxImportAttribute){
      importIds = dxImportAttribute.split(importSplitter);
    }else{
      importIds = [];
    }

    for(i = 0, ii = dxImportElements.length; i < ii; i++){
      parts = dxImportElements[i]
        .getAttribute('src').split(importSplitter);

      for(j = 0, jj = parts.length; j < jj; j++){
        importIds.push(parts[j]);
      }
    }

    if(!importIds.length){
      return Promise.resolve(this.appResources);
    }

    importIds = importIds.map(x => normalize(x, templateUrl));
    logger.debug(`importing resources for ${templateUrl}`, importIds);

    return this.resourceCoordinator.importResourcesFromModuleIds(importIds).then(toRegister => {
      var registry = new ViewResources(this.appResources);
      toRegister.forEach(x => x.register(registry));
      return registry;
    });
  }
}<commit_msg>fix(view-engine): rename dx-import to import<commit_after>import * as LogManager from 'aurelia-logging';
import {Loader} from 'aurelia-loader';
import {normalize} from 'aurelia-path';
import {ViewCompiler} from './view-compiler';
import {ResourceRegistry, ViewResources} from './resource-registry';

var importSplitter = /\s*,\s*/,
    logger = LogManager.getLogger('templating');

export class ViewEngine {
  static inject() { return [Loader, ViewCompiler, ResourceRegistry]; }
	constructor(loader, viewCompiler, appResources){
		this.loader = loader;
		this.viewCompiler = viewCompiler;
    this.appResources = appResources;
    this.importedViews = {};
	}

	loadViewFactoryForModuleId(moduleId, options){
		var url = moduleId + '.html';
		return this.loadViewFactory(url, options);
	}

	loadViewFactory(url, options){
    var existing = this.importedViews[url];
    if(existing){
      return Promise.resolve(existing);
    }

    return this.loader.loadTemplate(url).then(template => {
      return this.loadTemplateResources(url, template).then(resources => {
        var viewFactory = this.viewCompiler.compile(template, resources, options);
        this.importedViews[url] = viewFactory;
        return viewFactory;
      });
    });
  }

  loadTemplateResources(templateUrl, template){
    var importIds, i, ii, j, jj, parts,
        dxImportElements = template.content.querySelectorAll('dx-import');

    if(dxImportElements.length === 0){
      return Promise.resolve(this.appResources);
    }

    importIds = [];

    for(i = 0, ii = dxImportElements.length; i < ii; i++){
      parts = dxImportElements[i]
        .getAttribute('src').split(importSplitter);

      for(j = 0, jj = parts.length; j < jj; j++){
        importIds.push(parts[j]);
      }
    }

    if(importIds.length === 0){
      return Promise.resolve(this.appResources);
    }

    importIds = importIds.map(x => normalize(x, templateUrl));
    logger.debug(`importing resources for ${templateUrl}`, importIds);

    return this.resourceCoordinator.importResourcesFromModuleIds(importIds).then(toRegister => {
      var registry = new ViewResources(this.appResources);
      toRegister.forEach(x => x.register(registry));
      return registry;
    });
  }
}<|endoftext|>


<commit_before>var fs = require('fs');
var path = require('path');
var xmldom = require('xmldom');
var xpath = require('xpath');

function capitalize(value) {
    return value.charAt(0).toUpperCase() + value.slice(1);
}

function WadlParser(options) {
    this.options = options;

    this.parser = new xmldom.DOMParser();
    this.select = xpath.useNamespaces({
        'ns': 'http://wadl.dev.java.net/2009/02',
        'xs': 'http://www.w3.org/2001/XMLSchema'
    });
}

WadlParser.prototype.parse = function() {
    var doc = this.parser.parseFromString(fs.readFileSync(this.options.wadlFile, 'utf8'));

    this.typesById = {};
    this.types = [];
    this.select('//ns:application/ns:grammars/ns:include', doc).forEach(function(includeNode) {
        var xsdFile = path.join(path.dirname(this.options.wadlFile), includeNode.getAttribute('href'));
        var xsdDoc = this.parser.parseFromString(fs.readFileSync(xsdFile, 'utf8'));
        this.parseGrammarSchema(xsdDoc.documentElement);
    }.bind(this));

    var rootUrl = null;
    var serviceMap = {};
    this.methodCounter = 0;
    this.select('//ns:application/ns:resources', doc).forEach(function(resourcesNode) {
        rootUrl = this.options.rootUrl || resourcesNode.getAttribute('base');
        this.select('ns:resource', resourcesNode).forEach(function(resourceNode) {
            this.readResource(resourceNode, '/', [], null, serviceMap);
        }.bind(this));
    }.bind(this));

    return {
        types: this.types,
        rootUrl: rootUrl,
        services: Object.keys(serviceMap).map(function(key) {
            return serviceMap[key];
        })
    }
};

WadlParser.prototype.parseGrammarSchema = function(schemaNode) {
    this.select('xs:complexType|xs:simpleType', schemaNode).forEach(function(typeNode) {
        var type = {
            name: this.options.capitalize ? capitalize(typeNode.getAttribute('name')) : typeNode.getAttribute('name')
        };

        var elementNode = this.select('xs:element[@type="' + typeNode.getAttribute('name') + '"]', schemaNode)[0];
        if (elementNode) {
            this.typesById[elementNode.getAttribute('name')] = type;
        }

        if (typeNode.nodeName === 'xs:complexType') {
            type.type = 'class';
            var extensionNode = this.select('xs:complexContent/xs:extension', typeNode)[0];
            if (extensionNode) {
                type.parent = this.options.capitalize ? capitalize(extensionNode.getAttribute('base')) : extensionNode.getAttribute('base');
            }
            type.fields = this.select('xs:sequence/xs:element|xs:complexContent/xs:extension/xs:sequence/xs:element', typeNode).map(function(elemNode) {
                return this.parseFieldElement(elemNode);
            }.bind(this));
        } else {
            var enumNodes = this.select('xs:restriction[@base="xs:string"]/xs:enumeration', typeNode);
            if (enumNodes) {
                type.type = 'enum';
                type.values = enumNodes.map(function(enumNode) {
                    return enumNode.getAttribute('value');
                }.bind(this));
            }
        }

        this.types.push(type);
    }.bind(this));
};

WadlParser.prototype.parseFieldElement = function(elementNode) {
    var type = elementNode.getAttribute('type');
    var basic = false;
    if (type.indexOf('xs:') === 0) {
        basic = true;
        type = getJsType(type);
    } else if (this.options.capitalize) {
        type = capitalize(type);
    }

    var optional = false;
    if (elementNode.hasAttribute('minOccurs')) {
        optional = elementNode.getAttribute('minOccurs') === '0';
    }

    var array = false;
    if (elementNode.hasAttribute('maxOccurs')) {
        array = elementNode.getAttribute('maxOccurs') !== '1';
    }

    return {
        name: elementNode.getAttribute('name'),
        type: type,
        basic: basic,
        optional: optional,
        array: array
    };
};

function getJsType(type) {
    switch (type) {
        case 'xs:string':
            return 'string';
        case 'xs:byte':
        case 'xs:short':
        case 'xs:int':
        case 'xs:long':
        case 'xs:integer':
        case 'xs:float':
        case 'xs:double':
        case 'xs:number':
            return 'number';
        case 'xs:boolean':
            return 'boolean';
        case 'xs:date':
        case 'xs:time':
        case 'xs:dateTime':
            return 'Date';
        default:
            return 'Object'; //all others types
    }
}

WadlParser.prototype.readResource = function(resourceNode, parentUrlPath, parentUrlPathParams, parentName, serviceMap) {
    var name = parentName ? parentName : resourceNode.getAttribute('path').replace('/', '') || this.options.defaultServiceName;

    var urlPath = parentUrlPath + resourceNode.getAttribute('path');
    var urlPathParams = this.select('ns:param[@style="template"]', resourceNode).map(function(param) {
        return {
            name: param.getAttribute('name'),
            type: getJsType(param.getAttribute('type'))
        };
    }.bind(this));
    urlPathParams.sort(function(a, b) {
        return urlPath.indexOf('{' + a.name + '}') - urlPath.indexOf('{' + b.name + '}');
    });
    urlPathParams = parentUrlPathParams.concat(urlPathParams);

    this.select('ns:method', resourceNode).forEach(function(methodNode) {
        var method = {
            name: methodNode.getAttribute('id') || 'method' + this.methodCounter++,
            method: methodNode.getAttribute('name'),
            path: urlPath.replace(/(\/)\/+/g, '$1')
        };

        if (urlPathParams.length) {
            method.pathParams = urlPathParams;
        }

        var requestResponseFunc = function(variant) {
            var node = this.select('ns:' + variant, methodNode)[0];
            if (node) {
                var paramNodes = this.select('ns:param[@style="query"]', node);
                var representationNode = this.select('ns:representation', node)[0];

                var queryParams = paramNodes.map(function(param) {
                    return {
                        name: param.getAttribute('name'),
                        type: getJsType(param.getAttribute('type'))
                    };
                });
                if (queryParams.length) {
                    method.queryParams = queryParams; //response haven't query parameters
                }

                if (representationNode) {
                    var type = this.typesById[representationNode.getAttribute('element')];
                    if (type) {
                        method[variant + 'Type'] = type.name;
                    }
                    method[variant + 'MediaType'] = representationNode.getAttribute('mediaType');
                }
            }
        }.bind(this);
        requestResponseFunc('request');
        requestResponseFunc('response');

        var serviceName = (this.options.capitalize ? capitalize(name) : name) + this.options.serviceSuffix;

        if (!serviceMap[serviceName]) {
            serviceMap[serviceName] = {
                name: serviceName,
                methods: []
            };
        }
        serviceMap[serviceName].methods.push(method);
    }.bind(this));

    this.select('ns:resource', resourceNode).forEach(function(resNode) {
        this.readResource(resNode, urlPath, urlPathParams, name, serviceMap);
    }.bind(this));
};

module.exports = function(options) {
    var parser = new WadlParser(options);
    return parser.parse();
};
<commit_msg>Add support other XSD datatypes<commit_after>var fs = require('fs');
var path = require('path');
var xmldom = require('xmldom');
var xpath = require('xpath');

function capitalize(value) {
    return value.charAt(0).toUpperCase() + value.slice(1);
}

function WadlParser(options) {
    this.options = options;

    this.parser = new xmldom.DOMParser();
    this.select = xpath.useNamespaces({
        'ns': 'http://wadl.dev.java.net/2009/02',
        'xs': 'http://www.w3.org/2001/XMLSchema'
    });
}

WadlParser.prototype.parse = function() {
    var doc = this.parser.parseFromString(fs.readFileSync(this.options.wadlFile, 'utf8'));

    this.typesById = {};
    this.types = [];
    this.select('//ns:application/ns:grammars/ns:include', doc).forEach(function(includeNode) {
        var xsdFile = path.join(path.dirname(this.options.wadlFile), includeNode.getAttribute('href'));
        var xsdDoc = this.parser.parseFromString(fs.readFileSync(xsdFile, 'utf8'));
        this.parseGrammarSchema(xsdDoc.documentElement);
    }.bind(this));

    var rootUrl = null;
    var serviceMap = {};
    this.methodCounter = 0;
    this.select('//ns:application/ns:resources', doc).forEach(function(resourcesNode) {
        rootUrl = this.options.rootUrl || resourcesNode.getAttribute('base');
        this.select('ns:resource', resourcesNode).forEach(function(resourceNode) {
            this.readResource(resourceNode, '/', [], null, serviceMap);
        }.bind(this));
    }.bind(this));

    return {
        types: this.types,
        rootUrl: rootUrl,
        services: Object.keys(serviceMap).map(function(key) {
            return serviceMap[key];
        })
    }
};

WadlParser.prototype.parseGrammarSchema = function(schemaNode) {
    this.select('xs:complexType|xs:simpleType', schemaNode).forEach(function(typeNode) {
        var type = {
            name: this.options.capitalize ? capitalize(typeNode.getAttribute('name')) : typeNode.getAttribute('name')
        };

        var elementNode = this.select('xs:element[@type="' + typeNode.getAttribute('name') + '"]', schemaNode)[0];
        if (elementNode) {
            this.typesById[elementNode.getAttribute('name')] = type;
        }

        if (typeNode.nodeName === 'xs:complexType') {
            type.type = 'class';
            var extensionNode = this.select('xs:complexContent/xs:extension', typeNode)[0];
            if (extensionNode) {
                type.parent = this.options.capitalize ? capitalize(extensionNode.getAttribute('base')) : extensionNode.getAttribute('base');
            }
            type.fields = this.select('xs:sequence/xs:element|xs:complexContent/xs:extension/xs:sequence/xs:element', typeNode).map(function(elemNode) {
                return this.parseFieldElement(elemNode);
            }.bind(this));
        } else {
            var enumNodes = this.select('xs:restriction[@base="xs:string"]/xs:enumeration', typeNode);
            if (enumNodes) {
                type.type = 'enum';
                type.values = enumNodes.map(function(enumNode) {
                    return enumNode.getAttribute('value');
                }.bind(this));
            }
        }

        this.types.push(type);
    }.bind(this));
};

WadlParser.prototype.parseFieldElement = function(elementNode) {
    var type = elementNode.getAttribute('type');
    var basic = false;
    if (type.indexOf('xs:') === 0) {
        basic = true;
        type = getJsType(type);
    } else if (this.options.capitalize) {
        type = capitalize(type);
    }

    var optional = false;
    if (elementNode.hasAttribute('minOccurs')) {
        optional = elementNode.getAttribute('minOccurs') === '0';
    }

    var array = false;
    if (elementNode.hasAttribute('maxOccurs')) {
        array = elementNode.getAttribute('maxOccurs') !== '1';
    }

    return {
        name: elementNode.getAttribute('name'),
        type: type,
        basic: basic,
        optional: optional,
        array: array
    };
};

function getJsType(type) {
    switch (type) {
        case 'xs:string':
        case 'xs:normalizedString':
            return 'string';
        case 'xs:byte':
        case 'xs:short':
        case 'xs:int':
        case 'xs:long':
        case 'xs:integer':
        case 'xs:float':
        case 'xs:double':
        case 'xs:number':
        case 'xs:decimal':
        case 'xs:positiveInteger':
        case 'xs:nonPositiveInteger':
        case 'xs:negativeInteger':
        case 'xs:unsignedByte':
        case 'xs:unsignedShort':
        case 'xs:unsignedInt':
        case 'xs:unsignedLong':
            return 'number';
        case 'xs:boolean':
            return 'boolean';
        case 'xs:date':
        case 'xs:time':
        case 'xs:dateTime':
            return 'Date';
        default:
            return 'Object'; //all others types
    }
}

WadlParser.prototype.readResource = function(resourceNode, parentUrlPath, parentUrlPathParams, parentName, serviceMap) {
    var name = parentName ? parentName : resourceNode.getAttribute('path').replace('/', '') || this.options.defaultServiceName;

    var urlPath = parentUrlPath + resourceNode.getAttribute('path');
    var urlPathParams = this.select('ns:param[@style="template"]', resourceNode).map(function(param) {
        return {
            name: param.getAttribute('name'),
            type: getJsType(param.getAttribute('type'))
        };
    }.bind(this));
    urlPathParams.sort(function(a, b) {
        return urlPath.indexOf('{' + a.name + '}') - urlPath.indexOf('{' + b.name + '}');
    });
    urlPathParams = parentUrlPathParams.concat(urlPathParams);

    this.select('ns:method', resourceNode).forEach(function(methodNode) {
        var method = {
            name: methodNode.getAttribute('id') || 'method' + this.methodCounter++,
            method: methodNode.getAttribute('name'),
            path: urlPath.replace(/(\/)\/+/g, '$1')
        };

        if (urlPathParams.length) {
            method.pathParams = urlPathParams;
        }

        var requestResponseFunc = function(variant) {
            var node = this.select('ns:' + variant, methodNode)[0];
            if (node) {
                var paramNodes = this.select('ns:param[@style="query"]', node);
                var representationNode = this.select('ns:representation', node)[0];

                var queryParams = paramNodes.map(function(param) {
                    return {
                        name: param.getAttribute('name'),
                        type: getJsType(param.getAttribute('type'))
                    };
                });
                if (queryParams.length) {
                    method.queryParams = queryParams; //response haven't query parameters
                }

                if (representationNode) {
                    var type = this.typesById[representationNode.getAttribute('element')];
                    if (type) {
                        method[variant + 'Type'] = type.name;
                    }
                    method[variant + 'MediaType'] = representationNode.getAttribute('mediaType');
                }
            }
        }.bind(this);
        requestResponseFunc('request');
        requestResponseFunc('response');

        var serviceName = (this.options.capitalize ? capitalize(name) : name) + this.options.serviceSuffix;

        if (!serviceMap[serviceName]) {
            serviceMap[serviceName] = {
                name: serviceName,
                methods: []
            };
        }
        serviceMap[serviceName].methods.push(method);
    }.bind(this));

    this.select('ns:resource', resourceNode).forEach(function(resNode) {
        this.readResource(resNode, urlPath, urlPathParams, name, serviceMap);
    }.bind(this));
};

module.exports = function(options) {
    var parser = new WadlParser(options);
    return parser.parse();
};
<|endoftext|>


<commit_before>;(function(factory) {
    //CommonJS
    if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
        factory(require("knockout"), exports);
        //AMD
    } else if (typeof define === "function" && define.amd) {
        define(["knockout", "exports"], factory);
        //normal script tag
    } else {
        factory(ko, ko.actions = {});
    }
}(function(ko, actions) {
    var prefix = "ko_delegated_";
    var createDelegatedHandler = function(eventName, root) {
        return function(event) {
            var data, method, context, action, owner, matchingParent, command, result,
                el = event.target || event.srcElement,
                attr = "data-" + eventName,
                key = prefix + eventName;

            //loop until we either find an action, run out of elements, or hit the root element that has our delegated handler
            while (!method && el) {
                method = el.getAttribute(attr) || ko.utils.domData.get(el, key);
                if (!method) {
                    el = el !== root ? el.parentNode : null;
                }
            }

            if (method) {
                //get context of the element that actually held the action
                context = ko.contextFor(el);

                if (context) {
                    data = context.$data;

                    if (typeof method === "string") {
                        //check defined actions
                        if (method in actions) {
                            command = actions[method];
                            if (command) {
                                action = typeof command === "function" ? command : command.action;
                                owner = command.owner || data;
                            }
                        }
                        //search for the action
                        else if (data && data[method] && typeof data[method] === "function") {
                            action = data[method];
                            owner = data;
                        }

                        //search parents for the action
                        if (!action) {
                            matchingParent = ko.utils.arrayFirst(context.$parents, function(parent) {
                                return parent[method] && typeof parent[method] === "function";
                            });

                            action = matchingParent && matchingParent[method];
                            owner = matchingParent;
                        }
                    }
                    //a binding handler was used to associate the element with a function
                    else if (typeof method === "function") {
                        action = method;
                        owner = data;
                    }
                }

                //execute the action as KO normally would
                if (action) {
                    result = action.call(owner, data, event);

                    //prevent default action, if handler does not return true
                    if (result !== true) {
                        if (event.preventDefault) {
                            event.preventDefault();
                        }
                        else {
                            event.returnValue = false;
                        }
                    }
                }
            }
        };
    };

    //create a binding for an event to associate a function with the element
    var createDelegatedBinding = function(event) {
        var bindingName;
        if (!event) {
            return;
        }

        //capitalize first letter
        bindingName = "delegated" + event.substr(0, 1).toUpperCase() + event.slice(1);

        //create the binding, if it does not exist
        if (!ko.bindingHandlers[bindingName]) {
            ko.bindingHandlers[bindingName] = {
                init: function(element, valueAccessor) {
                    var action = valueAccessor();
                    ko.utils.domData.set(element, prefix + event, action);
                }
            };
        }
    };

    //add a handler on a parent element that responds to events from the children
    ko.bindingHandlers.delegatedHandler = {
        init: function(element, valueAccessor) {
            var events = ko.utils.unwrapObservable(valueAccessor()) || [];

            if (typeof events === "string") {
                events = [events];
            }

            ko.utils.arrayForEach(events, function(event) {
                createDelegatedBinding(event);
                ko.utils.registerEventHandler(element, event, createDelegatedHandler(event, element));
            });
        }
    };
}));
<commit_msg>Make submit delegated handler behave like knockout<commit_after>;(function(factory) {
    //CommonJS
    if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
        factory(require("knockout"), exports);
        //AMD
    } else if (typeof define === "function" && define.amd) {
        define(["knockout", "exports"], factory);
        //normal script tag
    } else {
        factory(ko, ko.actions = {});
    }
}(function(ko, actions) {
    var prefix = "ko_delegated_";
    var createDelegatedHandler = function(eventName, root) {
        return function(event) {
            var data, method, context, action, owner, matchingParent, command, result,
                el = event.target || event.srcElement,
                attr = "data-" + eventName,
                key = prefix + eventName;

            //loop until we either find an action, run out of elements, or hit the root element that has our delegated handler
            while (!method && el) {
                method = el.getAttribute(attr) || ko.utils.domData.get(el, key);
                if (!method) {
                    el = el !== root ? el.parentNode : null;
                }
            }

            if (method) {
                //get context of the element that actually held the action
                context = ko.contextFor(el);

                if (context) {
                    data = context.$data;

                    if (typeof method === "string") {
                        //check defined actions
                        if (method in actions) {
                            command = actions[method];
                            if (command) {
                                action = typeof command === "function" ? command : command.action;
                                owner = command.owner || data;
                            }
                        }
                        //search for the action
                        else if (data && data[method] && typeof data[method] === "function") {
                            action = data[method];
                            owner = data;
                        }

                        //search parents for the action
                        if (!action) {
                            matchingParent = ko.utils.arrayFirst(context.$parents, function(parent) {
                                return parent[method] && typeof parent[method] === "function";
                            });

                            action = matchingParent && matchingParent[method];
                            owner = matchingParent;
                        }
                    }
                    //a binding handler was used to associate the element with a function
                    else if (typeof method === "function") {
                        action = method;
                        owner = data;
                    }
                }

                //execute the action as KO normally would
                if (action) {
                    // if the event is a submit event, we want to just pass
                    // the form element, and set the context to 'this'.
                    // This matches the knockout behaviour for submit bindings.
                    if (eventName === 'submit') {
                      result = action.call(data, event.target);
                    } else {
                      result = action.call(owner, data, event);
                    }

                    //prevent default action, if handler does not return true
                    if (result !== true) {
                        if (event.preventDefault) {
                            event.preventDefault();
                        }
                        else {
                            event.returnValue = false;
                        }
                    }
                }
            }
        };
    };

    //create a binding for an event to associate a function with the element
    var createDelegatedBinding = function(event) {
        var bindingName;
        if (!event) {
            return;
        }

        //capitalize first letter
        bindingName = "delegated" + event.substr(0, 1).toUpperCase() + event.slice(1);

        //create the binding, if it does not exist
        if (!ko.bindingHandlers[bindingName]) {
            ko.bindingHandlers[bindingName] = {
                init: function(element, valueAccessor) {
                    var action = valueAccessor();
                    ko.utils.domData.set(element, prefix + event, action);
                }
            };
        }
    };

    //add a handler on a parent element that responds to events from the children
    ko.bindingHandlers.delegatedHandler = {
        init: function(element, valueAccessor) {
            var events = ko.utils.unwrapObservable(valueAccessor()) || [];

            if (typeof events === "string") {
                events = [events];
            }

            ko.utils.arrayForEach(events, function(event) {
                createDelegatedBinding(event);
                ko.utils.registerEventHandler(element, event, createDelegatedHandler(event, element));
            });
        }
    };
}));
<|endoftext|>


<commit_before>var buildPrototype = require('./utils/buildPrototype.js');
var chainIt = require('chainit');
var realPath = require('./utils/realPath.js');

buildPrototype(
    WebdriverJs.prototype,
    ['commands', 'protocol'].map(realPath(__dirname))
);

// save a reference to the chained API
var Wdjs =
    module.exports =
    chainIt(WebdriverJs);

function WebdriverJs(options) {
    var merge = require('lodash.merge');
    var log = require('./utils/log.js');
    var RequestHandler = require('./utils/RequestHandler.js');

    options = options || {};

    this.sessionId = null;

    this.desiredCapabilities = merge({
        browserName: "firefox",
        version: "",
        javascriptEnabled: true,
        platform: "ANY"
    }, options.desiredCapabilities || {});

    if (options && options.username && options.accessKey) {
        this._authString = options.username+":"+options.accessKey;
    }

    this.requestHandler = new RequestHandler(options);

    this.log = log({
        logLevel: options.logLevel || 'verbose',
        screenshotPath: options.screenshotPath
    });
};

// use the chained API reference to add static methods
Wdjs.remote = function remote(options) {
    var singleton = require('pragma-singleton')(Wdjs);
    if (options.singleton) {
        return new singleton(options);
    } else {
        return new Wdjs(options);
    }
}<commit_msg>logLevel defaults to silent<commit_after>var buildPrototype = require('./utils/buildPrototype.js');
var chainIt = require('chainit');
var realPath = require('./utils/realPath.js');

buildPrototype(
    WebdriverJs.prototype,
    ['commands', 'protocol'].map(realPath(__dirname))
);

// save a reference to the chained API
var Wdjs =
    module.exports =
    chainIt(WebdriverJs);

function WebdriverJs(options) {
    var merge = require('lodash.merge');
    var log = require('./utils/log.js');
    var RequestHandler = require('./utils/RequestHandler.js');

    options = options || {};

    this.sessionId = null;

    this.desiredCapabilities = merge({
        browserName: "firefox",
        version: "",
        javascriptEnabled: true,
        platform: "ANY"
    }, options.desiredCapabilities || {});

    if (options && options.username && options.accessKey) {
        this._authString = options.username+":"+options.accessKey;
    }

    this.requestHandler = new RequestHandler(options);

    this.log = log({
        logLevel: options.logLevel || 'silent',
        screenshotPath: options.screenshotPath
    });
};

// use the chained API reference to add static methods
Wdjs.remote = function remote(options) {
    var singleton = require('pragma-singleton')(Wdjs);
    if (options.singleton) {
        return new singleton(options);
    } else {
        return new Wdjs(options);
    }
}<|endoftext|>