<commit_before>$(document).ready(function(){

	$("#phone").mask("(999) 999-9999");
	$("#dob").mask("99/99/9999");
	$("#ssn").mask("999-99-9999");
	$("#pw").mask("99-9999999");

	$("#pw").on("keyup", function(){
		console.log( $(this).val() );
		var value = $(this).val();
		var bullet = "*";
		$(this).val( value.replace(value, bullet) );
	});

	/*$("#pw").keypress(function(e){
		$(this).attr("type", "text");
	}).keyup(function(e){
		$(this).attr("type", "password");
	});*/

	// Display Inputs for Rows w/o subfields
	$(".form_noSubFields").on("click", function(){

		$(this).children("label").css("font-size", "16px");
		$(this).css({
			"padding-bottom": "22px",
			"border": "1px solid #b3d4fc"
		});
	});

	// Display Inputs for Rows w/ subfields
	$(".form_hasSubFields").on("click", function(){

		$(this).children("label").hide();

		$(this).children(".subField").show();
		$(this).find("input").css({
			"border-bottom": "1px solid #ccc"
		});

		if( $(this).find("input").first().attr("id") == "first" ){
			$(this).find("input").first().focus();
		}

		$(this).css({
			"padding-bottom": "0px",
			"border": "1px solid #b3d4fc"
		});

	});

});

<commit_msg>test replace input value on change event<commit_after>$(document).ready(function(){

	$("#phone").mask("(999) 999-9999");
	$("#dob").mask("99/99/9999");
	$("#ssn").mask("999-99-9999");
	$("#pw").mask("99-9999999");

	$("#pw").on("change", function(){
		console.log( $(this).val() );
		var value = $(this).val();
		var bullet = "*";
		$(this).val( value.replace(value, bullet) );
	});

	// Display Inputs for Rows w/o subfields
	$(".form_noSubFields").on("click", function(){

		$(this).children("label").css("font-size", "16px");
		$(this).css({
			"padding-bottom": "22px",
			"border": "1px solid #b3d4fc"
		});
	});

	// Display Inputs for Rows w/ subfields
	$(".form_hasSubFields").on("click", function(){

		$(this).children("label").hide();

		$(this).children(".subField").show();
		$(this).find("input").css({
			"border-bottom": "1px solid #ccc"
		});

		if( $(this).find("input").first().attr("id") == "first" ){
			$(this).find("input").first().focus();
		}

		$(this).css({
			"padding-bottom": "0px",
			"border": "1px solid #b3d4fc"
		});

	});

});

<|endoftext|>


<commit_before>//= require bootstrap-sprockets

$(document).ready(function() {
  $.extend({
    playSound: function(){
      return $("<embed src='"+arguments[0]+".mp3' hidden='true' autostart='true' loop='false' class='playSound'>" + "<audio autoplay='autoplay' style='display:none;' controls='controls'><source src='"+arguments[0]+".mp3' /><source src='"+arguments[0]+".ogg' /></audio>").appendTo('body');
    }
  });

  $(document).keydown(function(e) {
    if (e.keyCode == 81) { // Q
      $.playSound('/sounds/throwup');
    } else if (e.keyCode == 87) { // W
      $.playSound('/sounds/orchestra');
    } else if (e.keyCode == 69) { // E
      $.playSound('/sounds/bubble-third');
    } else if (e.keyCode == 82) { // R
      $.playSound('/sounds/bubble-fourth');
    } else if (e.keyCode == 84) { // T
      $.playSound('/sounds/bell-low');
    } else if (e.keyCode == 89) { // Y
      $.playSound('/sounds/bell-high');
    } else if (e.keyCode == 85) { // U
      $.playSound('/sounds/chill');
    } else if (e.keyCode == 73) { // I
      $.playSound('/sounds/bass-1');
    } else if (e.keyCode == 79) { // O
      $.playSound('/sounds/chord_sequence-low');
    } else if (e.keyCode == 80) { // P
      $.playSound('/sounds/chord_sequence-high');
    } else if (e.keyCode == 65) { // A
      $.playSound('/sounds/clap');
    } else if (e.keyCode == 83) { // S
      $.playSound('/sounds/clock');
    } else if (e.keyCode == 68) { // D
      $.playSound('/sounds/coin-low');
    } else if (e.keyCode == 70) { // F
      $.playSound('/sounds/coin-mid');
    } else if (e.keyCode == 71) { // G
      $.playSound('/sounds/coin-high');
    } else if (e.keyCode == 72) { // H
      $.playSound('/sounds/crickets');
    } else if (e.keyCode == 74) { // J
      $.playSound('/sounds/cymbal-1');
    } else if (e.keyCode == 75) { // K
      $.playSound('/sounds/gunshot-1');
    } else if (e.keyCode == 76) { // L
      $.playSound('/sounds/gunshot-2');
    } else if (e.keyCode == 90) { // Z
      $.playSound('/sounds/harmonics-1');
    } else if (e.keyCode == 88) { // X
      $.playSound('/sounds/harmonics-2');
    } else if (e.keyCode == 67) { // C
      $.playSound('/sounds/harmonics-3');
    } else if (e.keyCode == 86) { // V
      $.playSound('/sounds/harmonics-4');
    } else if (e.keyCode == 66) { // B
      $.playSound('/sounds/herbie-low');
    } else if (e.keyCode == 78) { // N
      $.playSound('/sounds/herbie-mid');
    } else if (e.keyCode == 77) { // M
      $.playSound('/sounds/herbie-high');
    }
  });

  // First keyboard mapping
  // QWERTYUIOP
  $('#Q1').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W1').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E1').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R1').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T1').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y1').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U1').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I1').click(function() {
    $.playSound('/sounds/bass-1');
  });
  $('#O1').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P1').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A1').click(function() {
    $.playSound('/sounds/clap');
  });
  $('#S1').click(function() {
    $.playSound('/sounds/clock');
  });
  $('#D1').click(function() {
    $.playSound('/sounds/coin-low');
  });
  $('#F1').click(function() {
    $.playSound('/sounds/coin-mid');
  });
  $('#G1').click(function() {
    $.playSound('/sounds/coin-high');
  });
  $('#H1').click(function() {
    $.playSound('/sounds/crickets');
  });
  $('#J1').click(function() {
    $.playSound('/sounds/cymbal-1');
  });
  $('#K1').click(function() {
    $.playSound('/sounds/gunshot-1');
  });
  $('#L1').click(function() {
    $.playSound('/sounds/gunshot-2');
  });

  // ZXCVBNM
  $('#Z1').click(function() {
    $.playSound('/sounds/harmonics-1');
  });
  $('#X1').click(function() {
    $.playSound('/sounds/harmonics-2');
  });
  $('#C1').click(function() {
    $.playSound('/sounds/harmonics-3');
  });
  $('#V1').click(function() {
    $.playSound('/sounds/harmonics-4');
  });
  $('#B1').click(function() {
    $.playSound('/sounds/herbie-low');
  });
  $('#N1').click(function() {
    $.playSound('/sounds/herbie-mid');
  });
  $('#M1').click(function() {
    $.playSound('/sounds/herbie-high');
  });

  // Second keyboard mapping
  // QWERTYUIOP
  $('#Q2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W2').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E2').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R2').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T2').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y2').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U2').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I2').click(function() {
    $.playSound('/sounds/bass-2');
  });
  $('#O2').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P2').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#S2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#D2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#F2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#G2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#H2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#J2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#K2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#L2').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // ZXCVBNM
  $('#Z2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#X2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#C2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#V2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#B2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#N2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#M2').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // Third keyboard mapping
  // QWERTYUIOP
  $('#Q3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W3').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E3').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R3').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T3').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y3').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U3').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I3').click(function() {
    $.playSound('/sounds/bass-3');
  });
  $('#O3').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P3').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#S3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#D3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#F3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#G3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#H3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#J3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#K3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#L3').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // ZXCVBNM
  $('#Z3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#X3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#C3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#V3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#B3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#N3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#M3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
});
<commit_msg>change sounds<commit_after>//= require bootstrap-sprockets

