<commit_before>/*
|------------------------------------------|
| MelonHTML5 - Royal Preloader             |
|------------------------------------------|
| @author:  Lee Le (lee@melonhtml5.com)    |
| @version: 2.05 (05 March 2015)           |
| @website: www.melonhtml5.com             |
|------------------------------------------|
*/

/**
  (https://developer.mozilla.org/en-US/docs/DOM/document.cookie)
  docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
  docCookies.getItem(name)
  docCookies.removeItem(name[, path])
  docCookies.hasItem(name)
*/
var docCookies={getItem:function(a){return!a||!this.hasItem(a)?null:unescape(document.cookie.replace(RegExp("(?:^|.*;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1"))},setItem:function(a,c,b,e,f,g){if(a&&!/^(?:expires|max\-age|path|domain|secure)$/i.test(a)){var d="";if(b)switch(b.constructor){case Number:d=Infinity===b?"; expires=Tue, 19 Jan 2038 03:14:07 GMT":"; max-age="+b;break;case String:d="; expires="+b;break;case Date:d="; expires="+b.toGMTString()}document.cookie=
escape(a)+"="+escape(c)+d+(f?"; domain="+f:"")+(e?"; path="+e:"")+(g?"; secure":"")}},removeItem:function(a,c){a&&this.hasItem(a)&&(document.cookie=escape(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(c?"; path="+c:""))},hasItem:function(a){return RegExp("(?:^|;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)}};

var JQ=jQuery;window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();
window.transitionEnd=function(a,c){var b=!1,d=document.createElement("div");JQ(["transition","WebkitTransition","MozTransition","msTransition"]).each(function(a,c){if(void 0!==d.style[c])return b=!0,!1});b?a.bind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend",function(b){a.unbind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend");c(b,a)}):setTimeout(function(){c(null,a)},0);return a};
var Royal_Preloader={_overlay:null,_loader:null,_name:null,_percentage:null,_on_complete:null,_text_loader:null,_text_loader_overlay:null,_logo_loader:null,_logo_loader_meter:null,_total:0,_loaded:0,_image_queue:[],_percentage_loaded:0,_mode:"number",_text:"loading...",_text_colour:"#FFFFFF",_images:[],_show_progress:!0,_show_percentage:!0,_background:"#000000",_logo:"",_logo_size:[80,80],_cookie:!1,_timeout:10,_init:function(){JQ("img").each(function(a){JQ(this).attr("src")&&Royal_Preloader._images.push(JQ(this).attr("src"))});
if(Royal_Preloader._cookie){if(docCookies.getItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie)){JQ("#royal_preloader").remove();JQ(document.body).removeClass("royal_preloader");return}docCookies.setItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie,(new Date).getTime(),Infinity)}Royal_Preloader._total=Royal_Preloader._images.length;Royal_Preloader._build();Royal_Preloader._load()},_build:function(){this._overlay=JQ("#royal_preloader");this._overlay.length||(this._overlay=JQ("<div>").attr("id",
"royal_preloader").prependTo(JQ(document.body)));this._overlay.addClass("royal_preloader_"+this._mode);"line"!==this._mode&&this._overlay.css("background-color",this._background);switch(this._mode){case "number":this._percentage=JQ("<div>").addClass("royal_preloader_percentage").appendTo(this._overlay);break;case "text":this._text_loader=JQ("<div>").addClass("royal_preloader_loader").text(this._text).css("color",this._text_colour).appendTo(this._overlay);this._text_loader_overlay=JQ("<div>").css("background-color",
this._background).appendTo(this._text_loader);break;case "logo":this._logo_loader=JQ("<div>").css({width:this._logo_size[0],height:this._logo_size[1],"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2*-1,"background-image":'url("'+this._logo+'")'}).addClass("royal_preloader_loader").appendTo(this._overlay);this._logo_loader_meter=JQ("<div>").css("background-color",this._background).appendTo(this._logo_loader);this._show_progress&&(this._percentage=JQ("<div>").css({color:this._text_colour,
width:this._logo_size[0],height:this._logo_size[1],"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2,"background-color":this._background}).addClass("royal_preloader_percentage").appendTo(this._overlay));break;case "line":this._line_loader=JQ("<div>").addClass("royal_preloader_loader").css("background-color",this._background).appendTo(this._overlay);JQ("<div>").addClass("royal_preloader_peg").css("box-shadow","0 0 10px "+this._background).appendTo(this._line_loader);JQ(document.body).css("visibility",
"visible");break;case "progress":this._progress_loader=JQ("<div>").addClass("royal_preloader_loader").appendTo(this._overlay),this._progress_loader_meter=JQ("<div>").addClass("royal_preloader_meter").appendTo(this._progress_loader),this._show_progress&&(this._percentage=JQ("<div>").addClass("royal_preloader_percentage").text(0).appendTo(this._overlay))}this._overlay.appendTo(JQ(document.body));"text"===this._mode&&this._text_loader.css("margin-left",this._text_loader.width()/2*-1)},_load:function(){"number"!==
this._mode&&"logo"!==this._mode&&"progress"!==this._mode||!this._show_progress||(this._percentage.data("num",0),this._percentage.text("0"+(Royal_Preloader._show_percentage?"%":"")));JQ.each(this._images,function(a,c){var b=function(){Royal_Preloader._imageOnLoad(c)},d=new Image;d.src=c;d.complete?b():(d.onload=b,d.onerror=b)});setTimeout(function(){Royal_Preloader._overlay&&Royal_Preloader._animatePercentage(Royal_Preloader._percentage_loaded,100)},this._images.length?1E3*this._timeout:0)},_animatePercentage:function(a,
c){Royal_Preloader._percentage_loaded=a;a<c&&(a++,setTimeout(function(){switch(Royal_Preloader._mode){case "text":Royal_Preloader._text_loader_overlay.css("left",a+"%");break;case "line":Royal_Preloader._line_loader.width(a+"%");break;case "number":if(Royal_Preloader._show_progress){var b=a+(Royal_Preloader._show_percentage?"%":"");Royal_Preloader._percentage.text(b)}break;case "logo":Royal_Preloader._show_progress&&(b=a+(Royal_Preloader._show_percentage?"%":""),Royal_Preloader._percentage.text(b));
Royal_Preloader._logo_loader_meter.css("bottom",a+"%");break;case "progress":Royal_Preloader._show_progress&&(b=a+(Royal_Preloader._show_percentage?"%":""),Royal_Preloader._percentage.text(b)),Royal_Preloader._progress_loader_meter.width(a+"%")}Royal_Preloader._animatePercentage(a,c)},5),100===a&&Royal_Preloader._loadFinish())},_imageOnLoad:function(a){this._image_queue.push(a);this._image_queue.length&&this._image_queue[0]===a&&this._processQueue()},_reQueue:function(){Royal_Preloader._image_queue.splice(0,
1);Royal_Preloader._processQueue()},_processQueue:function(){0!==this._image_queue.length&&(this._loaded++,Royal_Preloader._animatePercentage(Royal_Preloader._percentage_loaded,parseInt(this._loaded/this._total*100,10)),this._reQueue())},_loadFinish:function(){transitionEnd(this._overlay,function(a,c){Royal_Preloader._overlay&&(Royal_Preloader._overlay.remove(),Royal_Preloader._overlay=null)});this._overlay.addClass("complete");JQ(document.body).removeClass("royal_preloader");this._on_complete&&this._on_complete()},
config:function(a){"undefined"!==typeof a.mode&&(this._mode=a.mode);"undefined"!==typeof a.text&&(this._text=a.text);"undefined"!==typeof a.text_colour&&(this._text_colour=a.text_colour);"undefined"!==typeof a.timeout&&(this._timeout=parseInt(a.timeout,10));"undefined"!==typeof a.showProgress&&(this._show_progress=a.showProgress?!0:!1);"undefined"!==typeof a.showPercentage&&(this._show_percentage=a.showPercentage?!0:!1);"undefined"!==typeof a.background&&(this._background=a.background);"undefined"!==
typeof a.logo&&(this._logo=a.logo);"undefined"!==typeof a.logo_size&&(this._logo_size=a.logo_size);"undefined"!==typeof a.onComplete&&(this._on_complete=a.onComplete);"undefined"!==typeof a.images&&(this._images=a.images);"undefined"!==typeof a.cookie&&(this._cookie=a.cookie)}};setTimeout(function(){JQ(document).ready(Royal_Preloader._init)});

Royal_Preloader.config({
    onComplete: function() {
        $('.bounce-animated').addClass('bounce animated');
        $('.flash-animated').addClass('flash animated');
        $('.pulse-animated').addClass('pulse animated');
        $('.rubberBand-animated').addClass('rubberBand animated');
        $('.shake-animated').addClass('shake animated');
        $('.swing-animated').addClass('swing animated');
        $('.tada-animated').addClass('tada animated');
        $('.wobble-animated').addClass('wobble animated');
        $('.bounceIn-animated').addClass('bounceIn animated');
        $('.bounceInDown-animated').addClass('bounceInDown animated');
        $('.bounceInLeft-animated').addClass('bounceInLeft animated');
        $('.bounceInRight-animated').addClass('bounceInRight animated');
        $('.bounceInUp-animated').addClass('bounceInUp animated');
        $('.bounceOut-animated').addClass('bounceOut animated');
        $('.bounceOutDown-animated').addClass('bounceOutDown animated');
        $('.bounceOutLeft-animated').addClass('bounceOutLeft animated');
        $('.bounceOutRight-animated').addClass('bounceOutRight animated');
        $('.bounceOutUp-animated').addClass('bounceOutUp animated');
        $('.fadeIn-animated').addClass('fadeIn animated');
        $('.fadeInDown-animated').addClass('fadeInDown animated');
        $('.fadeInDownBig-animated').addClass('fadeInDownBig animated');
        $('.fadeInLeft-animated').addClass('fadeInLeft animated');
        $('.fadeInLeftBig-animated').addClass('fadeInLeftBig animated');
        $('.fadeInRight-animated').addClass('fadeInRight animated');
        $('.fadeInRightBig-animated').addClass('fadeInRightBig animated');
        $('.fadeInUp-animated').addClass('fadeInUp animated');
        $('.fadeInUpBig-animated').addClass('fadeInUpBig animated');
        $('.fadeOut-animated').addClass('fadeOut animated');
        $('.fadeOutDown-animated').addClass('fadeOutDown animated');
        $('.fadeOutDownBig-animated').addClass('fadeOutDownBig animated');
        $('.fadeOutLeft-animated').addClass('fadeOutLeft animated');
        $('.fadeOutLeftBig-animated').addClass('fadeOutLeftBig animated');
        $('.fadeOutRight-animated').addClass('fadeOutRight animated');
        $('.fadeOutRightBig-animated').addClass('fadeOutRightBig animated');
        $('.fadeOutUp-animated').addClass('fadeOutUp animated');
        $('.fadeOutUpBig-animated').addClass('fadeOutUpBig animated');
        $('.flip-animated').addClass('flip animated');
        $('.flipInX-animated').addClass('flipInX animated');
        $('.flipInY-animated').addClass('flipInY animated');
        $('.flipOutX-animated').addClass('flipOutX animated');
        $('.flipOutY-animated').addClass('flipOutY animated');
        $('.lightSpeedIn-animated').addClass('lightSpeedIn animated');
        $('.lightSpeedOut-animated').addClass('lightSpeedOut animated');
        $('.rotateIn-animated').addClass('rotateIn animated');
        $('.rotateInDownLeft-animated').addClass('rotateInDownLeft animated');
        $('.rotateInDownRight-animated').addClass('rotateInDownRight animated');
        $('.rotateInUpLeft-animated').addClass('rotateInUpLeft animated');
        $('.rotateInUpRight-animated').addClass('rotateInUpRight animated');
        $('.rotateOut-animated').addClass('rotateOut animated');
        $('.rotateOutDownLeft-animated').addClass('rotateOutDownLeft animated');
        $('.rotateOutDownRight-animated').addClass('rotateOutDownRight animated');
        $('.rotateOutUpLeft-animated').addClass('rotateOutUpLeft animated');
        $('.rotateOutUpRight-animated').addClass('rotateOutUpRight animated');
        $('.slideInDown-animated').addClass('slideInDown animated');
        $('.slideInLeft-animated').addClass('slideInLeft animated');
        $('.slideInRight-animated').addClass('slideInRight animated');
        $('.slideInUp-animated').addClass('slideInUp animated');
        $('.slideOutDown-animated').addClass('slideOutDown animated');
        $('.slideOutLeft-animated').addClass('slideOutLeft animated');
        $('.slideOutRight-animated').addClass('slideOutRight animated');
        $('.slideOutUp-animated').addClass('slideOutUp animated');
        $('.zoomIn-animated').addClass('zoomIn animated');
        $('.zoomInDown-animated').addClass('zoomInDown animated');
        $('.zoomInLeft-animated').addClass('zoomInLeft animated');
        $('.zoomInRight-animated').addClass('zoomInRight animated');
        $('.zoomInUp-animated').addClass('zoomInUp animated');
        $('.zoomOut-animated').addClass('zoomOut animated');
        $('.zoomOutDown-animated').addClass('zoomOutDown animated');
        $('.zoomOutLeft-animated').addClass('zoomOutLeft animated');
        $('.zoomOutRight-animated').addClass('zoomOutRight animated');
        $('.zoomOutUp-animated').addClass('zoomOutUp animated');
        $('.hinge-animated').addClass('hinge animated');
        $('.rollin-animated').addClass('rollin animated');
        $('.rollOut-animated').addClass('rollOut animated');
	}
});<commit_msg>comment out obnoxious scrolling animation<commit_after>/*
|------------------------------------------|
| MelonHTML5 - Royal Preloader             |
|------------------------------------------|
| @author:  Lee Le (lee@melonhtml5.com)    |
| @version: 2.05 (05 March 2015)           |
| @website: www.melonhtml5.com             |
|------------------------------------------|
*/

/**
  (https://developer.mozilla.org/en-US/docs/DOM/document.cookie)
  docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
  docCookies.getItem(name)
  docCookies.removeItem(name[, path])
  docCookies.hasItem(name)
*/
// var docCookies={getItem:function(a){return!a||!this.hasItem(a)?null:unescape(document.cookie.replace(RegExp("(?:^|.*;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1"))},setItem:function(a,c,b,e,f,g){if(a&&!/^(?:expires|max\-age|path|domain|secure)$/i.test(a)){var d="";if(b)switch(b.constructor){case Number:d=Infinity===b?"; expires=Tue, 19 Jan 2038 03:14:07 GMT":"; max-age="+b;break;case String:d="; expires="+b;break;case Date:d="; expires="+b.toGMTString()}document.cookie=
// escape(a)+"="+escape(c)+d+(f?"; domain="+f:"")+(e?"; path="+e:"")+(g?"; secure":"")}},removeItem:function(a,c){a&&this.hasItem(a)&&(document.cookie=escape(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(c?"; path="+c:""))},hasItem:function(a){return RegExp("(?:^|;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)}};

// var JQ=jQuery;window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();
// window.transitionEnd=function(a,c){var b=!1,d=document.createElement("div");JQ(["transition","WebkitTransition","MozTransition","msTransition"]).each(function(a,c){if(void 0!==d.style[c])return b=!0,!1});b?a.bind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend",function(b){a.unbind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend");c(b,a)}):setTimeout(function(){c(null,a)},0);return a};
// var Royal_Preloader={_overlay:null,_loader:null,_name:null,_percentage:null,_on_complete:null,_text_loader:null,_text_loader_overlay:null,_logo_loader:null,_logo_loader_meter:null,_total:0,_loaded:0,_image_queue:[],_percentage_loaded:0,_mode:"number",_text:"loading...",_text_colour:"#FFFFFF",_images:[],_show_progress:!0,_show_percentage:!0,_background:"#000000",_logo:"",_logo_size:[80,80],_cookie:!1,_timeout:10,_init:function(){JQ("img").each(function(a){JQ(this).attr("src")&&Royal_Preloader._images.push(JQ(this).attr("src"))});
// if(Royal_Preloader._cookie){if(docCookies.getItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie)){JQ("#royal_preloader").remove();JQ(document.body).removeClass("royal_preloader");return}docCookies.setItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie,(new Date).getTime(),Infinity)}Royal_Preloader._total=Royal_Preloader._images.length;Royal_Preloader._build();Royal_Preloader._load()},_build:function(){this._overlay=JQ("#royal_preloader");this._overlay.length||(this._overlay=JQ("<div>").attr("id",
// "royal_preloader").prependTo(JQ(document.body)));this._overlay.addClass("royal_preloader_"+this._mode);"line"!==this._mode&&this._overlay.css("background-color",this._background);switch(this._mode){case "number":this._percentage=JQ("<div>").addClass("royal_preloader_percentage").appendTo(this._overlay);break;case "text":this._text_loader=JQ("<div>").addClass("royal_preloader_loader").text(this._text).css("color",this._text_colour).appendTo(this._overlay);this._text_loader_overlay=JQ("<div>").css("background-color",
// this._background).appendTo(this._text_loader);break;case "logo":this._logo_loader=JQ("<div>").css({width:this._logo_size[0],height:this._logo_size[1],"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2*-1,"background-image":'url("'+this._logo+'")'}).addClass("royal_preloader_loader").appendTo(this._overlay);this._logo_loader_meter=JQ("<div>").css("background-color",this._background).appendTo(this._logo_loader);this._show_progress&&(this._percentage=JQ("<div>").css({color:this._text_colour,
// width:this._logo_size[0],height:this._logo_size[1],"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2,"background-color":this._background}).addClass("royal_preloader_percentage").appendTo(this._overlay));break;case "line":this._line_loader=JQ("<div>").addClass("royal_preloader_loader").css("background-color",this._background).appendTo(this._overlay);JQ("<div>").addClass("royal_preloader_peg").css("box-shadow","0 0 10px "+this._background).appendTo(this._line_loader);JQ(document.body).css("visibility",
// "visible");break;case "progress":this._progress_loader=JQ("<div>").addClass("royal_preloader_loader").appendTo(this._overlay),this._progress_loader_meter=JQ("<div>").addClass("royal_preloader_meter").appendTo(this._progress_loader),this._show_progress&&(this._percentage=JQ("<div>").addClass("royal_preloader_percentage").text(0).appendTo(this._overlay))}this._overlay.appendTo(JQ(document.body));"text"===this._mode&&this._text_loader.css("margin-left",this._text_loader.width()/2*-1)},_load:function(){"number"!==
// this._mode&&"logo"!==this._mode&&"progress"!==this._mode||!this._show_progress||(this._percentage.data("num",0),this._percentage.text("0"+(Royal_Preloader._show_percentage?"%":"")));JQ.each(this._images,function(a,c){var b=function(){Royal_Preloader._imageOnLoad(c)},d=new Image;d.src=c;d.complete?b():(d.onload=b,d.onerror=b)});setTimeout(function(){Royal_Preloader._overlay&&Royal_Preloader._animatePercentage(Royal_Preloader._percentage_loaded,100)},this._images.length?1E3*this._timeout:0)},_animatePercentage:function(a,
// c){Royal_Preloader._percentage_loaded=a;a<c&&(a++,setTimeout(function(){switch(Royal_Preloader._mode){case "text":Royal_Preloader._text_loader_overlay.css("left",a+"%");break;case "line":Royal_Preloader._line_loader.width(a+"%");break;case "number":if(Royal_Preloader._show_progress){var b=a+(Royal_Preloader._show_percentage?"%":"");Royal_Preloader._percentage.text(b)}break;case "logo":Royal_Preloader._show_progress&&(b=a+(Royal_Preloader._show_percentage?"%":""),Royal_Preloader._percentage.text(b));
// Royal_Preloader._logo_loader_meter.css("bottom",a+"%");break;case "progress":Royal_Preloader._show_progress&&(b=a+(Royal_Preloader._show_percentage?"%":""),Royal_Preloader._percentage.text(b)),Royal_Preloader._progress_loader_meter.width(a+"%")}Royal_Preloader._animatePercentage(a,c)},5),100===a&&Royal_Preloader._loadFinish())},_imageOnLoad:function(a){this._image_queue.push(a);this._image_queue.length&&this._image_queue[0]===a&&this._processQueue()},_reQueue:function(){Royal_Preloader._image_queue.splice(0,
// 1);Royal_Preloader._processQueue()},_processQueue:function(){0!==this._image_queue.length&&(this._loaded++,Royal_Preloader._animatePercentage(Royal_Preloader._percentage_loaded,parseInt(this._loaded/this._total*100,10)),this._reQueue())},_loadFinish:function(){transitionEnd(this._overlay,function(a,c){Royal_Preloader._overlay&&(Royal_Preloader._overlay.remove(),Royal_Preloader._overlay=null)});this._overlay.addClass("complete");JQ(document.body).removeClass("royal_preloader");this._on_complete&&this._on_complete()},
// config:function(a){"undefined"!==typeof a.mode&&(this._mode=a.mode);"undefined"!==typeof a.text&&(this._text=a.text);"undefined"!==typeof a.text_colour&&(this._text_colour=a.text_colour);"undefined"!==typeof a.timeout&&(this._timeout=parseInt(a.timeout,10));"undefined"!==typeof a.showProgress&&(this._show_progress=a.showProgress?!0:!1);"undefined"!==typeof a.showPercentage&&(this._show_percentage=a.showPercentage?!0:!1);"undefined"!==typeof a.background&&(this._background=a.background);"undefined"!==
// typeof a.logo&&(this._logo=a.logo);"undefined"!==typeof a.logo_size&&(this._logo_size=a.logo_size);"undefined"!==typeof a.onComplete&&(this._on_complete=a.onComplete);"undefined"!==typeof a.images&&(this._images=a.images);"undefined"!==typeof a.cookie&&(this._cookie=a.cookie)}};setTimeout(function(){JQ(document).ready(Royal_Preloader._init)});

// Royal_Preloader.config({
//     onComplete: function() {
//         $('.bounce-animated').addClass('bounce animated');
//         $('.flash-animated').addClass('flash animated');
//         $('.pulse-animated').addClass('pulse animated');
//         $('.rubberBand-animated').addClass('rubberBand animated');
//         $('.shake-animated').addClass('shake animated');
//         $('.swing-animated').addClass('swing animated');
//         $('.tada-animated').addClass('tada animated');
//         $('.wobble-animated').addClass('wobble animated');
//         $('.bounceIn-animated').addClass('bounceIn animated');
//         $('.bounceInDown-animated').addClass('bounceInDown animated');
//         $('.bounceInLeft-animated').addClass('bounceInLeft animated');
//         $('.bounceInRight-animated').addClass('bounceInRight animated');
//         $('.bounceInUp-animated').addClass('bounceInUp animated');
//         $('.bounceOut-animated').addClass('bounceOut animated');
//         $('.bounceOutDown-animated').addClass('bounceOutDown animated');
//         $('.bounceOutLeft-animated').addClass('bounceOutLeft animated');
//         $('.bounceOutRight-animated').addClass('bounceOutRight animated');
//         $('.bounceOutUp-animated').addClass('bounceOutUp animated');
//         $('.fadeIn-animated').addClass('fadeIn animated');
//         $('.fadeInDown-animated').addClass('fadeInDown animated');
//         $('.fadeInDownBig-animated').addClass('fadeInDownBig animated');
//         $('.fadeInLeft-animated').addClass('fadeInLeft animated');
//         $('.fadeInLeftBig-animated').addClass('fadeInLeftBig animated');
//         $('.fadeInRight-animated').addClass('fadeInRight animated');
//         $('.fadeInRightBig-animated').addClass('fadeInRightBig animated');
//         $('.fadeInUp-animated').addClass('fadeInUp animated');
//         $('.fadeInUpBig-animated').addClass('fadeInUpBig animated');
//         $('.fadeOut-animated').addClass('fadeOut animated');
//         $('.fadeOutDown-animated').addClass('fadeOutDown animated');
//         $('.fadeOutDownBig-animated').addClass('fadeOutDownBig animated');
//         $('.fadeOutLeft-animated').addClass('fadeOutLeft animated');
//         $('.fadeOutLeftBig-animated').addClass('fadeOutLeftBig animated');
//         $('.fadeOutRight-animated').addClass('fadeOutRight animated');
//         $('.fadeOutRightBig-animated').addClass('fadeOutRightBig animated');
//         $('.fadeOutUp-animated').addClass('fadeOutUp animated');
//         $('.fadeOutUpBig-animated').addClass('fadeOutUpBig animated');
//         $('.flip-animated').addClass('flip animated');
//         $('.flipInX-animated').addClass('flipInX animated');
//         $('.flipInY-animated').addClass('flipInY animated');
//         $('.flipOutX-animated').addClass('flipOutX animated');
//         $('.flipOutY-animated').addClass('flipOutY animated');
//         $('.lightSpeedIn-animated').addClass('lightSpeedIn animated');
//         $('.lightSpeedOut-animated').addClass('lightSpeedOut animated');
//         $('.rotateIn-animated').addClass('rotateIn animated');
//         $('.rotateInDownLeft-animated').addClass('rotateInDownLeft animated');
//         $('.rotateInDownRight-animated').addClass('rotateInDownRight animated');
//         $('.rotateInUpLeft-animated').addClass('rotateInUpLeft animated');
//         $('.rotateInUpRight-animated').addClass('rotateInUpRight animated');
//         $('.rotateOut-animated').addClass('rotateOut animated');
//         $('.rotateOutDownLeft-animated').addClass('rotateOutDownLeft animated');
//         $('.rotateOutDownRight-animated').addClass('rotateOutDownRight animated');
//         $('.rotateOutUpLeft-animated').addClass('rotateOutUpLeft animated');
//         $('.rotateOutUpRight-animated').addClass('rotateOutUpRight animated');
//         $('.slideInDown-animated').addClass('slideInDown animated');
//         $('.slideInLeft-animated').addClass('slideInLeft animated');
//         $('.slideInRight-animated').addClass('slideInRight animated');
//         $('.slideInUp-animated').addClass('slideInUp animated');
//         $('.slideOutDown-animated').addClass('slideOutDown animated');
//         $('.slideOutLeft-animated').addClass('slideOutLeft animated');
//         $('.slideOutRight-animated').addClass('slideOutRight animated');
//         $('.slideOutUp-animated').addClass('slideOutUp animated');
//         $('.zoomIn-animated').addClass('zoomIn animated');
//         $('.zoomInDown-animated').addClass('zoomInDown animated');
//         $('.zoomInLeft-animated').addClass('zoomInLeft animated');
//         $('.zoomInRight-animated').addClass('zoomInRight animated');
//         $('.zoomInUp-animated').addClass('zoomInUp animated');
//         $('.zoomOut-animated').addClass('zoomOut animated');
//         $('.zoomOutDown-animated').addClass('zoomOutDown animated');
//         $('.zoomOutLeft-animated').addClass('zoomOutLeft animated');
//         $('.zoomOutRight-animated').addClass('zoomOutRight animated');
//         $('.zoomOutUp-animated').addClass('zoomOutUp animated');
//         $('.hinge-animated').addClass('hinge animated');
//         $('.rollin-animated').addClass('rollin animated');
//         $('.rollOut-animated').addClass('rollOut animated');
// 	}
// });<|endoftext|>


<commit_before>var webModel = require('../webModel');
var fs = require('fs');
var personalDataFile = process.env.HOME + '/.arlobot/personalDataForBehavior.json';
var personalData = JSON.parse(fs.readFileSync(personalDataFile, 'utf8'));
var io = require('socket.io/node_modules/socket.io-client'),
    assert = require('assert');
var personalDataFolder = process.env.HOME + '/.arlobot/';
var statusFolder = personalDataFolder + 'status/';
var quietFile = statusFolder + 'bequiet';
var stopFile = statusFolder + 'webStopRequested';
var webserver = require('../webserver');
var quietFileStatus,
    stopFileStatus;
var checkFileStatus = function(callback) {
    fs.readFile(quietFile, function(err, data) {
        if (err) quietFileStatus = false;
        if (data) quietFileStatus = true;
        fs.readFile(stopFile, function(err, data) {
            if (err) stopFileStatus = false;
            if (data) stopFileStatus = true;
            callback();
        });
    });
}
webserver.start();

describe('Suite of unit tests for webserver', function() {

    var socket;

    beforeEach(function(done) {
        // Setup
        socket = io.connect('http://localhost:' + personalData.webServerPort, {
            'reconnection delay': 0,
            'reopen delay': 0,
            'force new connection': true
        });
        socket.on('connect', function() {
            //console.log('worked...');
            done();
        });
        socket.on('event', function(data) {
            //console.log(data);
        });
        socket.on('startup', function(data) {
            //console.log('"startup" received over socket.');
        });
        socket.on('webModel', function(data) {
            //console.log('"webModel" received over socket.');
        });
        socket.on('disconnect', function() {
            //console.log('disconnected...');
        });
    });

    afterEach(function(done) {
        // Cleanup
        if (socket.connected) {
            //console.log('disconnecting...');
            socket.disconnect();
        } else {
            // There will not be a connection unless you have done() in beforeEach, socket.on('connect'...)
            //console.log('no connection to break...');
        }
        done();
    });

    describe('Check web Model for expected data', function() {

        it('should have Explore in the first mapList entry', function() {
            expect(webModel.mapList[0]).toEqual('Explore!');
        });

        it('should have maps in the mapList', function() {
            //console.log(webModel.mapList);
            expect(webModel.mapList[1]).not.toBe(undefined);
            expect(webModel.mapList[1]).not.toEqual('');
        });

    });

    describe('Remove semaphore files via socket', function() {

        beforeEach(function(done) {
            socket.emit('talk');
            socket.emit('unHaltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should unSet beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(false);
            expect(quietFileStatus).toBe(false);
        });

        it('should unSet haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(false);
            expect(stopFileStatus).toBe(false);
        });
    });

    describe('Set semaphore files via socket', function() {

        beforeEach(function(done) {
            socket.emit('beQuiet');
            socket.emit('haltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should set beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(true);
            expect(quietFileStatus).toBe(true);
        });

        it('should set haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(true);
            expect(stopFileStatus).toBe(true);
        });
    });

    describe('Remove semaphore files via socket again', function() {

        beforeEach(function(done) {
            socket.emit('talk');
            socket.emit('unHaltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should unSet beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(false);
            expect(quietFileStatus).toBe(false);
        });

        it('should unSet haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(false);
            expect(stopFileStatus).toBe(false);
        });
    });

});
<commit_msg>Changed file name.<commit_after>var webModel = require('../webModel');
var fs = require('fs');
var personalDataFile = process.env.HOME + '/.arlobot/personalDataForBehavior.json';
var personalData = JSON.parse(fs.readFileSync(personalDataFile, 'utf8'));
var io = require('socket.io/node_modules/socket.io-client'),
    assert = require('assert');
var personalDataFolder = process.env.HOME + '/.arlobot/';
var statusFolder = personalDataFolder + 'status/';
var quietFile = statusFolder + 'bequiet';
var stopFile = statusFolder + 'STOP';
var webserver = require('../webserver');
var quietFileStatus,
    stopFileStatus;
var checkFileStatus = function(callback) {
    fs.readFile(quietFile, function(err, data) {
        if (err) quietFileStatus = false;
        if (data) quietFileStatus = true;
        fs.readFile(stopFile, function(err, data) {
            if (err) stopFileStatus = false;
            if (data) stopFileStatus = true;
            callback();
        });
    });
}
webserver.start();

describe('Suite of unit tests for webserver', function() {

    var socket;

    beforeEach(function(done) {
        // Setup
        socket = io.connect('http://localhost:' + personalData.webServerPort, {
            'reconnection delay': 0,
            'reopen delay': 0,
            'force new connection': true
        });
        socket.on('connect', function() {
            //console.log('worked...');
            done();
        });
        socket.on('event', function(data) {
            //console.log(data);
        });
        socket.on('startup', function(data) {
            //console.log('"startup" received over socket.');
        });
        socket.on('webModel', function(data) {
            //console.log('"webModel" received over socket.');
        });
        socket.on('disconnect', function() {
            //console.log('disconnected...');
        });
    });

    afterEach(function(done) {
        // Cleanup
        if (socket.connected) {
            //console.log('disconnecting...');
            socket.disconnect();
        } else {
            // There will not be a connection unless you have done() in beforeEach, socket.on('connect'...)
            //console.log('no connection to break...');
        }
        done();
    });

    describe('Check web Model for expected data', function() {

        it('should have Explore in the first mapList entry', function() {
            expect(webModel.mapList[0]).toEqual('Explore!');
        });

        it('should have maps in the mapList', function() {
            //console.log(webModel.mapList);
            expect(webModel.mapList[1]).not.toBe(undefined);
            expect(webModel.mapList[1]).not.toEqual('');
        });

    });

    describe('Remove semaphore files via socket', function() {

        beforeEach(function(done) {
            socket.emit('talk');
            socket.emit('unHaltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should unSet beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(false);
            expect(quietFileStatus).toBe(false);
        });

        it('should unSet haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(false);
            expect(stopFileStatus).toBe(false);
        });
    });

    describe('Set semaphore files via socket', function() {

        beforeEach(function(done) {
            socket.emit('beQuiet');
            socket.emit('haltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should set beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(true);
            expect(quietFileStatus).toBe(true);
        });

        it('should set haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(true);
            expect(stopFileStatus).toBe(true);
        });
    });

    describe('Remove semaphore files via socket again', function() {

        beforeEach(function(done) {
            socket.emit('talk');
            socket.emit('unHaltRobot');
            setTimeout(function() {
                checkFileStatus(done)},
                1000);
        });

        it('should unSet beQuiet file and variable', function() {
            expect(webModel.beQuiet).toBe(false);
            expect(quietFileStatus).toBe(false);
        });

        it('should unSet haltRobot file and variable', function() {
            expect(webModel.haltRobot).toBe(false);
            expect(stopFileStatus).toBe(false);
        });
    });

});
<|endoftext|>


<commit_before>var generators = require('yeoman-generator');
var fse = require('fs-extra');
var git = require('nodegit');
var replace = require('replace');

var cwd = process.cwd();
var theme_name = cwd.split('/');
theme_name = theme_name[theme_name.length-1];

module.exports = generators.Base.extend({

  // Download the oddbaby
  download: function () {
    var done = this.async();

    this.log('Downloading Oddbaby...');

    // Download odd baby and put it in sites/all/themes/NAME
    var options = {
      remoteCallbacks: {
        certificateCheck: function() {
          return 1;
        }
      }
    };

    git.Clone.clone('https://github.com/oddhill/oddbaby.git', './', options).then(function(repository) {
      // Remove .git
      fse.unlink('./.git', function() {
        console.log('Done');
        done();
      });
    });
  },

  rename: function () {
    // Rename oddbaby.info till NAME.info.
    fse.move('oddbaby.info', theme_name + '.info', function(err) {
      if (!err) {
        console.log('Renamed oddbaby.info to ' + theme_name + '.info');

        // @TODO:
        // Rename Odd baby name in info file.

        // template.php - Replace the word "oddbaby" to NAME
        // preprocess.inc - Replace the word "oddbaby" to NAME
        // theme.inc - Replace the word "oddbaby" to NAME
        // js/main.js - Replace the word "oddbaby" to NAME

        var files = ['template.php', 'preprocess.inc', 'theme.inc', 'js/main.js'];

        for (name in files) {
          replace({
            regex: '/(oddbaby)/i',
            replacement: theme_name,
            paths: [files[name]],
            silent: true
          });
        }
      }
    });
  },

  install: function () {
    // Run npm-install
    this.npmInstall();
  }

});<commit_msg>Added end function<commit_after>var generators = require('yeoman-generator');
var fse = require('fs-extra');
var git = require('nodegit');
var replace = require('replace');

var cwd = process.cwd();
var theme_name = cwd.split('/');
theme_name = theme_name[theme_name.length-1];

module.exports = generators.Base.extend({

  // Download the oddbaby
  download: function () {
    var done = this.async();

    this.log('Downloading Oddbaby...');

    // Download odd baby and put it in sites/all/themes/NAME
    var options = {
      remoteCallbacks: {
        certificateCheck: function() {
          return 1;
        }
      }
    };

    git.Clone.clone('https://github.com/oddhill/oddbaby.git', './', options).then(function(repository) {
      // Remove .git
      fse.unlink('./.git', function() {
        console.log('Done');
        done();
      });
    });
  },

  rename: function () {
    // Rename oddbaby.info till NAME.info.
    fse.move('oddbaby.info', theme_name + '.info', function(err) {
      if (!err) {
        console.log('Renamed oddbaby.info to ' + theme_name + '.info');

        // @TODO:
        // Rename Odd baby name in info file.

        // template.php - Replace the word "oddbaby" to NAME
        // preprocess.inc - Replace the word "oddbaby" to NAME
        // theme.inc - Replace the word "oddbaby" to NAME
        // js/main.js - Replace the word "oddbaby" to NAME

        var files = ['template.php', 'preprocess.inc', 'theme.inc', 'js/main.js'];

        for (name in files) {
          replace({
            regex: '/(oddbaby)/i',
            replacement: theme_name,
            paths: [files[name]],
            silent: true
          });
        }
      }
    });
  },

  install: function () {
    // Run npm-install
    this.npmInstall();
  },

  end: function () {
    this.log('All done!');
  }

});<|endoftext|>


<commit_before>'use strict'

const path = require('path')
const express = require('express')
const firebase = require('firebase')
const hackernews = require('../../')

const server = express()
const hnservice = hackernews.init(firebase, {
	log: console.log
})
const watchmode = process.argv.includes('--watch')
const index = `

top

top at page 1

new

best

ask

show

job

kids/14545382

length/top

users/jl

</ui>`

server.get('/', (req, res) => {
	res.send(index)
})

server.get('/hackernews/*', (req, res) => {
	hnservice.fetch(req.path)
		.then(data => {
			res.send(typeof data === "number" ? String(data) : data)
		})
		.catch(err => {
			console.error(err)
			res.status(500).send(err.toString())
		})
})

Promise.resolve(watchmode && hnservice.watch()).then(() => {
	const PORT = 3001
	server.listen(PORT, () => {
		console.log(`server has started with ${watchmode ? 'watch' : 'fetch'} mode.` +
			` visit to http://localhost:${PORT}`)
	})
})
<commit_msg>bug: Fix missing typo<commit_after>'use strict'

const path = require('path')
const express = require('express')
const firebase = require('firebase')
const hackernews = require('../../')

const server = express()
const hnservice = hackernews.init(firebase, {
	log: console.log
})
const watchmode = process.argv.includes('--watch')
const index = `

top

top at page 1

new

best

ask

show

job

kids/14545382

length/top

users/jl

</ui>`

server.get('/', (req, res) => {
	res.send(index)
})

server.get('/hackernews/*', (req, res) => {
	hnservice.fetch(req.path)
		.then(data => {
			res.send(typeof data === "number" ? String(data) : data)
		})
		.catch(err => {
			console.error(err)
			res.status(500).send(err.toString())
		})
})

Promise.resolve(watchmode && hnservice.watch()).then(() => {
	const PORT = 3001
	server.listen(PORT, () => {
		console.log(`server has started with ${watchmode ? 'watch' : 'fetch'} mode.` +
			` visit to http://localhost:${PORT}`)
	})
})
<|endoftext|>


<commit_before>/**
 * Copyright 2013-2021 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* eslint-disable consistent-return */
const chalk = require('chalk');

const BaseBlueprintGenerator = require('../generator-base-blueprint');
const { files } = require('./files');
const constants = require('../generator-constants');
const { initDefaultPromptConfig } = require('../generator-defaults');

module.exports = class extends BaseBlueprintGenerator {
  constructor(args, opts) {
    super(args, opts);

    this.option('skip-prompts', {
      desc: 'Skips prompts',
      type: Boolean,
      defaults: false,
    });

    this.option('jhipster-version', {
      desc: 'Force jhipsterVersion for reproducibility',
      type: Boolean,
      hide: true,
    });

    if (this.options.help) return;

    this.instantiateBlueprints('init');
  }

  _initializing() {
    return {
      validateFromCli() {
        this.checkInvocationFromCLI();
      },
      sayHello() {
        if (!this.showHello()) return;
        this.log(chalk.white('⬢ Welcome to the JHipster Init ⬢'));
      },
      loadCliOptions() {
        this.loadInitCliOptions();
      },
      loadRuntimeOptions() {
        this.loadRuntimeOptions();
      },
    };
  }

  get initializing() {
    if (this.fromBlueprint) return;
    return this._initializing();
  }

  _prompting() {
    return {
      async showPrompts() {
        if (this.options.skipPrompts) return;
        // Consider existing baseName a project regeneration.
        if (this.jhipsterConfig.baseName && !this.options.askAnswered) return;
        await this.prompt(
          [
            {
              name: 'projectName',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the project name of your application?',
              default: () => this._getDefaultProjectName(),
            },
            {
              name: 'baseName',
              when: () => !this.abort,
              type: 'input',
              validate: input => this._validateBaseName(input),
              message: 'What is the base name of your application?',
              default: () => this.getDefaultAppName(),
            },
            {
              name: 'prettierDefaultIndent',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the default indentation?',
              default: 2,
            },
            {
              name: 'prettierJavaIndent',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the Java indentation?',
              default: 4,
            },
          ],
          this.config
        );
      },
    };
  }

  get prompting() {
    if (this.fromBlueprint) return;
    return this._prompting();
  }

  _configuring() {
    return {
      setDefaults() {
        this.config.defaults(initDefaultPromptConfig);
      },
    };
  }

  get configuring() {
    if (this.fromBlueprint) return;
    return this._configuring();
  }

  _loading() {
    return {
      loadConfig() {
        this.loadInitConfig();
      },
      loadDerivedConfig() {
        this.loadDerivedInitConfig();
      },
      loadConstant() {
        this.NODE_VERSION = constants.NODE_VERSION;
      },
      loadDependabotDependencies() {
        this.loadDependabotDependencies(this.fetchFromInstalledJHipster('init', 'templates', 'package.json'));
      },
    };
  }

  get loading() {
    if (this.fromBlueprint) return;
    return this._loading();
  }

  _writing() {
    return {
      writeFiles() {
        return this.writeFilesToDisk(files);
      },
    };
  }

  get writing() {
    if (this.fromBlueprint) return;
    return this._writing();
  }

  _install() {
    return {
      // Initialize git repository before package manager install for commit hooks
      initGitRepo() {
        if (!this.options.skipGit) {
          if (this.gitInstalled || this.isGitInstalled()) {
            const gitDir = this.gitExec('rev-parse --is-inside-work-tree', { trace: false }).stdout;
            // gitDir has a line break to remove (at least on windows)
            if (gitDir && gitDir.trim() === 'true') {
              this.gitInitialized = true;
            } else {
              const shellStr = this.gitExec('init', { trace: false });
              this.gitInitialized = shellStr.code === 0;
              if (this.gitInitialized) this.log(chalk.green.bold('Git repository initialized.'));
              else this.warning(`Failed to initialize Git repository.\n ${shellStr.stderr}`);
            }
          } else {
            this.warning('Git repository could not be initialized, as Git is not installed on your system');
          }
        }
      },
    };
  }

  get install() {
    if (this.fromBlueprint) return;
    return this._install();
  }

  _end() {
    return {
      /** Initial commit to git repository after package manager install for package-lock.json */
      gitCommit() {
        if (!this.options.skipGit && this.isGitInstalled()) {
          if (this.gitInitialized) {
            this.debug('Committing files to git');
            const done = this.async();
            this.gitExec('log --oneline -n 1 -- .', { trace: false }, (code, commits) => {
              if (code !== 0 || !commits || !commits.trim()) {
                // if no files in Git from current folder then we assume that this is initial application generation
                this.gitExec('add .', { trace: false }, code => {
                  if (code === 0) {
                    let commitMsg = `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`;
                    if (this.jhipsterConfig.blueprints && this.jhipsterConfig.blueprints.length > 0) {
                      const bpInfo = this.jhipsterConfig.blueprints.map(bp => `${bp.name}@${bp.version}`).join(', ');
                      commitMsg += ` with blueprints ${bpInfo}`;
                    }
                    this.gitExec(`commit -m "${commitMsg}" -- .`, { trace: false }, code => {
                      if (code === 0) {
                        this.log(chalk.green.bold(`Application successfully committed to Git from ${process.cwd()}.`));
                      } else {
                        this.log(chalk.red.bold(`Application commit to Git failed from ${process.cwd()}. Try to commit manually.`));
                      }
                      done();
                    });
                  } else {
                    this.warning(
                      `The generated application could not be committed to Git, because ${chalk.bold('git add')} command failed.`
                    );
                    done();
                  }
                });
              } else {
                // if found files in Git from current folder then we assume that this is application regeneration
                // if there are changes in current folder then inform user about manual commit needed
                this.gitExec('diff --name-only .', { trace: false }, (code, diffs) => {
                  if (code === 0 && diffs && diffs.trim()) {
                    this.log(
                      `Found commits in Git from ${process.cwd()}. So we assume this is application regeneration. Therefore automatic Git commit is not done. You can do Git commit manually.`
                    );
                  }
                  done();
                });
              }
            });
          } else {
            this.warning('The generated application could not be committed to Git, as a Git repository could not be initialized.');
          }
        }
      },
    };
  }

  get end() {
    if (this.fromBlueprint) return;
    return this._end();
  }

  /*
   * Start of local public API, blueprints may override to customize the generator behavior.
   */

  /**
   * @returns default app name
   */
  _getDefaultProjectName() {
    return initDefaultPromptConfig.projectName;
  }

  /**
   * Validates baseName
   * @param String input - Base name to be checked
   * @returns Boolean
   */
  _validateBaseName(input) {
    if (!/^([a-zA-Z0-9_]*)$/.test(input)) {
      return 'Your base name cannot contain special characters or a blank space';
    }
    if (/_/.test(input)) {
      return 'Your base name cannot contain underscores as this does not meet the URI spec';
    }
    if (input === 'application') {
      return "Your base name cannot be named 'application' as this is a reserved name for Spring Boot";
    }
    return true;
  }
};
<commit_msg>skip-prompts is added in generator-base.<commit_after>/**
 * Copyright 2013-2021 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* eslint-disable consistent-return */
const chalk = require('chalk');

const BaseBlueprintGenerator = require('../generator-base-blueprint');
const { files } = require('./files');
const constants = require('../generator-constants');
const { initDefaultPromptConfig } = require('../generator-defaults');

module.exports = class extends BaseBlueprintGenerator {
  constructor(args, opts) {
    super(args, opts);

    this.option('jhipster-version', {
      desc: 'Force jhipsterVersion for reproducibility',
      type: Boolean,
      hide: true,
    });

    if (this.options.help) return;

    this.instantiateBlueprints('init');
  }

  _initializing() {
    return {
      validateFromCli() {
        this.checkInvocationFromCLI();
      },
      sayHello() {
        if (!this.showHello()) return;
        this.log(chalk.white('⬢ Welcome to the JHipster Init ⬢'));
      },
      loadCliOptions() {
        this.loadInitCliOptions();
      },
      loadRuntimeOptions() {
        this.loadRuntimeOptions();
      },
    };
  }

  get initializing() {
    if (this.fromBlueprint) return;
    return this._initializing();
  }

  _prompting() {
    return {
      async showPrompts() {
        if (this.options.skipPrompts) return;
        // Consider existing baseName a project regeneration.
        if (this.jhipsterConfig.baseName && !this.options.askAnswered) return;
        await this.prompt(
          [
            {
              name: 'projectName',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the project name of your application?',
              default: () => this._getDefaultProjectName(),
            },
            {
              name: 'baseName',
              when: () => !this.abort,
              type: 'input',
              validate: input => this._validateBaseName(input),
              message: 'What is the base name of your application?',
              default: () => this.getDefaultAppName(),
            },
            {
              name: 'prettierDefaultIndent',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the default indentation?',
              default: 2,
            },
            {
              name: 'prettierJavaIndent',
              when: () => !this.abort,
              type: 'input',
              message: 'What is the Java indentation?',
              default: 4,
            },
          ],
          this.config
        );
      },
    };
  }

  get prompting() {
    if (this.fromBlueprint) return;
    return this._prompting();
  }

  _configuring() {
    return {
      setDefaults() {
        this.config.defaults(initDefaultPromptConfig);
      },
    };
  }

  get configuring() {
    if (this.fromBlueprint) return;
    return this._configuring();
  }

  _loading() {
    return {
      loadConfig() {
        this.loadInitConfig();
      },
      loadDerivedConfig() {
        this.loadDerivedInitConfig();
      },
      loadConstant() {
        this.NODE_VERSION = constants.NODE_VERSION;
      },
      loadDependabotDependencies() {
        this.loadDependabotDependencies(this.fetchFromInstalledJHipster('init', 'templates', 'package.json'));
      },
    };
  }

  get loading() {
    if (this.fromBlueprint) return;
    return this._loading();
  }

  _writing() {
    return {
      writeFiles() {
        return this.writeFilesToDisk(files);
      },
    };
  }

  get writing() {
    if (this.fromBlueprint) return;
    return this._writing();
  }

  _install() {
    return {
      // Initialize git repository before package manager install for commit hooks
      initGitRepo() {
        if (!this.options.skipGit) {
          if (this.gitInstalled || this.isGitInstalled()) {
            const gitDir = this.gitExec('rev-parse --is-inside-work-tree', { trace: false }).stdout;
            // gitDir has a line break to remove (at least on windows)
            if (gitDir && gitDir.trim() === 'true') {
              this.gitInitialized = true;
            } else {
              const shellStr = this.gitExec('init', { trace: false });
              this.gitInitialized = shellStr.code === 0;
              if (this.gitInitialized) this.log(chalk.green.bold('Git repository initialized.'));
              else this.warning(`Failed to initialize Git repository.\n ${shellStr.stderr}`);
            }
          } else {
            this.warning('Git repository could not be initialized, as Git is not installed on your system');
          }
        }
      },
    };
  }

  get install() {
    if (this.fromBlueprint) return;
    return this._install();
  }

  _end() {
    return {
      /** Initial commit to git repository after package manager install for package-lock.json */
      gitCommit() {
        if (!this.options.skipGit && this.isGitInstalled()) {
          if (this.gitInitialized) {
            this.debug('Committing files to git');
            const done = this.async();
            this.gitExec('log --oneline -n 1 -- .', { trace: false }, (code, commits) => {
              if (code !== 0 || !commits || !commits.trim()) {
                // if no files in Git from current folder then we assume that this is initial application generation
                this.gitExec('add .', { trace: false }, code => {
                  if (code === 0) {
                    let commitMsg = `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`;
                    if (this.jhipsterConfig.blueprints && this.jhipsterConfig.blueprints.length > 0) {
                      const bpInfo = this.jhipsterConfig.blueprints.map(bp => `${bp.name}@${bp.version}`).join(', ');
                      commitMsg += ` with blueprints ${bpInfo}`;
                    }
                    this.gitExec(`commit -m "${commitMsg}" -- .`, { trace: false }, code => {
                      if (code === 0) {
                        this.log(chalk.green.bold(`Application successfully committed to Git from ${process.cwd()}.`));
                      } else {
                        this.log(chalk.red.bold(`Application commit to Git failed from ${process.cwd()}. Try to commit manually.`));
                      }
                      done();
                    });
                  } else {
                    this.warning(
                      `The generated application could not be committed to Git, because ${chalk.bold('git add')} command failed.`
                    );
                    done();
                  }
                });
              } else {
                // if found files in Git from current folder then we assume that this is application regeneration
                // if there are changes in current folder then inform user about manual commit needed
                this.gitExec('diff --name-only .', { trace: false }, (code, diffs) => {
                  if (code === 0 && diffs && diffs.trim()) {
                    this.log(
                      `Found commits in Git from ${process.cwd()}. So we assume this is application regeneration. Therefore automatic Git commit is not done. You can do Git commit manually.`
                    );
                  }
                  done();
                });
              }
            });
          } else {
            this.warning('The generated application could not be committed to Git, as a Git repository could not be initialized.');
          }
        }
      },
    };
  }

  get end() {
    if (this.fromBlueprint) return;
    return this._end();
  }

  /*
   * Start of local public API, blueprints may override to customize the generator behavior.
   */

  /**
   * @returns default app name
   */
  _getDefaultProjectName() {
    return initDefaultPromptConfig.projectName;
  }

  /**
   * Validates baseName
   * @param String input - Base name to be checked
   * @returns Boolean
   */
  _validateBaseName(input) {
    if (!/^([a-zA-Z0-9_]*)$/.test(input)) {
      return 'Your base name cannot contain special characters or a blank space';
    }
    if (/_/.test(input)) {
      return 'Your base name cannot contain underscores as this does not meet the URI spec';
    }
    if (input === 'application') {
      return "Your base name cannot be named 'application' as this is a reserved name for Spring Boot";
    }
    return true;
  }
};
<|endoftext|>


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

    return this.each(function() {
      var opts = $.extend({}, $.fn.easyAudio.defaults, options);
      opts.$elem = $(this);

      var configured = $.fn.easyAudio.configure(opts);

      if ( ! configured) {
        alert("Your browser doesn't support audio");
        return false;
      }

      // $.fn.easyAudio.addAudio(opts);
      $.fn.easyAudio.bindEvents(opts);
    });

  };

  $.fn.easyAudio.defaults = {};

  $.fn.easyAudio.bindEvents = function(opts) {
    var ev = opts.event + '.easyaudio';
    opts.$elem.bind(ev, function() {
      var audio = $.fn.easyAudio.addAudio(opts);
      audio.play();

      opts.$elem.unbind(ev);
      $.fn.easyAudio.bindEvents(opts);

      if (opts.onPlay) {
        opts.onPlay();
      }
    });
  }

  $.fn.easyAudio.addAudio = function(opts) {
    var $audio = $('<audio src="' + opts.src + '" preload="auto"></audio');
    $audio.bind('ended', function() {
      $(this).remove();
      if (opts.onEnd) {
        opts.onEnd();
      }
    });
    return $audio[0]
  }

  $.fn.easyAudio.configure = function(opts) {
    var audio = document.createElement('audio');
    if (!!!audio.canPlayType) return false;

    var types = {
      'audio/mpeg' : 'mp3',
      'audio/wav' : 'wav',
      'audio/ogg' : 'ogg'
    };

    var keys = Object.keys(types);
    for (var i = 0; i < keys.length; i++) {
      if (!!audio.canPlayType(keys[i])) {
        opts.src = opts.src + '.' + types[keys[i]];
        return true;
      }
    }

    return false;
  };

}(jQuery));
<commit_msg>make sure we preload the audio<commit_after>(function() {
  $.fn.easyAudio = function(options) {

    return this.each(function() {
      var opts = $.extend({}, $.fn.easyAudio.defaults, options);
      opts.$elem = $(this);

      var configured = $.fn.easyAudio.configure(opts);

      if ( ! configured) {
        alert("Your browser doesn't support audio");
        return false;
      }

      // $.fn.easyAudio.addAudio(opts);
      $.fn.easyAudio.bindEvents(opts);
    });

  };

  $.fn.easyAudio.defaults = {};

  $.fn.easyAudio.bindEvents = function(opts) {
    var ev = opts.event + '.easyaudio';
    opts.$elem.bind(ev, function() {
      var audio = $.fn.easyAudio.addAudio(opts);
      audio.play();

      opts.$elem.unbind(ev);
      $.fn.easyAudio.bindEvents(opts);

      if (opts.onPlay) {
        opts.onPlay();
      }
    });
  }

  $.fn.easyAudio.addAudio = function(opts) {
    var $audio = $('<audio src="' + opts.src + '" preload="auto"></audio');
    $audio.bind('ended', function() {
      $(this).remove();
      if (opts.onEnd) {
        opts.onEnd();
      }
    });
    return $audio[0]
  }

  $.fn.easyAudio.configure = function(opts) {
    var audio = document.createElement('audio');
    if (!!!audio.canPlayType) return false;

    var types = {
      'audio/mpeg' : 'mp3',
      'audio/wav' : 'wav',
      'audio/ogg' : 'ogg'
    };

    var keys = Object.keys(types);
    for (var i = 0; i < keys.length; i++) {
      if (!!audio.canPlayType(keys[i])) {
        opts.src = opts.src + '.' + types[keys[i]];
        $.fn.easyAudio.preloadAudio(opts);
        return true;
      }
    }

    return false;
  };

  $.fn.easyAudio.preloadAudio(opts) {
    var audio = new Audio();
    audio.preload = "preload";
    audio.src = opts.src;
  }

}(jQuery));
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import { Link } from 'react-router-dom';

