<commit_before>var config = require('config');
var mapModule = require('map');
var plugins = require('./leaflet_plugins');
var polyUtil = require('./polyline_encoded.js');
var routeboxer = require('./leaflet_routeboxer.js');
var leaflet_label = require('./leaflet_label/leaflet.label-src.js');
var collision = require('./leaflet_layergroup_collision.js');
var session = require('session');

var center = config.geocode().center.split(',').map(parseFloat)
if (config.map_provider && config.map_provider() !== 'AmigoCloud') {
  L.mapbox.accessToken = config.mapbox_access_token();
}

module.exports = function(el) {
  var map, realtime, southWest, northEast, blurLayer;

  if (config.map_provider && config.map_provider() === 'AmigoCloud') {
    southWest = L.latLng(35.946877085397,-123.480610897013);
    northEast = L.latLng(40.763279543715,-118.789317362500);
    map = (new L.amigo.map(el, {
      amigoLogo: 'right',
      loadAmigoLayers: false,
      inertia: false,
      zoomAnimation: $('.hide-map').css('display') !== 'none',
      maxBounds: L.latLngBounds(southWest, northEast),
      minZoom: 8
    })).setView([center[1], center[0]], config.geocode().zoom);

    L.amigo.auth.setToken(config.support_data_token());

    blurLayer = L.tileLayer(
    'https://www.amigocloud.com/api/v1/users/'+
	'23/projects/3019/datasets/23835/tiles/{z}/{x}/{y}.png?' +
	'token=' + config.support_data_token(),
      {
        name: 'Uncovered Area'
      }
    );

    map.addAuthLayer({
      id: config.mapbox_map_id(),
      accessToken: config.mapbox_access_token(),
      name: 'Gray',
      provider: 'mapbox'
    });
    map.addBaseLayer(L.amigo.AmigoGray);
    map.layersControl.addBaseLayer(
      L.bingLayer(
        config.bing_key(),
	{
	  type: 'Road',
	  attribution: 'Bing Maps'
	}
      ),
      'Bing Road'
    );
    map.layersControl.addOverlay(blurLayer);
    blurLayer.addTo(map);

    module.exports.activeMap = map;

    map.realtimeControl = L.control.toggleRealTime().addTo(map);

    realtime = mapModule.realtime();

  } else {

    map = L.mapbox.map(el, config.mapbox_map_id(), {
      attributionControl: false,
      inertia: false,
      zoomAnimation: false
    }).setView([center[1], center[0]], config.geocode().zoom);
  }

  return map;
};

module.exports.getMap = function () {
  return this.activeMap;
};

module.exports.cleanRoute = function() {
    module.exports.activeRoute.removeLayer();
    module.exports.activeRoute = null;
};

module.exports.polyline_creadas = [];
module.exports.marker_creadas = [];
module.exports.makerpoint_creadas = [];
module.exports.collision_group = {};
module.exports.marker_collision_group = [];

module.exports.drawMakerCollision = function () {
  this.collision_group.onAdd(this.activeMap);
};
module.exports.getpolyline_creadas = function () {
  return this.polyline_creadas;
};

module.exports.getMarker_creadas = function () {
  return this.marker_creadas;
};