$(document).ready(function() {
  $.extend({
    playSound: function(){
      return $("<embed src='"+arguments[0]+".mp3' hidden='true' autostart='true' loop='false' class='playSound'>" + "<audio autoplay='autoplay' style='display:none;' controls='controls'><source src='"+arguments[0]+".mp3' /><source src='"+arguments[0]+".ogg' /></audio>").appendTo('body');
    }
  });

  $(document).keydown(function(e) {
    if (e.keyCode == 81) { // Q
      $.playSound('/sounds/bubble-first');
    } else if (e.keyCode == 87) { // W
      $.playSound('/sounds/bubble-second');
    } else if (e.keyCode == 69) { // E
      $.playSound('/sounds/bubble-third');
    } else if (e.keyCode == 82) { // R
      $.playSound('/sounds/bubble-fourth');
    } else if (e.keyCode == 84) { // T
      $.playSound('/sounds/bell-low');
    } else if (e.keyCode == 89) { // Y
      $.playSound('/sounds/bell-high');
    } else if (e.keyCode == 85) { // U
      $.playSound('/sounds/chill');
    } else if (e.keyCode == 73) { // I
      $.playSound('/sounds/bass-1');
    } else if (e.keyCode == 79) { // O
      $.playSound('/sounds/chord_sequence-low');
    } else if (e.keyCode == 80) { // P
      $.playSound('/sounds/chord_sequence-high');
    } else if (e.keyCode == 65) { // A
      $.playSound('/sounds/clap');
    } else if (e.keyCode == 83) { // S
      $.playSound('/sounds/clock');
    } else if (e.keyCode == 68) { // D
      $.playSound('/sounds/coin-low');
    } else if (e.keyCode == 70) { // F
      $.playSound('/sounds/coin-mid');
    } else if (e.keyCode == 71) { // G
      $.playSound('/sounds/coin-high');
    } else if (e.keyCode == 72) { // H
      $.playSound('/sounds/crickets');
    } else if (e.keyCode == 74) { // J
      $.playSound('/sounds/cymbal-1');
    } else if (e.keyCode == 75) { // K
      $.playSound('/sounds/gunshot-1');
    } else if (e.keyCode == 76) { // L
      $.playSound('/sounds/gunshot-2');
    } else if (e.keyCode == 90) { // Z
      $.playSound('/sounds/harmonics-1');
    } else if (e.keyCode == 88) { // X
      $.playSound('/sounds/harmonics-2');
    } else if (e.keyCode == 67) { // C
      $.playSound('/sounds/harmonics-3');
    } else if (e.keyCode == 86) { // V
      $.playSound('/sounds/harmonics-4');
    } else if (e.keyCode == 66) { // B
      $.playSound('/sounds/herbie-low');
    } else if (e.keyCode == 78) { // N
      $.playSound('/sounds/herbie-mid');
    } else if (e.keyCode == 77) { // M
      $.playSound('/sounds/herbie-high');
    }
  });

  // First keyboard mapping
  // QWERTYUIOP
  $('#Q1').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W1').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E1').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R1').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T1').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y1').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U1').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I1').click(function() {
    $.playSound('/sounds/bass-1');
  });
  $('#O1').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P1').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A1').click(function() {
    $.playSound('/sounds/clap');
  });
  $('#S1').click(function() {
    $.playSound('/sounds/clock');
  });
  $('#D1').click(function() {
    $.playSound('/sounds/coin-low');
  });
  $('#F1').click(function() {
    $.playSound('/sounds/coin-mid');
  });
  $('#G1').click(function() {
    $.playSound('/sounds/coin-high');
  });
  $('#H1').click(function() {
    $.playSound('/sounds/crickets');
  });
  $('#J1').click(function() {
    $.playSound('/sounds/cymbal-1');
  });
  $('#K1').click(function() {
    $.playSound('/sounds/gunshot-1');
  });
  $('#L1').click(function() {
    $.playSound('/sounds/gunshot-2');
  });

  // ZXCVBNM
  $('#Z1').click(function() {
    $.playSound('/sounds/harmonics-1');
  });
  $('#X1').click(function() {
    $.playSound('/sounds/harmonics-2');
  });
  $('#C1').click(function() {
    $.playSound('/sounds/harmonics-3');
  });
  $('#V1').click(function() {
    $.playSound('/sounds/harmonics-4');
  });
  $('#B1').click(function() {
    $.playSound('/sounds/herbie-low');
  });
  $('#N1').click(function() {
    $.playSound('/sounds/herbie-mid');
  });
  $('#M1').click(function() {
    $.playSound('/sounds/herbie-high');
  });

  // Second keyboard mapping
  // QWERTYUIOP
  $('#Q2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W2').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E2').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R2').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T2').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y2').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U2').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I2').click(function() {
    $.playSound('/sounds/bass-2');
  });
  $('#O2').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P2').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#S2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#D2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#F2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#G2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#H2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#J2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#K2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#L2').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // ZXCVBNM
  $('#Z2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#X2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#C2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#V2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#B2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#N2').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#M2').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // Third keyboard mapping
  // QWERTYUIOP
  $('#Q3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#W3').click(function() {
    $.playSound('/sounds/bubble-second');
  });
  $('#E3').click(function() {
    $.playSound('/sounds/bubble-third');
  });
  $('#R3').click(function() {
    $.playSound('/sounds/bubble-fourth');
  });
  $('#T3').click(function() {
    $.playSound('/sounds/bell-low');
  });
  $('#Y3').click(function() {
    $.playSound('/sounds/bell-high');
  });
  $('#U3').click(function() {
    $.playSound('/sounds/chill');
  });
  $('#I3').click(function() {
    $.playSound('/sounds/bass-3');
  });
  $('#O3').click(function() {
    $.playSound('/sounds/chord_sequence-low');
  });
  $('#P3').click(function() {
    $.playSound('/sounds/chord_sequence-high');
  });

  // ASDFGHJKL
  $('#A3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#S3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#D3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#F3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#G3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#H3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#J3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#K3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#L3').click(function() {
    $.playSound('/sounds/bubble-first');
  });

  // ZXCVBNM
  $('#Z3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#X3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#C3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#V3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#B3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#N3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
  $('#M3').click(function() {
    $.playSound('/sounds/bubble-first');
  });
});
<|endoftext|>


<commit_before>// je déclare la fonction fullscreen
function fullscreen(element) {
   return (element.requestFullscreen ||
      element.webkitRequestFullscreen ||
      element.mozRequestFullScreen ||
      element.msRequestFullscreen).call(element);
}

// je récupère le bouton grâce à son id que j'ai rajouté dans le code HTML
var $bouton = document.getElementById('fullscreen')

// j'attache le gestionnaire de click
$bouton.addEventListener('click', function() {
   // j'appelle la fonction fullscreen sur le <html>
   fullscreen(document.documentElement);
});

(function(window, document, $) {
	var $itemsContainer = $('.cd-items-wrapper'),
		$itemsSlider = $itemsContainer.children('.cd-slider'),
		$singleItemContent = $('.cd-item-content'),
		$sliderNav = $('.cd-slider-navigation');

	var resizing = false;

	//if on desktop - set a width for the $itemsSlider element
	setSliderContainer();
	$(window).on('resize', function(){
		//on resize - update $itemsSlider width and translate value
		if( !resizing ) {
			(!window.requestAnimationFrame) ? setSliderContainer() : window.requestAnimationFrame(setSliderContainer);
			resizing = true;
		}
	});

	//show the items slider if user clicks the show-items button
	$('.cd-intro-block').on('click', '.cd-content-wrapper>a', function(event) {
		event.preventDefault();
		var $introBlock = $(this).parent().parent();
		var $thisItemsContainer = $introBlock.next();
		$introBlock.addClass('items-visible');
		$thisItemsContainer.addClass('items-visible');
		//animate single item - entrance animation
		setTimeout(function(){
			showItemPreview($thisItemsContainer.children('.cd-slider').children('li').eq(0));
		}, 200);
	});
	//items slider is visible - hide slider and show the intro panel
	$('.cd-intro-block').on('click', function(event) {
		var $introSlider = $(this);
		var $introPanel = $introSlider.next();
		if( $introSlider.hasClass('items-visible') && !$(event.target).is('a[data-action="show-items"]') ) {
			$introSlider.removeClass('items-visible');
			$introPanel.removeClass('items-visible');
		}
	});
	//close items slider with button (as well as intro panel)
	$('.cd-items-wrapper>a').on('click',function(event){
		var $introPanel = $(this).parent();
		var $introSlider = $introPanel.prev();
		if( $introSlider.hasClass('items-visible') && $(event.target).is('a[data-action="close-items"]') ) {
			$introSlider.removeClass('items-visible');
			$introPanel.removeClass('items-visible');
		}
	});
	//select a single item - open item-content panel
	$('.cd-items-wrapper').on('click', '.cd-slider a', function(event) {
		event.preventDefault();
		var mq = checkMQ();
		var item_id = $(this).attr('data-action');
		if( $(this).parent('li').next('li').is('.current') && mq === 'desktop') {
			prevSides($itemsSlider);
		} else if ( $(this).parent('li').prev('li').prev('li').prev('li').is('.current') && mq === 'desktop') {
			nextSides($itemsSlider);
		} else {
			$('.cd-item-content#'+item_id).addClass('is-visible');
		}
	});

	//close single item content
	$singleItemContent.on('click', '.close', function(event){
		event.preventDefault();
		$singleItemContent.removeClass('is-visible');
	});

	//go to next/pre slide - clicking on the next/prev arrow
	$sliderNav.on('click', '.next', function(){
		nextSides($('.cd-items-wrapper').children('.cd-slider'));
	});
	$sliderNav.on('click','.prev',function(){
		prevSides($('.cd-items-wrapper').children('.cd-slider'));
	});

	$itemsSlider.on('swipeleft', function(){
		var mq = checkMQ();
		if( !($sliderNav.find('.next').hasClass('inactive')) && (mq == 'desktop') ) nextSides($itemsSlider);
	});

	$itemsSlider.on('swiperight', function(){
		var mq = checkMQ();
		if ( !($sliderNav.find('.prev').hasClass('inactive')) && (mq == 'desktop') ) prevSides($itemsSlider);
	});

	function showItemPreview(item) {
		if(item.length > 0 ) {
			setTimeout(function(){
				item.addClass('slides-in');
				showItemPreview(item.next());
			}, 50);
		}
	}

	function checkMQ() {
		//check if mobile or desktop device
		return window.getComputedStyle(document.querySelector('.cd-items-wrapper'), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "");
	}

	function setSliderContainer() {
		var mq = checkMQ();
		if(mq == 'desktop') {
			var	slides = $itemsSlider.children('li'),
				slideWidth = slides.eq(0).width(),
				marginLeft = Number($itemsSlider.children('li').eq(1).css('margin-left').replace('px', '')),
				sliderWidth = ( slideWidth + marginLeft )*( slides.length + 1 ) + 'px',
				slideCurrentIndex = $itemsSlider.children('li.current').index();
			$itemsSlider.css('width', sliderWidth);
			( slideCurrentIndex != 0 ) && setTranslateValue($itemsSlider, (  slideCurrentIndex * (slideWidth + marginLeft) + 'px'));
		} else {
			$itemsSlider.css('width', '');
			setTranslateValue($itemsSlider, 0);
		}
		resizing = false;
	}

	function nextSides(slider) {
		var actual = slider.children('.current'),
			index = actual.index(),
			following = actual.nextAll('li').length,
			width = actual.width(),
			marginLeft = Number(slider.children('li').eq(1).css('margin-left').replace('px', ''));

		index = (following > 4 ) ? index + 3 : index + following - 2;
		//calculate the translate value of the slider container
		translate = index * (width + marginLeft) + 'px';

		slider.addClass('next');
		setTranslateValue(slider, translate);
		slider.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			updateSlider('next', actual, slider, following);
		});

		if( $('.no-csstransitions').length > 0 ) updateSlider('next', actual, slider, following);
	}

	function prevSides(slider) {
		var actual = slider.children('.previous'),
			index = actual.index(),
			width = actual.width(),
			marginLeft = Number(slider.children('li').eq(1).css('margin-left').replace('px', ''));
		console.log(marginLeft);

		translate = index * (width + marginLeft) + 'px';

		slider.addClass('prev');
		setTranslateValue(slider, translate);
		slider.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			updateSlider('prev', actual, slider);
		});

		if( $('.no-csstransitions').length > 0 ) updateSlider('prev', actual, slider);
	}

	function updateSlider(direction, actual, slider, numerFollowing) {
		if( direction == 'next' ) {
			slider.removeClass('next').find('.previous').removeClass('previous');
			actual.removeClass('current');
			if( numerFollowing > 4 ) {
				actual.addClass('previous').next('li').next('li').next('li').addClass('current');
			} else if ( numerFollowing == 4 ) {
				actual.next('li').next('li').addClass('current');
				actual.prev('li').addClass('previous');
			} else if( numerFollowing == 3 ) {
				actual.next('li').addClass('current');
				actual.prev('li').prev('li').addClass('previous');
			}
		} else {
			slider.removeClass('prev').find('.current').removeClass('current');
			actual.removeClass('previous').addClass('current');
			if(actual.prevAll('li').length > 2 ) {
				actual.prev('li').prev('li').prev('li').addClass('previous');
			} else {
				( !slider.children('li').eq(0).hasClass('current') ) && slider.children('li').eq(0).addClass('previous');
			}
		}

		updateNavigation();
	}

	function updateNavigation() {
		//update visibility of next/prev buttons according to the visible slides
		var current = $itemsContainer.find('li.current');
		(current.is(':first-child')) ? $sliderNav.find('.prev').addClass('inactive') : $sliderNav.find('.prev').removeClass('inactive');
		(current.nextAll('li').length < 3 ) ? $sliderNav.find('.next').addClass('inactive') : $sliderNav.find('.next').removeClass('inactive');
	}

	function setTranslateValue(item, translate) {
		item.css({
		    '-moz-transform': 'translateX(-' + translate + ')',
		    '-webkit-transform': 'translateX(-' + translate + ')',
			'-ms-transform': 'translateX(-' + translate + ')',
			'-o-transform': 'translateX(-' + translate + ')',
			'transform': 'translateX(-' + translate + ')',
		});
	}

}(window, document, window.jQuery));
<commit_msg>edit js<commit_after>// je déclare la fonction fullscreen
function fullscreen(element) {
   return (element.requestFullscreen ||
      element.webkitRequestFullscreen ||
      element.mozRequestFullScreen ||
      element.msRequestFullscreen).call(element);
}