class List extends Component {
	constructor(props) {
		super(props);
		this.months = ['Jan ', 'Feb ', 'Mar ', 'Apr ', 'May ', 'Jun ', 'Jul ', 'Aug ', 'Sept ', 'Oct ', 'Nov ', 'Dec '];
	}

	formatTimeString(tweet) {
        const d = new Date(parseInt(tweet.date));
        const dateString = this.months[d.getMonth()] + d.getDate() + ', ' + d.getFullYear();
        const timeString = Math.abs(d.getHours() - 12) + ':' + (d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes())  + (d.getHours() < 12 ? 'am' : 'pm');
        return dateString + ' ' + timeString;
	}

	render() {
        const self = this;
        const listStyle = self.props.showList ? '' : "list-hidden";
		return (

				{this.props.tweets.map(function(tweet) {
					return (

 self.props.findTweet(tweet, evt)}>

                                {self.formatTimeString(tweet)}

					);
				})}

		);
	}
}

export default List;<commit_msg>Fix tweet times in list<commit_after>import React, { Component } from 'react';
import { Link } from 'react-router-dom';

class List extends Component {
	constructor(props) {
		super(props);
		this.months = ['Jan ', 'Feb ', 'Mar ', 'Apr ', 'May ', 'Jun ', 'Jul ', 'Aug ', 'Sept ', 'Oct ', 'Nov ', 'Dec '];
	}

