<commit_before>/*global Modernizr: false */
var isIE = (/MSIE/.test(navigator.userAgent)),
    isAndroid = (/Android/.test(navigator.userAgent)),
    isChrome = (/Chrome/.test(navigator.userAgent)),
    demoBar = function(){
        var d = document;
        d.write('<!DOCTYPE html><meta charset="UTF-8"><title>'+
        d.title +
        '<\/title><link rel="stylesheet" href="css/demobar.css"><\/head>' +
        '' +
        '' +
        '
<\/div>' +
        '
' +
        // '  Tablet Landscape<\/span><\/a>' +
        '  Tablet<\/span><\/a>' +
        // '  iPhone Landscape<\/span><\/a>' +
        '  Phone<\/span><\/a>' +
        '  Desktop<\/span><\/a>' +
        '  <\/div><\/header>

<\/iframe><\/div><\/section>'+
        '<\/body><\/html>');
    };

$(function(){
  if ( parent.$("#devices").length <=0 && !Modernizr.touch && !isIE) {
    demoBar();

    window.resbook = {};

    (function (rb) {
        var d = document,
            w = window,
            url = d.URL,
            title = d.title,
            wrapper = null,
            devices = null,
            close = null,
            //keyboard = null,
            body = null,
            size = null,
            auto = true,
            isResized = false,
            isAnimated = false,
            sizes = {
              smartphonePortrait: [320, 480],
              smartphoneLandscape: [480, 320],
              tabletPortrait: [750, 1024],
              tabletLandscape: [1024, 768],
              auto: 'auto'
            },

            resize = function (w, h, f) {
              w = w || wrapper.clientWidth;
              //h = h || wrapper.clientHeight;
              f = f || "Desktop";
              size.innerHTML = f; //w + 'x' + h
            },

            setPosition = function (wh, t, cl, myTxt) {
              var width = (wh === 'auto') ? w.innerWidth : wh[0],
                  height = (wh === 'auto') ? w.innerHeight : wh[1],
                  style = 'width:' + width + 'px;';
              if (typeof (width) === 'undefined' || typeof (height) === 'undefined') { return false; }
              style += (wh === 'auto') ? 'margin-top:0;' : '';
              wrapper.setAttribute('style', style);
              wrapper.setAttribute('data-device', cl);
              body.setAttribute('style', 'min-width:' + width + 'px;');
              resize(width, height, myTxt);
              if (wh === 'auto' && !t) {
                isResized = false;
                setTimeout(function () {
                  wrapper.setAttribute('style', '');
                  body.setAttribute('style', '');
                  isAnimated = false;
                }, 260);
              }
              else {
                isAnimated = false;
              }
            },
            readyElement = function (id, callback) {
              var interval = setInterval(function () {
                if (d.getElementById(id)) {
                  callback(d.getElementById(id));
                  clearInterval(interval);
                }
              }, 60);
            };

        rb.changeUrl = function (u, t) {
          d.title = t;
          if (history.pushState) {
            try {
              history.pushState({}, "New Page", u);
            } catch (e) {}
          }
        };

        readyElement('wrapper', function () {
            wrapper = d.getElementById('wrapper');
            devices = d.getElementById('devices');
            size = d.getElementById('size');
            close = d.querySelector('.close a');
            //keyboard = d.querySelector('.keyboard a');
            body = d.querySelector('body');
            if (window.chrome || (window.getComputedStyle && !window.globalStorage && !window.opera)) {}
            [].forEach.call(document.querySelectorAll('#devices a'), function (el) {
              el.addEventListener('click', function (e) {
                [].forEach.call(document.querySelectorAll('#devices a'), function (el) {
                  el.classList.remove('active');
                });
                e.preventDefault();
                e.stopPropagation();
                var self = this;
                if ((self.classList.contains('auto') && isResized === false) || isAnimated === true) {
                  return false;
                }
                isAnimated = true;
                if (isResized === false) {
                  isResized = true;
                  setPosition(sizes.auto, true, 'auto', 'auto');
                }
                setTimeout(function () {
                  self.classList.add('active');
                  if (self.classList.contains('smartphone-portrait')) {
                    setPosition(sizes.smartphonePortrait, false, 'smartphonePortrait', "Phone");
                  }
                  // else if (self.classList.contains('smartphone-landscape')) {
                  //   setPosition(sizes.smartphoneLandscape, false, 'smartphoneLandscape', "Phone Landscape");
                  // }
                  else if (self.classList.contains('tablet-portrait')) {
                    setPosition(sizes.tabletPortrait, false, 'tabletPortrait', "Tablet");
                  }
                  // else if (self.classList.contains('tablet-landscape')) {
                  //   setPosition(sizes.tabletLandscape, false, 'tabletLandscape', "Tablet Landscape");
                  // }
                  else if (self.classList.contains('auto')) {
                    setPosition(sizes.auto, false, 'auto', "Desktop");
                  }
                }, 10);
              });
            });

            w.addEventListener('resize', function () {
              resize();
            }, false);

            w.addEventListener('keyup', function (e) {
              var key = e.keyCode ? e.keyCode : e.charCode,
                  keys = {
                    49: 'tabletPortrait',
                    50: 'tabletLandscape',
                    51: 'smartphonePortrait',
                    52: 'smartphoneLandscape',
                    53: 'auto'
                  };
              if (typeof (keys[key]) === 'undefined') { return false; }
              setPosition(sizes[keys[key]], false, keys[key], "auto");
            }, false);

            resize();

            size.style.minWidth = 0;

            // Enable animations now that the page has loaded
            document.getElementById('wrapper').classList.add('enableTransitions');

            // if (isNav == true) {
            //   $(".tablet-portrait")[0].click();
            // }

        });
    })(window.resbook);
  }
  else if (isIE || (isAndroid && !isChrome) ) {
    $("body").prepend('

Non-Optimal Browser Detected

To get the best demo experience, it\'s recommended that you use Google Chrome
If you cannot upgrade your browser, you can resize your browser to experience it.

');
  }
});
<commit_msg>Message<commit_after>/*global Modernizr: false */
var isIE = (/MSIE/.test(navigator.userAgent)),
    isAndroid = (/Android/.test(navigator.userAgent)),
    isChrome = (/Chrome/.test(navigator.userAgent)),
    demoBar = function(){
        var d = document;
        d.write('<!DOCTYPE html><meta charset="UTF-8"><title>'+
        d.title +
        '<\/title><link rel="stylesheet" href="css/demobar.css"><\/head>' +
        '' +
        '' +
        '
<\/div>' +
        '
' +
        // '  Tablet Landscape<\/span><\/a>' +
        '  Tablet<\/span><\/a>' +
        // '  iPhone Landscape<\/span><\/a>' +
        '  Phone<\/span><\/a>' +
        '  Desktop<\/span><\/a>' +
        '  <\/div><\/header>

<\/iframe><\/div><\/section>'+
        '<\/body><\/html>');
    };

$(function(){
  if ( parent.$("#devices").length <=0 && !Modernizr.touch && !isIE) {
    demoBar();

    window.resbook = {};

    (function (rb) {
        var d = document,
            w = window,
            url = d.URL,
            title = d.title,
            wrapper = null,
            devices = null,
            close = null,
            //keyboard = null,
            body = null,
            size = null,
            auto = true,
            isResized = false,
            isAnimated = false,
            sizes = {
              smartphonePortrait: [320, 480],
              smartphoneLandscape: [480, 320],
              tabletPortrait: [750, 1024],
              tabletLandscape: [1024, 768],
              auto: 'auto'
            },

            resize = function (w, h, f) {
              w = w || wrapper.clientWidth;
              //h = h || wrapper.clientHeight;
              f = f || "Desktop";
              size.innerHTML = f; //w + 'x' + h
            },

            setPosition = function (wh, t, cl, myTxt) {
              var width = (wh === 'auto') ? w.innerWidth : wh[0],
                  height = (wh === 'auto') ? w.innerHeight : wh[1],
                  style = 'width:' + width + 'px;';
              if (typeof (width) === 'undefined' || typeof (height) === 'undefined') { return false; }
              style += (wh === 'auto') ? 'margin-top:0;' : '';
              wrapper.setAttribute('style', style);
              wrapper.setAttribute('data-device', cl);
              body.setAttribute('style', 'min-width:' + width + 'px;');
              resize(width, height, myTxt);
              if (wh === 'auto' && !t) {
                isResized = false;
                setTimeout(function () {
                  wrapper.setAttribute('style', '');
                  body.setAttribute('style', '');
                  isAnimated = false;
                }, 260);
              }
              else {
                isAnimated = false;
              }
            },
            readyElement = function (id, callback) {
              var interval = setInterval(function () {
                if (d.getElementById(id)) {
                  callback(d.getElementById(id));
                  clearInterval(interval);
                }
              }, 60);
            };

        rb.changeUrl = function (u, t) {
          d.title = t;
          if (history.pushState) {
            try {
              history.pushState({}, "New Page", u);
            } catch (e) {}
          }
        };

        readyElement('wrapper', function () {
            wrapper = d.getElementById('wrapper');
            devices = d.getElementById('devices');
            size = d.getElementById('size');
            close = d.querySelector('.close a');
            //keyboard = d.querySelector('.keyboard a');
            body = d.querySelector('body');
            if (window.chrome || (window.getComputedStyle && !window.globalStorage && !window.opera)) {}
            [].forEach.call(document.querySelectorAll('#devices a'), function (el) {
              el.addEventListener('click', function (e) {
                [].forEach.call(document.querySelectorAll('#devices a'), function (el) {
                  el.classList.remove('active');
                });
                e.preventDefault();
                e.stopPropagation();
                var self = this;
                if ((self.classList.contains('auto') && isResized === false) || isAnimated === true) {
                  return false;
                }
                isAnimated = true;
                if (isResized === false) {
                  isResized = true;
                  setPosition(sizes.auto, true, 'auto', 'auto');
                }
                setTimeout(function () {
                  self.classList.add('active');
                  if (self.classList.contains('smartphone-portrait')) {
                    setPosition(sizes.smartphonePortrait, false, 'smartphonePortrait', "Phone");
                  }
                  // else if (self.classList.contains('smartphone-landscape')) {
                  //   setPosition(sizes.smartphoneLandscape, false, 'smartphoneLandscape', "Phone Landscape");
                  // }
                  else if (self.classList.contains('tablet-portrait')) {
                    setPosition(sizes.tabletPortrait, false, 'tabletPortrait', "Tablet");
                  }
                  // else if (self.classList.contains('tablet-landscape')) {
                  //   setPosition(sizes.tabletLandscape, false, 'tabletLandscape', "Tablet Landscape");
                  // }
                  else if (self.classList.contains('auto')) {
                    setPosition(sizes.auto, false, 'auto', "Desktop");
                  }
                }, 10);
              });
            });

            w.addEventListener('resize', function () {
              resize();
            }, false);

            w.addEventListener('keyup', function (e) {
              var key = e.keyCode ? e.keyCode : e.charCode,
                  keys = {
                    49: 'tabletPortrait',
                    50: 'tabletLandscape',
                    51: 'smartphonePortrait',
                    52: 'smartphoneLandscape',
                    53: 'auto'
                  };
              if (typeof (keys[key]) === 'undefined') { return false; }
              setPosition(sizes[keys[key]], false, keys[key], "auto");
            }, false);
            resize();
            size.style.minWidth = 0;

            // Enable animations now that the page has loaded
            document.getElementById('wrapper').classList.add('enableTransitions');

            // if (isNav == true) {
            //   $(".tablet-portrait")[0].click();
            // }

        });
    })(window.resbook);
  }
  else if (isIE || (isAndroid && !isChrome) ) {
    $("body").prepend('

Non-Optimal Browser Detected

To get the best demo experience, it\'s recommended that you use Google Chrome
If you cannot upgrade your browser, you can resize your browser to experience it.

');
  }
});
<|endoftext|>


<commit_before>(function(){
	'use strict';

	var fb      = new Firebase('https://tictactoemax.firebaseio.com/'),
        counter = 0;

        $('#newGame').on('click', newGame
        )

        function newGame () {
        	$('.move').remove();

        }

	fb.child('games/test').once('value',function (snap) {
		var data = snap.val();

	    $('.panel').on('click', function (event) {
		   	var $panel  = $(this);

	        if ($panel.attr("data-move")) {
		      alert("already played")
		    }
		    else if (counter % 2 === 0) {
		      $(this).attr('data-move', 'X');
			  $(this).append('
X
');
		      changeBoardState($panel, data);
		      counter++;
	        }
		    else if (counter % 2 === 1) {
	          $(this).attr('data-move', 'O');
			  $(this).append('
O
');
		      changeBoardState($panel, data);
	   	      counter++;
		    }

		    var piece = 'X';

		    if (piece === 'X') {
              piece === 'O'
		    } else {
              piece === 'X'
		    }

		   	if ($('#0').attr('data-move') === piece && $('#1').attr('data-move') === piece && $('#2').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#3').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#5').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#6').attr('data-move') === piece && $('#7').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#0').attr('data-move') === piece && $('#3').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#1').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#7').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#2').attr('data-move') === piece && $('#5').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#0').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#2').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	}
        });

	}); //end fb.child

  fb.child('games/test').once('value',function (snap) {
    var data = snap.val();

    loadBoardState(data)
  });

	function changeBoardState(panel, data) {
      var fbTestGame     = fb.child('games/test/boardState'),
	        $boardPosition = panel.attr('id'),
          $boardMove     = panel.attr('data-move'),
          position       = 'position' + $boardPosition,
	        boardPosition  = {};

          boardPosition[position] = $boardMove;

	      fbTestGame.update(boardPosition);
	} //end changeBoardState

  function loadBoardState(data) {
    var boardState = data.boardState;
    console.log(boardState);

    _.forEach(boardState, function (position, key) {
      var panelId = key[8];

      $('p#' + panelId).append('
' + position + '
');
    });
  }

}()); // end IIFE<commit_msg>changed alignement of variable<commit_after>(function(){
	'use strict';

	var fb      = new Firebase('https://tictactoemax.firebaseio.com/'),
        counter = 0;

        $('#newGame').on('click', newGame
        )

        function newGame () {
        	$('.move').remove();

        }

	fb.child('games/test').once('value',function (snap) {
		var data = snap.val();

	    $('.panel').on('click', function (event) {
		   	var $panel  = $(this);

	        if ($panel.attr("data-move")) {
		      alert("already played")
		    }
		    else if (counter % 2 === 0) {
		      $(this).attr('data-move', 'X');
			  $(this).append('
X
');
		      changeBoardState($panel, data);
		      counter++;
	        }
		    else if (counter % 2 === 1) {
	          $(this).attr('data-move', 'O');
			  $(this).append('
O
');
		      changeBoardState($panel, data);
	   	      counter++;
		    }

		    var piece = 'X';

		    if (piece === 'X') {
              piece === 'O'
		    } else {
              piece === 'X'
		    }

		   	if ($('#0').attr('data-move') === piece && $('#1').attr('data-move') === piece && $('#2').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#3').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#5').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#6').attr('data-move') === piece && $('#7').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#0').attr('data-move') === piece && $('#3').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#1').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#7').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#2').attr('data-move') === piece && $('#5').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#0').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	} else if ($('#2').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.panel').off('click');
		   	}
        });

	}); //end fb.child

  fb.child('games/test').once('value',function (snap) {
    var data = snap.val();

    loadBoardState(data)
  });

	function changeBoardState(panel, data) {
      var fbTestGame     = fb.child('games/test/boardState'),
	      $boardPosition = panel.attr('id'),
          $boardMove     = panel.attr('data-move'),
          position       = 'position' + $boardPosition,
	      boardPosition  = {};

          boardPosition[position] = $boardMove;

	      fbTestGame.update(boardPosition);
	} //end changeBoardState

  function loadBoardState(data) {
    var boardState = data.boardState;
    console.log(boardState);

    _.forEach(boardState, function (position, key) {
      var panelId = key[8];

      $('p#' + panelId).append('
' + position + '
');
    });
  }

}()); // end IIFE<|endoftext|>


<commit_before>var TIMEOUT_TIME = 1000;

var map;
var geocoder;
var timeoutPID;
var inputElement;
var canvasElement;
var answerElement;
var datalistElement;
var marker;
var RESET_TITLE;
var RESET_CENTER;
var RESET_ZOOM;
var FOUND_ZOOM;
var RESET_NOT_FOUND = "No neighborhood found.";

var initialize = function() {
    RESET_TITLE = document.title;
    RESET_CENTER = new google.maps.LatLng(41.875696, -87.624207);
    RESET_ZOOM = 12;
    FOUND_ZOOM = 15;
    canvasElement = document.getElementsByTagName('div')[0];
    datalistElement = document.getElementsByTagName('datalist')[0];

    navigator.geolocation.getCurrentPosition(
        function(position) {
            initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            searchLocation(initialLocation);
            ga('send', 'event', 'result', 'auto');
        },
        function() {
            inputElement.className = 'invalid';
            resetMap(RESET_NOT_FOUND);
        }
    );

    var mapOptions = {
        center: RESET_CENTER,
        zoom: RESET_ZOOM,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        disableDefaultUI: true
    };

    map = new google.maps.Map(
        canvasElement,
        mapOptions
    );

    google.maps.Map.prototype.clearOverlays = function() {
        for (var i = 0; i < markersArray.length; i++ ) {
            markersArray[i].setMap(null);
        }
    };

    geocoder = new google.maps.Geocoder();

    var keyup = function() {
        updateMap(this.value, false);
    };

    var blur = function(event) {
        updateMap(this.value, true);
        ga('send', 'event', 'form', event.type);

        event.preventDefault();
        return false;
    };

    var updateMap = function(address, toFormat) {
        window.clearTimeout(timeoutPID);

        resetMap('Searching...');
        timeoutPID = window.setTimeout(function() {
            searchLocation(address, toFormat);
        }, TIMEOUT_TIME);
    };

    var form = document.getElementsByTagName('form')[0];
    inputElement = document.getElementsByTagName('input')[0];
    answerElement = document.getElementsByTagName('p')[0];

    addListener(inputElement, 'keyup', keyup);
    addListener(inputElement, 'blur', blur);
    addListener(form, 'submit', blur);
};

var centerMap = function() {
    var position = RESET_CENTER;
    var zoom = RESET_ZOOM;

    if (marker != null) {
        position = marker.position;
        zoom = FOUND_ZOOM;
    }

    map.setCenter(position);
    map.setZoom(zoom);
};

var searchLocation = function(address, toFormat) {
    if (address.length === 0) {
        resetMap();
        return;
    }

    var findType = function(result, type) {
        var i = 0;
        var l = result.address_components.length;
        var component;

        for(; i < l; i++) {
            component = result.address_components[i];
            if (component.types[0] == type) {
                return component;
            }
        }

        return false;
    };

    var findSuggestions = function(results) {
        // var suggestions = [];
        var i = 0;
        // var l = results.length;
        var l = 3;

        // Clear list
        datalistElement.innerHTML = '';

        for(; i < l; i++) {
            // suggestions.push(results[i].formatted_address);
            var option = document.createElement('option');
            option.value = results[i].formatted_address;
            option.text = results[i].formatted_address;
            datalistElement.appendChild(option);
            // str += '<option value="' + results[i].formatted_address + '">' + results[i].formatted_address + '</option>';
        }

    };

    var callback = function(results, status) {
        if (status != google.maps.GeocoderStatus.OK) {
            resetMap();
            ga('send', 'event', 'result', 'failed');
            return;
        }

        findSuggestions(results);

        var result = results[0];

        console.log(result);

        var neighborhood = findType(result, 'neighborhood').long_name;

        if (!neighborhood || !neighborhood.length) {
            inputElement.className = 'invalid';
            resetMap(RESET_NOT_FOUND);
            return;
        }

        inputElement.className = 'valid';

        var country = findType(result, 'country').long_name;
        var administrative_area_level_1 = findType(result, 'administrative_area_level_1').long_name;

        ga('send', 'event', 'country', country);
        ga('send', 'event', 'state', administrative_area_level_1);
        ga('send', 'event', 'neighborhood', neighborhood);

        map.setZoom(FOUND_ZOOM);
        map.setCenter(result.geometry.location);

        if (marker == null) {
            marker = new google.maps.Marker({
                map: map,
                position: result.geometry.location
            });
        } else {
            marker.setPosition(result.geometry.location);
        }

        updateNeighborhood(neighborhood);

        if (toFormat) {
            inputElement.value = result.formatted_address;
        }
    };

    var options = { 'address': address };

    if (typeof address != 'string') {
        options = { 'latLng': address };
    }

    geocoder.geocode(options, callback);
};

var resetMap = function(message) {
    document.title = RESET_TITLE;

    if (message) {
        answerElement.style.display = 'block';
        answerElement.innerHTML = message;
    } else {
        answerElement.style.display = 'none';
        answerElement.innerHTML = '';
    }

    if (marker) {
        marker.setMap(null);
        marker = null;
    }

    centerMap();
};

var updateNeighborhood = function(neighborhood) {

    if (!neighborhood || neighborhood.length === 0) {
        resetMap();
        return;
    }

    var text = 'You are in ';

    document.title = text + neighborhood + '.';

    answerElement.style.display = 'block';
    answerElement.innerHTML = text + '' + neighborhood + '.';

};

google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, 'resize', centerMap);

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-40976307-2', 'wnaii.com');ga('send', 'pageview');

/**
 * Utility to wrap the different behaviors between W3C-compliant browsers
 * and IE when adding event handlers.
 *
 * @param {Object} element Object on which to attach the event listener.
 * @param {string} type A string representing the event type to listen for
 *     (e.g. load, click, etc.).
 * @param {function()} callback The function that receives the notification.
 */
function addListener(element, type, callback) {
    if (element.addEventListener) element.addEventListener(type, callback);
    else if (element.attachEvent) element.attachEvent('on' + type, callback);
}
<commit_msg>uncommitted code.<commit_after>var TIMEOUT_TIME = 1000;

var map;
var geocoder;
var timeoutPID;
var inputElement;
var canvasElement;
var answerElement;
var datalistElement;
var marker;
var RESET_TITLE;
var RESET_CENTER;
var RESET_ZOOM;
var FOUND_ZOOM;
var RESET_NOT_FOUND = "No neighborhood found.";

var initialize = function() {
    RESET_TITLE = document.title;
    RESET_CENTER = new google.maps.LatLng(41.875696, -87.624207);
    RESET_ZOOM = 12;
    FOUND_ZOOM = 15;
    canvasElement = document.getElementsByTagName('div')[0];
    datalistElement = document.getElementsByTagName('datalist')[0];

    navigator.geolocation.getCurrentPosition(
        function(position) {
            initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            searchLocation(initialLocation);
            ga('send', 'event', 'result', 'auto');
        },
        function() {
            inputElement.className = 'invalid';
            resetMap(RESET_NOT_FOUND);
        }
    );

    var mapOptions = {
        center: RESET_CENTER,
        zoom: RESET_ZOOM,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        disableDefaultUI: true
    };

    map = new google.maps.Map(
        canvasElement,
        mapOptions
    );

    google.maps.Map.prototype.clearOverlays = function() {
        for (var i = 0; i < markersArray.length; i++ ) {
            markersArray[i].setMap(null);
        }
    };

    geocoder = new google.maps.Geocoder();

    var keyup = function() {
        updateMap(this.value, false);
    };

    var blur = function(event) {
        updateMap(this.value, true);
        ga('send', 'event', 'form', event.type);

        event.preventDefault();
        return false;
    };

    var updateMap = function(address, toFormat) {
        window.clearTimeout(timeoutPID);

        resetMap('Searching...');
        timeoutPID = window.setTimeout(function() {
            searchLocation(address, toFormat);
        }, TIMEOUT_TIME);
    };

    var form = document.getElementsByTagName('form')[0];
    inputElement = document.getElementsByTagName('input')[0];
    answerElement = document.getElementsByTagName('p')[0];

    addListener(inputElement, 'keyup', keyup);
    addListener(inputElement, 'blur', blur);
    addListener(form, 'submit', blur);
};

var centerMap = function() {
    var position = RESET_CENTER;
    var zoom = RESET_ZOOM;

    if (marker != null) {
        position = marker.position;
        zoom = FOUND_ZOOM;
    }

    map.setCenter(position);
    map.setZoom(zoom);
};

var searchLocation = function(address, toFormat) {
    if (address.length === 0) {
        resetMap();
        return;
    }

    var findType = function(result, type) {
        var i = 0;
        var l = result.address_components.length;
        var component;

        for(; i < l; i++) {
            component = result.address_components[i];
            if (component.types[0] == type) {
                return component;
            }
        }

        return false;
    };

    var findSuggestions = function(results) {
        // var suggestions = [];
        var i = 0;
        // var l = results.length;
        var l = 3;

        // Clear list
        datalistElement.innerHTML = '';

        for(; i < l; i++) {
            if (results[i] == undefined) {
                continue;
            }

            // suggestions.push(results[i].formatted_address);
            var option = document.createElement('option');
            option.value = results[i].formatted_address;
            option.text = results[i].formatted_address;
            datalistElement.appendChild(option);
            // str += '<option value="' + results[i].formatted_address + '">' + results[i].formatted_address + '</option>';
        }

    };

    var callback = function(results, status) {
        if (status != google.maps.GeocoderStatus.OK) {
            resetMap();
            ga('send', 'event', 'result', 'failed');
            return;
        }

        findSuggestions(results);

        var result = results[0];

        console.log(results);

        var neighborhood = {};

        for (var i = 0; i < results.length; i++) {
            var hood = findType(results[i], 'neighborhood').long_name;
            if (hood && hood.length > 0) {
                neighborhood[hood] = true;
            }
        }

        neighborhood = Object.keys(neighborhood);

        if (!neighborhood || !neighborhood.length) {
            inputElement.className = 'invalid';
            resetMap(RESET_NOT_FOUND);
            return;
        }

        inputElement.className = 'valid';

        var country = findType(result, 'country').long_name;
        var administrative_area_level_1 = findType(result, 'administrative_area_level_1').long_name;

        ga('send', 'event', 'country', country);
        ga('send', 'event', 'state', administrative_area_level_1);
        ga('send', 'event', 'neighborhood', neighborhood);

        map.setZoom(FOUND_ZOOM);
        map.setCenter(result.geometry.location);

        if (marker == null) {
            marker = new google.maps.Marker({
                map: map,
                position: result.geometry.location
            });
        } else {
            marker.setPosition(result.geometry.location);
        }

        updateNeighborhood(neighborhood);

        if (toFormat) {
            inputElement.value = result.formatted_address;
        }
    };

    var options = { 'address': address };

    if (typeof address != 'string') {
        options = { 'latLng': address };
    }

    geocoder.geocode(options, callback);
};

var resetMap = function(message) {
    document.title = RESET_TITLE;

    if (message) {
        answerElement.style.display = 'block';
        answerElement.innerHTML = message;
    } else {
        answerElement.style.display = 'none';
        answerElement.innerHTML = '';
    }

    if (marker) {
        marker.setMap(null);
        marker = null;
    }

    centerMap();
};

var updateNeighborhood = function(neighborhood) {

    if (!neighborhood || neighborhood.length === 0) {
        resetMap();
        return;
    }

    var text = 'You are in ';

    document.title = text + neighborhood.join(', ') + '.';

    answerElement.style.display = 'block';
    answerElement.innerHTML = text + '' + neighborhood.join(', ') + '.';

};

google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, 'resize', centerMap);

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-40976307-2', 'wnaii.com');ga('send', 'pageview');

/**
 * Utility to wrap the different behaviors between W3C-compliant browsers
 * and IE when adding event handlers.
 *
 * @param {Object} element Object on which to attach the event listener.
 * @param {string} type A string representing the event type to listen for
 *     (e.g. load, click, etc.).
 * @param {function()} callback The function that receives the notification.
 */
function addListener(element, type, callback) {
    if (element.addEventListener) element.addEventListener(type, callback);
    else if (element.attachEvent) element.attachEvent('on' + type, callback);
}
<|endoftext|>


<commit_before>/* globals $:false */

(function(){
	'use strict';

	var fb      = new Firebase('https://tictactoemax.firebaseio.com/'),
      $moves;

  $('#newGame').on('click', function newGame () {
    	$('.move').remove();
      $('.panel').removeAttr('data-move');
    });

	    $('.panel').on('click', function (event, data) {
		   	var $panel  = $(this);

        $moves = $('.move').length || 0;

	        if ($panel.attr("data-move")) {
		      alert("already played")
		    }
		    else if ($moves % 2 === 0) {
		      $(this).attr('data-move', 'X');
			  $(this).append('
X
');
		      changeBoardState($panel, data);

	        }
		    else if ($moves % 2 === 1) {
	          $(this).attr('data-move', 'O');
			  $(this).append('
O
');
		      changeBoardState($panel, data);

		    }

        $moves = $('.move').length;

		    var piece = 'X';

		    if (piece === 'X') {
              piece === 'O'
		    } else {
              piece === 'X'
		    }

		   	if ($('#0').attr('data-move') === piece && $('#1').attr('data-move') === piece && $('#2').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#3').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#5').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#6').attr('data-move') === piece && $('#7').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#0').attr('data-move') === piece && $('#3').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
         $('.panel').removeAttr('data-move');
		   	} else if ($('#1').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#7').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#2').attr('data-move') === piece && $('#5').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#0').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	} else if ($('#2').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
		   		alert(piece + ' Wins!');
		   		$('.move').remove();
          $('.panel').removeAttr('data-move');
		   	}
});

  fb.child('games/test').once('value',function (snap) {
    var data = snap.val();

    loadBoardState(data);
  });

  $('#newGame').on('click', function () {
        var fbTestGame    = fb.child('games/test/boardState')
        var newBoardState = {
                            position0: 'undefined',
                            position1: 'undefined',
                            position2: 'undefined',
                            position3: 'undefined',
                            position4: 'undefined',
                            position5: 'undefined',
                            position6: 'undefined',
                            position7: 'undefined',
                            position8: 'undefined'
                            };

        fbTestGame.set(newBoardState);
      });

	function changeBoardState(panel, data) {
      var fbTestGame     = fb.child('games/test/boardState'),
	      $boardPosition = panel.attr('id'),
          $boardMove     = panel.attr('data-move'),
          position       = 'position' + $boardPosition,
	      boardPosition  = {};

          boardPosition[position] = $boardMove;

	      fbTestGame.update(boardPosition);
	} //end changeBoardState

  function loadBoardState(data) {
    var boardState = data.boardState;
    console.log(boardState);

    _.forEach(boardState, function (position, key) {
      var panelId = key[8];

      if (position !== 'undefined') {
      $('p#' + panelId).append('
' + position + '
');
      $('p#' + panelId).attr('data-move', position);
      }

    });
  }

}()); // end IIFE<commit_msg>commiting for merge<commit_after>/* globals $:false */

(function(){
	'use strict';

	var fb      = new Firebase('https://tictactoemax.firebaseio.com/'),
      $moves;

  $('#newGame').on('click', function() {
    newGame();
  });

  $('.panel').on('click', function (event, data) {
   	var $panel  = $(this);

    $moves = $('.move').length || 0;

      if ($panel.attr("data-move")) {
      alert("already played")
    }
    else if ($moves % 2 === 0) {
      $(this).attr('data-move', 'X');
	  $(this).append('
X
');
      changeBoardState($panel, data);

      }
    else if ($moves % 2 === 1) {
        $(this).attr('data-move', 'O');
	  $(this).append('
O
');
      changeBoardState($panel, data);

    }

    $moves = $('.move').length;

    var piece = 'X';

    if (piece === 'X') {
          piece === 'O'
    } else {
          piece === 'X'
    }

   	if ($('#0').attr('data-move') === piece && $('#1').attr('data-move') === piece && $('#2').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#3').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#5').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#6').attr('data-move') === piece && $('#7').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#0').attr('data-move') === piece && $('#3').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#1').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#7').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#2').attr('data-move') === piece && $('#5').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#0').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#8').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	} else if ($('#2').attr('data-move') === piece && $('#4').attr('data-move') === piece && $('#6').attr('data-move') === piece) {
   		alert(piece + ' Wins!');
   		newGame();
   	}
});

  fb.child('games/test').once('value',function (snap) {
    var data = snap.val();
    loadBoardState(data);
  });

  function newGame () {
    var fbTestGame    = fb.child('games/test/boardState'),
        newBoardState = {
                            position0: 'undefined',
                            position1: 'undefined',
                            position2: 'undefined',
                            position3: 'undefined',
                            position4: 'undefined',
                            position5: 'undefined',
                            position6: 'undefined',
                            position7: 'undefined',
                            position8: 'undefined'
                            };

        fbTestGame.set(newBoardState);

        $('.move').remove();
        $('.panel').removeAttr('data-move');

  }

	function changeBoardState(panel, data) {
      var fbTestGame     = fb.child('games/test/boardState'),
	      $boardPosition = panel.attr('id'),
          $boardMove     = panel.attr('data-move'),
          position       = 'position' + $boardPosition,
	      boardPosition  = {};

          boardPosition[position] = $boardMove;

	      fbTestGame.update(boardPosition);
	} //end changeBoardState

  function loadBoardState(data) {
    var boardState = data.boardState;
    console.log(boardState);

    _.forEach(boardState, function (position, key) {
      var panelId = key[8];

      if (position !== 'undefined') {
      $('p#' + panelId).append('
' + position + '
');
      $('p#' + panelId).attr('data-move', position);
      }

    });
  }

}()); // end IIFE<|endoftext|>


<commit_before>module.exports.create = create;

function create(players, ui, services, eventBus) {
  var instance = {
    id: 'play',
    states: ['standby', 'online'],
    determineStation: determineStation,
    action: action
  };

  return instance;

  function action(stationId) {
    var device = this;

    stationId = determineStation(stationId);

    // emit LEDS
    ui.RGBLEDs.power.emit({
      emit: true, colour: ui.colours.green
    });

    return players.main.add({
      // add station
      clear: true,
      playlist: [services.playlist(stationId)]
    }).then(function() {
      // play
      return players.main.play();
    }).then(function(){
      // update device state
      device.transition('online');

      // set service as active
      return services.change(stationId);
    });

  };

  // play given service, current service,
  // or default service
  function determineStation(stationId) {
    if(stationId) {
     return stationId;
    } else {
     return services.current() || services.default;
    }
  }
}
<commit_msg>Clear other players when playing a station normally<commit_after>module.exports.create = create;

function create(players, ui, services, eventBus) {
  var instance = {
    id: 'play',
    states: ['standby', 'online'],
    determineStation: determineStation,
    action: action
  };

  return instance;

  function action(stationId) {
    var device = this;

    stationId = determineStation(stationId);

    // emit LEDS
    ui.RGBLEDs.power.emit({
      emit: true, colour: ui.colours.green
    });

    players.announcer.clear();
    players.avoider.clear();

    return players.main.add({
      // add station
      clear: true,
      playlist: [services.playlist(stationId)]
    }).then(function() {
      // play
      return players.main.play();
    }).then(function(){
      // update device state
      device.transition('online');

      // set service as active
      return services.change(stationId);
    });

  };

  // play given service, current service,
  // or default service
  function determineStation(stationId) {
    if(stationId) {
     return stationId;
    } else {
     return services.current() || services.default;
    }
  }
}
<|endoftext|>


<commit_before>(function(){
	'use strict';

	var fb = new Firebase('https://tictactoemax.firebaseio.com/');

	fb.child('games/test');

	$('.panel').on('click', function (event) {
	  $(this).attr('data-move', 'x');
	});
}());<commit_msg>click event wont fire if div already clicked<commit_after>(function(){
	'use strict';

	var fb = new Firebase('https://tictactoemax.firebaseio.com/');

	fb.child('games/test');

	$('.panel').on('click', function (event) {
	  var $panel = $(this);

      if ($panel.attr("data-move")) {
      	console.log("already played")
      } else {
		  $(this).attr('data-move', 'x');
	  }
	});
}());<|endoftext|>


<commit_before>'use strict';

const angular = require('angular');

import { BakeryReader, Registry } from '@spinnaker/core';

module.exports = angular
  .module('spinnaker.amazon.pipeline.stage.findImageFromTagsStage', [])
  .config(function() {
    Registry.pipeline.registerStage({
      provides: 'findImageFromTags',
      cloudProvider: 'oracle',
      templateUrl: require('./findImageFromTagsStage.html'),
      executionDetailsUrl: require('./findImageFromTagsExecutionDetails.html'),
      executionConfigSections: ['findImageConfig', 'taskStatus'],
      validators: [
        { type: 'requiredField', fieldName: 'regions' },
        { type: 'requiredField', fieldName: 'packageName' },
      ],
    });
  })
  .controller('oracleFindImageFromTagsStageCtrl', function($scope) {
    $scope.stage.packageName = $scope.stage.packageName || '*';
    $scope.stage.tags = $scope.stage.tags || {};
    $scope.stage.regions = $scope.stage.regions || [];
    $scope.stage.cloudProvider = $scope.stage.cloudProvider || 'oracle';

    BakeryReader.getRegions('oracle').then(function(regions) {
      $scope.regions = regions;
    });
  });
<commit_msg>fix(oracle/pipeline): Rename ng module to spinnaker.oracle.* (#6219)<commit_after>'use strict';

const angular = require('angular');

import { BakeryReader, Registry } from '@spinnaker/core';

module.exports = angular
  .module('spinnaker.oracle.pipeline.stage.findImageFromTagsStage', [])
  .config(function() {
    Registry.pipeline.registerStage({
      provides: 'findImageFromTags',
      cloudProvider: 'oracle',
      templateUrl: require('./findImageFromTagsStage.html'),
      executionDetailsUrl: require('./findImageFromTagsExecutionDetails.html'),
      executionConfigSections: ['findImageConfig', 'taskStatus'],
      validators: [
        { type: 'requiredField', fieldName: 'regions' },
        { type: 'requiredField', fieldName: 'packageName' },
      ],
    });
  })
  .controller('oracleFindImageFromTagsStageCtrl', function($scope) {
    $scope.stage.packageName = $scope.stage.packageName || '*';
    $scope.stage.tags = $scope.stage.tags || {};
    $scope.stage.regions = $scope.stage.regions || [];
    $scope.stage.cloudProvider = $scope.stage.cloudProvider || 'oracle';

    BakeryReader.getRegions('oracle').then(function(regions) {
      $scope.regions = regions;
    });
  });
<|endoftext|>


<commit_before>'use strict';
var nodes = function() {}
nodes.customNode = require('./nodeHelpers/customNode');
nodes.infuraNode = require('./nodeHelpers/infura');
nodes.metamaskNode = require('./nodeHelpers/metamask');
nodes.nodeTypes = {
    ETH: "ETH",
    ETC: "ETC",
    MUS: "MUSIC",
    Ropsten: "ROPSTEN ETH",
    Kovan: "KOVAN ETH",
    Rinkeby: "RINKEBY ETH",
    RSK: "RSK",
    EXP: "EXP",
    UBQ: "UBQ",
    POA: "POA",
    TOMO: "TOMO",
    ELLA: "ELLA",
    Custom: "CUSTOM ETH"
};
nodes.ensNodeTypes = [nodes.nodeTypes.ETH, nodes.nodeTypes.Ropsten];
nodes.domainsaleNodeTypes = [nodes.nodeTypes.ETH, nodes.nodeTypes.Ropsten];
nodes.customNodeObj = {
    'name': 'CUS',
    'blockExplorerTX': '',
    'blockExplorerAddr': '',
    'type': nodes.nodeTypes.Custom,
    'eip155': false,
    'chainId': '',
    'tokenList': [],
    'abiList': [],
    'service': 'Custom',
    'lib': null
};
nodes.nodeList = {
    'eth_mew': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'MyEtherWallet',
        'lib': new nodes.customNode('https://api.myetherapi.com/eth', '')
    },
    'eth_ethscan': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscan')
    },
    'eth_infura': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://mainnet.infura.io/mew')
    },
    'eth_giveth': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'Giveth.io',
        'lib': new nodes.customNode('https://mew.giveth.io', '')
    },
    'etc_epool': {
        'name': 'ETC',
        'blockExplorerTX': 'https://gastracker.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://gastracker.io/addr/[[address]]',
        'type': nodes.nodeTypes.ETC,
        'eip155': true,
        'chainId': 61,
        'tokenList': require('./tokens/etcTokens.json'),
        'abiList': require('./abiDefinitions/etcAbi.json'),
        'service': 'Epool.io',
        'lib': new nodes.customNode('https://mewapi.epool.io', '')
    },
    'rop_mew': {
        'name': 'Ropsten',
        'type': nodes.nodeTypes.Ropsten,
        'blockExplorerTX': 'https://ropsten.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ropsten.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 3,
        'tokenList': require('./tokens/ropstenTokens.json'),
        'abiList': require('./abiDefinitions/ropstenAbi.json'),
        'service': 'MyEtherWallet',
        'lib': new nodes.customNode('https://api.myetherapi.com/rop', '')
    },
    'rop_infura': {
        'name': 'Ropsten',
        'blockExplorerTX': 'https://ropsten.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ropsten.etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.Ropsten,
        'eip155': true,
        'chainId': 3,
        'tokenList': require('./tokens/ropstenTokens.json'),
        'abiList': require('./abiDefinitions/ropstenAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://ropsten.infura.io/mew')
    },
    'kov_ethscan': {
        'name': 'Kovan',
        'type': nodes.nodeTypes.Kovan,
        'blockExplorerTX': 'https://kovan.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://kovan.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 42,
        'tokenList': require('./tokens/kovanTokens.json'),
        'abiList': require('./abiDefinitions/kovanAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscanKov')
    },
    'kov_infura': {
        'name': 'Kovan',
        'type': nodes.nodeTypes.Kovan,
        'blockExplorerTX': 'https://kovan.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://kovan.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 42,
        'tokenList': require('./tokens/kovanTokens.json'),
        'abiList': require('./abiDefinitions/kovanAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://kovan.infura.io/mew')
    },
    'rin_ethscan': {
        'name': 'Rinkeby',
        'type': nodes.nodeTypes.Rinkeby,
        'blockExplorerTX': 'https://rinkeby.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://rinkeby.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 4,
        'tokenList': require('./tokens/rinkebyTokens.json'),
        'abiList': require('./abiDefinitions/rinkebyAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscanRin')
    },
    'rin_infura': {
        'name': 'Rinkeby',
        'blockExplorerTX': 'https://rinkeby.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://rinkeby.etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.Rinkeby,
        'eip155': true,
        'chainId': 4,
        'tokenList': require('./tokens/rinkebyTokens.json'),
        'abiList': require('./abiDefinitions/rinkebyAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://rinkeby.infura.io/mew')
    },
    'exp': {
        'name': 'EXP',
        'blockExplorerTX': 'http://www.gander.tech/tx/[[txHash]]',
        'blockExplorerAddr': 'http://www.gander.tech/address/[[address]]',
        'type': nodes.nodeTypes.EXP,
        'eip155': true,
        'chainId': 2,
        'tokenList': require('./tokens/expTokens.json'),
        'abiList': require('./abiDefinitions/expAbi.json'),
        'estimateGas': true,
        'service': 'Expanse.tech',
        'lib': new nodes.customNode('https://node.expanse.tech/', '')
    },
    'ubq': {
        'name': 'UBQ',
        'blockExplorerTX': 'https://ubiqscan.io/en/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ubiqscan.io/en/address/[[address]]',
        'type': nodes.nodeTypes.UBQ,
        'eip155': true,
        'chainId': 8,
        'tokenList': require('./tokens/ubqTokens.json'),
        'abiList': require('./abiDefinitions/ubqAbi.json'),
        'estimateGas': true,
        'service': 'ubiqscan.io',
        'lib': new nodes.customNode('https://pyrus2.ubiqscan.io', '')
    },
    'poa': {
        'name': 'POA',
        'blockExplorerTX': 'https://core-explorer.poa.network/tx/[[txHash]]',
        'blockExplorerAddr': 'https://core-explorer.poa.network/account/[[address]]',
        'type': nodes.nodeTypes.POA,
        'eip155': true,
        'chainId': 99,
        'tokenList': require('./tokens/poaTokens.json'),
        'abiList': require('./abiDefinitions/poaAbi.json'),
        'estimateGas': true,
        'service': 'core.poa.network',
        'lib': new nodes.customNode('https://core.poa.network', '')
    },
    'tomo': {
        'name': 'TOMO',
        'blockExplorerTX': 'https://explorer.tomocoin.io/#/tx/[[txHash]]',
        'blockExplorerAddr': 'https://explorer.tomocoin.io/#/address/[[address]]',
        'type': nodes.nodeTypes.TOMO,
        'eip155': true,
        'chainId': 40686,
        'tokenList': require('./tokens/tomoTokens.json'),
        'abiList': require('./abiDefinitions/tomoAbi.json'),
        'estimateGas': true,
        'service': 'core.tomocoin.io',
        'lib': new nodes.customNode('https://core.tomocoin.io', '')
    },
    'ella': {
        'name': 'ELLA',
        'blockExplorerTX': 'https://explorer.ellaism.org/tx/[[txHash]]',
        'blockExplorerAddr': 'https://explorer.ellaism.org/addr/[[address]]',
        'type': nodes.nodeTypes.ELLA,
        'eip155': true,
        'chainId': 64,
        'tokenList': require('./tokens/ellaTokens.json'),
        'abiList': require('./abiDefinitions/ellaAbi.json'),
        'estimateGas': true,
        'service': 'ellaism.org',
        'lib': new nodes.customNode('https://jsonrpc.ellaism.org', '')
    }
};

nodes.ethPrice = require('./nodeHelpers/ethPrice');
module.exports = nodes;
<commit_msg>add MyCrypto ETH endpoint<commit_after>'use strict';
var nodes = function() {}
nodes.customNode = require('./nodeHelpers/customNode');
nodes.infuraNode = require('./nodeHelpers/infura');
nodes.metamaskNode = require('./nodeHelpers/metamask');
nodes.nodeTypes = {
    ETH: "ETH",
    ETC: "ETC",
    MUS: "MUSIC",
    Ropsten: "ROPSTEN ETH",
    Kovan: "KOVAN ETH",
    Rinkeby: "RINKEBY ETH",
    RSK: "RSK",
    EXP: "EXP",
    UBQ: "UBQ",
    POA: "POA",
    TOMO: "TOMO",
    ELLA: "ELLA",
    Custom: "CUSTOM ETH"
};
nodes.ensNodeTypes = [nodes.nodeTypes.ETH, nodes.nodeTypes.Ropsten];
nodes.domainsaleNodeTypes = [nodes.nodeTypes.ETH, nodes.nodeTypes.Ropsten];
nodes.customNodeObj = {
    'name': 'CUS',
    'blockExplorerTX': '',
    'blockExplorerAddr': '',
    'type': nodes.nodeTypes.Custom,
    'eip155': false,
    'chainId': '',
    'tokenList': [],
    'abiList': [],
    'service': 'Custom',
    'lib': null
};
nodes.nodeList = {
    'eth_mew': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'MyEtherWallet',
        'lib': new nodes.customNode('https://api.myetherapi.com/eth', '')
    },
    'eth_mycrypto': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'MyCrypto',
        'lib': new nodes.customNode('https://api.mycryptoapi.com/eth', '')
    },
    'eth_ethscan': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscan')
    },
    'eth_infura': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://mainnet.infura.io/mew')
    },
    'eth_giveth': {
        'name': 'ETH',
        'blockExplorerTX': 'https://etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.ETH,
        'eip155': true,
        'chainId': 1,
        'tokenList': require('./tokens/ethTokens.json'),
        'abiList': require('./abiDefinitions/ethAbi.json'),
        'service': 'Giveth.io',
        'lib': new nodes.customNode('https://mew.giveth.io', '')
    },
    'etc_epool': {
        'name': 'ETC',
        'blockExplorerTX': 'https://gastracker.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://gastracker.io/addr/[[address]]',
        'type': nodes.nodeTypes.ETC,
        'eip155': true,
        'chainId': 61,
        'tokenList': require('./tokens/etcTokens.json'),
        'abiList': require('./abiDefinitions/etcAbi.json'),
        'service': 'Epool.io',
        'lib': new nodes.customNode('https://mewapi.epool.io', '')
    },
    'rop_mew': {
        'name': 'Ropsten',
        'type': nodes.nodeTypes.Ropsten,
        'blockExplorerTX': 'https://ropsten.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ropsten.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 3,
        'tokenList': require('./tokens/ropstenTokens.json'),
        'abiList': require('./abiDefinitions/ropstenAbi.json'),
        'service': 'MyEtherWallet',
        'lib': new nodes.customNode('https://api.myetherapi.com/rop', '')
    },
    'rop_infura': {
        'name': 'Ropsten',
        'blockExplorerTX': 'https://ropsten.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ropsten.etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.Ropsten,
        'eip155': true,
        'chainId': 3,
        'tokenList': require('./tokens/ropstenTokens.json'),
        'abiList': require('./abiDefinitions/ropstenAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://ropsten.infura.io/mew')
    },
    'kov_ethscan': {
        'name': 'Kovan',
        'type': nodes.nodeTypes.Kovan,
        'blockExplorerTX': 'https://kovan.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://kovan.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 42,
        'tokenList': require('./tokens/kovanTokens.json'),
        'abiList': require('./abiDefinitions/kovanAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscanKov')
    },
    'kov_infura': {
        'name': 'Kovan',
        'type': nodes.nodeTypes.Kovan,
        'blockExplorerTX': 'https://kovan.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://kovan.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 42,
        'tokenList': require('./tokens/kovanTokens.json'),
        'abiList': require('./abiDefinitions/kovanAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://kovan.infura.io/mew')
    },
    'rin_ethscan': {
        'name': 'Rinkeby',
        'type': nodes.nodeTypes.Rinkeby,
        'blockExplorerTX': 'https://rinkeby.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://rinkeby.etherscan.io/address/[[address]]',
        'eip155': true,
        'chainId': 4,
        'tokenList': require('./tokens/rinkebyTokens.json'),
        'abiList': require('./abiDefinitions/rinkebyAbi.json'),
        'service': 'Etherscan.io',
        'lib': require('./nodeHelpers/etherscanRin')
    },
    'rin_infura': {
        'name': 'Rinkeby',
        'blockExplorerTX': 'https://rinkeby.etherscan.io/tx/[[txHash]]',
        'blockExplorerAddr': 'https://rinkeby.etherscan.io/address/[[address]]',
        'type': nodes.nodeTypes.Rinkeby,
        'eip155': true,
        'chainId': 4,
        'tokenList': require('./tokens/rinkebyTokens.json'),
        'abiList': require('./abiDefinitions/rinkebyAbi.json'),
        'service': 'infura.io',
        'lib': new nodes.infuraNode('https://rinkeby.infura.io/mew')
    },
    'exp': {
        'name': 'EXP',
        'blockExplorerTX': 'http://www.gander.tech/tx/[[txHash]]',
        'blockExplorerAddr': 'http://www.gander.tech/address/[[address]]',
        'type': nodes.nodeTypes.EXP,
        'eip155': true,
        'chainId': 2,
        'tokenList': require('./tokens/expTokens.json'),
        'abiList': require('./abiDefinitions/expAbi.json'),
        'estimateGas': true,
        'service': 'Expanse.tech',
        'lib': new nodes.customNode('https://node.expanse.tech/', '')
    },
    'ubq': {
        'name': 'UBQ',
        'blockExplorerTX': 'https://ubiqscan.io/en/tx/[[txHash]]',
        'blockExplorerAddr': 'https://ubiqscan.io/en/address/[[address]]',
        'type': nodes.nodeTypes.UBQ,
        'eip155': true,
        'chainId': 8,
        'tokenList': require('./tokens/ubqTokens.json'),
        'abiList': require('./abiDefinitions/ubqAbi.json'),
        'estimateGas': true,
        'service': 'ubiqscan.io',
        'lib': new nodes.customNode('https://pyrus2.ubiqscan.io', '')
    },
    'poa': {
        'name': 'POA',
        'blockExplorerTX': 'https://core-explorer.poa.network/tx/[[txHash]]',
        'blockExplorerAddr': 'https://core-explorer.poa.network/account/[[address]]',
        'type': nodes.nodeTypes.POA,
        'eip155': true,
        'chainId': 99,
        'tokenList': require('./tokens/poaTokens.json'),
        'abiList': require('./abiDefinitions/poaAbi.json'),
        'estimateGas': true,
        'service': 'core.poa.network',
        'lib': new nodes.customNode('https://core.poa.network', '')
    },
    'tomo': {
        'name': 'TOMO',
        'blockExplorerTX': 'https://explorer.tomocoin.io/#/tx/[[txHash]]',
        'blockExplorerAddr': 'https://explorer.tomocoin.io/#/address/[[address]]',
        'type': nodes.nodeTypes.TOMO,
        'eip155': true,
        'chainId': 40686,
        'tokenList': require('./tokens/tomoTokens.json'),
        'abiList': require('./abiDefinitions/tomoAbi.json'),
        'estimateGas': true,
        'service': 'core.tomocoin.io',
        'lib': new nodes.customNode('https://core.tomocoin.io', '')
    },
    'ella': {
        'name': 'ELLA',
        'blockExplorerTX': 'https://explorer.ellaism.org/tx/[[txHash]]',
        'blockExplorerAddr': 'https://explorer.ellaism.org/addr/[[address]]',
        'type': nodes.nodeTypes.ELLA,
        'eip155': true,
        'chainId': 64,
        'tokenList': require('./tokens/ellaTokens.json'),
        'abiList': require('./abiDefinitions/ellaAbi.json'),
        'estimateGas': true,
        'service': 'ellaism.org',
        'lib': new nodes.customNode('https://jsonrpc.ellaism.org', '')
    }
};

nodes.ethPrice = require('./nodeHelpers/ethPrice');
module.exports = nodes;
<|endoftext|>


<commit_before>/*
Graphical Module BBH1 Building Block Histogram.

This module has all functionalities for graphical display of user data.

Module Dependencies: d3, THREE, BBMathematics, BBStatistics.

*/
define( [ 'd3', 'THREE', 'Axis' , 'Painter' ], function( d3, THREE, Axis , Painter ){
  "use strict";

  // Object Constructor BBH1 Building Block Histogram 1D.
  function H1( name, title, nbinsx, xmin, xmax ){
    this.fDimension = 1; // Dimension of the plot data.
    this.name = name;
    this.title = title;
    this.nbinsx = nbinsx;
    this.xmin = xmin;
    this.xmax = xmax;
    this.rawData = []; // data array filled by Fill function.
    this.freqData = new Array( nbinsx + 2 ); // data array of frequencies for each bin. Two bins extra have been added, one for underflow and the another one for overflow.

    this.fXaxis = Object.create( Axis() );
    this.fYaxis = Object.create( Axis() );
	this.fPainter = Object.create( Painter() );
  }

  H1.prototype = {
    constructor: H1,

    Fill: function( value ) {
      return this.rawData.push( value );
    },

    // Deattach data preparation
    Prepare: function(){
      var binxlow = this.xmin;
      var binwidth = ( this.xmax - this.xmin ) / this.nbinsx;
      var binxup = binxlow + binwidth;

      // Initialize frequencies to zero.
      for( var i = 0; i < this.freqData.length; i++ ){
        this.freqData[ i ] = 0;
      }

      // First fill array of frequencies for each bin: freqData.
      for( var i = 0; i < this.rawData.length; i++ ){
        binxlow = this.xmin;
        binxup = binxlow + binwidth;
        if( this.rawData[ i ] < this.xmin ) this.freqData[ 0 ] += 1; // Underflow.
        if( this.rawData[ i ] >= this.xmax ) this.freqData[ nbinsx + 1 ] += 1; // Overflow.
        // From index 1 til index nbinsx-2 of freqData Array.
        for( var j = 1; j < this.freqData.length - 1; j++ ){
          if( this.rawData[ i ] >= binxlow && this.rawData[ i ] < binxup ){
            this.freqData[ j ] += 1;
            break;
          }
          // Go to the next bin
          binxlow = binxup;
          binxup += binwidth;
        }
      }
      console.log(this.freqData);

    },

    Draw: function(){
      this.Prepare();
      var binwidth = ( this.xmax - this.xmin ) / this.nbinsx;
      // **************************************************************
      // Now start visualization
      // **************************************************************
      var margin = { top:20, right:40, bottom: 30, left:60 };
      var width = 640 -  margin.left - margin.right ;
      var height = 400 -  margin.top - margin.bottom ;
      var svg = d3.select( "#c1" ).append( "svg" )
        .attr( "width", height + margin.left + margin.right )
        .attr( "height", width + margin.top + margin.bottom );
      // Drawing a chart inside the svg
      var chart = svg.append( "g" )
        .attr( "transform", "translate(" + margin.left + "," + margin.top + ")" );
      // Scaling the data
      var xScale = d3.scale.linear().range( [ 0, width ] );
      var yScale = d3.scale.linear().range( [ height, 0 ] );
      // Defining the plot's domain
      xScale.domain([ this.xmin, this.xmax ]).nice();
      yScale.domain([ 0, d3.max( this.rawData ) ]).nice();

      var xAxis = d3.svg.axis()
        .scale( xScale )
        .orient( "bottom" );

      var yAxis = d3.svg.axis()
        .scale( yScale )
        .orient( "left" );

      var xAxisGroup = chart.append( "g" )
        .attr( "transform", "translate(0," + height + ")" );

      var yAxisGroup = chart.append( "g" )
        .attr( "transform", "translate(0," + height + ")" );

      xAxis( xAxisGroup );
      yAxis( yAxisGroup );
      // Definining text labels for axis.
      // Don't do it because that need to be accessed by the user

      // Displaying data
      this.freqData.forEach(function(d,i){
		        chart.append( "rect" )
          .attr( "x", function(){return (i-1)*xScale(binwidth);} )
          .attr( "width", xScale(binwidth)-2)
          .attr( "y", yScale(d) )
          .attr( "height", function(){return height-yScale(d);}  )
		        .attr("fill", "steelblue");
      });
    }, // Ends function Draw

    GetXaxis: function(){
      return this.fXaxis;
    },

    GetYaxis: function(){
      return this.fYaxis;
    },

  };

  return H1;

}); // Ends Module H1

<commit_msg>New object definition of Axis .<commit_after>/*
Graphical Module BBH1 Building Block Histogram.

This module has all functionalities for graphical display of user data.

Module Dependencies: d3, THREE, BBMathematics, BBStatistics.

*/
define( [ 'd3', 'THREE', 'Axis' , 'Painter' ], function( d3, THREE, Axis , Painter ){
  "use strict";

  // Object Constructor H1 Building Block Histogram 1D.
  function H1( name, title, nbinsx, xmin, xmax ){
    this.fDimension = 1; // Dimension of the plot data.
    this.name = name;
    this.title = title;
    this.nbinsx = nbinsx;
    this.xmin = xmin;
    this.xmax = xmax;
    this.rawData = []; // data array filled by Fill function.
    this.freqData = new Array( nbinsx + 2 ); // data array of frequencies for each bin. Two bins extra have been added, one for underflow and the another one for overflow.

    this.fXaxis =new Axis("xaxishisto", "Eje x en [u]") ;
    this.fYaxis =new Axis("xaxishisto", "Eje x en [u]") ;
	//this.fPainter = Object.create( Painter() );
  }

  H1.prototype = {
    constructor: H1,

    Fill: function( value ) {
      return this.rawData.push( value );
    },

    // Deattach data preparation
    Prepare: function(){
      var binxlow = this.xmin;
      var binwidth = ( this.xmax - this.xmin ) / this.nbinsx;
      var binxup = binxlow + binwidth;

      // Initialize frequencies to zero.
      for( var i = 0; i < this.freqData.length; i++ ){
        this.freqData[ i ] = 0;
      }

      // First fill array of frequencies for each bin: freqData.
      for( var i = 0; i < this.rawData.length; i++ ){
        binxlow = this.xmin;
        binxup = binxlow + binwidth;
        if( this.rawData[ i ] < this.xmin ) this.freqData[ 0 ] += 1; // Underflow.
        if( this.rawData[ i ] >= this.xmax ) this.freqData[ nbinsx + 1 ] += 1; // Overflow.
        // From index 1 til index nbinsx-2 of freqData Array.
        for( var j = 1; j < this.freqData.length - 1; j++ ){
          if( this.rawData[ i ] >= binxlow && this.rawData[ i ] < binxup ){
            this.freqData[ j ] += 1;
            break;
          }
          // Go to the next bin
          binxlow = binxup;
          binxup += binwidth;
        }
      }
      console.log(this.freqData);

    },

    Draw: function(){
      this.Prepare();
      var binwidth = ( this.xmax - this.xmin ) / this.nbinsx;
      // **************************************************************
      // Now start visualization
      // **************************************************************
      var margin = { top:20, right:40, bottom: 30, left:60 };
      var width = 640 -  margin.left - margin.right ;
      var height = 400 -  margin.top - margin.bottom ;
      var svg = d3.select( "#c1" ).append( "svg" )
        .attr( "width", width + margin.left + margin.right )
        .attr( "height", height + margin.top + margin.bottom );
      // Drawing a chart inside the svg
      var chart = svg.append( "g" )
        .attr( "transform", "translate(" + margin.left + "," + margin.top + ")" );
      // Scaling the data
      var xScale = d3.scale.linear().domain([ this.xmin, this.xmax ]).range( [ 0, width ] );
      var yScale = d3.scale.linear().domain([ 0, d3.max( this.freqData ) ]).range( [ height, 0 ] );
      // Defining the plot's domain
      //xScale..nice();
      //yScale.nice();

      var xAxis = d3.svg.axis()
        .scale( xScale )
        .orient( "bottom" );

      var yAxis = d3.svg.axis()
        .scale( yScale )
        .orient( "left" );

      var xAxisGroup = chart.append( "g" )
        .attr( "transform", "translate(0," + height + ")" );

      var yAxisGroup = chart.append( "g" )
        .attr( "transform", "translate(0,0)" );

      xAxis( xAxisGroup );
      yAxis( yAxisGroup );
      // Definining text labels for axis.
      // Don't do it because that need to be accessed by the user

      // Displaying data
      this.freqData.forEach(function(d,i){
		        chart.append( "rect" )
          .attr( "x", function(){return (i-1)*xScale(binwidth);} )
          .attr( "width", xScale(binwidth)-2)
          .attr( "y", yScale(d) )
          .attr( "height", function(){return height-yScale(d);}  )
		        .attr("fill", "steelblue");
      });
    }, // Ends function Draw

    GetXaxis: function(){
      return this.fXaxis;
    },

    GetYaxis: function(){
      return this.fYaxis;
    },

};
  return H1;

}); // Ends Module H1

<|endoftext|>