// je récupère le bouton grâce à son id que j'ai rajouté dans le code HTML
var $bouton = document.getElementById('fullscreen')

// j'attache le gestionnaire de click
$bouton.addEventListener('click', function() {
   // j'appelle la fonction fullscreen sur le <html>
   fullscreen(document.documentElement);
});

(function(window, document, $) {
	var $itemsContainer = $('.cd-items-wrapper'),
		$itemsSlider = $itemsContainer.children('.cd-slider'),
		$singleItemContent = $('.cd-item-content'),
		$sliderNav = $('.cd-slider-navigation');

	var resizing = false;

	//if on desktop - set a width for the $itemsSlider element
	setSliderContainer();
	$(window).on('resize', function(){
		//on resize - update $itemsSlider width and translate value
		if( !resizing ) {
			(!window.requestAnimationFrame) ? setSliderContainer() : window.requestAnimationFrame(setSliderContainer);
			resizing = true;
		}
	});

	//show the items slider if user clicks the show-items button
	$('.cd-intro-block').on('click', '.cd-content-wrapper>a', function(event) {
		event.preventDefault();
		var $introBlock = $(this).parent().parent();
		var $thisItemsContainer = $introBlock.next();
		$introBlock.addClass('items-visible');
		$thisItemsContainer.addClass('items-visible');
		//animate single item - entrance animation
		setTimeout(function(){
			showItemPreview($thisItemsContainer.children('.cd-slider').children('li').eq(0));
		}, 200);
	});
	//items slider is visible - hide slider and show the intro panel
	$('.cd-intro-block').on('click', function(event) {
		var $introSlider = $(this);
		var $introPanel = $introSlider.next();
		if( $introSlider.hasClass('items-visible') && !$(event.target).is('a[data-action="show-items"]') ) {
			$introSlider.removeClass('items-visible');
			$introPanel.removeClass('items-visible');
		}
	});
	//close items slider with button (as well as intro panel)
	$('.cd-items-wrapper>a').on('click',function(event){
		var $introPanel = $(this).parent();
		var $introSlider = $introPanel.prev();
		if( $introSlider.hasClass('items-visible') && $(event.target).is('a[data-action="close-items"]') ) {
			$introSlider.removeClass('items-visible');
			$introPanel.removeClass('items-visible');
		}
	});
	//select a single item - open item-content panel
	$('.cd-items-wrapper').on('click', '.cd-slider a', function(event) {
		event.preventDefault();
		var mq = checkMQ();
		var item_id = $(this).attr('data-action');
		if( $(this).parent('li').next('li').is('.current') && mq === 'desktop') {
			prevSides($itemsSlider);
		} else if ( $(this).parent('li').prev('li').prev('li').prev('li').is('.current') && mq === 'desktop') {
			nextSides($itemsSlider);
		} else {
			$('.cd-item-content#'+item_id).addClass('is-visible');
		}
	});

	//close single item content
	$singleItemContent.on('click', '.close', function(event){
		event.preventDefault();
		$singleItemContent.removeClass('is-visible');
	});

	//go to next/pre slide - clicking on the next/prev arrow
	$sliderNav.on('click', '.next', function(){
		nextSides($('.cd-items-wrapper').children('.cd-slider'));
	});
	$sliderNav.on('click','.prev',function(){
		prevSides($('.cd-items-wrapper').children('.cd-slider'));
	});

	$itemsSlider.on('swipeleft', function(){
		var mq = checkMQ();
		if( !($sliderNav.find('.next').hasClass('inactive')) && (mq == 'desktop') ) nextSides($itemsSlider);
	});

	$itemsSlider.on('swiperight', function(){
		var mq = checkMQ();
		if ( !($sliderNav.find('.prev').hasClass('inactive')) && (mq == 'desktop') ) prevSides($itemsSlider);
	});

	function showItemPreview(item) {
		if(item.length > 0 ) {
			setTimeout(function(){
				item.addClass('slides-in');
				showItemPreview(item.next());
			}, 50);
		}
	}

	function checkMQ() {
		//check if mobile or desktop device
		return window.getComputedStyle(document.querySelector('.cd-items-wrapper'), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "");
	}

	function setSliderContainer() {
		var mq = checkMQ();
		if(mq == 'desktop') {
			var	slides = $itemsSlider.children('li'),
				slideWidth = slides.eq(0).width(),
				marginLeft = Number($itemsSlider.children('li').eq(1).css('margin-left').replace('px', '')),
				sliderWidth = ( slideWidth + marginLeft )*( slides.length + 1 ) + 'px',
				slideCurrentIndex = $itemsSlider.children('li.current').index();
			$itemsSlider.css('width', sliderWidth);
			( slideCurrentIndex != 0 ) && setTranslateValue($itemsSlider, (  slideCurrentIndex * (slideWidth + marginLeft) + 'px'));
		} else {
			$itemsSlider.css('width', '');
			setTranslateValue($itemsSlider, 0);
		}
		resizing = false;
	}

	function nextSides(slider) {
		var actual = slider.children('.current'),
			index = actual.index(),
			following = actual.nextAll('li').length,
			width = actual.width(),
			marginLeft = Number(slider.children('li').eq(1).css('margin-left').replace('px', ''));

		index = (following > 4 ) ? index + 3 : index + following - 2;
		//calculate the translate value of the slider container
		translate = index * (width + marginLeft) + 'px';

		slider.addClass('next');
		setTranslateValue(slider, translate);
		slider.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			updateSlider('next', actual, slider, following);
		});

		if( $('.no-csstransitions').length > 0 ) updateSlider('next', actual, slider, following);
	}

	function prevSides(slider) {
		var actual = slider.children('.previous'),
			index = actual.index(),
			width = actual.width(),
			marginLeft = Number(slider.children('li').eq(1).css('margin-left').replace('px', ''));
		console.log(marginLeft);

		translate = index * (width + marginLeft) + 'px';

		slider.addClass('prev');
		setTranslateValue(slider, translate);
		slider.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			updateSlider('prev', actual, slider);
		});

		if( $('.no-csstransitions').length > 0 ) updateSlider('prev', actual, slider);
	}

	function updateSlider(direction, actual, slider, numerFollowing) {
		if( direction == 'next' ) {
			slider.removeClass('next').find('.previous').removeClass('previous');
			actual.removeClass('current');
			if( numerFollowing > 4 ) {
				actual.addClass('previous').next('li').next('li').next('li').addClass('current');
			} else if ( numerFollowing == 4 ) {
				actual.next('li').next('li').addClass('current');
				actual.prev('li').addClass('previous');
			} else if( numerFollowing == 3 ) {
				actual.next('li').addClass('current');
				actual.prev('li').prev('li').addClass('previous');
			}
		} else {
			slider.removeClass('prev').find('.current').removeClass('current');
			actual.removeClass('previous').addClass('current');
			if(actual.prevAll('li').length > 2 ) {
				actual.prev('li').prev('li').prev('li').addClass('previous');
			} else {
				( !slider.children('li').eq(0).hasClass('current') ) && slider.children('li').eq(0).addClass('previous');
			}
		}

		updateNavigation();
	}

	function updateNavigation() {
		//update visibility of next/prev buttons according to the visible slides
		var current = $itemsContainer.find('li.current');
		(current.is(':first-child')) ? $sliderNav.find('.prev').addClass('inactive') : $sliderNav.find('.prev').removeClass('inactive');
		(current.nextAll('li').length < 3 ) ? $sliderNav.find('.next').addClass('inactive') : $sliderNav.find('.next').removeClass('inactive');
	}

	function setTranslateValue(item, translate) {
		item.css({
		    '-moz-transform': 'translateX(-' + translate + ')',
		    '-webkit-transform': 'translateX(-' + translate + ')',
			'-ms-transform': 'translateX(-' + translate + ')',
			'-o-transform': 'translateX(-' + translate + ')',
			'transform': 'translateX(-' + translate + ')',
		});
	}

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