	formatTimeString(tweet) {
        const d = new Date(parseInt(tweet.date));
        const dateString = this.months[d.getMonth()] + d.getDate() + ', ' + d.getFullYear();
        const timeString = this.formatHours(d) + ':' + this.formatMinutes(d);
        return dateString + ' ' + timeString;
	}

    formatHours(date) {
        return (date.getHours() + 24) % 12 || 12;
    }

    formatMinutes(date) {
        let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
        return (date.getHours() < 12 ? (minutes += 'am') : (minutes += 'pm'));
    }

	render() {
        const self = this;
        const listStyle = self.props.showList ? '' : "list-hidden";
		return (

				{this.props.tweets.map(function(tweet) {
					return (

 self.props.findTweet(tweet, evt)}>

                                {self.formatTimeString(tweet)}

					);
				})}

		);
	}
}

export default List;<|endoftext|>


<commit_before>var layout = (function(window, document, $) {

    'use strict';

    var $window = $(window),
        windowWidth = $window.width(),
        windowHeight = $window.height(),

        init = function() {

            stickOnScroll();
            navigation();
            particles();

            if (windowWidth > 767) {
                codeHoverEffect();
            }

            var height = windowHeight - $('.project-header').outerHeight() - $('.copyright').outerHeight();
            $('.project-content').css('min-height', height);

        },

        stickOnScroll = function() {

            window.setTimeout(function() {
                var ele = $('.project-content-navigation');
                ele.css('height', ele.outerHeight()).stickOnScroll({
                    topOffset: 10
                });
            }, 100);

        },

        codeHoverEffect = function() {

            var elements = $('pre'),
                wrapperWidth = $('.l-page-wrapper').width();

            elements.each(function(index, el) {
                var $el = $(el),
                    width = $el.find('code').width();

                if (width > wrapperWidth) {
                    var maxWidth = $window.width() * 0.8;

                    $el.css({
                        width: wrapperWidth,
                        maxWidth: maxWidth
                    });

                    $(el).hover(function() {
                        var marginLeft = (wrapperWidth - width) / 2;

                        if (width > maxWidth) {
                            width = maxWidth;
                            marginLeft = (maxWidth - wrapperWidth) / 2 * -1
                        }

                        $el.css({
                            width: width,
                            marginLeft: marginLeft
                        });
                    }, function() {
                        $el.css({
                            width: wrapperWidth,
                            marginLeft: 0
                        });
                    });
                }
            });

        },

        particles = function() {
            particlesJS('particles', {
                canvas: {
                    color_hex_bg: '#000',
                    opacity: 1
                },
                particles: {
                    color_hex: '#fff',
                    opacity: 1,
                    size: 2.5,
                    size_random: true,
                    nb: 120,
                    anim: {
                        speed: 2
                    }
                },
                retina_detect: true
            });
        },

        navigation = function() {

            var $el,
                element;
            $('.project-content-left').append('

');
            $('.project-content-right').find('h1, h2, h3').each(function(index, el) {
                $el = $(el);
                $el.attr('id', $el.text().replace(' ', '-').toLowerCase());
                element = '
' + $el.text() + '
';
                $('.project-content-left').find('.project-content-navigation ol').append(element);
            });

        };

    return {
        init: init
    };

})(window, document, $);
<commit_msg>Reduce particles number on mobile<commit_after>var layout = (function(window, document, $) {

    'use strict';

    var $window = $(window),
        windowWidth = $window.width(),
        windowHeight = $window.height(),

        init = function() {

            stickOnScroll();
            navigation();
            particles();

            if (windowWidth > 767) {
                codeHoverEffect();
            }

            var height = windowHeight - $('.project-header').outerHeight() - $('.copyright').outerHeight();
            $('.project-content').css('min-height', height);

        },

        stickOnScroll = function() {

            window.setTimeout(function() {
                var ele = $('.project-content-navigation');
                ele.css('height', ele.outerHeight()).stickOnScroll({
                    topOffset: 10
                });
            }, 100);

        },

        codeHoverEffect = function() {

            var elements = $('pre'),
                wrapperWidth = $('.l-page-wrapper').width();

            elements.each(function(index, el) {
                var $el = $(el),
                    width = $el.find('code').width();

                if (width > wrapperWidth) {
                    var maxWidth = $window.width() * 0.8;

                    $el.css({
                        width: wrapperWidth,
                        maxWidth: maxWidth
                    });

                    $(el).hover(function() {
                        var marginLeft = (wrapperWidth - width) / 2;

                        if (width > maxWidth) {
                            width = maxWidth;
                            marginLeft = (maxWidth - wrapperWidth) / 2 * -1
                        }

                        $el.css({
                            width: width,
                            marginLeft: marginLeft
                        });
                    }, function() {
                        $el.css({
                            width: wrapperWidth,
                            marginLeft: 0
                        });
                    });
                }
            });

        },

        particles = function() {
            var nbParticles = 120;

            if (windowWidth < 768) {
                nbParticles = 50;
            }

            particlesJS('particles', {
                canvas: {
                    color_hex_bg: '#000',
                    opacity: 1
                },
                particles: {
                    color_hex: '#fff',
                    opacity: 1,
                    size: 2.5,
                    size_random: true,
                    nb: nbParticles,
                    anim: {
                        speed: 2
                    }
                },
                retina_detect: true
            });
        },

        navigation = function() {

            var $el,
                element;
            $('.project-content-left').append('

');
            $('.project-content-right').find('h1, h2, h3').each(function(index, el) {
                $el = $(el);
                $el.attr('id', $el.text().replace(' ', '-').toLowerCase());
                element = '
' + $el.text() + '
';
                $('.project-content-left').find('.project-content-navigation ol').append(element);
            });

        };

    return {
        init: init
    };

})(window, document, $);
<|endoftext|>


<commit_before>(function() {

  'use strict';

  var Utilities = function(){}

  Utilities.prototype = {
    openNav : function(){
      $('#mySidenav').css('width', '25%');
    },

    // Set the width of the side navigation to 0
    closeNav : function(){
      $('#mySidenav').css('width','0px');
    },
    getIDFromPokemonURL : function(url){
      /*
        Grabs the value between the last two /'s
        (i.e http://pokeapi.co/api/v2/pokemon/1/ => 1)
        */
      // var id = url.replace(/(.*)(pokemon|pokemon\-species)\/(.*)\//, '$3');
      var id = url.replace(/.*\/.*\/(.*?)\//, '$1');
      return id;
    },

    showSection : function(sectionName){
      sectionName = sectionName.trim();

      if ($( "#" + sectionName ).hasClass("hidden")) {
        $('.' + sectionName + ' button').html('–');
        $('#' + sectionName).removeClass("hidden").addClass("expanded");
        $('#' + sectionName).focus();
      }else {
        $('.' + sectionName + ' button').html('+');
        $('#' + sectionName).addClass("hidden").removeClass("expanded");
      }
    },

    setAutoComplete : function(results, input) {
      var array = [];
      $.each(results, function(index, value){
        var name = value.name.replace(/\-/ig, ' ');
        array.push(name);
      });

      var searchBox = document.getElementById(input);
      new Awesomplete(searchBox, {
        list        :   array,
        minChars    :   2,
        maxChars    :   50
      });
      var _self = this;

      searchBox.addEventListener('awesomplete-selectcomplete', function(data){
        console.log(data);

        var pokemonName = (data.text) ?  data.text.value : null;
        pokemonName = (!pokemonName) ? $(data.srcElement).val() : pokemonName;
        console.log(pokemonName);

        if (pokemonName !== null) {
          pokemonName = pokemonName.toLowerCase();
          //make sure that pokemon name exists
          if(array.indexOf(pokemonName) > -1){
            _self.changePage(pokemonName.replace(/\s/g, '-'));
          }
        }
      }, false);

      $('#' + input).keyup(function (e) {
        if (e.keyCode == 13) {
          // Do something
          var event = new Event('awesomplete-selectcomplete');
          searchBox.dispatchEvent(event);
        }
      });

    },

    showOverlay : function() {
      $('.overlay').removeClass('hidden');
    },

    changePage : function(pokemonID) {
      console.log('show overlay...');
      $('.overlay').removeClass('hidden');
      $('#searchContainer').addClass('hidden');
      window.location = "./" + pokemonID;
    },

    showSearch : function(){
      if ($( "#searchContainer" ).hasClass("hidden")) {
        $('#searchContainer').removeClass("hidden");
        $('.searchBox').focus();
      }else {
        $('#searchContainer').addClass("hidden");
      }
    },

    getQS : function(object){
      /*
      Query string values get returned back to the object
      Use object.key|object[key] //returns value
      */
      var pl     = /\+/g;  // Regex for replacing addition symbol with a space
      var search = /([^&=]+)=?([^&]*)/g;
      var decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); };
      var query  = window.location.search.substring(1);
      var match;

      while (match = search.exec(query)){
        object[decode(match[1])] = decode(match[2]);
      }
    }

  }

  function init(){
    console.log('----- utilities init -----');
    var me = self.Utilities;

    $('#navButton').click(function(){
      me.openNav();
    });

    $('.closebtn').click(function(){
      me.closeNav();
    });
  }

   // Are we in a browser? Check for Document constructor
  if (typeof Document !== "undefined") {
    // DOM already loaded?
    if (document.readyState !== "loading") {
      init();
    }else{
      // Wait for it
      document.addEventListener("DOMContentLoaded", init);
    }
  }

  // Make sure to export Awesomplete on self when in a browser
  if (typeof self !== "undefined") {
    self.Utilities = Utilities;
  }

  // Expose Awesomplete as a CJS module
  if (typeof module === "object" && module.exports) {
    module.exports = Utilities;
  }

  return Utilities;

}());<commit_msg>Update utilities.js<commit_after>(function() {

  'use strict';

  var Utilities = function(){}

  Utilities.prototype = {
    openNav : function(){
      $('#mySidenav').css('width', '25%');
    },

    // Set the width of the side navigation to 0
    closeNav : function(){
      $('#mySidenav').css('width','0px');
    },
    getIDFromPokemonURL : function(url){
      /*
        Grabs the value between the last two /'s
        (i.e http://pokeapi.co/api/v2/pokemon/1/ => 1)
        */
      // var id = url.replace(/(.*)(pokemon|pokemon\-species)\/(.*)\//, '$3');
      var id = url.replace(/.*\/.*\/(.*?)\//, '$1');
      return id;
    },

    showSection : function(sectionName){
      sectionName = sectionName.trim();

      if ($( "#" + sectionName ).hasClass("hidden")) {
        $('.' + sectionName + ' button').html('–');
        $('#' + sectionName).removeClass("hidden").addClass("expanded");
        $('#' + sectionName).focus();
      }else {
        $('.' + sectionName + ' button').html('+');
        $('#' + sectionName).addClass("hidden").removeClass("expanded");
      }
    },

    setAutoComplete : function(results, input) {
      var array = [];
      $.each(results, function(index, value){
        var name = value.name.replace(/\-/ig, ' ');
        array.push(name);
      });

      var searchBox = document.getElementById(input);
      new Awesomplete(searchBox, {
        list        :   array,
        minChars    :   2,
        maxChars    :   50
      });
      var _self = this;

      searchBox.addEventListener('awesomplete-selectcomplete', function(data){
        console.log(data);

        var pokemonName = (data.text) ?  data.text.value : null;
        pokemonName = (!pokemonName) ? $(data.srcElement).val() : pokemonName;
        console.log(pokemonName);

        if (pokemonName !== null) {
          pokemonName = pokemonName.toLowerCase();
          //make sure that pokemon name exists
          if(array.indexOf(pokemonName) > -1){
            _self.changePage(pokemonName.replace(/\s/g, '-'));
          }
        }
      }, false);

      $('#' + input).keyup(function (e) {
        if (e.keyCode == 13) {
          // Do something
          var event = new Event('awesomplete-selectcomplete');
          searchBox.dispatchEvent(event);
        }
      });

    },

    showOverlay : function() {
      $('.overlay').removeClass('hidden');
    },

    changePage : function(pokemonID) {
      console.log('show overlay...');
      $('.overlay').removeClass('hidden');
      $('#searchContainer').addClass('hidden');
      window.location = "./" + pokemonID;
    },

    showSearch : function(){
      if ($( "#searchContainer" ).hasClass("hidden")) {
        $('#searchContainer').removeClass("hidden");
        $('.searchBox').focus();
      }else {
        $('#searchContainer').addClass("hidden");
      }
    },

    getQS : function(object){
      /*
      Query string values get returned back to the object
      Use object.key|object[key] //returns value
      */
      var pl     = /\+/g;  // Regex for replacing addition symbol with a space
      var search = /([^&=]+)=?([^&]*)/g;
      var decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); };
      var query  = window.location.search.substring(1);
      var match;

      while (match = search.exec(query)){
        object[decode(match[1])] = decode(match[2]);
      }
    }

  }

  function init(){
    console.log('----- utilities init -----');
    var me = self.Utilities;

    $('#navButton').click(function(){
      me.openNav();
    });

    $('.closebtn').click(function(){
      me.closeNav();
    });
  }

   // Are we in a browser? Check for Document constructor
  if (typeof Document !== "undefined") {
    // DOM already loaded?
    if (document.readyState !== "loading") {
      init();
    }else{
      // Wait for it
      document.addEventListener("DOMContentLoaded", init);
    }
  }

  if (typeof self !== "undefined") {
    self.Utilities = Utilities;
  }

  if (typeof module === "object" && module.exports) {
    module.exports = Utilities;
  }

  return Utilities;

}());
<|endoftext|>