module.exports.cleanPolyline = function() {
    var polyline_creadas = this.getpolyline_creadas();
    var map = this.activeMap;
    for (i in polyline_creadas) {
        try {
                map.removeLayer(polyline_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }

  }
  this.polyline_creadas = [];

};

module.exports.cleanMarker = function() {
    var map = this.activeMap;
    for (i in this.marker_creadas) {
        try {
                map.removeLayer(this.marker_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }
    }

  this.marker_creadas = [];

};

module.exports.cleanMarkerpoint = function() {
    var map = this.activeMap;
    for (i in this.makerpoint_creadas) {
        try {
                map.removeLayer(this.makerpoint_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }
    }

  this.makerpoint_creadas = [];

};

module.exports.marker_map = function(from, to){
     var IconStart = L.icon({
        iconUrl: 'assets/images/graphics/start.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });
    var IconEnd = L.icon({
        iconUrl: 'assets/images/graphics/end.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });

    var markerform = new L.marker([from[0],from[1]], {icon: IconStart, draggable: true})
        .addTo(this.activeMap);
    var markerto = new L.marker([to[0],to[1]], {icon: IconEnd, draggable: true})
        .addTo(this.activeMap);
    var _this = this;

    markerform.on('dragend', function(e){
       var marker = e.target;
       var result = marker.getLatLng();
       _this.cleanPolyline();
       _this.cleanMarkerpoint();
       var plan = session.plan();

            plan.setAddress('from', result.lng + ',' + result.lat, function(err, rees) {
                plan.updateRoutes();
          });
    });

    markerto.on('dragend', function(e){
       var marker = e.target;
       var result = marker.getLatLng();
       _this.cleanPolyline();
       _this.cleanMarkerpoint();
       var plan = session.plan();
            plan.setAddress('to', result.lng + ',' + result.lat, function(err, rees) {
                plan.updateRoutes();
          });
    });

    this.marker_creadas.push(markerform);
    this.marker_creadas.push(markerto);
};

module.exports.marker_map_point = function(to, map, set_hover){

    var name = to[2];
    var icon_url = '';
    var layer;
    var markers ;
    if (!set_hover){
        icon_url = 'assets/images/graphics/icono.png'
    }else{
        icon_url = 'assets/images/graphics/icono1.png'
    }

    var IconEnd = L.icon({
        iconUrl: icon_url,
        iconSize: [20, 20],
        iconAnchor: [0, 0],
        popupAnchor:  [-3, -76]
    });

    if (!set_hover){
        markers = [L.marker([to[0], to[1]], {icon: IconEnd}).bindLabel(name)];
    }else{
        markers = [L.marker([to[0], to[1]], {icon: IconEnd})];
    }

    var marker = L.marker([to[0], to[1]], {icon: IconEnd}).bindLabel(name);
    layer = L.layerGroup(markers).addTo(map).eachLayer(function(layer){layer.showLabel()});
    this.makerpoint_creadas.push(layer);

    var collision_group = L.layerGroup.collision({margin:5});
    collision_group.addLayer(marker);
    this.collision_group = collision_group;
    this.marker_collision_group.push(marker);
};

module.exports.drawRouteAmigo = function(legs,mode, option) {

    var route = legs.legGeometry.points;
    var circle_from = [legs.from.lat, legs.from.lon, legs.from.name];
    var circle_to = [legs.to.lat, legs.to.lon, legs.to.name];
    var color = '#000000';
    var weight = 5;
    var set_hover = false;
    if (option.stroke){
        set_hover = true;
    }

    var dasharray= '';

        if (mode=="CAR") {
            color = '#9E9E9E';
            dasharray= '6';
            weight = 3;

        }else if(mode=="BICYCLE") {
            color = '#FF0000';
            if(!(legs.routeColor === undefined)) {
                color = "#"+legs.routeColor;
             }
            dasharray= '6';
            weight = 3;

        }else if(mode=="SUBWAY" || mode=="RAIL") {
             if(!(legs.routeColor === undefined)) {
                if (legs.routeColor != "" || legs.routeColor.length == 6) {
                    color = "#"+legs.routeColor;
                }

             }
             weight = 8;
             this.marker_map_point(circle_from, this.activeMap, set_hover);
             this.marker_map_point(circle_to, this.activeMap, set_hover);

        }
        else if(mode == "WALK") {
            color = '#0BC8F4';
            dasharray= '6';
             weight = 3;
        }

        else if(mode=="BUS") {
            //color = '#FEF0B5';
            if(!(legs.routeColor === undefined)) {
                if (legs.routeColor != "" || legs.routeColor.length == 6) {
                    color = "#"+legs.routeColor;
                }
             }
             weight = 5;
             this.marker_map_point(circle_from, this.activeMap, set_hover);
             this.marker_map_point(circle_to, this.activeMap, set_hover);
        }

       var color_options = {
            color:color,
            weight: weight,
            opacity:1,
            dashArray: dasharray
        };

       if (option.stroke){
         delete color_options.opacity;
       }
       if (option.class_name){
            color_options.className = 'message_';
            color_options.fillColor = '#7FFFD4';
            color_options.fillOpacity = '1';
       }
        console.log("color_options", color_options);
       //stroke: false;

      var argpolyline = L.PolylineUtil.decode(route, 5);
      argpolyline.unshift(circle_from);
      route = new L.Polyline(argpolyline, color_options);
      this.polyline_creadas.push(route);
      var boxes = L.RouteBoxer.box(route, 5);
      var boxpolys = new Array(boxes.length);
      route.addTo(this.activeMap);
};

<commit_msg>adding changes css<commit_after>var config = require('config');
var mapModule = require('map');
var plugins = require('./leaflet_plugins');
var polyUtil = require('./polyline_encoded.js');
var routeboxer = require('./leaflet_routeboxer.js');
var leaflet_label = require('./leaflet_label/leaflet.label-src.js');
var collision = require('./leaflet_layergroup_collision.js');
var session = require('session');

var center = config.geocode().center.split(',').map(parseFloat)
if (config.map_provider && config.map_provider() !== 'AmigoCloud') {
  L.mapbox.accessToken = config.mapbox_access_token();
}

module.exports = function(el) {
  var map, realtime, southWest, northEast, blurLayer;

  if (config.map_provider && config.map_provider() === 'AmigoCloud') {
    southWest = L.latLng(35.946877085397,-123.480610897013);
    northEast = L.latLng(40.763279543715,-118.789317362500);
    map = (new L.amigo.map(el, {
      amigoLogo: 'right',
      loadAmigoLayers: false,
      inertia: false,
      zoomAnimation: $('.hide-map').css('display') !== 'none',
      maxBounds: L.latLngBounds(southWest, northEast),
      minZoom: 8
    })).setView([center[1], center[0]], config.geocode().zoom);

    L.amigo.auth.setToken(config.support_data_token());

    blurLayer = L.tileLayer(
    'https://www.amigocloud.com/api/v1/users/'+
	'23/projects/3019/datasets/23835/tiles/{z}/{x}/{y}.png?' +
	'token=' + config.support_data_token(),
      {
        name: 'Uncovered Area'
      }
    );

    map.addAuthLayer({
      id: config.mapbox_map_id(),
      accessToken: config.mapbox_access_token(),
      name: 'Gray',
      provider: 'mapbox'
    });
    map.addBaseLayer(L.amigo.AmigoGray);
    map.layersControl.addBaseLayer(
      L.bingLayer(
        config.bing_key(),
	{
	  type: 'Road',
	  attribution: 'Bing Maps'
	}
      ),
      'Bing Road'
    );
    map.layersControl.addOverlay(blurLayer);
    blurLayer.addTo(map);

    module.exports.activeMap = map;

    map.realtimeControl = L.control.toggleRealTime().addTo(map);

    realtime = mapModule.realtime();

  } else {

    map = L.mapbox.map(el, config.mapbox_map_id(), {
      attributionControl: false,
      inertia: false,
      zoomAnimation: false
    }).setView([center[1], center[0]], config.geocode().zoom);
  }

  return map;
};

module.exports.getMap = function () {
  return this.activeMap;
};

module.exports.cleanRoute = function() {
    module.exports.activeRoute.removeLayer();
    module.exports.activeRoute = null;
};

module.exports.polyline_creadas = [];
module.exports.marker_creadas = [];
module.exports.makerpoint_creadas = [];
module.exports.collision_group = {};
module.exports.marker_collision_group = [];

module.exports.drawMakerCollision = function () {
  this.collision_group.onAdd(this.activeMap);
};
module.exports.getpolyline_creadas = function () {
  return this.polyline_creadas;
};

module.exports.getMarker_creadas = function () {
  return this.marker_creadas;
};

module.exports.cleanPolyline = function() {
    var polyline_creadas = this.getpolyline_creadas();
    var map = this.activeMap;
    for (i in polyline_creadas) {
        try {
                map.removeLayer(polyline_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }

  }
  this.polyline_creadas = [];

};

module.exports.cleanMarker = function() {
    var map = this.activeMap;
    for (i in this.marker_creadas) {
        try {
                map.removeLayer(this.marker_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }
    }

  this.marker_creadas = [];

};

module.exports.cleanMarkerpoint = function() {
    var map = this.activeMap;
    for (i in this.makerpoint_creadas) {
        try {
                map.removeLayer(this.makerpoint_creadas[i]);

            } catch (e) {
                console.log("problema al eliminar " + e);
            }
    }

  this.makerpoint_creadas = [];

};

module.exports.marker_map = function(from, to){
     var IconStart = L.icon({
        iconUrl: 'assets/images/graphics/start.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });
    var IconEnd = L.icon({
        iconUrl: 'assets/images/graphics/end.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });

    var markerform = new L.marker([from[0],from[1]], {icon: IconStart, draggable: true})
        .addTo(this.activeMap);
    var markerto = new L.marker([to[0],to[1]], {icon: IconEnd, draggable: true})
        .addTo(this.activeMap);
    var _this = this;

    markerform.on('dragend', function(e){
       var marker = e.target;
       var result = marker.getLatLng();
       _this.cleanPolyline();
       _this.cleanMarkerpoint();
       var plan = session.plan();

            plan.setAddress('from', result.lng + ',' + result.lat, function(err, rees) {
                plan.updateRoutes();
          });
    });

    markerto.on('dragend', function(e){
       var marker = e.target;
       var result = marker.getLatLng();
       _this.cleanPolyline();
       _this.cleanMarkerpoint();
       var plan = session.plan();
            plan.setAddress('to', result.lng + ',' + result.lat, function(err, rees) {
                plan.updateRoutes();
          });
    });

    this.marker_creadas.push(markerform);
    this.marker_creadas.push(markerto);
};

module.exports.marker_map_point = function(to, map, set_hover){

    var name = to[2];
    var icon_url = '';
    var layer;
    var markers ;
    if (!set_hover){
        icon_url = 'assets/images/graphics/icono.png'
    }else{
        icon_url = 'assets/images/graphics/icono1.png'
    }

    var IconEnd = L.icon({
        iconUrl: icon_url,
        iconSize: [20, 20],
        iconAnchor: [0, 0],
        popupAnchor:  [-3, -76]
    });

    if (!set_hover){
        markers = [L.marker([to[0], to[1]], {icon: IconEnd}).bindLabel(name)];
    }else{
        markers = [L.marker([to[0], to[1]], {icon: IconEnd})];
    }

    var marker = L.marker([to[0], to[1]], {icon: IconEnd}).bindLabel(name);
    layer = L.layerGroup(markers).addTo(map).eachLayer(function(layer){layer.showLabel()});
    this.makerpoint_creadas.push(layer);

    var collision_group = L.layerGroup.collision({margin:5});
    collision_group.addLayer(marker);
    this.collision_group = collision_group;
    this.marker_collision_group.push(marker);
};

module.exports.drawRouteAmigo = function(legs,mode, option) {

    var route = legs.legGeometry.points;
    var circle_from = [legs.from.lat, legs.from.lon, legs.from.name];
    var circle_to = [legs.to.lat, legs.to.lon, legs.to.name];
    var color = '#000000';
    var weight = 5;
    var set_hover = false;
    if (option.stroke){
        set_hover = true;
    }

    var dasharray= '';

        if (mode=="CAR") {
            color = '#9E9E9E';
            dasharray= '6';
            weight = 3;

        }else if(mode=="BICYCLE") {
            color = '#FF0000';
            if(!(legs.routeColor === undefined)) {
                color = "#"+legs.routeColor;
             }
            dasharray= '6';
            weight = 3;

        }else if(mode=="SUBWAY" || mode=="RAIL") {
             if(!(legs.routeColor === undefined)) {
                if (legs.routeColor != "" || legs.routeColor.length == 6) {
                    color = "#"+legs.routeColor;
                }

             }
             weight = 8;
             this.marker_map_point(circle_from, this.activeMap, set_hover);
             this.marker_map_point(circle_to, this.activeMap, set_hover);

        }
        else if(mode == "WALK") {
            color = '#0BC8F4';
            dasharray= '6';
             weight = 3;
        }

        else if(mode=="BUS") {
            //color = '#FEF0B5';
            if(!(legs.routeColor === undefined)) {
                if (legs.routeColor != "" || legs.routeColor.length == 6) {
                    color = "#"+legs.routeColor;
                }
             }
             weight = 5;
             this.marker_map_point(circle_from, this.activeMap, set_hover);
             this.marker_map_point(circle_to, this.activeMap, set_hover);
        }

       var color_options = {
            color:color,
            weight: weight,
            opacity:1,
            dashArray: dasharray
        };

       if (option.stroke){
         delete color_options.opacity;
       }
       if (option.class_name){
            //color_options.className = 'message_';
            color_options.fillColor = '#7FFFD4';
            color_options.color = '#7FFFD4';
       }
        console.log("color_options", color_options);
       //stroke: false;

      var argpolyline = L.PolylineUtil.decode(route, 5);
      argpolyline.unshift(circle_from);
      route = new L.Polyline(argpolyline, color_options);
      this.polyline_creadas.push(route);
      var boxes = L.RouteBoxer.box(route, 5);
      var boxpolys = new Array(boxes.length);
      route.addTo(this.activeMap);
};

<|endoftext|>


<commit_before>"use strict";
(function() {
  var baseURL = "https://dl.dropboxusercontent.com/s/";

  var currentChapter = -1;
  var currentTitle = "";
  var currentNumber = "";
  var currentPage = -1;
  var chapterSize = -1;
  var currentExtension = "";

  var imageElement = null;
  var loadingElement = null;
  var leftElement = null;
  var rightElement = null;

  function switchChapter(chapterIndex, pageIndex) {
    currentChapter = chapterIndex;
    currentExtension = chapterInfo[currentChapter].extension;
    currentTitle = chapterInfo[currentChapter].title;
    currentNumber = chapterInfo[currentChapter].number;
    chapterSize = chapterInfo[currentChapter].pages.length - 1;
    loadPage(pageIndex > 0 ? pageIndex : 1); // handles not-passed case too becuase lol Javascript
  }

  function loadPage(pageIndex) {
    startLoading();
    currentPage = pageIndex;
    document.title = seriesTitle + " Ch " + currentNumber + ": " + currentTitle + " p" + currentPage;
    setFragment();
    var newURL = baseURL + chapterInfo[currentChapter].pages[currentPage];
    if (currentPage < 2 && currentChapter < 2) {
      leftElement.className = "side";
    }
    else {
      leftElement.className = "side hand";
    }
    if (currentPage >= chapterSize && currentChapter >= lastChapter) {
      rightElement.className = "side";
    }
    else {
      rightElement.className = "side hand";
    }
    loadingElement.innerHTML = "Loading... 0.00%";
    var xhr = new XMLHttpRequest();
    xhr.open("GET", newURL);
    xhr.responseType = "arraybuffer";
    xhr.onprogress = function(data) {
      var percentDisplay = (data.loaded / data.total * 100).toFixed(2);
      loadingElement.innerHTML = "Loading..." + percentDisplay + "%";
    };
    xhr.onload = function(data) {
      loadingElement.innerHTML = "Loading... 100.00%";
      var blob = new Blob([this.response], {type: "image/" + currentExtension});
      imageElement.src = window.URL.createObjectURL(blob);
    };
    xhr.send();
  }

  function startLoading() {
    loadingElement.className = "";
  }

  function stopLoading() {
    imageElement.className = "";
    loadingElement.className = "hidden";
    window.scrollTo(0, 0);
  }

  function pageBack() {
    if (currentPage < 2) {
      if (currentChapter > 1) {
        switchChapter(currentChapter - 1);
      }
    }
    else {
      loadPage(currentPage - 1);
    }
  }

  function pageForward() {
    if (currentPage >= chapterSize) {
      if (currentChapter < lastChapter) {
        switchChapter(currentChapter + 1);
      }
    }
    else {
      loadPage(currentPage + 1);
    }
  }

  function keyCheck(e) {
    if (e.keyCode === 37) { // Left Arrow
      pageBack();
    }
    else if (e.keyCode === 39) { // Right Arrow
      pageForward();
    }
  }

  function setFragment() {
    window.location.hash = currentChapter + "," + currentPage;
  }

  function parseFragment() {
    var split = window.location.hash.split("#")[1].split(",");
    var chapterIndex = parseInt(split[0]);
    if (isNaN(chapterIndex)) {
      chapterIndex = 1;
    }
    var pageIndex = parseInt(split[1]);
    if (isNaN(pageIndex)) {
      pageIndex = 1;
    }
    switchChapter(chapterIndex, pageIndex);
  }

  function setup() {
    document.removeEventListener("DOMContentLoaded", setup);
    imageElement = document.getElementById("image");
    loadingElement = document.getElementById("loading");
    leftElement = document.getElementById("left")
    rightElement = document.getElementById("right");
    leftElement.addEventListener("click", pageBack);
    rightElement.addEventListener("click", pageForward);
    imageElement.addEventListener("load", stopLoading);
    document.addEventListener("keydown", keyCheck);
    if (window.location.hash === "") {
      switchChapter(1);
    }
    else {
      parseFragment();
    }
  }

  var chapterInfo = [{},
    {
      "number": "1",
      "title": "One Punch",
      "extension": "jpg",
      "pages": ["",
        "cadz9o1zrnftgjd/OPM_1_01.jpg",
        "tm10u82i6fisd8c/OPM_1_02-03.jpg",
        "dnccp9idmwlbj82/OPM_1_04.jpg",
        "1ppjf2cdj708zku/OPM_1_05.jpg",
        "q46jiur8xkmtrxv/OPM_1_06.jpg",
        "yf2ch4b9m9pxtyp/OPM_1_07.jpg",
        "b8n0t27zf0ruzt7/OPM_1_08.jpg",
        "efcfbrw4jzglpyz/OPM_1_09.jpg",
        "gtowm1j5qrtbgm5/OPM_1_10.jpg",
        "r4ajxgkmfzr0xa3/OPM_1_11.jpg",
        "a6znj0s5zsp5we4/OPM_1_12.jpg",
        "trzmatbr9s1rpdm/OPM_1_13.jpg",
        "xm05vuha9g3mdo6/OPM_1_14-15.jpg",
        "ng0x19z2r740hf5/OPM_1_16.jpg",
        "41yx5va4bwyk9i4/OPM_1_17.jpg",
        "d1pc2ruexmo8box/OPM_1_18-19.jpg",
        "98rx0erbl7boqnh/OPM_1_20-21.jpg",
        "9gsjxzy85na9h0q/OPM_1_22.jpg"
      ]
    },
    {
      "number": "2",
      "title": "Crab & Job Hunting",
      "extension": "jpg",
      "pages": ["",
        "tq8zyif6xbqmweu/OPM_2_01.jpg",
        "upl37zdg436ona9/OPM_2_02.jpg",
        "j9f43kybqkey89k/OPM_2_03.jpg",
        "9ae9y9dhwrcwc82/OPM_2_04.jpg",
        "v3gyfcqyeaacyoy/OPM_2_05.jpg",
        "934cyuol31865a1/OPM_2_06.jpg",
        "p2g8wvcgjfv2a3n/OPM_2_07.jpg",
        "8wncqu1e4zd94p1/OPM_2_08.jpg",
        "nvtirqk2n9cvg5r/OPM_2_09.jpg",
        "5pfwt22hzb4cts3/OPM_2_10.jpg",
        "oy7hdqs0abjb4pc/OPM_2_11.jpg",
        "q5n2y5a5sjf4v86/OPM_2_12.jpg",
        "quefekggtoyuayw/OPM_2_13.jpg",
        "v8jyp2mhintzldn/OPM_2_14.jpg",
        "qpgtvdplhvksxa8/OPM_2_15.jpg",
        "w8ttwgqdb8mqe5y/OPM_2_16.jpg"
      ]
    },
    {
      "number": "2",
      "title": "Crab & Job Hunting",
      "extension": "jpg",
      "pages": ["",
        "iqwvj5nna8f56k2/OPM_3_01.jpg",
        "notv804xhop5e6s/OPM_3_02.jpg",
        "f31tmzc7q25zzc8/OPM_3_03.jpg",
        "txzw1brn2hl78az/OPM_3_04.jpg",
        "3zbdhcb04beozcs/OPM_3_05.jpg",
        "gmcva2ro5q7w5sg/OPM_3_06.jpg",
        "uqef0p65qajdite/OPM_3_07.jpg",
        "n7uzay58ogn6bjs/OPM_3_08.jpg",
        "mtgdbtdiap5ipdu/OPM_3_09.jpg",
        "ftze1snfnkkd5o5/OPM_3_10.jpg",
        "ipyzgu9zlwbv92f/OPM_3_11.jpg",
        "a99y686gpfr1vsu/OPM_3_12.jpg",
        "mr2gf7me7h4i6l3/OPM_3_13.jpg",
        "ooirsvbblmmgzn0/OPM_3_14.jpg",
        "cqihfz1aezfohf4/OPM_3_15.jpg",
        "3bwgkk63cvw9alz/OPM_3_16.jpg",
        "qknwoqpwax5vg9v/OPM_3_17.jpg",
        "xaz70qas27ynrm1/OPM_3_18-19.jpg",
        "utenhhuciopr3h2/OPM_3_20-21.jpg",
        "jhy2ngyxmz1v425/OPM_3_22.jpg"
      ]
    }
  ]

  var lastChapter = chapterInfo.length - 1;

  document.addEventListener("DOMContentLoaded", setup);
  var seriesTitle = "One-Punch Man";
  document.title = seriesTitle;
}).call(this);
<commit_msg>Update read.js<commit_after>"use strict";
(function() {
  var baseURL = "https://dl.dropboxusercontent.com/s/";

  var currentChapter = -1;
  var currentTitle = "";
  var currentNumber = "";
  var currentPage = -1;
  var chapterSize = -1;
  var currentExtension = "";

  var imageElement = null;
  var loadingElement = null;
  var leftElement = null;
  var rightElement = null;

  function switchChapter(chapterIndex, pageIndex) {
    currentChapter = chapterIndex;
    currentExtension = chapterInfo[currentChapter].extension;
    currentTitle = chapterInfo[currentChapter].title;
    currentNumber = chapterInfo[currentChapter].number;
    chapterSize = chapterInfo[currentChapter].pages.length - 1;
    loadPage(pageIndex > 0 ? pageIndex : 1); // handles not-passed case too becuase lol Javascript
  }

  function loadPage(pageIndex) {
    startLoading();
    currentPage = pageIndex;
    document.title = seriesTitle + " Ch " + currentNumber + ": " + currentTitle + " p" + currentPage;
    setFragment();
    var newURL = baseURL + chapterInfo[currentChapter].pages[currentPage];
    if (currentPage < 2 && currentChapter < 2) {
      leftElement.className = "side";
    }
    else {
      leftElement.className = "side hand";
    }
    if (currentPage >= chapterSize && currentChapter >= lastChapter) {
      rightElement.className = "side";
    }
    else {
      rightElement.className = "side hand";
    }
    loadingElement.innerHTML = "Loading... 0.00%";
    var xhr = new XMLHttpRequest();
    xhr.open("GET", newURL);
    xhr.responseType = "arraybuffer";
    xhr.onprogress = function(data) {
      var percentDisplay = (data.loaded / data.total * 100).toFixed(2);
      loadingElement.innerHTML = "Loading..." + percentDisplay + "%";
    };
    xhr.onload = function(data) {
      loadingElement.innerHTML = "Loading... 100.00%";
      var blob = new Blob([this.response], {type: "image/" + currentExtension});
      imageElement.src = window.URL.createObjectURL(blob);
    };
    xhr.send();
  }

  function startLoading() {
    loadingElement.className = "";
  }

  function stopLoading() {
    imageElement.className = "";
    loadingElement.className = "hidden";
    window.scrollTo(0, 0);
  }

  function pageBack() {
    if (currentPage < 2) {
      if (currentChapter > 1) {
        switchChapter(currentChapter - 1);
      }
    }
    else {
      loadPage(currentPage - 1);
    }
  }

  function pageForward() {
    if (currentPage >= chapterSize) {
      if (currentChapter < lastChapter) {
        switchChapter(currentChapter + 1);
      }
    }
    else {
      loadPage(currentPage + 1);
    }
  }

  function keyCheck(e) {
    if (e.keyCode === 37) { // Left Arrow
      pageBack();
    }
    else if (e.keyCode === 39) { // Right Arrow
      pageForward();
    }
  }

  function setFragment() {
    window.location.hash = currentChapter + "," + currentPage;
  }

  function parseFragment() {
    var split = window.location.hash.split("#")[1].split(",");
    var chapterIndex = parseInt(split[0]);
    if (isNaN(chapterIndex)) {
      chapterIndex = 1;
    }
    var pageIndex = parseInt(split[1]);
    if (isNaN(pageIndex)) {
      pageIndex = 1;
    }
    switchChapter(chapterIndex, pageIndex);
  }

  function setup() {
    document.removeEventListener("DOMContentLoaded", setup);
    imageElement = document.getElementById("image");
    loadingElement = document.getElementById("loading");
    leftElement = document.getElementById("left")
    rightElement = document.getElementById("right");
    leftElement.addEventListener("click", pageBack);
    rightElement.addEventListener("click", pageForward);
    imageElement.addEventListener("load", stopLoading);
    document.addEventListener("keydown", keyCheck);
    if (window.location.hash === "") {
      switchChapter(1);
    }
    else {
      parseFragment();
    }
  }

  var chapterInfo = [{},
    {
      "number": "1",
      "title": "One Punch",
      "extension": "jpg",
      "pages": ["",
        "cadz9o1zrnftgjd/OPM_1_01.jpg",
        "tm10u82i6fisd8c/OPM_1_02-03.jpg",
        "dnccp9idmwlbj82/OPM_1_04.jpg",
        "1ppjf2cdj708zku/OPM_1_05.jpg",
        "q46jiur8xkmtrxv/OPM_1_06.jpg",
        "yf2ch4b9m9pxtyp/OPM_1_07.jpg",
        "b8n0t27zf0ruzt7/OPM_1_08.jpg",
        "efcfbrw4jzglpyz/OPM_1_09.jpg",
        "gtowm1j5qrtbgm5/OPM_1_10.jpg",
        "r4ajxgkmfzr0xa3/OPM_1_11.jpg",
        "a6znj0s5zsp5we4/OPM_1_12.jpg",
        "trzmatbr9s1rpdm/OPM_1_13.jpg",
        "xm05vuha9g3mdo6/OPM_1_14-15.jpg",
        "ng0x19z2r740hf5/OPM_1_16.jpg",
        "41yx5va4bwyk9i4/OPM_1_17.jpg",
        "d1pc2ruexmo8box/OPM_1_18-19.jpg",
        "98rx0erbl7boqnh/OPM_1_20-21.jpg",
        "9gsjxzy85na9h0q/OPM_1_22.jpg"
      ]
    },
    {
      "number": "2",
      "title": "Crab & Job Hunting",
      "extension": "jpg",
      "pages": ["",
        "tq8zyif6xbqmweu/OPM_2_01.jpg",
        "upl37zdg436ona9/OPM_2_02.jpg",
        "j9f43kybqkey89k/OPM_2_03.jpg",
        "9ae9y9dhwrcwc82/OPM_2_04.jpg",
        "v3gyfcqyeaacyoy/OPM_2_05.jpg",
        "934cyuol31865a1/OPM_2_06.jpg",
        "p2g8wvcgjfv2a3n/OPM_2_07.jpg",
        "8wncqu1e4zd94p1/OPM_2_08.jpg",
        "nvtirqk2n9cvg5r/OPM_2_09.jpg",
        "5pfwt22hzb4cts3/OPM_2_10.jpg",
        "oy7hdqs0abjb4pc/OPM_2_11.jpg",
        "q5n2y5a5sjf4v86/OPM_2_12.jpg",
        "quefekggtoyuayw/OPM_2_13.jpg",
        "v8jyp2mhintzldn/OPM_2_14.jpg",
        "qpgtvdplhvksxa8/OPM_2_15.jpg",
        "w8ttwgqdb8mqe5y/OPM_2_16.jpg"
      ]
    },
    {
      "number": "3",
      "title": "A Disastrous Being",
      "extension": "jpg",
      "pages": ["",
        "iqwvj5nna8f56k2/OPM_3_01.jpg",
        "notv804xhop5e6s/OPM_3_02.jpg",
        "f31tmzc7q25zzc8/OPM_3_03.jpg",
        "txzw1brn2hl78az/OPM_3_04.jpg",
        "3zbdhcb04beozcs/OPM_3_05.jpg",
        "gmcva2ro5q7w5sg/OPM_3_06.jpg",
        "uqef0p65qajdite/OPM_3_07.jpg",
        "n7uzay58ogn6bjs/OPM_3_08.jpg",
        "mtgdbtdiap5ipdu/OPM_3_09.jpg",
        "ftze1snfnkkd5o5/OPM_3_10.jpg",
        "ipyzgu9zlwbv92f/OPM_3_11.jpg",
        "a99y686gpfr1vsu/OPM_3_12.jpg",
        "mr2gf7me7h4i6l3/OPM_3_13.jpg",
        "ooirsvbblmmgzn0/OPM_3_14.jpg",
        "cqihfz1aezfohf4/OPM_3_15.jpg",
        "3bwgkk63cvw9alz/OPM_3_16.jpg",
        "qknwoqpwax5vg9v/OPM_3_17.jpg",
        "xaz70qas27ynrm1/OPM_3_18-19.jpg",
        "utenhhuciopr3h2/OPM_3_20-21.jpg",
        "jhy2ngyxmz1v425/OPM_3_22.jpg"
      ]
    }
  ]

  var lastChapter = chapterInfo.length - 1;

  document.addEventListener("DOMContentLoaded", setup);
  var seriesTitle = "One-Punch Man";
  document.title = seriesTitle;
}).call(this);
<|endoftext|>


<commit_before>iD.behavior.Draw = function(context) {
    var event = d3.dispatch('move', 'click', 'clickWay',
            'clickNode', 'undo', 'cancel', 'finish',
            'spacedown', 'spacedownNode', 'spacedownWay'),
        keybinding = d3.keybinding('draw'),
        hover = iD.behavior.Hover(context)
            .altDisables(true)
            .on('hover', context.ui().sidebar.hover),
        tail = iD.behavior.Tail(),
        edit = iD.behavior.Edit(context),
        closeTolerance = 4,
        tolerance = 12,
        lastDatum;

    function datum() {
        if (d3.event.altKey) return {};

        if (d3.event.type === 'mousemove') {
            lastDatum = d3.event.target.__data__;
        }

        if (d3.event.type === 'keydown') {
            return lastDatum || {};
        } else {
            return d3.event.target.__data__ || {};
        }
    }

    function mousedown() {

        function point() {
            var p = context.container().node();
            return touchId !== null ? d3.touches(p).filter(function(p) {
                return p.identifier === touchId;
            })[0] : d3.mouse(p);
        }

        var element = d3.select(this),
            touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null,
            t1 = +new Date(),
            p1 = point();

        element.on('mousemove.draw', null);

        d3.select(window).on('mouseup.draw', function() {
            var t2 = +new Date(),
                p2 = point(),
                dist = iD.geo.euclideanDistance(p1, p2);

            element.on('mousemove.draw', mousemove);
            d3.select(window).on('mouseup.draw', null);

            if (dist < closeTolerance || (dist < tolerance && (t2 - t1) < 500)) {
                // Prevent a quick second click
                d3.select(window).on('click.draw-block', function() {
                    d3.event.stopPropagation();
                }, true);

                context.map().dblclickEnable(false);

                window.setTimeout(function() {
                    context.map().dblclickEnable(true);
                    d3.select(window).on('click.draw-block', null);
                }, 500);

                click();
            }
        });
    }

    function mousemove() {
        event.move(datum());
    }

    function click() {
        var d = datum();
        if (d.type === 'way') {
            var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection),
                edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
            event.clickWay(choice.loc, edge);

        } else if (d.type === 'node') {
            event.clickNode(d);

        } else {
            event.click(context.map().mouseCoordinates());
        }
    }

    function space() {
        d3.event.preventDefault();
        d3.event.stopPropagation();
        click();
    }

    function backspace() {
        d3.event.preventDefault();
        event.undo();
    }

    function del() {
        d3.event.preventDefault();
        event.cancel();
    }

    function ret() {
        d3.event.preventDefault();
        event.finish();
    }

    function draw(selection) {
        context.install(hover);
        context.install(edit);

        if (!context.inIntro() && !iD.behavior.Draw.usedTails[tail.text()]) {
            context.install(tail);
        }

        keybinding
            .on('⌫', backspace)
            .on('⌦', del)
            .on('⎋', ret)
            .on('↩', ret)
            .on('space', space, false);

        selection
            .on('mousedown.draw', mousedown)
            .on('mousemove.draw', mousemove);

        d3.select(document)
            .call(keybinding);

        return draw;
    }

    draw.off = function(selection) {
        context.ui().sidebar.hover.cancel();
        context.uninstall(hover);
        context.uninstall(edit);

        if (!context.inIntro() && !iD.behavior.Draw.usedTails[tail.text()]) {
            context.uninstall(tail);
            iD.behavior.Draw.usedTails[tail.text()] = true;
        }

        selection
            .on('mousedown.draw', null)
            .on('mousemove.draw', null);

        d3.select(window)
            .on('mouseup.draw', null);

        d3.select(document)
            .call(keybinding.off);
    };

    draw.tail = function(_) {
        tail.text(_);
        return draw;
    };

    return d3.rebind(draw, event, 'on');
};

iD.behavior.Draw.usedTails = {};
<commit_msg>For spacebar clicking, only accept events on map surface<commit_after>iD.behavior.Draw = function(context) {
    var event = d3.dispatch('move', 'click', 'clickWay',
            'clickNode', 'undo', 'cancel', 'finish'),
        keybinding = d3.keybinding('draw'),
        hover = iD.behavior.Hover(context)
            .altDisables(true)
            .on('hover', context.ui().sidebar.hover),
        tail = iD.behavior.Tail(),
        edit = iD.behavior.Edit(context),
        closeTolerance = 4,
        tolerance = 12,
        disableSpace = false,
        lastMouse;

    function datum() {
        if (d3.event.altKey) return {};

        if (d3.event.type === 'mousemove') {
            lastMouse = d3.event;
        }

        if (d3.event.type === 'keydown') {
            return lastMouse.target.__data__ || {};
        } else {
            return d3.event.target.__data__ || {};
        }
    }

    function mousedown() {

        function point() {
            var p = context.container().node();
            return touchId !== null ? d3.touches(p).filter(function(p) {
                return p.identifier === touchId;
            })[0] : d3.mouse(p);
        }

        var element = d3.select(this),
            touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null,
            t1 = +new Date(),
            p1 = point();

        element.on('mousemove.draw', null);

        d3.select(window).on('mouseup.draw', function() {
            var t2 = +new Date(),
                p2 = point(),
                dist = iD.geo.euclideanDistance(p1, p2);

            element.on('mousemove.draw', mousemove);
            d3.select(window).on('mouseup.draw', null);

            if (dist < closeTolerance || (dist < tolerance && (t2 - t1) < 500)) {
                // Prevent a quick second click
                d3.select(window).on('click.draw-block', function() {
                    d3.event.stopPropagation();
                }, true);

                context.map().dblclickEnable(false);

                window.setTimeout(function() {
                    context.map().dblclickEnable(true);
                    d3.select(window).on('click.draw-block', null);
                }, 500);

                click();
            }
        });
    }

    function mousemove() {
        event.move(datum());
    }

    function mouseenter() {
        disableSpace = false;
    }

    function mouseleave() {
        disableSpace = true;
    }

    function click() {
        var d = datum();
        if (d.type === 'way') {
            var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection),
                edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
            event.clickWay(choice.loc, edge);

        } else if (d.type === 'node') {
            event.clickNode(d);

        } else {
            event.click(context.map().mouseCoordinates());
        }
    }

    function space() {
        if (disableSpace || !lastMouse) return;
        d3.event.preventDefault();
        click();
    }

    function backspace() {
        d3.event.preventDefault();
        event.undo();
    }

    function del() {
        d3.event.preventDefault();
        event.cancel();
    }

    function ret() {
        d3.event.preventDefault();
        event.finish();
    }

    function draw(selection) {
        disableSpace = false;
        lastMouse = null;

        context.install(hover);
        context.install(edit);

        if (!context.inIntro() && !iD.behavior.Draw.usedTails[tail.text()]) {
            context.install(tail);
        }

        keybinding
            .on('⌫', backspace)
            .on('⌦', del)
            .on('⎋', ret)
            .on('↩', ret)
            .on('space', space);

        selection
            .on('mouseenter.draw', mouseenter)
            .on('mouseleave.draw', mouseleave)
            .on('mousedown.draw', mousedown)
            .on('mousemove.draw', mousemove);

        d3.select(document)
            .call(keybinding);

        return draw;
    }

    draw.off = function(selection) {
        context.ui().sidebar.hover.cancel();
        context.uninstall(hover);
        context.uninstall(edit);

        if (!context.inIntro() && !iD.behavior.Draw.usedTails[tail.text()]) {
            context.uninstall(tail);
            iD.behavior.Draw.usedTails[tail.text()] = true;
        }

        selection
            .on('mouseenter.draw', null)
            .on('mouseleave.draw', null)
            .on('mousedown.draw', null)
            .on('mousemove.draw', null);

        d3.select(window)
            .on('mouseup.draw', null);

        d3.select(document)
            .call(keybinding.off);
    };

    draw.tail = function(_) {
        tail.text(_);
        return draw;
    };

    return d3.rebind(draw, event, 'on');
};

iD.behavior.Draw.usedTails = {};
<|endoftext|>


<commit_before>/**
 * scania-angular-ui-tpls
 * https://github.com/scania-bootstrap/scania-angular-ui
 * License: MIT
 *
 *
 */

(function () {
    'use strict';

    /**
     * @ngdoc module
     * @name scania.angular.lightbox.tpls
     *
     * @description
     * Scania lightbox module including templates
     */
    angular.module('scania.angular.ui').run(["$templateCache", function ($templateCache) {
        $templateCache.put("template/scania-angular-upload.html",
            "
\n" +
            "
\n" +
            "       <input type=\"file\" multiple=\"multiple\" style=\"visibility: hidden; position: absolute;\">\n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "	        \n" +
            "               \n" +
            "           \n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "");
    }]);
    angular.module('scania.angular.ui').run(["$templateCache", function ($templateCache) {
        $templateCache.put("template/scania-angular-lightbox.html",
            "
\n" +
            "
\n" +
            "
\n" +
            "           \n" +
            "           \n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "       <carousel interval=\"lightbox.interval\">\n" +
            "           <slide ng-repeat=\"slide in slides\" active=\"slide.active\">\n" +
            "                \n" +
            "           </slide>\n" +
            "       </carousel>\n" +
            "
\n" +
            "
\n" +
            "");
    }]);

})();
<commit_msg>Isolated ui-bootstrap  in scania-angular-ui and updated the lightbox design<commit_after>/**
 * scania-angular-ui-tpls
 * https://github.com/scania-bootstrap/scania-angular-lightbox
 * License: MIT
 *
 *
 */

(function () {
    'use strict';

    /**
     * @ngdoc module
     * @name scania.angular.lightbox.tpls
     *
     * @description
     * Scania lightbox module including templates
     */
    angular.module('scania.angular.lightbox').run(["$templateCache", function ($templateCache) {
        $templateCache.put("template/scania-angular-upload.html",
            "
\n" +
            "
\n" +
            "       <input type=\"file\" multiple=\"multiple\" style=\"visibility: hidden; position: absolute;\">\n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "	        \n" +
            "               \n" +
            "           \n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "");
    }]);
    angular.module('scania.angular.lightbox').run(["$templateCache", function ($templateCache) {
        $templateCache.put("template/scania-angular-lightbox.html",
            "
\n" +
            "
\n" +
            "
\n" +
            "           \n" +
            "           \n" +
            "
\n" +
            "
\n" +
            "
\n" +
            "       <carousel interval=\"lightbox.interval\">\n" +
            "           <slide ng-repeat=\"slide in slides\" active=\"slide.active\">\n" +
            "                \n" +
            "           </slide>\n" +
            "       </carousel>\n" +
            "
\n" +
            "
\n" +
            "");
    }]);

})();
<|endoftext|>


<commit_before>var config = require('config');
var mapModule = require('map');
var plugins = require('./leaflet_plugins');
var polyUtil = require('./polyline_encoded.js');
var routeboxer = require('./leaflet_routeboxer.js');

var center = config.geocode().center.split(',').map(parseFloat)
if (config.map_provider && config.map_provider() !== 'AmigoCloud') {
  L.mapbox.accessToken = config.mapbox_access_token();
}

module.exports = function(el) {
  var map, realtime, southWest, northEast, blurLayer;

  if (config.map_provider && config.map_provider() === 'AmigoCloud') {
    southWest = L.latLng(35.946877085397,-123.480610897013);
    northEast = L.latLng(40.763279543715,-118.789317362500);
    map = (new L.amigo.map(el, {
      amigoLogo: 'right',
      loadAmigoLayers: false,
      inertia: false,
      zoomAnimation: $('.hide-map').css('display') !== 'none',
      maxBounds: L.latLngBounds(southWest, northEast),
      minZoom: 8
    })).setView([center[1], center[0]], config.geocode().zoom);

    L.amigo.auth.setToken(config.support_data_token());

    blurLayer = L.tileLayer(
    'https://www.amigocloud.com/api/v1/users/'+
	'23/projects/3019/datasets/23835/tiles/{z}/{x}/{y}.png?' +
	'token=' + config.support_data_token(),
      {
        name: 'Uncovered Area'
      }
    );

    map.addAuthLayer({
      id: config.mapbox_map_id(),
      accessToken: config.mapbox_access_token(),
      name: 'Gray',
      provider: 'mapbox'
    });
    map.addBaseLayer(L.amigo.AmigoGray);
    map.layersControl.addBaseLayer(
      L.bingLayer(
        config.bing_key(),
	{
	  type: 'Road',
	  attribution: 'Bing Maps'
	}
      ),
      'Bing Road'
    );
    map.layersControl.addOverlay(blurLayer);
    blurLayer.addTo(map);

    module.exports.activeMap = map;

    map.realtimeControl = L.control.toggleRealTime().addTo(map);

    realtime = mapModule.realtime();
    console.log("entre amigo", map)

  } else {
    console.log("entre mapaboxs");
    map = L.mapbox.map(el, config.mapbox_map_id(), {
      attributionControl: false,
      inertia: false,
      zoomAnimation: false
    }).setView([center[1], center[0]], config.geocode().zoom);
  }

  return map;
};

module.exports.getMap = function () {
  return this.activeMap;
};

module.exports.cleanRoute = function() {
    module.exports.activeRoute.removeLayer();
    module.exports.activeRoute = null;
};

module.exports.marker_map = function(lon, lat, map){
     var IconStart = L.icon({
        iconUrl: 'assets/images/graphics/start.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });
    var IconEnd = L.icon({
        iconUrl: 'assets/images/graphics/end.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });

    //L.marker([37.35337508231001,-121.93626880645752], {icon: IconStart}).bindPopup('From').addTo(map);
    //L.marker([37.44377324953697,-122.16601610183714], {icon: IconEnd}).bindPopup('to').addTo(map);
    L.marker([lon[0],lon[1]], {icon: IconStart}).bindPopup('From').addTo(map);
    L.marker([lat[0],lat[1]], {icon: IconEnd}).bindPopup('to').addTo(map);

};

module.exports.drawRouteAmigo = function(route,mode) {
      var color = '#000';
      var weight = 5;
      var dasharray= '';
        console.log("imprime mode ->", mode);
        if (mode=="CAR") {
            color = '#FF0000';
            dasharray= '6';
            weight = 3;

        }else if(mode=="BICYCLE") {
            color = '#9E9E9E';
            dasharray= '6';
            weight = 3;

        }else if(mode=="SUBWAY" || mode=="RAIL") {
            color = '#FF0000';
             weight = 8;

        }
        else if(mode == "WALK") {
            color = '#0BC8F4';
            dasharray= '6';
             weight = 3;
        }

       var color_options = {
            color: color,
            opacity: 1,
            weight: weight,
            dashArray: dasharray
        };

      route = new L.Polyline(L.PolylineUtil.decode(route, 5), color_options);
      var boxes = L.RouteBoxer.box(route, 5);
      var bounds = new L.LatLngBounds([]);
      var boxpolys = new Array(boxes.length);

      for (var i = 0; i < boxes.length; i++) {
        bounds.extend(boxes[i]);
      }
      route.addTo(this.activeMap);
      this.activeMap.fitBounds(bounds);
};

<commit_msg>adding mark map<commit_after>var config = require('config');
var mapModule = require('map');
var plugins = require('./leaflet_plugins');
var polyUtil = require('./polyline_encoded.js');
var routeboxer = require('./leaflet_routeboxer.js');

var center = config.geocode().center.split(',').map(parseFloat)
if (config.map_provider && config.map_provider() !== 'AmigoCloud') {
  L.mapbox.accessToken = config.mapbox_access_token();
}

module.exports = function(el) {
  var map, realtime, southWest, northEast, blurLayer;

  if (config.map_provider && config.map_provider() === 'AmigoCloud') {
    southWest = L.latLng(35.946877085397,-123.480610897013);
    northEast = L.latLng(40.763279543715,-118.789317362500);
    map = (new L.amigo.map(el, {
      amigoLogo: 'right',
      loadAmigoLayers: false,
      inertia: false,
      zoomAnimation: $('.hide-map').css('display') !== 'none',
      maxBounds: L.latLngBounds(southWest, northEast),
      minZoom: 8
    })).setView([center[1], center[0]], config.geocode().zoom);

    L.amigo.auth.setToken(config.support_data_token());

    blurLayer = L.tileLayer(
    'https://www.amigocloud.com/api/v1/users/'+
	'23/projects/3019/datasets/23835/tiles/{z}/{x}/{y}.png?' +
	'token=' + config.support_data_token(),
      {
        name: 'Uncovered Area'
      }
    );

    map.addAuthLayer({
      id: config.mapbox_map_id(),
      accessToken: config.mapbox_access_token(),
      name: 'Gray',
      provider: 'mapbox'
    });
    map.addBaseLayer(L.amigo.AmigoGray);
    map.layersControl.addBaseLayer(
      L.bingLayer(
        config.bing_key(),
	{
	  type: 'Road',
	  attribution: 'Bing Maps'
	}
      ),
      'Bing Road'
    );
    map.layersControl.addOverlay(blurLayer);
    blurLayer.addTo(map);

    module.exports.activeMap = map;

    map.realtimeControl = L.control.toggleRealTime().addTo(map);

    realtime = mapModule.realtime();
    console.log("entre amigo", map)

  } else {
    console.log("entre mapaboxs");
    map = L.mapbox.map(el, config.mapbox_map_id(), {
      attributionControl: false,
      inertia: false,
      zoomAnimation: false
    }).setView([center[1], center[0]], config.geocode().zoom);
  }

  return map;
};

module.exports.getMap = function () {
  return this.activeMap;
};

module.exports.cleanRoute = function() {
    module.exports.activeRoute.removeLayer();
    module.exports.activeRoute = null;
};

module.exports.marker_map = function(from, to, map){
     var IconStart = L.icon({
        iconUrl: 'assets/images/graphics/start.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });
    var IconEnd = L.icon({
        iconUrl: 'assets/images/graphics/end.svg',
        iconSize: [40, 55],
        iconAnchor: [20, 50],
        popupAnchor:  [0, -50]
    });

    //L.marker([37.35337508231001,-121.93626880645752], {icon: IconStart}).bindPopup('From').addTo(map);
    //L.marker([37.44377324953697,-122.16601610183714], {icon: IconEnd}).bindPopup('to').addTo(map);
    L.marker([from[0],from[1]], {icon: IconStart}).bindPopup('From').addTo(map);
    L.marker([to[0],to[1]], {icon: IconEnd}).bindPopup('to').addTo(map);

};

module.exports.drawRouteAmigo = function(route,mode) {
      var color = '#000';
      var weight = 5;
      var dasharray= '';
        console.log("imprime mode ->", mode);
        if (mode=="CAR") {
            color = '#FF0000';
            dasharray= '6';
            weight = 3;

        }else if(mode=="BICYCLE") {
            color = '#9E9E9E';
            dasharray= '6';
            weight = 3;

        }else if(mode=="SUBWAY" || mode=="RAIL") {
            color = '#FF0000';
             weight = 8;

        }
        else if(mode == "WALK") {
            color = '#0BC8F4';
            dasharray= '6';
             weight = 3;
        }

       var color_options = {
            color: color,
            opacity: 1,
            weight: weight,
            dashArray: dasharray
        };

      route = new L.Polyline(L.PolylineUtil.decode(route, 5), color_options);
      var boxes = L.RouteBoxer.box(route, 5);
      var bounds = new L.LatLngBounds([]);
      var boxpolys = new Array(boxes.length);

      for (var i = 0; i < boxes.length; i++) {
        bounds.extend(boxes[i]);
      }
      route.addTo(this.activeMap);
      this.activeMap.fitBounds(bounds);
};

<|endoftext|>


<commit_before>function Rect() {
  this.x = Math.floor(Math.random() * (640 - 30));;
  this.y = Math.floor(Math.random() * (480 - 30));;
  this.velocity = Math.random() > 0.5 ? -1 : 1;
  this.veleftright = 0;
};

Rect.prototype.draw = function(context) {
  context.fillRect(this.x, this.y, 30, 30);
};

Rect.prototype.update = function() {
  if (this.y < 0) {
    this.velocity = 1;
  } else if (this.y > 450) {
    this.velocity = -1;
  }

  if(player.input.left == true){
    this.veleftright = -1;
  }else if(player.input.right == true){
    this.veleftright = 1;
  } else{
    this.veleftright = 0;
  }

  this.y += this.velocity;
  this.x += this.veleftright;
};
<commit_msg>Update rect.js<commit_after>function Rect() {
  this.x = Math.floor(Math.random() * (640 - 30));;
  this.y = Math.floor(Math.random() * (480 - 30));;
  this.velocity = Math.random() > 0.5 ? -1 : 1;
  this.veleftright = 0;
};

Rect.prototype.draw = function(context) {
  context.fillRect(this.x, this.y, 30, 30);
};

Rect.prototype.update = function() {
  if (this.y < 0) {
    this.velocity = 1;
  } else if (this.y > 450) {
    this.velocity = -1;
  }

  if(player.input.left == true){
    this.veleftright = -5;
  }else if(player.input.right == true){
    this.veleftright = 5;
  } else{
    this.veleftright = 0;
  }

  this.y += this.velocity;
  this.x += this.veleftright;
};
<|endoftext|>


<commit_before>(function( $ ){
    $.fn.geocodify = function(options) {

        var settings = {
          'width' : 400,
          'height' : 27,
          'fontSize': '16px',
          'buttonValue': 'GO',
          'regionBias': null,
          'viewportBias': null,
          'onSelect': function(ele) { alert('Jump to: ' + ele.formatted_address ); },
          'minimumCharacters': 5,
          'prepSearchString': null,
          'filterResults': null,
          'errorHandler': null,
          'initialText': null,
          'noResultsText': "No results found. Please refine your search.",
          'css': {
                'padding': 0,
                'margin': 0,
                'position': 'absolute',
                'top': 0,
                'left': 0,
                'outline-style': 'none',
                'outline-width': 'initial',
                'outline-color': 'initial',
                "border": "1px solid #9C9C9C"
            },
          'acceptableAddressTypes': [
                'street_address',
                'route',
                'intersection',
                'political',
                'country',
                'administrative_area_level_1',
                'administrative_area_level_2',
                'administrative_area_level_3 ',
                'colloquial_area',
                'locality',
                'sublocality',
                'neighborhood',
                'premise',
                'subpremise',
                'postal_code',
                'natural_feature',
                'airport',
                'park',
                'point_of_interest',
                'post_box',
                'street_number',
                'floor',
                'room'
            ],
            'keyCodes' : {
                UP: 38,
                DOWN: 40,
                DEL: 46,
                TAB: 9,
                RETURN: 13,
                ESC: 27,
                COMMA: 188,
                PAGEUP: 33,
                PAGEDOWN: 34,
                BACKSPACE: 8
            }
        };

        return this.each(function() {
            var $this = $(this);

            if (options) {
                $.extend(settings, options);
            }

            // Clear out any existing stuff inside the form and set its style
            $this
                .empty()
                .css({
                    'position': 'relative',
                    'margin': 0,
                    'padding': 0,
                    'width': settings.width,
                    'height': settings.height,
                    'font-size': settings.fontSize,
                    'z-index': 9001
                });
            document.getElementById($this.attr("id")).setAttribute("autocomplete", "off");

            // Add a text input
            var inputId = $this.attr("id") + "-input";
            $('<input>')
                .attr({type: 'text', id: inputId})
                .css({
                    'width': settings.width,
                    'height': settings.height,
                    'line-height': settings.fontSize,
                    'font-size': settings.fontSize
                })
                .css(settings.css)
                .addClass("geocodifyInput")
                .appendTo($this);
            document.getElementById(inputId).setAttribute("autocomplete", "off");
            var input = $("#" + inputId);

            // Fill in initialText, if it is specified
            if (settings.initialText) {
                input.val(settings.initialText);
                input.css("color", "#9C9C9C");
                input.focus(function() {
                    if (input.val() == settings.initialText) {
                        input.val("");
                        input.css("color", "black");
                    }
                });
            }

            if (settings.buttonValue) {
                // Add the submit button
                var buttonId = $this.attr("id") + "-button";
                $('<input>')
                    .attr({type: 'button', id: buttonId,
                           value: settings.buttonValue})
                    .css({
                        'position': 'absolute',
                        'top': 0,
                        'left': settings.width + 10,
                        'padding': '2px',
                        'margin': 0,
                        'font-size': "90%"
                    })
                    .addClass("geocodifyButton")
                    .appendTo($this);
                var button = $("#" + buttonId);
            }

            // Add the close box
            var closeId = $this.attr("id") + "-close";
            $("<div>")
                .attr({id: closeId})
                .hide()
                .css({
                    'cursor': 'pointer',
                    'position': 'absolute',
                    'right': "5px",
                    'top': "5px",
                    'height': input.height() + 12,
                    'color': '#2262CC',
                    'font-weight': 'bold',
                    'font-family': 'Arial, sans-serif'
                })
                .addClass("geocodifyClose")
                .html("×")
                .appendTo($this);
            var close = $("#" + closeId);

            // Add the dropdown box
            var dropdownId = $this.attr("id") + "-dropdown";
            $("<div>")
                .attr({id: dropdownId})
                .css({
                    'position': 'absolute',
                    'top': input.height() + 2,
                    'left': 0,
                    'border': '1px solid #CCC',
                    'width': settings.width - 2,
                    'z-index': 8001
                })
                .addClass("geocodifyDropdown")
                .hide()
                .appendTo($this);
            var dropdown = $("#" + dropdownId);

            // Define what will happen when the form is reset
            $this.reset = function () {
                dropdown.empty();
                dropdown.hide();
                close.hide();
            };

            // Create the bizness for how the geocoder work
            $this.previousSearch = null;
            $this.searchCache = {};
            $this.google = new google.maps.Geocoder();
            $this.fetch = function(query, force) {
                if (query === $this.previousSearch && !(force)) {
                    return false;
                }
                if (query === settings.initialText) {
                    return false;
                }
                $this.previousSearch = query;
                var qLength = query.length;
                if (qLength < settings.minimumCharacters && !(force)) {
                    dropdown.html("");
                    dropdown.hide();
                    close.hide();
                    return false;
                }
                if (settings.prepSearchString) {
                    query = settings.prepSearchString(query);
                }
                var params = { 'address': query };
                if (settings.regionBias) {
                    params['region'] = settings.regionBias;
                }
                if (settings.viewportBias) {
                    params['bounds'] = settings.viewportBias;
                }
                this.google.geocode(params, $this.onGeocode(force));
            };

            // The callback that runs after the geocoder returns
            $this.onGeocode = function(force) {
                return function(results, status) {
                    $this.reset();

                    // Handle errors
                    if (status != google.maps.GeocoderStatus.OK) {
                        if (settings.errorHandler) {
                            settings.errorHandler(results, status);
                            return false;
                        }
                    }

                    // Loop through the results and filter out precision
                    // levels we will not accept.
                    var keep = [];
                    $.each(results, function(i, val) {
                        $.each(val.types, function(ii, type) {
                            if (new RegExp(type).test(settings.acceptableAddressTypes.join("|"))) {
                                keep.push(val);
                                return false;
                            }
                        });
                    });

                    // Further filter the results if a function has been provided
                    if (settings.filterResults) {
                        keep = settings.filterResults(keep);
                    }

                    var count = keep.length,
                        ul;

                    if (count === 0) {
                        ul = $("<ul>").css({'margin': 0, 'padding': 0, 'background-color': 'white'});
                        var li = $("<li>")
                            .html(settings.noResultsText)
                            .css({
                                    'cursor': 'pointer',
                                    'margin-left': 0,
                                    'padding': '5px 0 5px 8px',
                                    'list-style-type': 'none',
                                    'text-align': 'left'
                                })
                            .appendTo(ul);
                        ul.appendTo(dropdown);
                        dropdown.show();
                        $("li", dropdown).css("cursor", "default");
                        close.show();
                        close.click($this.reset);
                    } else if (count === 1 && force) {
                        settings.onSelect(keep[0]);
                        $this.reset();
                        $this.previousSearch = results[0].formatted_address;
                        input.val(keep[0].formatted_address);
                    } else {
                        ul = $("<ul>").css({'margin': 0, 'padding': 0, 'background-color': 'white'});
                        $.each(keep, function(i, val) {
                            $('<li>')
                                .html(val.formatted_address)
                                .css({
                                    'cursor': 'pointer',
                                    'margin-left': 0,
                                    'padding': '5px 0 5px 8px',
                                    'list-style-type': 'none',
                                    'font-size': settings.fontSize,
                                    'text-align': 'left'
                                })
                                .click(function(){
                                    settings.onSelect(val);
                                    $this.reset();
                                    $this.previousSearch = val.formatted_address;
                                    input.val(val.formatted_address);
                                })
                                .hover(
                                    function() {
                                        $(this).css({'background-color': '#EEE', 'cursor': 'pointer'});
                                    },
                                    function() {
                                        $(this).css({'background-color': 'white', 'cursor': 'auto'});
                                    })
                                .appendTo(ul);
                        });
                        ul.appendTo(dropdown);
                        dropdown.show();
                        close.show();
                        close.click($this.reset);
                    }
                };
            };

            // Bind our geocoding operation to the form
            setInterval(function(){ $this.fetch(input.val(), false); }, 250);
            $this.submit(function(){return false;});
            if (button) {
                button.click(function(){$this.fetch(input.val(), true);return false;});
            }

            // Bind key up and down events
            $this.bind("keydown", function(event) {
                var resultList,
                    selectedIndex;

                switch(event.keyCode) {
                    case settings.keyCodes.UP:
                        resultList = $("li", dropdown);
                        selectedIndex = 0;
                        $.each(resultList, function(i, li) {
                            if ( $(li).hasClass("selected") ) {
                                selectedIndex = i;
                                $(li)
                                    .removeClass("selected")
                                    .css({'background-color': 'white'});
                            }
                        });
                        if (selectedIndex -1 < 0) {
                            break;
                        }
                        $(resultList[selectedIndex-1])
                            .addClass("selected")
                            .css({'background-color': '#EEE'});
                        break;
                    case settings.keyCodes.DOWN:
                        resultList = $("li", dropdown);
                        selectedIndex = -1;
                        $.each(resultList, function(i, li) {
                            if ( $(li).hasClass("selected") ) {
                                selectedIndex = i;
                                $(li).removeClass("selected")
                                    .css({'background-color': 'white'});
                            }
                        });
                        if (selectedIndex -1 >= resultList.length) {
                            break;
                        }
                        $(resultList[selectedIndex+1])
                            .addClass("selected")
                            .css({'background-color': '#EEE'});
                        break;
                    case settings.keyCodes.RETURN:
                        resultList = $("li.selected", dropdown);
                        if (resultList) {
                            resultList.click();
                        } else {
                            $this.fetch(input.val(), true);
                        }
                        break;
                    default:
                        break;
                }
            });

        });
    };
})(jQuery);
<commit_msg>Adjust default style options<commit_after>(function( $ ){
    $.fn.geocodify = function(options) {

        var settings = {
          'width' : 360,
          'height' : 27,
          'fontSize': '16px',
          'buttonValue': 'GO',
          'regionBias': null,
          'viewportBias': null,
          'onSelect': function(ele) { alert('Jump to: ' + ele.formatted_address ); },
          'minimumCharacters': 5,
          'prepSearchString': null,
          'filterResults': null,
          'errorHandler': null,
          'initialText': null,
          'noResultsText': "No results found. Please refine your search.",
          'css': {
                'padding': 0,
                'margin': 0,
                'position': 'absolute',
                'top': 0,
                'left': 0,
                'outline-style': 'none',
                'outline-width': 'initial',
                'outline-color': 'initial',
                "border": "1px solid #9C9C9C"
            },
          'acceptableAddressTypes': [
                'street_address',
                'route',
                'intersection',
                'political',
                'country',
                'administrative_area_level_1',
                'administrative_area_level_2',
                'administrative_area_level_3 ',
                'colloquial_area',
                'locality',
                'sublocality',
                'neighborhood',
                'premise',
                'subpremise',
                'postal_code',
                'natural_feature',
                'airport',
                'park',
                'point_of_interest',
                'post_box',
                'street_number',
                'floor',
                'room'
            ],
            'keyCodes' : {
                UP: 38,
                DOWN: 40,
                DEL: 46,
                TAB: 9,
                RETURN: 13,
                ESC: 27,
                COMMA: 188,
                PAGEUP: 33,
                PAGEDOWN: 34,
                BACKSPACE: 8
            }
        };

        return this.each(function() {
            var $this = $(this);

            if (options) {
                $.extend(settings, options);
            }

            // Clear out any existing stuff inside the form and set its style
            $this
                .empty()
                .css({
                    'position': 'relative',
                    'margin': 0,
                    'padding': 0,
                    'width': settings.width,
                    'height': settings.height,
                    'font-size': settings.fontSize,
                    'z-index': 9001
                });
            document.getElementById($this.attr("id")).setAttribute("autocomplete", "off");

            // Add a text input
            var inputId = $this.attr("id") + "-input";
            $('<input>')
                .attr({type: 'text', id: inputId})
                .css({
                    'width': settings.width,
                    'height': settings.height,
                    'line-height': settings.fontSize,
                    'font-size': settings.fontSize
                })
                .css(settings.css)
                .addClass("geocodifyInput")
                .appendTo($this);
            document.getElementById(inputId).setAttribute("autocomplete", "off");
            var input = $("#" + inputId);

            // Fill in initialText, if it is specified
            if (settings.initialText) {
                input.val(settings.initialText);
                input.css("color", "#9C9C9C");
                input.focus(function() {
                    if (input.val() == settings.initialText) {
                        input.val("");
                        input.css("color", "black");
                    }
                });
            }

            if (settings.buttonValue) {
                // Add the submit button
                var buttonId = $this.attr("id") + "-button";
                $('<input>')
                    .attr({type: 'button', id: buttonId,
                           value: settings.buttonValue})
                    .css({
                        'position': 'absolute',
                        'top': 0,
                        'left': settings.width + 10,
                        'padding': '2px',
                        'margin': 0,
                        'font-size': "90%"
                    })
                    .addClass("geocodifyButton")
                    .appendTo($this);
                var button = $("#" + buttonId);
            }

            // Add the close box
            var closeId = $this.attr("id") + "-close";
            $("<div>")
                .attr({id: closeId})
                .hide()
                .css({
                    'cursor': 'pointer',
                    'position': 'absolute',
                    'right': "5px",
                    'top': "5px",
                    'height': input.height() + 12,
                    'color': '#2262CC',
                    'font-weight': 'bold',
                    'font-family': 'Arial, sans-serif'
                })
                .addClass("geocodifyClose")
                .html("×")
                .appendTo($this);
            var close = $("#" + closeId);

            // Add the dropdown box
            var dropdownId = $this.attr("id") + "-dropdown";
            $("<div>")
                .attr({id: dropdownId})
                .css({
                    'position': 'absolute',
                    'top': input.height() + 2,
                    'left': 0,
                    'border': '1px solid #CCC',
                    'width': settings.width - 2,
                    'z-index': 8001
                })
                .addClass("geocodifyDropdown")
                .hide()
                .appendTo($this);
            var dropdown = $("#" + dropdownId);

            // Define what will happen when the form is reset
            $this.reset = function () {
                dropdown.empty();
                dropdown.hide();
                close.hide();
            };

            // Create the bizness for how the geocoder work
            $this.previousSearch = null;
            $this.searchCache = {};
            $this.google = new google.maps.Geocoder();
            $this.fetch = function(query, force) {
                if (query === $this.previousSearch && !(force)) {
                    return false;
                }
                if (query === settings.initialText) {
                    return false;
                }
                $this.previousSearch = query;
                var qLength = query.length;
                if (qLength < settings.minimumCharacters && !(force)) {
                    dropdown.html("");
                    dropdown.hide();
                    close.hide();
                    return false;
                }
                if (settings.prepSearchString) {
                    query = settings.prepSearchString(query);
                }
                var params = { 'address': query };
                if (settings.regionBias) {
                    params['region'] = settings.regionBias;
                }
                if (settings.viewportBias) {
                    params['bounds'] = settings.viewportBias;
                }
                this.google.geocode(params, $this.onGeocode(force));
            };

            // The callback that runs after the geocoder returns
            $this.onGeocode = function(force) {
                return function(results, status) {
                    $this.reset();

                    // Handle errors
                    if (status != google.maps.GeocoderStatus.OK) {
                        if (settings.errorHandler) {
                            settings.errorHandler(results, status);
                            return false;
                        }
                    }

                    // Loop through the results and filter out precision
                    // levels we will not accept.
                    var keep = [];
                    $.each(results, function(i, val) {
                        $.each(val.types, function(ii, type) {
                            if (new RegExp(type).test(settings.acceptableAddressTypes.join("|"))) {
                                keep.push(val);
                                return false;
                            }
                        });
                    });

                    // Further filter the results if a function has been provided
                    if (settings.filterResults) {
                        keep = settings.filterResults(keep);
                    }

                    var count = keep.length,
                        ul;

                    if (count === 0) {
                        ul = $("<ul>").css({'margin': 0, 'padding': 0, 'background-color': 'white'});
                        var li = $("<li>")
                            .html(settings.noResultsText)
                            .css({
                                    'cursor': 'pointer',
                                    'margin-left': 0,
                                    'padding': '5px 0 5px 8px',
                                    'list-style-type': 'none',
                                    'text-align': 'left'
                                })
                            .appendTo(ul);
                        ul.appendTo(dropdown);
                        dropdown.show();
                        $("li", dropdown).css("cursor", "default");
                        close.show();
                        close.click($this.reset);
                    } else if (count === 1 && force) {
                        settings.onSelect(keep[0]);
                        $this.reset();
                        $this.previousSearch = results[0].formatted_address;
                        input.val(keep[0].formatted_address);
                    } else {
                        ul = $("<ul>").css({'margin': 0, 'padding': 0, 'background-color': 'white'});
                        $.each(keep, function(i, val) {
                            $('<li>')
                                .html(val.formatted_address)
                                .css({
                                    'cursor': 'pointer',
                                    'margin-left': 0,
                                    'padding': '5px 0 5px 8px',
                                    'list-style-type': 'none',
                                    'font-size': settings.fontSize,
                                    'text-align': 'left'
                                })
                                .click(function(){
                                    settings.onSelect(val);
                                    $this.reset();
                                    $this.previousSearch = val.formatted_address;
                                    input.val(val.formatted_address);
                                })
                                .hover(
                                    function() {
                                        $(this).css({'background-color': '#EEE', 'cursor': 'pointer'});
                                    },
                                    function() {
                                        $(this).css({'background-color': 'white', 'cursor': 'auto'});
                                    })
                                .appendTo(ul);
                        });
                        ul.appendTo(dropdown);
                        dropdown.show();
                        close.show();
                        close.click($this.reset);
                    }
                };
            };

            // Bind our geocoding operation to the form
            setInterval(function(){ $this.fetch(input.val(), false); }, 250);
            $this.submit(function(){return false;});
            if (button) {
                button.click(function(){$this.fetch(input.val(), true);return false;});
            }

            // Bind key up and down events
            $this.bind("keydown", function(event) {
                var resultList,
                    selectedIndex;

                switch(event.keyCode) {
                    case settings.keyCodes.UP:
                        resultList = $("li", dropdown);
                        selectedIndex = 0;
                        $.each(resultList, function(i, li) {
                            if ( $(li).hasClass("selected") ) {
                                selectedIndex = i;
                                $(li)
                                    .removeClass("selected")
                                    .css({'background-color': 'white'});
                            }
                        });
                        if (selectedIndex -1 < 0) {
                            break;
                        }
                        $(resultList[selectedIndex-1])
                            .addClass("selected")
                            .css({'background-color': '#EEE'});
                        break;
                    case settings.keyCodes.DOWN:
                        resultList = $("li", dropdown);
                        selectedIndex = -1;
                        $.each(resultList, function(i, li) {
                            if ( $(li).hasClass("selected") ) {
                                selectedIndex = i;
                                $(li).removeClass("selected")
                                    .css({'background-color': 'white'});
                            }
                        });
                        if (selectedIndex -1 >= resultList.length) {
                            break;
                        }
                        $(resultList[selectedIndex+1])
                            .addClass("selected")
                            .css({'background-color': '#EEE'});
                        break;
                    case settings.keyCodes.RETURN:
                        resultList = $("li.selected", dropdown);
                        if (resultList) {
                            resultList.click();
                        } else {
                            $this.fetch(input.val(), true);
                        }
                        break;
                    default:
                        break;
                }
            });

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


<commit_before>/**
* @author Lianna Eeftinck / https://github.com/Leeft
*/

import THREE from 'three';

class LineSegments {
  constructor () {
    this._positions = [];
    this._colors = [];
    this._indices = [];
    this.index = 0;
  }

  addColoredLine ( v1, c1, v2, c2 ) {
    if ( this.index >= THREE.BufferGeometry.MaxIndex ) {
      throw new Error('Too many points');
    }

    this._positions.push( v1.x, v1.y, v1.z );
    this._colors.push( c1.r, c1.g, c1.b );

    this._positions.push( v2.x, v2.y, v2.z );
    this._colors.push( c2.r, c2.g, c2.b );

    this._indices.push( this.index, this.index + 1 );

    return ( this.index += 2 );
  }

  geometry () {
    this._geometry = new THREE.BufferGeometry();

    if ( ( THREE.BufferGeometry.MaxIndex > 65535 ) && ( this._indices.length > 65535 ) ) {
      this._geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( this._indices ), 1 ) );
    } else {
      this._geometry.setIndex( new THREE.BufferAttribute( new Uint16Array( this._indices ), 1 ) );
    }

    if ( this._positions.length ) {
      this._geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( this._positions ), 3 ) );
    }

    if ( this._colors.length ) {
      this._geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( this._colors ), 3 ) );
    }

    this._geometry.dynamic = false;
    this._geometry.computeBoundingBox();

    return this._geometry;
  }

  mesh () {
    const material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors });
    const mesh     = new THREE.LineSegments( this.geometry(), material );
    mesh.matrixAutoUpdate = false;
    return mesh;
  }
}

export default LineSegments;
<commit_msg>LineSegments allows building single color geometry<commit_after>/**
* @author Lianna Eeftinck / https://github.com/Leeft
*/

import THREE from 'three';

class LineSegments {
  constructor () {
    this._positions = [];
    this._colors = [];
    this._indices = [];
    this.index = 0;
  }

  addLine ( v1, v2 ) {
    if ( this.index >= THREE.BufferGeometry.MaxIndex ) {
      throw new Error('Too many points');
    }

    this._positions.push( v1.x, v1.y, v1.z );
    this._positions.push( v2.x, v2.y, v2.z );
    this._indices.push( this.index, this.index + 1 );
    return ( this.index += 2 );
  }

  addColoredLine ( v1, c1, v2, c2 ) {
    if ( this.index >= THREE.BufferGeometry.MaxIndex ) {
      throw new Error('Too many points');
    }

    this._positions.push( v1.x, v1.y, v1.z );
    this._colors.push( c1.r, c1.g, c1.b );

    this._positions.push( v2.x, v2.y, v2.z );
    this._colors.push( c2.r, c2.g, c2.b );

    this._indices.push( this.index, this.index + 1 );

    return ( this.index += 2 );
  }

  geometry () {
    this._geometry = new THREE.BufferGeometry();

    if ( ( THREE.BufferGeometry.MaxIndex > 65535 ) && ( this._indices.length > 65535 ) ) {
      this._geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( this._indices ), 1 ) );
    } else {
      this._geometry.setIndex( new THREE.BufferAttribute( new Uint16Array( this._indices ), 1 ) );
    }

    if ( this._positions.length ) {
      this._geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( this._positions ), 3 ) );
    }

    if ( this._colors.length ) {
      this._geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( this._colors ), 3 ) );
    }

    this._geometry.dynamic = false;
    this._geometry.computeBoundingBox();

    return this._geometry;
  }

  mesh ( color ) {
    if ( ! color ) {
      color = 0xFFFFFF;
    }

    let vertexColors = THREE.NoColors;
    if ( this._colors.length ) {
      vertexColors = THREE.VertexColors;
    }

    const material = new THREE.LineBasicMaterial({ vertexColors: vertexColors, color: color });
    const mesh     = new THREE.LineSegments( this.geometry(), material );
    mesh.matrixAutoUpdate = false;
    return mesh;
  }
}

export default LineSegments;
<|endoftext|>


<commit_before>var _ = require('lodash');
var React = require('react');

var GraduationStatus = require('./graduationStatus');
var CourseTable = require('./courseTable');

var Student = React.createClass({
    render: function() {
        console.log('student render')
        return (
            React.DOM.div( {className:"student"},
                GraduationStatus( {name:this.props.name,
                    schedules:this.props.schedules,
                    studies:this.props.studies}),
                CourseTable( {schedules:this.props.schedules})
            )
            // <CourseQuery />
        );
    }
});

module.exports = Student
<commit_msg>Just give GraduationStatus the entire object<commit_after>var _ = require('lodash');
var React = require('react');

var GraduationStatus = require('./graduationStatus');
var CourseTable = require('./courseTable');

var Student = React.createClass({
    render: function() {
        console.log('student render')
        return (
            React.DOM.div( {className:"student"},
                GraduationStatus(this.props),
                CourseTable( {schedules:this.props.schedules})
            )
            // <CourseQuery />
        );
    }
});

module.exports = Student
<|endoftext|>


<commit_before>var player=null;
var firebase = new Firebase('https://adr2370.firebaseio.com/');
var songdb = firebase.child('songs');
var playerdb = firebase.child('playerdb');
var commentdb = firebase.child('comments');
var currentdb = firebase.child('current');

var songs=new Array();

window.setInterval(function(){
	if(player!=null) {
		if(player.getPlayerState()==1) {
			currentdb.child('time').once('value', function(dataSnapshot) {
				if(dataSnapshot.val()<player.getCurrentTime()) {
					currentdb.child('time').set(player.getCurrentTime());
				} else if(Math.abs(dataSnapshot.val()-player.getCurrentTime())>0.10){
					player.seekTo(dataSnapshot.val(),true);
				}
			});
		} else {
			//currentdb.child('time').set(0);
		}
	}
}, 1000);

currentdb.on('child_changed', function(snapshot, prevChildName) {
	//CHANGE RATING OR SKIP VIDEO
	if(snapshot.name()=="rating") {
		setMeter(snapshot.val());
	} else if(snapshot.name()=="skip"&&snapshot.val()==1) {
		nextVideo();
	} else if(snapshot.name()=="play") {
		if(snapshot.val()==1) {
			player.playVideo();
		} else if(snapshot.val()==2) {
			player.pauseVideo();
		}
	} else if(snapshot.name()=="fullScreen"&&snapshot.val()==1) {
		currentdb.child('fullScreen').set(0);
		window.fullScreen();
	}
});

currentdb.on('child_added', function(snapshot, prevChildName) {
	//ADDED SONG
	if(snapshot.name()=="id") {
		startVideo();
	}
});

songdb.on('child_added', function(snapshot, prevChildName) {
	//ADDS SOMETHING TO QUEUE
	//snapshot.name() is youtube id, all else is below
	songs.push(snapshot.name());
	$("#queue").append('
'+snapshot.child('name').val()+'<\/td>'+snapshot.child('length').val()+'<\/td><\/td>'+snapshot.child('numViews').val()+'<\/tr>');
	currentdb.on('value', function(snapshot, prevChildName) {
		if(snapshot.val()==null) {
			nextVideo();
		}
	});
});

songdb.on('child_moved', function(snapshot, prevChildName) {
	//SWITCHES ORDER OF STUFF IN QUEUE
	//prevChildName is the name of the previous one, snapshot.name is the id of the snapshot
	if(prevChildName==null) {
		$("#topQueue").after($("#"+snapshot.name()).remove());
	} else {
		$("#"+prevChildName).after($("#"+snapshot.name()).remove());
	}
});

playerdb.on('child_changed', function(snapshot, prevChildName) {
	player.setVolume(snapshot.val());
});

commentdb.on('child_added', function(snapshot, prevChildName) {
	//COMMENTS ADDED
	//snapshot.val() is each comment
	$("#comments").prepend("
" + snapshot.val()+"<\/p>");
});

function startVideo() {
	//youtube video
	currentdb.once('value', function(dataSnapshot) {
		var id=dataSnapshot.child('id').val();
		if(player==null) {
			player=new YT.Player('youtube', {
				height: '390',
				width: '640',
				videoId: id,
				playerVars: { autoplay:1, enablejsapi:1, modestbranding:1, rel:0, showinfo:0, iv_load_policy:3, volume:50, start:0 },
				events: {
					'onStateChange': onPlayerStateChange,
					//'onError': onError
				}});
		} else {
			player.loadVideoById(id, 5, "large");
		}
		currentdb.child('play').once('value', function(dataSnapshot) {
			if(dataSnapshot.val()==2) {
				player.pauseVideo();
			} else {
				currentdb.child('play').set(1);
			}
		});
		$("#visuals canvas").hide();
		$("#"+id).remove();
		songdb.child(id).remove();
		removeA(songs, id);
	});
}

function nextVideo() {
	setMeter(0);
	$("#comments").html("");
	commentdb.remove();
	if(songs.length>0) {
		songdb.child(songs[0]).once('value', function(dataSnapshot) {
			currentdb.set(dataSnapshot.val());
			currentdb.child('rating').set(0);
			currentdb.child('skip').set(0);
			currentdb.child('play').set(0);
			currentdb.child('fullScreen').set(0);
			currentdb.child('time').set(0);
			currentdb.child('id').set(songs[0]);
		});
	} else {
		$("#youtube").replaceWith($('
<\/div>'));
		player=null;
	}
}

function onPlayerStateChange(event) {
	if(event.data == 0) {
		nextVideo();
	} else if(event.data == 1) {
		currentdb.child('time').once('value', function(dataSnapshot) {
			if(dataSnapshot.val()<player.getCurrentTime()) {
				currentdb.child('time').set(player.getCurrentTime());
			} else if(Math.abs(dataSnapshot.val()-player.getCurrentTime())>0.10){
				player.seekTo(dataSnapshot.val(),true);
			}
		});
		playerdb.child('volume').once('value', function(dataSnapshot) {
			player.setVolume(dataSnapshot.val());
		});
	} else if(event.data == 2) {
		currentdb.child('play').set(2);
		//currentdb.child('time').set(0);
	}
}

function onError(event) {
	nextVideo();
}

function setMeter(rating) {
	if(rating>=6) {
		var x=500;
	} else if(rating<=-6) {
		var x=-500;
	} else {
		var x=rating*100;
	}
	var r=$("#meterRed");
	var g=$("#meterGreen");
	g.animate({width: (583+x)}, Math.abs(g.width()-(583+x)));
	r.animate({width: (583-x)}, Math.abs(r.width()-(583-x)));
}

function removeA(arr) {
    var what, a = arguments, L = a.length, ax;
    while (L > 1 && arr.length) {
        what = a[--L];
        while ((ax= arr.indexOf(what)) !== -1) {
            arr.splice(ax, 1);
        }
    }
    return arr;
}<commit_msg>Revert "Moved play value"<commit_after>var player=null;
var firebase = new Firebase('https://adr2370.firebaseio.com/');
var songdb = firebase.child('songs');
var playerdb = firebase.child('playerdb');
var commentdb = firebase.child('comments');
var currentdb = firebase.child('current');

var songs=new Array();

window.setInterval(function(){
	if(player!=null) {
		if(player.getPlayerState()==1) {
			currentdb.child('time').once('value', function(dataSnapshot) {
				if(dataSnapshot.val()<player.getCurrentTime()) {
					currentdb.child('time').set(player.getCurrentTime());
				} else if(Math.abs(dataSnapshot.val()-player.getCurrentTime())>0.10){
					player.seekTo(dataSnapshot.val(),true);
				}
			});
		} else {
			//currentdb.child('time').set(0);
		}
	}
}, 1000);

currentdb.on('child_changed', function(snapshot, prevChildName) {
	//CHANGE RATING OR SKIP VIDEO
	if(snapshot.name()=="rating") {
		setMeter(snapshot.val());
	} else if(snapshot.name()=="skip"&&snapshot.val()==1) {
		nextVideo();
	} else if(snapshot.name()=="play") {
		if(snapshot.val()==1) {
			player.playVideo();
		} else if(snapshot.val()==2) {
			player.pauseVideo();
		}
	} else if(snapshot.name()=="fullScreen"&&snapshot.val()==1) {
		currentdb.child('fullScreen').set(0);
		window.fullScreen();
	}
});

currentdb.on('child_added', function(snapshot, prevChildName) {
	//ADDED SONG
	if(snapshot.name()=="id") {
		startVideo();
	}
});

songdb.on('child_added', function(snapshot, prevChildName) {
	//ADDS SOMETHING TO QUEUE
	//snapshot.name() is youtube id, all else is below
	songs.push(snapshot.name());
	$("#queue").append('
'+snapshot.child('name').val()+'<\/td>'+snapshot.child('length').val()+'<\/td><\/td>'+snapshot.child('numViews').val()+'<\/tr>');
	currentdb.on('value', function(snapshot, prevChildName) {
		if(snapshot.val()==null) {
			nextVideo();
		}
	});
});

songdb.on('child_moved', function(snapshot, prevChildName) {
	//SWITCHES ORDER OF STUFF IN QUEUE
	//prevChildName is the name of the previous one, snapshot.name is the id of the snapshot
	if(prevChildName==null) {
		$("#topQueue").after($("#"+snapshot.name()).remove());
	} else {
		$("#"+prevChildName).after($("#"+snapshot.name()).remove());
	}
});

playerdb.on('child_changed', function(snapshot, prevChildName) {
	player.setVolume(snapshot.val());
});

commentdb.on('child_added', function(snapshot, prevChildName) {
	//COMMENTS ADDED
	//snapshot.val() is each comment
	$("#comments").prepend("
" + snapshot.val()+"<\/p>");
});

function startVideo() {
	//youtube video
	currentdb.once('value', function(dataSnapshot) {
		var id=dataSnapshot.child('id').val();
		if(player==null) {
			player=new YT.Player('youtube', {
				height: '390',
				width: '640',
				videoId: id,
				playerVars: { autoplay:1, enablejsapi:1, modestbranding:1, rel:0, showinfo:0, iv_load_policy:3, volume:50, start:0 },
				events: {
					'onStateChange': onPlayerStateChange,
					//'onError': onError
				}});
		} else {
			player.loadVideoById(id, 5, "large");
		}
		$("#visuals canvas").hide();
		$("#"+id).remove();
		songdb.child(id).remove();
		removeA(songs, id);
	});
}

function nextVideo() {
	setMeter(0);
	$("#comments").html("");
	commentdb.remove();
	if(songs.length>0) {
		songdb.child(songs[0]).once('value', function(dataSnapshot) {
			currentdb.set(dataSnapshot.val());
			currentdb.child('rating').set(0);
			currentdb.child('skip').set(0);
			currentdb.child('play').set(0);
			currentdb.child('fullScreen').set(0);
			currentdb.child('time').set(0);
			currentdb.child('id').set(songs[0]);
		});
	} else {
		$("#youtube").replaceWith($('
<\/div>'));
		player=null;
	}
}

function onPlayerStateChange(event) {
	if(event.data == 0) {
		nextVideo();
	} else if(event.data == 1) {
		currentdb.child('time').once('value', function(dataSnapshot) {
			if(dataSnapshot.val()<player.getCurrentTime()) {
				currentdb.child('time').set(player.getCurrentTime());
			} else if(Math.abs(dataSnapshot.val()-player.getCurrentTime())>0.10){
				player.seekTo(dataSnapshot.val(),true);
			}
		});
		playerdb.child('volume').once('value', function(dataSnapshot) {
			player.setVolume(dataSnapshot.val());
		});
		currentdb.child('play').once('value', function(dataSnapshot) {
			if(dataSnapshot.val()==2) {
				player.pauseVideo();
			} else {
				currentdb.child('play').set(1);
			}
		});
	} else if(event.data == 2) {
		currentdb.child('play').set(2);
		//currentdb.child('time').set(0);
	}
}

function onError(event) {
	nextVideo();
}

function setMeter(rating) {
	if(rating>=6) {
		var x=500;
	} else if(rating<=-6) {
		var x=-500;
	} else {
		var x=rating*100;
	}
	var r=$("#meterRed");
	var g=$("#meterGreen");
	g.animate({width: (583+x)}, Math.abs(g.width()-(583+x)));
	r.animate({width: (583-x)}, Math.abs(r.width()-(583-x)));
}

function removeA(arr) {
    var what, a = arguments, L = a.length, ax;
    while (L > 1 && arr.length) {
        what = a[--L];
        while ((ax= arr.indexOf(what)) !== -1) {
            arr.splice(ax, 1);
        }
    }
    return arr;
}<|endoftext|>