<commit_before>function queryObj() {
	var result = {}, queryString = location.search.slice(1),
		re = /([^&=]+)=([^&]*)/g, m;

	while (m = re.exec(queryString)) {
		result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
	}
	return result;
}

(function () {

	Logo = {
	};

	Logo.randomColor = function() {
		var color = '#'
		for(var i = 0; i < 3; i++) {
			var r = Math.floor(Math.random() * 15);
			color += r < 9 ? r : String.fromCharCode(65 + r - 9);
		}
		return color;
	};

	Logo.queryObj = new queryObj();

	Logo.backStyles = new Array('blank', 'striped', 'diag', 'exed', 'habs', 'roundel', 'dots');
	Logo.fontFamilies = new Array("Calibri", "Times New Roman", "Comic Sans MS", "Palatino Linotype", "Arial", "Helvetica", "Tahoma");

	if(Object.keys(Logo.queryObj).length < 1 || Logo.queryObj.random) {
		// ERMAGOD RANDOM LOGO
		Logo.backColor = Logo.randomColor();
		Logo.fontColor = Logo.randomColor();
		Logo.fontStroke = Logo.backColor;
		Logo.stripeColor = Logo.randomColor();
		Logo.letters = new Array();
		var letterLength = 1 + Math.floor(Math.random() * 2);
		for(var i = 0; i < letterLength; i++) {
			Logo.letters.push([String.fromCharCode(65 + Math.floor(Math.random() * 26))]);
		}
		Logo.backStyle = Logo.backStyles[Math.floor(Math.random() * Logo.backStyles.length)];
		Logo.offsetX = Math.floor(Math.random() * 50);
		Logo.fontFamily = Logo.fontFamilies[Math.floor(Math.random() * Logo.fontFamilies.length)];
	} else {
		Logo.backColor = '#' + Logo.queryObj.backColor ? Logo.queryObj.backColor : '333';
		Logo.fontColor = '#' + Logo.queryObj.fontColor ? Logo.queryObj.fontColor : '999';
		Logo.fontStroke = '#' + (Logo.queryObj.fontStroke ? Logo.queryObj.fontStroke : Logo.backColor);
		Logo.backStyle = Logo.queryObj.backStyle ? Logo.queryObj.backStyle : 'blank';
		Logo.stripeColor = '#' + (Logo.queryObj.foreColor ? Logo.queryObj.foreColor : Logo.backColor);
		Logo.letters = Logo.queryObj.logoLetter.split("|");
		Logo.offsetX = Logo.queryObj.offsetX? Logo.queryObj.offsetX : 0;
		Logo.fontFamily = Logo.queryObj.fontFamily ? Logo.queryObj.fontFamily : "Calibri";
	}

	Logo.url = 'http://' + window.location.hostname + '/?backColor=' + Logo.backColor+ '&fontColor=' + Logo.fontColor + '&fontStroke=' + Logo.fontStroke + '&backStyle=' + Logo.backStyle + '&stripeColor=' + Logo.stripeColor + '&logoLetter=' + Logo.letters.join('|');

	Logo.kinetic = {}; // All kinetic object references go in here

	Logo.kinetic.stage = new Kinetic.Stage( {
		container: 'logo',
		width: Logo.queryObj.width? Logo.queryObj.width : 275, //Math.min(window.innerWidth, window.innerHeight),
		height: Logo.queryObj.height? Logo.queryObj.height : 275 //Math.min(window.innerWidth, window.innerHeight)
	});

	Logo.kinetic.layer = new Kinetic.Layer();

	Logo.kinetic.wrapper = new Kinetic.Rect( {
		x:0,
		y:0,
		width: Logo.kinetic.stage.getWidth(),
		height: Logo.kinetic.stage.getHeight(),
		fill: Logo.backColor
	});

	Logo.kinetic.layer.add(Logo.kinetic.wrapper);

	Logo.kinetic.stripes = new Array();

	if(Logo.backStyle == 'striped') {
		for(var i = 0; i < 2; i++) {
			var x = (i % 2 == 0)? Logo.kinetic.stage.getWidth() * .2 : Logo.kinetic.stage.getWidth() - (Logo.kinetic.stage.getWidth() * .2);
			var stripe = new Kinetic.Line({
				points: [ x, 0, x, Logo.kinetic.stage.getHeight() ],
				stroke: Logo.stripeColor,
				strokeWidth: Logo.kinetic.stage.getWidth() * .1
			});
			Logo.kinetic.stripes.push(stripe);
			Logo.kinetic.layer.add(stripe);
		}
	}
	if(Logo.backStyle == 'diag' || Logo.backStyle == 'exed') {
		var count = Logo.backStyle == 'diag' ? 1 : 2;
		for(var i = 0; i < count; i++) {
			var stripe = new Kinetic.Line({
				points: (i % 2 == 0) ? [0, 0, Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()] : [0, Logo.kinetic.stage.getHeight(), Logo.kinetic.stage.getWidth(), 0],
				stroke: Logo.stripeColor,
				strokeWidth: Logo.kinetic.stage.getWidth() * .2
			});
			Logo.kinetic.stripes.push(stripe);
			Logo.kinetic.layer.add(stripe);
		}
	}
	if(Logo.backStyle == 'habs') {
		var stripe = new Kinetic.Line({
			points: [0, Logo.kinetic.stage.getHeight() * .5, Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight() * .5],
			stroke: Logo.stripeColor,
			strokeWidth: Logo.kinetic.stage.getWidth() * .25
		});
		Logo.kinetic.stripes.push(stripe);
		Logo.kinetic.layer.add(stripe);
	}
	if(Logo.backStyle == 'roundel') {
		var circle = new Kinetic.Circle({
			x: Logo.kinetic.stage.getWidth() * .5,
			y: Logo.kinetic.stage.getHeight() * .5,
			fill: Logo.stripeColor,
			radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .2
		});
		Logo.kinetic.stripes.push(circle);
		Logo.kinetic.layer.add(circle);

		var circle = new Kinetic.Circle({
			x: Logo.kinetic.stage.getWidth() * .5,
			y: Logo.kinetic.stage.getHeight() * .5,
			strokeWidth: Logo.kinetic.stage.getWidth() * .15,
			radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .4,
			stroke: Logo.stripeColor
		});
		Logo.kinetic.stripes.push(circle);
		Logo.kinetic.layer.add(circle);
	}
	if(Logo.backStyle == 'dots') {
		for(var i = 0; i < 4; i++) {
			for(var j = 0; j < 4; j++) {
				var circle = new Kinetic.Circle({
					x: (Logo.kinetic.stage.getWidth() / 3*( i )) + ((j%2) * Logo.kinetic.stage.getWidth()/6),
					y: Logo.kinetic.stage.getHeight() / 3 * (j ),
					radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .1,
					fill: Logo.stripeColor
				});
				Logo.kinetic.stripes.push(circle);
				Logo.kinetic.layer.add(circle);
			}
		}
	}
	Logo.kinetic.letters = new Array();
	for(var i = Logo.letters.length-1; i >= 0; i--) {
		var y = i * Logo.kinetic.stage.getHeight() * .1;
		var x = 0;
		if(Logo.letters.length > 1) {
			x = (i == 0? -1 : 1) * Logo.offsetX * Logo.kinetic.stage.getWidth() / 200;
		}
		if(Logo.letters.length == 2) {
			y  -= Logo.kinetic.stage.getHeight() * (i == 0? .1 : -.02);
		}
		var letter = new Kinetic.Text({
			x: x,
			y: y,
			width: Logo.kinetic.stage.getWidth(),
			fill: Logo.fontColor,
			fontFamily: Logo.fontFamily,
			fontSize: Logo.kinetic.stage.getHeight() - 25,
			text: Logo.letters[i],
			align: 'center',
			fontStyle: 'bold',
			strokeWidth: 2,
			stroke: Logo.fontStroke
		});
		Logo.kinetic.letters.push(letter);
		Logo.kinetic.layer.add(letter);
	}

     Logo.kinetic.gloss = new Kinetic.Shape({
		drawFunc: function(canvas) {
			var borderSize = Logo.kinetic.stage.getWidth() * .03;
			var context = canvas.getContext();
			context.beginPath();
			context.moveTo(borderSize, borderSize);
			context.lineTo(Logo.kinetic.stage.getWidth() - borderSize , borderSize);
			context.lineTo(Logo.kinetic.stage.getWidth() - borderSize, Logo.kinetic.stage.getHeight() * .3);
			context.quadraticCurveTo(Logo.kinetic.stage.getWidth() - borderSize, Logo.kinetic.stage.getHeight() * .5, Logo.kinetic.stage.getWidth() * .5, Logo.kinetic.stage.getHeight() * .5);
			context.quadraticCurveTo(borderSize, Logo.kinetic.stage.getWidth() * .5, borderSize, Logo.kinetic.stage.getWidth() * .6);
			context.closePath();
			canvas.fillStroke(this);
		},
		fill: "cecece",
		opacity: .25
	});

	Logo.kinetic.layer.add(Logo.kinetic.gloss);

	Logo.kinetic.stage.add(Logo.kinetic.layer);

})();<commit_msg>get back ground and font color fixed when requesting through query string<commit_after>function queryObj() {
	var result = {}, queryString = location.search.slice(1),
		re = /([^&=]+)=([^&]*)/g, m;

	while (m = re.exec(queryString)) {
		result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
	}
	return result;
}

(function () {

	Logo = {
	};

	Logo.randomColor = function() {
		var color = '#'
		for(var i = 0; i < 3; i++) {
			var r = Math.floor(Math.random() * 15);
			color += r < 9 ? r : String.fromCharCode(65 + r - 9);
		}
		return color;
	};

	Logo.queryObj = new queryObj();

	Logo.backStyles = new Array('blank', 'striped', 'diag', 'exed', 'habs', 'roundel', 'dots');
	Logo.fontFamilies = new Array("Calibri", "Times New Roman", "Comic Sans MS", "Palatino Linotype", "Arial", "Helvetica", "Tahoma");

	if(Object.keys(Logo.queryObj).length < 1 || Logo.queryObj.random) {
		// ERMAGOD RANDOM LOGO
		Logo.backColor = Logo.randomColor();
		Logo.fontColor = Logo.randomColor();
		Logo.fontStroke = Logo.backColor;
		Logo.stripeColor = Logo.randomColor();
		Logo.letters = new Array();
		var letterLength = 1 + Math.floor(Math.random() * 2);
		for(var i = 0; i < letterLength; i++) {
			Logo.letters.push([String.fromCharCode(65 + Math.floor(Math.random() * 26))]);
		}
		Logo.backStyle = Logo.backStyles[Math.floor(Math.random() * Logo.backStyles.length)];
		Logo.offsetX = Math.floor(Math.random() * 50);
		Logo.fontFamily = Logo.fontFamilies[Math.floor(Math.random() * Logo.fontFamilies.length)];
	} else {
		Logo.backColor = '#' + (Logo.queryObj.backColor ? Logo.queryObj.backColor : '333');
		Logo.fontColor = '#' + (Logo.queryObj.fontColor ? Logo.queryObj.fontColor : '999');
		Logo.fontStroke = '#' + (Logo.queryObj.fontStroke ? Logo.queryObj.fontStroke : Logo.backColor);
		Logo.backStyle = Logo.queryObj.backStyle ? Logo.queryObj.backStyle : 'blank';
		Logo.stripeColor = '#' + (Logo.queryObj.foreColor ? Logo.queryObj.foreColor : Logo.backColor);
		Logo.letters = Logo.queryObj.logoLetter.split("|");
		Logo.offsetX = Logo.queryObj.offsetX? Logo.queryObj.offsetX : 0;
		Logo.fontFamily = Logo.queryObj.fontFamily ? Logo.queryObj.fontFamily : "Calibri";
	}

	Logo.url = 'http://' + window.location.hostname + '/?backColor=' + Logo.backColor+ '&fontColor=' + Logo.fontColor + '&fontStroke=' + Logo.fontStroke + '&backStyle=' + Logo.backStyle + '&stripeColor=' + Logo.stripeColor + '&logoLetter=' + Logo.letters.join('|');

	Logo.kinetic = {}; // All kinetic object references go in here

	Logo.kinetic.stage = new Kinetic.Stage( {
		container: 'logo',
		width: Logo.queryObj.width? Logo.queryObj.width : 275, //Math.min(window.innerWidth, window.innerHeight),
		height: Logo.queryObj.height? Logo.queryObj.height : 275 //Math.min(window.innerWidth, window.innerHeight)
	});

	Logo.kinetic.layer = new Kinetic.Layer();

	Logo.kinetic.wrapper = new Kinetic.Rect( {
		x:0,
		y:0,
		width: Logo.kinetic.stage.getWidth(),
		height: Logo.kinetic.stage.getHeight(),
		fill: Logo.backColor
	});

	Logo.kinetic.layer.add(Logo.kinetic.wrapper);

	Logo.kinetic.stripes = new Array();

	if(Logo.backStyle == 'striped') {
		for(var i = 0; i < 2; i++) {
			var x = (i % 2 == 0)? Logo.kinetic.stage.getWidth() * .2 : Logo.kinetic.stage.getWidth() - (Logo.kinetic.stage.getWidth() * .2);
			var stripe = new Kinetic.Line({
				points: [ x, 0, x, Logo.kinetic.stage.getHeight() ],
				stroke: Logo.stripeColor,
				strokeWidth: Logo.kinetic.stage.getWidth() * .1
			});
			Logo.kinetic.stripes.push(stripe);
			Logo.kinetic.layer.add(stripe);
		}
	}
	if(Logo.backStyle == 'diag' || Logo.backStyle == 'exed') {
		var count = Logo.backStyle == 'diag' ? 1 : 2;
		for(var i = 0; i < count; i++) {
			var stripe = new Kinetic.Line({
				points: (i % 2 == 0) ? [0, 0, Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()] : [0, Logo.kinetic.stage.getHeight(), Logo.kinetic.stage.getWidth(), 0],
				stroke: Logo.stripeColor,
				strokeWidth: Logo.kinetic.stage.getWidth() * .2
			});
			Logo.kinetic.stripes.push(stripe);
			Logo.kinetic.layer.add(stripe);
		}
	}
	if(Logo.backStyle == 'habs') {
		var stripe = new Kinetic.Line({
			points: [0, Logo.kinetic.stage.getHeight() * .5, Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight() * .5],
			stroke: Logo.stripeColor,
			strokeWidth: Logo.kinetic.stage.getWidth() * .25
		});
		Logo.kinetic.stripes.push(stripe);
		Logo.kinetic.layer.add(stripe);
	}
	if(Logo.backStyle == 'roundel') {
		var circle = new Kinetic.Circle({
			x: Logo.kinetic.stage.getWidth() * .5,
			y: Logo.kinetic.stage.getHeight() * .5,
			fill: Logo.stripeColor,
			radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .2
		});
		Logo.kinetic.stripes.push(circle);
		Logo.kinetic.layer.add(circle);

		var circle = new Kinetic.Circle({
			x: Logo.kinetic.stage.getWidth() * .5,
			y: Logo.kinetic.stage.getHeight() * .5,
			strokeWidth: Logo.kinetic.stage.getWidth() * .15,
			radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .4,
			stroke: Logo.stripeColor
		});
		Logo.kinetic.stripes.push(circle);
		Logo.kinetic.layer.add(circle);
	}
	if(Logo.backStyle == 'dots') {
		for(var i = 0; i < 4; i++) {
			for(var j = 0; j < 4; j++) {
				var circle = new Kinetic.Circle({
					x: (Logo.kinetic.stage.getWidth() / 3*( i )) + ((j%2) * Logo.kinetic.stage.getWidth()/6),
					y: Logo.kinetic.stage.getHeight() / 3 * (j ),
					radius: Math.min(Logo.kinetic.stage.getWidth(), Logo.kinetic.stage.getHeight()) * .1,
					fill: Logo.stripeColor
				});
				Logo.kinetic.stripes.push(circle);
				Logo.kinetic.layer.add(circle);
			}
		}
	}
	Logo.kinetic.letters = new Array();
	for(var i = Logo.letters.length-1; i >= 0; i--) {
		var y = i * Logo.kinetic.stage.getHeight() * .1;
		var x = 0;
		if(Logo.letters.length > 1) {
			x = (i == 0? -1 : 1) * Logo.offsetX * Logo.kinetic.stage.getWidth() / 200;
		}
		if(Logo.letters.length == 2) {
			y  -= Logo.kinetic.stage.getHeight() * (i == 0? .1 : -.02);
		}
		var letter = new Kinetic.Text({
			x: x,
			y: y,
			width: Logo.kinetic.stage.getWidth(),
			fill: Logo.fontColor,
			fontFamily: Logo.fontFamily,
			fontSize: Logo.kinetic.stage.getHeight() - 25,
			text: Logo.letters[i],
			align: 'center',
			fontStyle: 'bold',
			strokeWidth: 2,
			stroke: Logo.fontStroke
		});
		Logo.kinetic.letters.push(letter);
		Logo.kinetic.layer.add(letter);
	}

     Logo.kinetic.gloss = new Kinetic.Shape({
		drawFunc: function(canvas) {
			var borderSize = Logo.kinetic.stage.getWidth() * .03;
			var context = canvas.getContext();
			context.beginPath();
			context.moveTo(borderSize, borderSize);
			context.lineTo(Logo.kinetic.stage.getWidth() - borderSize , borderSize);
			context.lineTo(Logo.kinetic.stage.getWidth() - borderSize, Logo.kinetic.stage.getHeight() * .3);
			context.quadraticCurveTo(Logo.kinetic.stage.getWidth() - borderSize, Logo.kinetic.stage.getHeight() * .5, Logo.kinetic.stage.getWidth() * .5, Logo.kinetic.stage.getHeight() * .5);
			context.quadraticCurveTo(borderSize, Logo.kinetic.stage.getWidth() * .5, borderSize, Logo.kinetic.stage.getWidth() * .6);
			context.closePath();
			canvas.fillStroke(this);
		},
		fill: "cecece",
		opacity: .25
	});

	Logo.kinetic.layer.add(Logo.kinetic.gloss);

	Logo.kinetic.stage.add(Logo.kinetic.layer);

})();<|endoftext|>


<commit_before>'use strict';

var $ = require('jquery');
var m = require('mithril');
var $osf = require('js/osfHelpers');
var utils = require('./utils');
var Results = {};

Results.view = function(ctrl) {
    var res = [];
    var len = 0;
    if (ctrl.vm.results){
        res = $.map(ctrl.vm.results, ctrl.renderResult);
        len = ctrl.vm.results.length;
    }
    return m('', [
        m('.row', m('.col-md-12', (!utils.arrayEqual(res, [])) ? res : (!ctrl.vm.resultsLoading() && (ctrl.vm.results !== null)) ? m('span', {style: {margin: 'auto'}}, 'No results for this query') : [])),
        m('.row', m('.col-md-12', ctrl.vm.resultsLoading() ? utils.loadingIcon : [])),
        m('.row', m('.col-md-12', m('div', {style: {display: 'block', margin: 'auto', 'text-align': 'center'}},
            len > 0 && len < ctrl.vm.count ?
            m('a.btn.btn-md.btn-default', {
                onclick: function(){
                    utils.loadMore(ctrl.vm)
                        .then(function(data) {
                            utils.updateVM(ctrl.vm, data);
                        });
                }
            }, 'More') : [])
         ))
    ]);

};

Results.controller = function(vm) {
    var self = this;
    self.vm = vm;
    self.vm.resultsLoading = m.prop(false);

    self.renderResult = function(result, index) {
        return m( '.animated.fadeInUp', [
            m('div', [
                m('h4', [
                    m('a[href=' + result.uris.canonicalUri + ']', m.trust(result.title) || 'No title provided'),
                    m('br'),
                    (function(){
                        if ((result.description || '').length > 350) {
                            return m('p.readable.pointer',
                                {onclick:function(){result.showAll = result.showAll ? false : true;}},
                                m.trust(result.showAll ? result.description : $.trim(result.description.substring(0, 350)) + '...')
                            );
                        }
                        return m('p.readable', m.trust(result.description));
                    }()),
                ]),
                m('.row', [
                    m('.col-md-7', m('span.pull-left', (function(){
                        var renderPeople = function(people) {
                            return $.map(people, function(person, index) {
                                return m('span', [
                                    m('span', index !== 0 ? ' · ' : ''),
                                    m('a', {
                                        onclick: function() {
                                            utils.updateFilter(self.vm, 'contributors.familyName:' + person.familyName, true);
                                            utils.updateFilter(self.vm, 'contributors.givenName:' + person.givenName, true);
                                        }
                                    }, person.name)
                                ]);
                            });
                        };

                        return m('span.pull-left', {style: {'text-align': 'left'}},
                            result.showAllContrib || result.contributors.length < 8 ?
                                renderPeople(result.contributors) :
                                m('span', [
                                    renderPeople(result.contributors.slice(0, 7)),
                                    m('br'),
                                    m('a', {onclick: function(){result.showAllContrib = result.showAllContrib ? false : true;}}, 'See All')
                                ])
                        );
                    }()))),
                    m('.col-md-5',
                        m('.pull-right', {style: {'text-align': 'right'}},
                            (function(){
                                var rendersubject = function(subject) {
                                    return [
                                        m('.badge.pointer', {onclick: function(){
                                            utils.updateFilter(self.vm, 'subjects:"' + subject + '"', true);
                                        }}, subject.length < 50 ? subject : subject.substring(0, 47) + '...'),
                                        ' '
                                    ];
                                };

                                if (result.showAllsubjects || (result.subjects || []).length < 5) {
                                    return $.map((result.subjects || []), rendersubject);
                                }
                                return m('span', [
                                    $.map((result.subjects || []).slice(0, 5), rendersubject),
                                    m('br'),
                                    m('div', m('a', {onclick: function() {result.showAllsubjects = result.showAllsubjects ? false : true;}},'See All'))
                                ]);
                            }())
                        )
                    )
                ]),
                m('br'),
                m('br'),
                m('div', [
                    m('span', 'Released on ' + new $osf.FormattableDate(result.providerUpdatedDateTime).local),
                    m('span.pull-right', [
                        m('img', {src: self.vm.ProviderMap[result.shareProperties.source].favicon, style: {width: '16px', height: '16px'}}),
                        ' ',
                        m('a', {onclick: function() {utils.updateFilter(self.vm, 'shareProperties.source:' + result.shareProperties.source);}}, self.vm.ProviderMap[result.shareProperties.source].long_name),
                        m('br')
                    ]),
                ]),
                m('.row', [
                    m('.col-md-5',
                        m('.pull-right', {style: {'text-align': 'right'}},
                            (function(){
                                return m('span', [
                                    m('br'),
                                    m('div', m('a', {onclick: function() {result.showRawNormed = result.showRawNormed ? false : true;}},'More')),
                                    m('br'),
                                    result.showRawNormed ? m('div', [
                                        m('p', 'raaaaaaw for' + result.shareProperties.docID),
                                        m('p', 'noooorrrmmeeedddd for ' + result.shareProperties.docID)
                                    ]) : m('span')
                                ]);
                            }())
                        )
                    )
                ])
            ]),
            m('hr')
        ]);
    };

    // Uncomment for infinite scrolling!
    // $(window).scroll(function() {
    //     if  ($(window).scrollTop() === $(document).height() - $(window).height()){
    //         utils.loadMore(self.vm);
    //     }
    // });
};

module.exports = Results;
<commit_msg>Upade results js to show raw and normed docs on frontendwow<commit_after>'use strict';

var $ = require('jquery');
var m = require('mithril');
var $osf = require('js/osfHelpers');
var utils = require('./utils');
var Results = {};

Results.view = function(ctrl) {
    var res = [];
    var len = 0;
    if (ctrl.vm.results){
        res = $.map(ctrl.vm.results, ctrl.renderResult);
        len = ctrl.vm.results.length;
    }
    return m('', [
        m('.row', m('.col-md-12', (!utils.arrayEqual(res, [])) ? res : (!ctrl.vm.resultsLoading() && (ctrl.vm.results !== null)) ? m('span', {style: {margin: 'auto'}}, 'No results for this query') : [])),
        m('.row', m('.col-md-12', ctrl.vm.resultsLoading() ? utils.loadingIcon : [])),
        m('.row', m('.col-md-12', m('div', {style: {display: 'block', margin: 'auto', 'text-align': 'center'}},
            len > 0 && len < ctrl.vm.count ?
            m('a.btn.btn-md.btn-default', {
                onclick: function(){
                    utils.loadMore(ctrl.vm)
                        .then(function(data) {
                            utils.updateVM(ctrl.vm, data);
                        });
                }
            }, 'More') : [])
         ))
    ]);

};

Results.controller = function(vm) {
    var self = this;
    self.vm = vm;
    self.vm.resultsLoading = m.prop(false);

    self.renderResult = function(result, index) {
        return m( '.animated.fadeInUp', [
            m('div', [
                m('h4', [
                    m('a[href=' + result.uris.canonicalUri + ']', m.trust(result.title) || 'No title provided'),
                    m('br'),
                    (function(){
                        if ((result.description || '').length > 350) {
                            return m('p.readable.pointer',
                                {onclick:function(){result.showAll = result.showAll ? false : true;}},
                                m.trust(result.showAll ? result.description : $.trim(result.description.substring(0, 350)) + '...')
                            );
                        }
                        return m('p.readable', m.trust(result.description));
                    }()),
                ]),
                m('.row', [
                    m('.col-md-7', m('span.pull-left', (function(){
                        var renderPeople = function(people) {
                            return $.map(people, function(person, index) {
                                return m('span', [
                                    m('span', index !== 0 ? ' · ' : ''),
                                    m('a', {
                                        onclick: function() {
                                            utils.updateFilter(self.vm, 'contributors.familyName:' + person.familyName, true);
                                            utils.updateFilter(self.vm, 'contributors.givenName:' + person.givenName, true);
                                        }
                                    }, person.name)
                                ]);
                            });
                        };

                        return m('span.pull-left', {style: {'text-align': 'left'}},
                            result.showAllContrib || result.contributors.length < 8 ?
                                renderPeople(result.contributors) :
                                m('span', [
                                    renderPeople(result.contributors.slice(0, 7)),
                                    m('br'),
                                    m('a', {onclick: function(){result.showAllContrib = result.showAllContrib ? false : true;}}, 'See All')
                                ])
                        );
                    }()))),
                    m('.col-md-5',
                        m('.pull-right', {style: {'text-align': 'right'}},
                            (function(){
                                var rendersubject = function(subject) {
                                    return [
                                        m('.badge.pointer', {onclick: function(){
                                            utils.updateFilter(self.vm, 'subjects:"' + subject + '"', true);
                                        }}, subject.length < 50 ? subject : subject.substring(0, 47) + '...'),
                                        ' '
                                    ];
                                };

                                if (result.showAllsubjects || (result.subjects || []).length < 5) {
                                    return $.map((result.subjects || []), rendersubject);
                                }
                                return m('span', [
                                    $.map((result.subjects || []).slice(0, 5), rendersubject),
                                    m('br'),
                                    m('div', m('a', {onclick: function() {result.showAllsubjects = result.showAllsubjects ? false : true;}},'See All'))
                                ]);
                            }())
                        )
                    )
                ]),
                m('br'),
                m('br'),
                m('div', [
                    m('span', 'Released on ' + new $osf.FormattableDate(result.providerUpdatedDateTime).local),
                    m('span.pull-right', [
                        m('img', {src: self.vm.ProviderMap[result.shareProperties.source].favicon, style: {width: '16px', height: '16px'}}),
                        ' ',
                        m('a', {onclick: function() {utils.updateFilter(self.vm, 'shareProperties.source:' + result.shareProperties.source);}}, self.vm.ProviderMap[result.shareProperties.source].long_name),
                        m('br')
                    ]),
                ]),
                m('.row', [
                    m('.col-md-5',
                        m('.pull-right', {style: {'text-align': 'right'}},
                            (function(){
                                return m('span', [
                                    m('br'),
                                    m('div', m('a', {
                                        onclick: function() {
                                            result.showRawNormed = result.showRawNormed ? false : true;
                                            if (!result.raw) {
                                                utils.loadRawNormalized(result)
                                            }
                                        }},'More')
                                    ),
                                    m('br'),
                                    result.showRawNormed && result.raw ? m('div', [
                                        m('.col-md-6',
                                            m('p', result.raw),
                                            m('p', result.normalized)
                                        )
                                    ]) : m('span')
                                ]);
                            }())
                        )
                    )
                ])
            ]),
            m('hr')
        ]);
    };

    // Uncomment for infinite scrolling!
    // $(window).scroll(function() {
    //     if  ($(window).scrollTop() === $(document).height() - $(window).height()){
    //         utils.loadMore(self.vm);
    //     }
    // });
};

module.exports = Results;
<|endoftext|>


<commit_before>// HEP Packet Generator for Devs
var HEPjs = require('hep-js');
var dgram = require('dgram');
const execSync = require('child_process').execSync;
const exec = require('child_process').exec;

var version = 'v0.1.4';
var debug = false;
var stats = {rcvd: 0, parsed: 0, hepsent: 0, err: 0, heperr: 0 };

/* UDP Socket Handler */

var getSocket = function (type) {
    if (undefined === socket) {
        socket = dgram.createSocket(type);
        socket.on('error', socketErrorHandler);
        /**
         * Handles socket's 'close' event,
         * recover socket in case of unplanned closing.
         */
        var socketCloseHandler = function () {
            if (socketUsers > 0) {
                socket = undefined;
                --socketUsers;
                getSocket(type);
            }
        };
        socket.on('close', socketCloseHandler);
    }
    return socket;
}

var socket = dgram.createSocket("udp4");
    socket = getSocket('udp4');

var countDown = function(){
	count--;
	if (count == 0) {
		if(socket) socket.close();
		console.log(stats);
		console.log('Done! Exiting...');
		process.exit(0);
	}
}

var sendHEP3 = function(msg,rcinfo){
	if (rcinfo) {
		try {
			if (debug) console.log('Sending HEP3 Packet to '+_config_.HEP_SERVER+':'+_config_.HEP_PORT+'...');
			var hep_message = HEPjs.encapsulate(msg,rcinfo);
			stats.parsed++;
			if (hep_message) {
				socket.send(hep_message, 0, hep_message.length, _config_.HEP_PORT, _config_.HEP_SERVER, function(err) {
					stats.hepsent++;
					countDown();
				});
			} else { console.log('HEP Parsing error!'); stats.heperr++; }
		}
		catch (e) {
			console.log('HEP3 Error sending!');
			console.log(e);
			stats.heperr++;
		}
	}
}

var sendAPI = function(msg,rcinfo){
	/* 	PUSH non-HEP data to API using methods in rcinfo for Query parameters.
		For an example API message format, see config/log.js
	*/
	if (debug) console.log('API DEBUG',_config_,rcinfo,msg);
	const http = require('http')
	const options = {
	  hostname: rcinfo.hostname || _config_.API_SERVER || '127.0.0.1',
	  port: rcinfo.port || _config_.API_PORT || 3100,
	  path: rcinfo.path,
	  method: rcinfo.method,
	  headers: {
	    'Content-Type': 'application/json',
	    'Content-Length': JSON.stringify(msg).length
	  }
	}

	const req = http.request(options, (res) => {
	  console.log(`API statusCode: ${res.statusCode}`)
	  stats.hepsent++;
	  countDown();
	  res.on('data', (d) => {
	    process.stdout.write(d)
	  })
	})

	req.on('error', (error) => {
	  console.error(error)
	  stats.heperr++;
	})
	req.write(JSON.stringify(msg));
	req.end();

}

var routeOUT = function(msg,rcinfo){
  console.log('ROUTING',msg,rcinfo);
	if (rcinfo.type === "HEP"){
		sendHEP3(msg,rcinfo);
	} else if(rcinfo.type === "API") {
		sendAPI(msg,rcinfo);
	} else {
		console.error('Unsupported Type!',rcinfo);
	}
};

function sleep(ms) {
  var start = new Date().getTime(), expire = start + ms;
  while (new Date().getTime() < expire) { }
  return;
}

var count = 0;
var pause = 0;

const execHEP = function(messages) {
  count = messages.length;
  messages.forEach(function preHep(message) {

	var rcinfo = message.rcinfo;
	var msg = message.payload;
	if (debug) console.log(msg);
	stats.rcvd++;

	if (message.sleep) {
		console.log('sleeping '+message.sleep+' ms...');
		sleep( message.sleep );
	}

	var hrTime = process.hrtime();
	var datenow = new Date().getTime();
	rcinfo.time_sec = Math.floor( datenow / 1000);
	rcinfo.time_usec = datenow - (rcinfo.time_sec*1000);

	if (debug) console.log(rcinfo);
	if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100;
	if (message.pause && message.pause > 0) {
		pause += message.pause;
		setTimeout(function() {
		    // delayed ts
	            var datenow = new Date().getTime();
		    rcinfo.time_sec = Math.floor( datenow / 1000);
		    rcinfo.time_usec = datenow - (rcinfo.time_sec*1000);
		    routeOUT(msg,rcinfo);
		    process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r");
		}, pause);
	} else {
		routeOUT(msg,rcinfo);
		process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r");
	}
  });
}

if(process.argv.indexOf("-d") != -1){
    debug = true;
}

var _config_ = require("./config/default");

if(process.argv.indexOf("-c") != -1){
    _config_ = require(process.argv[process.argv.indexOf("-c") + 1]);
	if(process.argv.indexOf("-d") != -1){
		debug = true;
	}
	if(process.argv.indexOf("-s") != -1){
	    _config_.HEP_SERVER = process.argv[process.argv.indexOf("-s") + 1];
	}
	if(process.argv.indexOf("-p") != -1){
	    _config_.HEP_PORT = process.argv[process.argv.indexOf("-p") + 1];
	}
	if(process.argv.indexOf("-a") != -1){
	    _config_.API_SERVER = process.argv[process.argv.indexOf("-a") + 1];
	}
	if (debug) console.log(_config_);
        execHEP(_config_.MESSAGES);
}

if(process.argv.indexOf("-P") != -1){

	const { spawn } = require('child_process');
	const top = spawn('nodejs', ['tools/convert.js', process.argv[process.argv.indexOf("-P") + 1]] );
	var message = '';

	top.stdout.on('data', (data) => {
	  message += data;
	});

	top.stderr.on('data', (data) => {
	  console.log('Error parsing input!');
	});

	top.on('close', (code) => {
	  _config_ = JSON.parse(message);
	  if(process.argv.indexOf("-s") != -1){
	    _config_.HEP_SERVER = process.argv[process.argv.indexOf("-s") + 1];
  	  }
	  if(process.argv.indexOf("-p") != -1){
	    _config_.HEP_PORT = process.argv[process.argv.indexOf("-p") + 1];
	  }
	  execHEP(_config_.MESSAGES);
	});

}

<commit_msg>fixed useconds<commit_after>// HEP Packet Generator for Devs
var HEPjs = require('hep-js');
var dgram = require('dgram');
const execSync = require('child_process').execSync;
const exec = require('child_process').exec;

var version = 'v0.1.4';
var debug = false;
var stats = {rcvd: 0, parsed: 0, hepsent: 0, err: 0, heperr: 0 };

/* UDP Socket Handler */

var getSocket = function (type) {
    if (undefined === socket) {
        socket = dgram.createSocket(type);
        socket.on('error', socketErrorHandler);
        /**
         * Handles socket's 'close' event,
         * recover socket in case of unplanned closing.
         */
        var socketCloseHandler = function () {
            if (socketUsers > 0) {
                socket = undefined;
                --socketUsers;
                getSocket(type);
            }
        };
        socket.on('close', socketCloseHandler);
    }
    return socket;
}

var socket = dgram.createSocket("udp4");
    socket = getSocket('udp4');

var countDown = function(){
	count--;
	if (count == 0) {
		if(socket) socket.close();
		console.log(stats);
		console.log('Done! Exiting...');
		process.exit(0);
	}
}

var sendHEP3 = function(msg,rcinfo){
	if (rcinfo) {
		try {
			if (debug) console.log('Sending HEP3 Packet to '+_config_.HEP_SERVER+':'+_config_.HEP_PORT+'...');
			var hep_message = HEPjs.encapsulate(msg,rcinfo);
			stats.parsed++;
			if (hep_message) {
				socket.send(hep_message, 0, hep_message.length, _config_.HEP_PORT, _config_.HEP_SERVER, function(err) {
					stats.hepsent++;
					countDown();
				});
			} else { console.log('HEP Parsing error!'); stats.heperr++; }
		}
		catch (e) {
			console.log('HEP3 Error sending!');
			console.log(e);
			stats.heperr++;
		}
	}
}

var sendAPI = function(msg,rcinfo){
	/* 	PUSH non-HEP data to API using methods in rcinfo for Query parameters.
		For an example API message format, see config/log.js
	*/
	if (debug) console.log('API DEBUG',_config_,rcinfo,msg);
	const http = require('http')
	const options = {
	  hostname: rcinfo.hostname || _config_.API_SERVER || '127.0.0.1',
	  port: rcinfo.port || _config_.API_PORT || 3100,
	  path: rcinfo.path,
	  method: rcinfo.method,
	  headers: {
	    'Content-Type': 'application/json',
	    'Content-Length': JSON.stringify(msg).length
	  }
	}

	const req = http.request(options, (res) => {
	  console.log(`API statusCode: ${res.statusCode}`)
	  stats.hepsent++;
	  countDown();
	  res.on('data', (d) => {
	    process.stdout.write(d)
	  })
	})

	req.on('error', (error) => {
	  console.error(error)
	  stats.heperr++;
	})
	req.write(JSON.stringify(msg));
	req.end();

}

var routeOUT = function(msg,rcinfo){
  console.log('ROUTING',msg,rcinfo);
	if (rcinfo.type === "HEP"){
		sendHEP3(msg,rcinfo);
	} else if(rcinfo.type === "API") {
		sendAPI(msg,rcinfo);
	} else {
		console.error('Unsupported Type!',rcinfo);
	}
};

function sleep(ms) {
  var start = new Date().getTime(), expire = start + ms;
  while (new Date().getTime() < expire) { }
  return;
}

var count = 0;
var pause = 0;

const execHEP = function(messages) {
  count = messages.length;
  messages.forEach(function preHep(message) {

	var rcinfo = message.rcinfo;
	var msg = message.payload;
	if (debug) console.log(msg);
	stats.rcvd++;

	if (message.sleep) {
		console.log('sleeping '+message.sleep+' ms...');
		sleep( message.sleep );
	}

	var hrTime = process.hrtime();
	var datenow = new Date().getTime();
	rcinfo.time_sec = Math.floor( datenow / 1000);
	rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000;

	if (debug) console.log(rcinfo);
	if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100;
	if (message.pause && message.pause > 0) {
		pause += message.pause;
		setTimeout(function() {
		    // delayed ts
	            var datenow = new Date().getTime();
		    rcinfo.time_sec = Math.floor( datenow / 1000);
		    rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000;
		    routeOUT(msg,rcinfo);
		    process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r");
		}, pause);
	} else {
		routeOUT(msg,rcinfo);
		process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r");
	}
  });
}

if(process.argv.indexOf("-d") != -1){
    debug = true;
}

var _config_ = require("./config/default");

if(process.argv.indexOf("-c") != -1){
    _config_ = require(process.argv[process.argv.indexOf("-c") + 1]);
	if(process.argv.indexOf("-d") != -1){
		debug = true;
	}
	if(process.argv.indexOf("-s") != -1){
	    _config_.HEP_SERVER = process.argv[process.argv.indexOf("-s") + 1];
	}
	if(process.argv.indexOf("-p") != -1){
	    _config_.HEP_PORT = process.argv[process.argv.indexOf("-p") + 1];
	}
	if(process.argv.indexOf("-a") != -1){
	    _config_.API_SERVER = process.argv[process.argv.indexOf("-a") + 1];
	}
	if (debug) console.log(_config_);
        execHEP(_config_.MESSAGES);
}

if(process.argv.indexOf("-P") != -1){

	const { spawn } = require('child_process');
	const top = spawn('nodejs', ['tools/convert.js', process.argv[process.argv.indexOf("-P") + 1]] );
	var message = '';

	top.stdout.on('data', (data) => {
	  message += data;
	});

	top.stderr.on('data', (data) => {
	  console.log('Error parsing input!');
	});

	top.on('close', (code) => {
	  _config_ = JSON.parse(message);
	  if(process.argv.indexOf("-s") != -1){
	    _config_.HEP_SERVER = process.argv[process.argv.indexOf("-s") + 1];
  	  }
	  if(process.argv.indexOf("-p") != -1){
	    _config_.HEP_PORT = process.argv[process.argv.indexOf("-p") + 1];
	  }
	  execHEP(_config_.MESSAGES);
	});

}

<|endoftext|>


<commit_before>var socket = io.connect();

socket.on('connect', function (data) {

  var screenName = window.location.pathname.substring(8);
  if(screenName === "")
    screenName = "home"

  socket.emit('screen', { screenName: screenName });

});
socket.on('reload', function (data) {
  window.location.reload();
});

socket.on('display', function (data) {

  $(".offscreen").removeClass("show");

  setTimeout(function(){
    $(".offscreen").removeClass("show");
  }, data.maxtime || 3000);

  if(data.action === "image"){
    $("div.showImage").css({"background-image": "url('"+data.url+"')",
                            "background-size": "cover",
                            "background-repeat": "no-repeat"});
    $("div.showImage").addClass("show");
  }
  if(data.action === "iframe"){
    $("iframe.showIFrame").attr("href", data.url);
    $("iframe.showIFrame").addClass("show");
  }
  if(data.action === "video"){
    // This one is going to be a bit more complex.
    // To start only support youtube, but it would be great to return to the deault
    // at the end of the video.

    $("div.showVideo").html("<object width='425' height='350'><param name='movie' "+
                            "value='http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1'>"+
                            "</param><embed src='http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1'"+
                            +" type='application/x-shockwave-flash' width='425' height='350'></embed></object>");
    $("div.showVideo").addClass("show");
  }

});
<commit_msg>should be maxTime<commit_after>var socket = io.connect();

socket.on('connect', function (data) {

  var screenName = window.location.pathname.substring(8);
  if(screenName === "")
    screenName = "home"

  socket.emit('screen', { screenName: screenName });

});
socket.on('reload', function (data) {
  window.location.reload();
});

socket.on('display', function (data) {

  $(".offscreen").removeClass("show");

  setTimeout(function(){
    $(".offscreen").removeClass("show");
  }, data.maxTime || 3000);

  if(data.action === "image"){
    $("div.showImage").css({"background-image": "url('"+data.url+"')",
                            "background-size": "cover",
                            "background-repeat": "no-repeat"});
    $("div.showImage").addClass("show");
  }
  if(data.action === "iframe"){
    $("iframe.showIFrame").attr("href", data.url);
    $("iframe.showIFrame").addClass("show");
  }
  if(data.action === "video"){
    // This one is going to be a bit more complex.
    // To start only support youtube, but it would be great to return to the deault
    // at the end of the video.

    $("div.showVideo").html("<object width='425' height='350'><param name='movie' "+
                            "value='http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1'>"+
                            "</param><embed src='http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1'"+
                            +" type='application/x-shockwave-flash' width='425' height='350'></embed></object>");
    $("div.showVideo").addClass("show");
  }

});
<|endoftext|>


<commit_before>var app = angular.module('refApp', []);

app.controller('MainCtrl', [function() {
  var self = this
  self.references = [];
  // self.columns = 12
  self.addRef = function(url, size) {
    var added = {url: url, size: size};
    self.references.push(added);
    // self.columns -= size;
    console.log(self.columns)
  };

  var urlChecker = function(url) {
    //checks if pattern is present
    // if not, adds on http to url
  }

}]);
<commit_msg>begins regex for urlChecker<commit_after>var app = angular.module('refApp', []);

app.controller('MainCtrl', [function() {
  var self = this
  self.references = [];
  // self.columns = 12
  self.addRef = function(url, size) {
    urlChecker(url);
    var added = {url: url, size: size};
    self.references.push(added);
    // self.columns -= size;
    // console.log(self.columns)
  };

  var urlChecker = function(url) {
    //checks if pattern is present
    // if not, adds on http to url
      // what if https needed? error handling?
      var pattern = /^(https?:\/\/)?/
      if(!pattern.test(url)) {
        url = "http://" + url;
        console.log('added http')
      }
      console.log('urlChecker done')
    }

  }]);
<|endoftext|>


<commit_before>$(document).ready(function(){
	$('#spot1').wuSlide();
});
/*Wu Slider Core*/
(function ( $ ) {

	$.fn.wuSlide = function(){

	};

}( jQuery ));
<commit_msg>It's a working plugin!<commit_after>$(document).ready(function(){
	$('.slide').wuSlide({
		color:"red"
	});
});
/*Wu Slider Core*/
(function($){
	$.fn.wuSlide = function(options){
		 var settings = $.extend({
			// These are the defaults.
			color: "#556b2f",
		}, options );
		$(this).css('background',settings.color);
		console.log(this);
		 return this.css({
			color: settings.backgroundColor
		});
	};
}(jQuery));
<|endoftext|>


<commit_before>var TestModule = ( function( window, undefined ) {

  /****************************************************
  **
  ** Caching DOM objects with variable names.
  **
  ****************************************************/
  var $setTrue = $( '.set-true' ),
      $setFalse = $( '.set-false' ),
      $messageBox = $( '.messages' );

  /****************************************************
  **
  ** Setting variables and methods initial states.
  **
  ****************************************************/
  var changer = null;
  console.log( "variable 'changer' default state is: ", changer );

  /****************************************************
  **
  ** Methods that are called in other methods.
  **
  ****************************************************/
  function trueSetter() {
    changer = true;
    useChosenFunction();
  }

  function falseSetter() {
    changer = false;
    useChosenFunction();
  }

  function setMessage( message ) {
    $messageBox.html( message );
  }

  /****************************************************
  **
  ** Methods that are called in the return object.
  **
  ****************************************************/
  function useChosenFunction() {
    if( changer == true ) {
      console.log( "You set the state of variable 'changer' to: ", changer );
      setMessage( "Chosen state is: true" );
    }
    else if( changer == false ) {
      console.log( "You set the state of variable 'changer' to: ", changer );
      setMessage( "Chosen state is: false" );
    }
  }

  function clickHandlers() {
    $setTrue.on( 'click', trueSetter );
    $setFalse.on( 'click', falseSetter );
  }

  /****************************************************
  **
  ** Return methods.
  **
  ****************************************************/
  return {
    setVariable : useChosenFunction,
    clickEvents : clickHandlers
  }

})( window );

TestModule.setVariable();
TestModule.clickEvents();
<commit_msg>Fix: A comment.<commit_after>var TestModule = ( function( window, undefined ) {

  /****************************************************
  **
  ** Caching DOM objects with variable names.
  **
  ****************************************************/
  var $setTrue = $( '.set-true' ),
      $setFalse = $( '.set-false' ),
      $messageBox = $( '.messages' );

  /****************************************************
  **
  ** Setting variables and methods initial states.
  **
  ****************************************************/
  var changer = null;
  console.log( "variable 'changer' default state is: ", changer );

  /****************************************************
  **
  ** Methods that are called in other methods.
  ** Not in the return object.
  **
  ****************************************************/
  function trueSetter() {
    changer = true;
    useChosenFunction();
  }

  function falseSetter() {
    changer = false;
    useChosenFunction();
  }

  function setMessage( message ) {
    $messageBox.html( message );
  }

  /****************************************************
  **
  ** Methods that are called in the return object.
  **
  ****************************************************/
  function useChosenFunction() {
    if( changer == true ) {
      console.log( "You set the state of variable 'changer' to: ", changer );
      setMessage( "Chosen state is: true" );
    }
    else if( changer == false ) {
      console.log( "You set the state of variable 'changer' to: ", changer );
      setMessage( "Chosen state is: false" );
    }
  }

  function clickHandlers() {
    $setTrue.on( 'click', trueSetter );
    $setFalse.on( 'click', falseSetter );
  }

  /****************************************************
  **
  ** Return methods.
  **
  ****************************************************/
  return {
    setVariable : useChosenFunction,
    clickEvents : clickHandlers
  }

})( window );

TestModule.setVariable();
TestModule.clickEvents();
<|endoftext|>