<commit_before>(function($){

	if(typeof(window.EMMA) === 'undefined') {
            window.EMMA = {};
    }

    EMMA.sliderTimer = null;
    EMMA.logoSliderTimer = null;

// Fix Placeholder
function fixPlaceholder() {
	jQuery.support.placeholder = false;
	var test = document.createElement('input');
	if('placeholder' in test) jQuery.support.placeholder = true;
	if(!$.support.placeholder) {
		var active = document.activeElement;
		$('input,textarea').focus(function () {
			if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
				$(this).val('').removeClass('hasPlaceholder');
			}
		}).blur(function () {
			if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
				$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
			}
		});
		$('input,textarea').blur();
		$(active).focus();
		$('form').submit(function () { $(this).find('.hasPlaceholder').each(function() { $(this).val(''); }); });
	}
}

// Slider
function initSlider() {
	// Main Slider
	sliderFunction('.slidecontrol','slidecontainer','slide',638,8000);
	// Logoslider
	sliderFunction('#logoslidecontrols','logoslidercontainer','logoslide',960,16000);
}
function sliderFunction(controls,container,slide,width,interval) {

	$(controls+' div').click(function() {
		if ($(this).hasClass('prev')) {
			$('#'+container+' .'+slide+':last').detach().prependTo('#'+container);
			$('#'+container).animate({marginLeft: '-='+width+'px'},0);
			$('#'+container).animate({marginLeft: '+='+width+'px'},1000);
		} else {
			$('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
				$('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
				$('#'+container).animate({marginLeft: '+='+width+'px'},0);
			});
		}
	});

    // mouseover to stop sliding
    $('div#slider').mouseover(function(){
        clearInterval(EMMA.sliderTimer); // stops interval, ie, turn off sliding
    }).mouseout(function(){
        autoSlider('.slidecontrol','slidecontainer','slide',638, interval);
    });

    $('div#logoslider').mouseover(function(){
        clearInterval(EMMA.logoSliderTimer); // stops interval, ie, turn off sliding
    }).mouseout(function(){
        autoSlider('#logoslidecontrols','logoslidercontainer','logoslide',960, interval);
    });

    // auto slide in defined time interval for both slides and logos
    if ( slide == 'slide' ){
        autoSlider('.slidecontrol','slidecontainer','slide',638, interval);
    }
    else {
        autoSlider('#logoslidecontrols','logoslidercontainer','logoslide',960, interval);
    }
}
function autoSlider(controls,container,slide,width,interval){

    if (slide == 'slide' ){
        if(EMMA.sliderTimer){
            clearInterval(EMMA.sliderTimer);
        }
        EMMA.sliderTimer = setInterval(function() {
            $('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
		        $('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
		        $('#'+container).animate({marginLeft: '+='+width+'px'},0);
	        });
        }, interval);
    }
    else {
        if(EMMA.logoSliderTimer){
            clearInterval(EMMA.logoSliderTimer);
        }
        EMMA.logoSliderTimer = setInterval(function() {
            $('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
		        $('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
		        $('#'+container).animate({marginLeft: '+='+width+'px'},0);
	        });
        }, interval);
    }
}

// Sidenavi
function initSideNavi() {
	if (!$('html').hasClass('ie7')) {
		// Helper for sidenavi rollover
		$('#block-menu-block-2 .expanded > a').each(function() { $(this).prepend('

'); });
		$('.helpclicker').live('click',function(e) {
			e.preventDefault();
			$(this).closest('li').toggleClass('active-trail');
		});
		$('.helpclicker').live('mouseover mouseout',function(e) { $(this).closest('li').toggleClass('over'); });
		// Helper for toggling content elements
		$('.togglehead .helper').live('mouseover mouseout',function(e) { $(this).closest('.togglehead').toggleClass('over'); });
	}
}

// various actions
function initActions() {
	// Toggle help box on frontpage
	$('#togglehelp').click(function() { $('#stooltip').toggle(); });
	// Animated Scrolling to top
	$("#toplink").click(function(e){ e.preventDefault(); $('html,body').animate({scrollTop:0}, 1500); });
	// Kill .error when focusing a input field
	$('.error input').live('focus',function() {
		$(this).closest('.form-item').removeClass('error');
	});
}

// Tabcontent
function initTabContent() {
	if ($('.field-collection-item-field-tab').length > 0) {
		var container = $('.field-collection-item-field-tab').eq(0);
		$(container).before('

');
		$('.field-collection-item-field-tab').each(function() {
			var title = $('.title',this).text();
			$('#tabs ul').append('
'+title+'
');
			$('.title',this).remove();
		});
		$('#tabs a').live('click',function(e) {
			e.preventDefault();
			var index = $(this).index('#tabs a');
			$('#tabs a').removeClass('active');
			$(this).addClass('active');
			$('.field-collection-item-field-tab').hide();
			$('.field-collection-item-field-tab').eq(index).show();
		});
		$('#tabs a:first').trigger('click');
	}
}

// Togglebox
function initToggleContent() {
	$('.togglehead').live('click',function(e) {
		$(this).closest('.toggle').toggleClass('active');
		$(this).next('.togglecontent').toggle('fast');
	});
}

// Autoheight of boxes
function autoHeightFront() {
	var aboutHeight = $('#box-abouttext .boxcontent').innerHeight();
	var smallHeight = (aboutHeight - 105) / 2;
	$('#box-partnership .boxcontent').css('min-height',smallHeight+'px')
}

// Content margin, when no special Boxes inside the main node
function initContentMargin() {
	var headBox   = $('#block-system-main .node:first .head').length;
	var innerBoxes = $('#block-system-main .innerbox').length;
	var teaserBox = $('.view-subpages-teaser').length;
	if (teaserBox == 1 && innerBoxes == 0 && headBox == 0) {
		$('#block-system-main').addClass('margbottom');
	}
}

// span Tooltips
function initTooltips() {
	$('.tooltip').live('mouseenter',function(e) {
		var offset = $(this).offset();
		var spanwidth = $(this).width();
		$('body').append('
'+$(this).attr('data-tooltip')+'

');
		var w = $('#tip').width();
		var h = $('#tip').height();
		$('#tip').css({top: (offset.top-h-30)+'px',left: (offset.left+(spanwidth/2)-(w/2))+'px'});
		$('#tip .bubble').css({marginLeft: w/2-5+'px'});
	});
	$('.tooltip').live('mouseleave',function() { $('#tip').remove(); });
}

// Parse Contents to improve user experience
function parseContent() {
	// Check if tables in the content have a thead
	$('.region-content table').each(function() {
		if ($('thead',this).length == 0) { $(this).addClass('nothead');	}
	});
	// Count toggleboxes
	$('.toggle:first').addClass('first');
	$('.toggle:last').addClass('last');
}

function customiseReadMoreTextAndLinks(){

	// open meetingtool page on a new tab
	if (window.location.pathname == '/' ){
		$('ul.menu li').find('a[href*="meetingtool"]').attr({'target':'__blank'});
	}

	// hacking 'Read more' text for some pages
	var readMores = {
		'biomart': {
			'path': '/resources-and-services/access-emma-mouse-resources',
			'url': '/biomart/martview/',
			'label': 'Search EMMA Biomart',
			'title': 'Advanced BioMart search'
		},
		'submission': {
			'path': '/resources-and-services/deposit-mice-emma-repository',
			'url': '/emma/publicSubmission/submissionForm.emma',
			'label': 'Submit mice to EMMA',
			'title': 'Submission form'
		},
        	'meetings': {
			'path': '/infrafrontier-research-infrastructure/public-relations',
			'url': '/meetingtool',
			'label': 'Register to a meeting',
			'title': 'Meeting registration'
		},
	};
	for ( var i in readMores ){
		if ( window.location.pathname == readMores[i].path ){
			$('ul.menu li').find('a[href*="biomart/martview"]').attr({'target':'__blank', 'href': '/biomar/martview'});
		    	$('div.view-content div h3').find('a').each(function(){
		        	if ( $(this).text() == readMores[i].title ){
				    //resources-and-services/access-emma-mouse-resources/advanced-biomart-search
				    var url = readMores[i].url;
				    $(this).attr('href', url);
				    $(this).parent().siblings('p.more').find('a').text(readMores[i].label).attr({'href': url, 'target':'__blank'});
		       		}
		    	});

		   	$('ul.menu li').find('a[href*="meetingtool"]').attr({'target':'__blank'});
		}
	}

}
function hide_imprint_login_register(){
	$('div#tn').find('.hide_this').hide();
}
function do_NKI_cells_page() {
	if (window.location.pathname == '/resources-and-services/access-emma-mouse-resources/nki-gemm-esc-archive' ){
		// load NKI cells dataTable
		$('div.content').append("

");
		var url = fetch_url() + "?nki=true";

		$.get(url, function(data){
			var data = eval('(' + data + ')');

			$('div.content div.toggle.first .togglecontent').append(data.subTable);
			//$('div#nki').html(data.fullTable);

       		$('span.nkiShort').click(function(){

				if ( $(this).hasClass('display') ){
					$(this).removeClass('display');
					$(this).siblings('.nkiLong').addClass('display');
				}
			});
			$('span.nkiLong').click(function(){

				if ( $(this).hasClass('display') ){
					$(this).removeClass('display');
					$(this).siblings('.nkiShort').addClass('display');
				}
			});
		});
	}
}
function redirectLoggedInUserByRoles(){

	var oUser = Drupal.settings.infrafrontier.drupaluser;

	if (window.location.pathname == '/users/' + oUser.name){

		var aRoles = ['infrafrontier', 'Infrafrontier GmbH', 'Infrafrontier_I3', 'EMMA', 'InfraCoMP', 'emma_infra13', 'rome_meeting'];
		var oUser_roles = oUser.roles;

		// check user roles for page redirect
		for (var r in oUser_roles ){
			if ( inArray(oUser_roles[r], aRoles) ){
				window.location.href = "/internal";
				break;
			}
		}
	}
}
function inArray(item, list) {
    var length = list.length;
    for(var i = 0; i < length; i++) {
        if(list[i] == item){
			return true;
		}
    }
    return false;
}

$(document).ready(function() {

	initTabContent();
	initToggleContent();
	initSideNavi();
	initContentMargin();
	initSlider();
	initActions();
	initTooltips();
	parseContent();
	fixPlaceholder();
	customiseReadMoreTextAndLinks();
	hide_imprint_login_register();
	do_NKI_cells_page();
	redirectLoggedInUserByRoles();

	if ($('body').hasClass('front')) { autoHeightFront(); }

});

})(window.jQuery);
window.jQuery.noConflict();
<commit_msg>test role name<commit_after>(function($){

	if(typeof(window.EMMA) === 'undefined') {
            window.EMMA = {};
    }

    EMMA.sliderTimer = null;
    EMMA.logoSliderTimer = null;

// Fix Placeholder
function fixPlaceholder() {
	jQuery.support.placeholder = false;
	var test = document.createElement('input');
	if('placeholder' in test) jQuery.support.placeholder = true;
	if(!$.support.placeholder) {
		var active = document.activeElement;
		$('input,textarea').focus(function () {
			if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
				$(this).val('').removeClass('hasPlaceholder');
			}
		}).blur(function () {
			if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
				$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
			}
		});
		$('input,textarea').blur();
		$(active).focus();
		$('form').submit(function () { $(this).find('.hasPlaceholder').each(function() { $(this).val(''); }); });
	}
}

// Slider
function initSlider() {
	// Main Slider
	sliderFunction('.slidecontrol','slidecontainer','slide',638,8000);
	// Logoslider
	sliderFunction('#logoslidecontrols','logoslidercontainer','logoslide',960,16000);
}
function sliderFunction(controls,container,slide,width,interval) {

	$(controls+' div').click(function() {
		if ($(this).hasClass('prev')) {
			$('#'+container+' .'+slide+':last').detach().prependTo('#'+container);
			$('#'+container).animate({marginLeft: '-='+width+'px'},0);
			$('#'+container).animate({marginLeft: '+='+width+'px'},1000);
		} else {
			$('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
				$('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
				$('#'+container).animate({marginLeft: '+='+width+'px'},0);
			});
		}
	});

    // mouseover to stop sliding
    $('div#slider').mouseover(function(){
        clearInterval(EMMA.sliderTimer); // stops interval, ie, turn off sliding
    }).mouseout(function(){
        autoSlider('.slidecontrol','slidecontainer','slide',638, interval);
    });

    $('div#logoslider').mouseover(function(){
        clearInterval(EMMA.logoSliderTimer); // stops interval, ie, turn off sliding
    }).mouseout(function(){
        autoSlider('#logoslidecontrols','logoslidercontainer','logoslide',960, interval);
    });

    // auto slide in defined time interval for both slides and logos
    if ( slide == 'slide' ){
        autoSlider('.slidecontrol','slidecontainer','slide',638, interval);
    }
    else {
        autoSlider('#logoslidecontrols','logoslidercontainer','logoslide',960, interval);
    }
}
function autoSlider(controls,container,slide,width,interval){

    if (slide == 'slide' ){
        if(EMMA.sliderTimer){
            clearInterval(EMMA.sliderTimer);
        }
        EMMA.sliderTimer = setInterval(function() {
            $('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
		        $('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
		        $('#'+container).animate({marginLeft: '+='+width+'px'},0);
	        });
        }, interval);
    }
    else {
        if(EMMA.logoSliderTimer){
            clearInterval(EMMA.logoSliderTimer);
        }
        EMMA.logoSliderTimer = setInterval(function() {
            $('#'+container).animate({marginLeft: '-='+width+'px'},1000,function() {
		        $('#'+container+' .'+slide+':first').detach().appendTo('#'+container);
		        $('#'+container).animate({marginLeft: '+='+width+'px'},0);
	        });
        }, interval);
    }
}

// Sidenavi
function initSideNavi() {
	if (!$('html').hasClass('ie7')) {
		// Helper for sidenavi rollover
		$('#block-menu-block-2 .expanded > a').each(function() { $(this).prepend('

'); });
		$('.helpclicker').live('click',function(e) {
			e.preventDefault();
			$(this).closest('li').toggleClass('active-trail');
		});
		$('.helpclicker').live('mouseover mouseout',function(e) { $(this).closest('li').toggleClass('over'); });
		// Helper for toggling content elements
		$('.togglehead .helper').live('mouseover mouseout',function(e) { $(this).closest('.togglehead').toggleClass('over'); });
	}
}

// various actions
function initActions() {
	// Toggle help box on frontpage
	$('#togglehelp').click(function() { $('#stooltip').toggle(); });
	// Animated Scrolling to top
	$("#toplink").click(function(e){ e.preventDefault(); $('html,body').animate({scrollTop:0}, 1500); });
	// Kill .error when focusing a input field
	$('.error input').live('focus',function() {
		$(this).closest('.form-item').removeClass('error');
	});
}

// Tabcontent
function initTabContent() {
	if ($('.field-collection-item-field-tab').length > 0) {
		var container = $('.field-collection-item-field-tab').eq(0);
		$(container).before('

');
		$('.field-collection-item-field-tab').each(function() {
			var title = $('.title',this).text();
			$('#tabs ul').append('
'+title+'
');
			$('.title',this).remove();
		});
		$('#tabs a').live('click',function(e) {
			e.preventDefault();
			var index = $(this).index('#tabs a');
			$('#tabs a').removeClass('active');
			$(this).addClass('active');
			$('.field-collection-item-field-tab').hide();
			$('.field-collection-item-field-tab').eq(index).show();
		});
		$('#tabs a:first').trigger('click');
	}
}

// Togglebox
function initToggleContent() {
	$('.togglehead').live('click',function(e) {
		$(this).closest('.toggle').toggleClass('active');
		$(this).next('.togglecontent').toggle('fast');
	});
}

// Autoheight of boxes
function autoHeightFront() {
	var aboutHeight = $('#box-abouttext .boxcontent').innerHeight();
	var smallHeight = (aboutHeight - 105) / 2;
	$('#box-partnership .boxcontent').css('min-height',smallHeight+'px')
}

// Content margin, when no special Boxes inside the main node
function initContentMargin() {
	var headBox   = $('#block-system-main .node:first .head').length;
	var innerBoxes = $('#block-system-main .innerbox').length;
	var teaserBox = $('.view-subpages-teaser').length;
	if (teaserBox == 1 && innerBoxes == 0 && headBox == 0) {
		$('#block-system-main').addClass('margbottom');
	}
}

// span Tooltips
function initTooltips() {
	$('.tooltip').live('mouseenter',function(e) {
		var offset = $(this).offset();
		var spanwidth = $(this).width();
		$('body').append('
'+$(this).attr('data-tooltip')+'

');
		var w = $('#tip').width();
		var h = $('#tip').height();
		$('#tip').css({top: (offset.top-h-30)+'px',left: (offset.left+(spanwidth/2)-(w/2))+'px'});
		$('#tip .bubble').css({marginLeft: w/2-5+'px'});
	});
	$('.tooltip').live('mouseleave',function() { $('#tip').remove(); });
}

// Parse Contents to improve user experience
function parseContent() {
	// Check if tables in the content have a thead
	$('.region-content table').each(function() {
		if ($('thead',this).length == 0) { $(this).addClass('nothead');	}
	});
	// Count toggleboxes
	$('.toggle:first').addClass('first');
	$('.toggle:last').addClass('last');
}

function customiseReadMoreTextAndLinks(){

	// open meetingtool page on a new tab
	if (window.location.pathname == '/' ){
		$('ul.menu li').find('a[href*="meetingtool"]').attr({'target':'__blank'});
	}

	// hacking 'Read more' text for some pages
	var readMores = {
		'biomart': {
			'path': '/resources-and-services/access-emma-mouse-resources',
			'url': '/biomart/martview/',
			'label': 'Search EMMA Biomart',
			'title': 'Advanced BioMart search'
		},
		'submission': {
			'path': '/resources-and-services/deposit-mice-emma-repository',
			'url': '/emma/publicSubmission/submissionForm.emma',
			'label': 'Submit mice to EMMA',
			'title': 'Submission form'
		},
        	'meetings': {
			'path': '/infrafrontier-research-infrastructure/public-relations',
			'url': '/meetingtool',
			'label': 'Register to a meeting',
			'title': 'Meeting registration'
		},
	};
	for ( var i in readMores ){
		if ( window.location.pathname == readMores[i].path ){
			$('ul.menu li').find('a[href*="biomart/martview"]').attr({'target':'__blank', 'href': '/biomar/martview'});
		    	$('div.view-content div h3').find('a').each(function(){
		        	if ( $(this).text() == readMores[i].title ){
				    //resources-and-services/access-emma-mouse-resources/advanced-biomart-search
				    var url = readMores[i].url;
				    $(this).attr('href', url);
				    $(this).parent().siblings('p.more').find('a').text(readMores[i].label).attr({'href': url, 'target':'__blank'});
		       		}
		    	});

		   	$('ul.menu li').find('a[href*="meetingtool"]').attr({'target':'__blank'});
		}
	}

}
function hide_imprint_login_register(){
	$('div#tn').find('.hide_this').hide();
}
function do_NKI_cells_page() {
	if (window.location.pathname == '/resources-and-services/access-emma-mouse-resources/nki-gemm-esc-archive' ){
		// load NKI cells dataTable
		$('div.content').append("

");
		var url = fetch_url() + "?nki=true";

		$.get(url, function(data){
			var data = eval('(' + data + ')');

			$('div.content div.toggle.first .togglecontent').append(data.subTable);
			//$('div#nki').html(data.fullTable);

       		$('span.nkiShort').click(function(){

				if ( $(this).hasClass('display') ){
					$(this).removeClass('display');
					$(this).siblings('.nkiLong').addClass('display');
				}
			});
			$('span.nkiLong').click(function(){

				if ( $(this).hasClass('display') ){
					$(this).removeClass('display');
					$(this).siblings('.nkiShort').addClass('display');
				}
			});
		});
	}
}
function redirectLoggedInUserByRoles(){

	var oUser = Drupal.settings.infrafrontier.drupaluser;

	if (window.location.pathname == '/users/' + oUser.name){
		console.log(oUser);
		console.log(oUser.name + ' --- ' + oUser.roles);
		var aRoles = ['infrafrontier', 'Infrafrontier GmbH', 'Infrafrontier_I3', 'EMMA', 'InfraCoMP', 'emma_infra13', 'rome_meeting'];
		var oUser_roles = oUser.roles;

		// check user roles for page redirect
		for (var r in oUser_roles ){
			if ( inArray(oUser_roles[r], aRoles) ){
				window.location.href = "/internal";
				break;
			}
		}
	}
}
function inArray(item, list) {
    var length = list.length;
    for(var i = 0; i < length; i++) {
        if(list[i] == item){
			return true;
		}
    }
    return false;
}

$(document).ready(function() {

	initTabContent();
	initToggleContent();
	initSideNavi();
	initContentMargin();
	initSlider();
	initActions();
	initTooltips();
	parseContent();
	fixPlaceholder();
	customiseReadMoreTextAndLinks();
	hide_imprint_login_register();
	do_NKI_cells_page();
	redirectLoggedInUserByRoles();

	if ($('body').hasClass('front')) { autoHeightFront(); }

});

})(window.jQuery);
window.jQuery.noConflict();
<|endoftext|>


<commit_before>// Splash
var splash = ""
	+ "+----------------------------------------------------------------------\n"
	+ "|\n"
	+ "|              .___   SanctumWare Systems \n"
	+ "|            __| _/_______  _______ _______   ____ _____\n"
	+ "|           / __ |/ __ \\  \\/ /\\__  \\_  __ \\_/ __ \\__  \\\n"
	+ "|          / /_/ \\  ___/\\   /  / __ \\|  | \\/\\  ___/ / __ \\_\n"
	+ "|          \\____ |\\___  >\\_/  (____  /__|    \\___  >____  /\n"
	+ "|               \\/    \\/           \\/            \\/     \\/ .org\n"
	+ "|\n"
	+ "+----------------------------------------------------------------------\n";

var hasSplash = true;

// Details
var name = "SanctumWare Systems";
var loc = "Philippines";
var lookingfor = "";
var pdfLink = "http://en.wikipedia.org/wiki/R%C3%A9sum%C3%A9";

// Settings
var showForks = false; // Shows forks of repositories on Github

// Github and Bitbucket accounts
var githubUsername = "example";
var bitbucketUsername = "example";
var githubURL = "https://github.com/" + githubUsername;
var bitbucketURL = "https://bitbucket.org/" + bitbucketUsername;

// If left blank e.g. url = "" then it won't appear
var websiteURL = "http://www.example.com/";
var blogURL = "";
var portfolioURL = "";
var twitterURL = "https://twitter.com/";
var facebookURL = "https://facebook.com/";
var skypeAccount = "test";
var socialMedia = [["Github", githubURL], ["Bitbucket", bitbucketURL], ["Website", websiteURL],
	["Blog", blogURL], ["Portfolio", portfolioURL], ["Twitter", twitterURL], ["Facebook", facebookURL],
	["Skype", skypeAccount]];

// Education list
var education = [["South Hamptom Institute of Technology", "Master of Computers", "Graduate July, 2014"], ["School of Hard Knocks", "Bachelor of Life", "Graduate November, 2008"]];

// Employment list
var employment = [["Prestige Worldwide", "Beat Lab Technician", "November 2013 - Present"]];

// Volunteering list
var volunteering = [["Volunteer", "Voluntation", "November 2013 - Present"]];

// Awards list
var awards = [["Mad Coder", "Programmer Institute", "December 2013"]];

// Membership list
var membership = [["Some Society", "Pizza Box Opener"]];

// Skills list
var skillsLanguages = [["Proficient", "C/C++ Java Python"],
	["Experienced", "C# .NET"],
	["Familiar", "PHP Javascript Bash"]];

var skillsTools = [["Proficient", "Git Wordpress"],
	["Experienced", "Android Github"],
	["Familiar", "TCP/IP SVN"]];

var skillsConcepts = [["Proficient", "Kanban Agile"],
	["Experienced", "Functional Testing"],
	["Familiar", "Functional Programming"]];

var publicPGPkey = "\n"
//  + "fingerprint:	95FFF5095B4A658A972FD7BBEBAE73B2B11F25D4\n"
//  + "64-bit:	EBAE73B2B11F25D4\n"
//  + "curl/raw:	keybase.io/sanctumware/key.asc\n"
  + ";
<commit_msg>minor update<commit_after>// Splash
var splash = ""
	+ "+----------------------------------------------------------------------\n"
	+ "|\n"
	+ "|              .___   SanctumWare Systems \n"
	+ "|            __| _/_______  _______ _______   ____ _____\n"
	+ "|           / __ |/ __ \\  \\/ /\\__  \\_  __ \\_/ __ \\__  \\\n"
	+ "|          / /_/ \\  ___/\\   /  / __ \\|  | \\/\\  ___/ / __ \\_\n"
	+ "|          \\____ |\\___  >\\_/  (____  /__|    \\___  >____  /\n"
	+ "|               \\/    \\/           \\/            \\/     \\/ .org\n"
	+ "|\n"
	+ "+----------------------------------------------------------------------\n";

var hasSplash = true;

// Details
var name = "SanctumWare Systems";
var loc = "Philippines";
var lookingfor = "";
var pdfLink = "http://en.wikipedia.org/wiki/R%C3%A9sum%C3%A9";

// Settings
var showForks = false; // Shows forks of repositories on Github

// Github and Bitbucket accounts
var githubUsername = "example";
var bitbucketUsername = "example";
var githubURL = "https://github.com/" + githubUsername;
var bitbucketURL = "https://bitbucket.org/" + bitbucketUsername;

// If left blank e.g. url = "" then it won't appear
var websiteURL = "http://www.example.com/";
var blogURL = "";
var portfolioURL = "";
var twitterURL = "https://twitter.com/";
var facebookURL = "https://facebook.com/";
var skypeAccount = "test";
var socialMedia = [["Github", githubURL], ["Bitbucket", bitbucketURL], ["Website", websiteURL],
	["Blog", blogURL], ["Portfolio", portfolioURL], ["Twitter", twitterURL], ["Facebook", facebookURL],
	["Skype", skypeAccount]];

// Education list
var education = [["South Hamptom Institute of Technology", "Master of Computers", "Graduate July, 2014"], ["School of Hard Knocks", "Bachelor of Life", "Graduate November, 2008"]];

// Employment list
var employment = [["Prestige Worldwide", "Beat Lab Technician", "November 2013 - Present"]];

// Volunteering list
var volunteering = [["Volunteer", "Voluntation", "November 2013 - Present"]];

// Awards list
var awards = [["Mad Coder", "Programmer Institute", "December 2013"]];

// Membership list
var membership = [["Some Society", "Pizza Box Opener"]];

// Skills list
var skillsLanguages = [["Proficient", "C/C++ Java Python"],
	["Experienced", "C# .NET"],
	["Familiar", "PHP Javascript Bash"]];

var skillsTools = [["Proficient", "Git Wordpress"],
	["Experienced", "Android Github"],
	["Familiar", "TCP/IP SVN"]];

var skillsConcepts = [["Proficient", "Kanban Agile"],
	["Experienced", "Functional Testing"],
	["Familiar", "Functional Programming"]];

var publicPGPkey = "\n";
//  + "fingerprint:	95FFF5095B4A658A972FD7BBEBAE73B2B11F25D4\n"
//  + "64-bit:	EBAE73B2B11F25D4\n"
//  + "curl/raw:	keybase.io/sanctumware/key.asc\n"
//  + ";
<|endoftext|>


<commit_before>// ## draeton.github.com
//
// Site code for my personal site
// [http://draeton.github.com/draeton.github.com](http://draeton.github.com/draeton.github.com)
//
// Copyright 2011, Matthew Cobbs
// Licensed under the MIT license.
//
/*global jQuery*/
(function (window, $) {

    var document = window.document;

    var Draeton = function () {
        this.init();
    };

    Draeton.prototype = {
        init: function () {
            this.bindHandlers();
            this.initMenu();
        },

        bindHandlers: function () {
            var $search = $(".navbar form");

            // search form
            $search.on("click", "a.add-on", function () {
                $search.submit();
            });

            // tooltips
            if ($.fn.tooltip) {
                $('a[data-toggle="tooltip"]').tooltip();
            }
        },

        initMenu: function () {
            var href = document.location.href;

            $("ul.nav li > a").each(function () {
                if (this.href.replace(/[/#]+$/, "") === href.replace(/[/#]+$/, "")) {
                    $(this).parents("li").addClass("active");
                }
            });
        }
    };

    $(document).ready(function () {
        window.draeton = new Draeton();
    });

})(window, jQuery);<commit_msg> Fixing tooltips<commit_after>// ## draeton.github.com
//
// Site code for my personal site
// [http://draeton.github.com/draeton.github.com](http://draeton.github.com/draeton.github.com)
//
// Copyright 2011, Matthew Cobbs
// Licensed under the MIT license.
//
/*global jQuery*/
(function (window, $) {

    var document = window.document;

    var Draeton = function () {
        this.init();
    };

    Draeton.prototype = {
        init: function () {
            this.bindHandlers();
            this.initMenu();
        },

        bindHandlers: function () {
            var $search = $(".navbar form");

            // search form
            $search.on("click", "a.add-on", function () {
                $search.submit();
            });

            // tooltips
            if ($.fn.tooltip) {
                $('[data-toggle="tooltip"]').tooltip();
            }
        },

        initMenu: function () {
            var href = document.location.href;

            $("ul.nav li > a").each(function () {
                if (this.href.replace(/[/#]+$/, "") === href.replace(/[/#]+$/, "")) {
                    $(this).parents("li").addClass("active");
                }
            });
        }
    };

    $(document).ready(function () {
        window.draeton = new Draeton();
    });

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


<commit_before>
function Dungeon(scene, player, map) {
	var self = this;
	this.width = map.map[0].length;
	this.depth = map.map.length;
	this.mesh = undefined;
	this.monsters = [];
	this.objects = [];
	var dummy_material = new THREE.MeshBasicMaterial({color: 0x000000});

	map.gridSize *= UNIT;

	var materials = {};
	for (var tex in map.blocks) {
		if (!map.blocks.hasOwnProperty(tex)) continue;
		var floor_mat = map.blocks[tex].floor ? cache.getMaterial(map.blocks[tex].floor) : dummy_material;
		var wall_mat = map.blocks[tex].wall ? cache.getMaterial(map.blocks[tex].wall) : dummy_material;
		var ceiling_mat = map.blocks[tex].ceiling ? cache.getMaterial(map.blocks[tex].ceiling) : dummy_material;
		materials[tex] = [
			wall_mat, // right
			wall_mat, // left
			ceiling_mat, // top
			floor_mat, // bottom
			wall_mat, // back
			wall_mat  // front
		];
	}

	function getCell(x, z) {
		if (x < 0 || x >= map.map[0].length) return "#";
		else if (z < 0 || z >= map.map.length) return "#";
		return map.map[z][x];
	}

	function getObjectHandler(x, y, z, def) {
		return function(geom) {
			if (!def) def = {};
			var obj;
			if (def.collision) {
				var material = Physijs.createMaterial(
					geom.materials[0], 0.7, 0.2); // friction, restition
				if (def.collision == "plane")
					obj = new Physijs.PlaneMesh(geom, material, def.mass);
				else if (def.collision == "box")
					obj = new Physijs.BoxMesh(geom, material, def.mass);
				else if (def.collision == "sphere")
					obj = new Physijs.SphereMesh(geom, material, def.mass);
				else if (def.collision == "cylinder")
					obj = new Physijs.CylinderMesh(geom, material, def.mass);
				else if (def.collision == "cone")
					obj = new Physijs.ConeMesh(geom, material, def.mass);
				else if (def.collision == "convex")
					obj = new Physijs.ConvexMesh(geom, material, def.mass);
				else throw "Unsupported collision mesh type " + def.collision;
				self.objects.push(obj);
			} else {
				obj = new THREE.Mesh(geom, def.faceMaterial ? new THREE.MeshFaceMaterial() : geom.materials[0]);
			}
			// Auto-height
			if (y === null) {
				if (geom.boundingBox)
					y = 1.5 + 0.5 * (geom.boundingBox.max.y - geom.boundingBox.min.y) + 0.001;
				else if (geom.boundingSphere)
					y = geom.boundingSphere.radius + 0.001;
				else
					y = 0;
			}
			obj.position.set(x, y, z);
			if (!def.noShadows) {
				obj.castShadow = true;
				obj.receiveShadow = true;
			}
			scene.add(obj);
		};
	}

	function getBlockGeometry(materials, sides) {
		return function() {
			return new BlockGeometry(map.gridSize, map.roomHeight, map.gridSize,
				1, 1, 1, materials, sides);
		};
	}

	var cell, cell2, px, nx, pz, nz, py;
	var ambientLight = new THREE.AmbientLight(0xaaaaaa);
	scene.add(ambientLight);

	player.light = new THREE.PointLight(0x88bbff, 1, map.gridSize * 2);
	scene.add(player.light);
	player.shadow = new THREE.SpotLight(player.light.color, player.light.intensity, player.light.distance);
	player.shadow.angle = Math.PI / 4;
	player.shadow.onlyShadow = true;
	player.shadow.castShadow = true;
	player.shadow.shadowCameraNear = 0.1 * UNIT;
	player.shadow.shadowCameraFar = 10 * UNIT;
	player.shadow.shadowCameraFov = 60;
	player.shadow.shadowBias = -0.0002;
	player.shadow.shadowDarkness = 0.3;
	player.shadow.shadowMapWidth = 1024;
	player.shadow.shadowMapHeight = 1024;
	player.shadow.shadowCameraVisible = false;
	scene.add(player.shadow);

	// TODO: Set player rotation
	player.position.set(map.start[0] * map.gridSize, map.roomHeight, map.start[1] * map.gridSize);

	var geometry = new THREE.Geometry(), light, light2, light_body, obj;
	var sphere = new THREE.SphereGeometry(0.05 * UNIT, 16, 8);

	for (var z = 0; z < this.depth; z++) {
		for (var x = 0; x < this.width; x++) {
			px = nx = pz = nz = py = 0;
			cell = getCell(x, z);
			// TODO: Remove hard coded "#", determine wall from block definitions
			if (cell == "#") {
				cell2 = getCell(x + 1, z);
				px = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x - 1, z);
				nx = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x, z + 1);
				pz = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x, z - 1);
				nz = cell2 != "#" ? 1 : 0;
			} else {
				py = 1;
			}
			var sides = { px: px, nx: nx, py: py, ny: true, pz: pz, nz: nz };
			var cube = cache.getGeometry(cell + "-" + JSON.stringify(sides), getBlockGeometry(materials[cell], sides));
			this.mesh = new THREE.Mesh(cube);
			this.mesh.position.x = x * map.gridSize;
			this.mesh.position.y = map.roomHeight;
			this.mesh.position.z = z * map.gridSize;
			THREE.GeometryUtils.merge(geometry, this.mesh);
			// Collision body for walls
			if (cell == "#") {
				var wallbody = new Physijs.BoxMesh(cube, dummy_material, 0);
				wallbody.position.copy(this.mesh.position);
				wallbody.visible = false;
				scene.add(wallbody);
			}
			// Light
			if (cell == "*") {
				// Actual light
				light = new THREE.PointLight(0xffffaa, 1, 2 * map.gridSize);
				light.position.set(this.mesh.position.x, this.mesh.position.y + 1, this.mesh.position.z);
				scene.add(light);
				lightManager.addLight(light);
				// Shadow casting light
				light2 = new THREE.SpotLight(0xffffaa, light.intensity, light.distance);
				light2.position = light.position; //set(light.position.x, light.position.y, light.position.z);
				light2.target.position.set(light2.position.x, light2.position.y - 1, light2.position.z);
				light2.angle = Math.PI / 2;
				light2.castShadow = true;
				light2.onlyShadow = true;
				light2.shadowCameraNear = 0.1 * UNIT;
				light2.shadowCameraFar = 10 * UNIT;
				light2.shadowCameraFov = 100;
				light2.shadowBias = -0.0002;
				light2.shadowDarkness = 0.3;
				light2.shadowMapWidth = 256;
				light2.shadowMapHeight = 256;
				//light2.shadowCameraVisible = true;
				scene.add(light2);
				lightManager.addShadow(light2);
				// Debug body
				if (DEBUG) {
					light_body = new THREE.Mesh(sphere, new THREE.MeshBasicMaterial({ color: 0xffffaa }));
					light_body.position = light.position;
					scene.add(light_body);
				}
			// Objects
			} else if (map.objects[cell]) {
				obj = map.objects[cell];
				cache.loadModel("assets/models/" + obj.name + "/" + obj.name + ".js",
					getObjectHandler(x * map.gridSize, null, z * map.gridSize, obj));
			}
		}
	}
	geometry.computeTangents();
	this.mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial());
	this.mesh.castShadow = true;
	this.mesh.receiveShadow = true;
	scene.add(this.mesh);

	// Physics plane
	var ground_plane = new Physijs.BoxMesh(
		new THREE.CubeGeometry(map.gridSize * this.width, 1, map.gridSize * this.depth),
		Physijs.createMaterial(dummy_material, 0.9, 0.0), // friction, restitution
		0 // mass
	);
	ground_plane.position = new THREE.Vector3(map.gridSize * this.width * 0.5, 1, map.gridSize * this.depth * 0.5);
	ground_plane.visible = false;
	scene.add(ground_plane);

	// Weapon
	/*cache.loadModel("assets/models/knife/knife.js", function(geometry) {
		player.rhand = new THREE.Mesh(geometry, geometry.materials[0]);
		//player.rhand.castShadow = true;
		player.rhand.receiveShadow = true;
		scene.add(player.rhand);
	});*/

	// Items
	//cache.loadModel("assets/models/items/health.js",
	//	getObjectHandler(player.position.x, 2, player.position.z, { faceMaterial: true, noShadows: true }));
	//cache.loadModel("assets/models/items/mana.js",
	//	getObjectHandler(player.position.x + 1, 2, player.position.z, { faceMaterial: true, noShadows: true }));

	// Monster
	/*cache.loadModel("assets/models/shdw3/shdw3.js", function(geometry) {
		geometry.computeMorphNormals();
		var colorMap = geometry.morphColors[ 0 ];
		for (var i = 0; i < colorMap.colors.length; ++i) {
			geometry.faces[i].color = colorMap.colors[i];
		}

		var material = new THREE.MeshPhongMaterial({
			color: 0x222222, specular: 0xffffff, shininess: 10,
			morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors,
			shading: THREE.SmoothShading, perPixel: true
		});

		var monster = new Physijs.CylinderMesh(
			new THREE.CylinderGeometry(0.4 * UNIT, 0.4 * UNIT, 2 * UNIT),
			dummy_material, 100000
		);
		monster.visible = false;
		monster.position.set(player.position.x + 4, player.position.y - 0.8, player.position.z);
		self.monsters.push(monster);

		monster.mesh = new THREE.MorphAnimMesh(geometry, material);
		monster.mesh.speed = 0.4;
		monster.mesh.duration = 2000;
		monster.mesh.time = 600 * Math.random();
		monster.mesh.castShadow = true;
		monster.mesh.receiveShadow = true;
		monster.add(monster.mesh);
		scene.add(monster);
		monster.setAngularFactor({ x: 0, y: 0, z: 0 });
	});*/

}
<commit_msg>Sort out the y-coordinate hell.<commit_after>
function Dungeon(scene, player, map) {
	var self = this;
	this.width = map.map[0].length;
	this.depth = map.map.length;
	this.mesh = undefined;
	this.monsters = [];
	this.objects = [];
	var dummy_material = new THREE.MeshBasicMaterial({color: 0x000000});

	map.gridSize *= UNIT;

	var materials = {};
	for (var tex in map.blocks) {
		if (!map.blocks.hasOwnProperty(tex)) continue;
		var floor_mat = map.blocks[tex].floor ? cache.getMaterial(map.blocks[tex].floor) : dummy_material;
		var wall_mat = map.blocks[tex].wall ? cache.getMaterial(map.blocks[tex].wall) : dummy_material;
		var ceiling_mat = map.blocks[tex].ceiling ? cache.getMaterial(map.blocks[tex].ceiling) : dummy_material;
		materials[tex] = [
			wall_mat, // right
			wall_mat, // left
			ceiling_mat, // top
			floor_mat, // bottom
			wall_mat, // back
			wall_mat  // front
		];
	}

	function getCell(x, z) {
		if (x < 0 || x >= map.map[0].length) return "#";
		else if (z < 0 || z >= map.map.length) return "#";
		return map.map[z][x];
	}

	function getObjectHandler(x, y, z, def) {
		return function(geom) {
			if (!def) def = {};
			var obj;
			if (def.collision) {
				var material = Physijs.createMaterial(
					geom.materials[0], 0.7, 0.2); // friction, restition
				if (def.collision == "plane")
					obj = new Physijs.PlaneMesh(geom, material, def.mass);
				else if (def.collision == "box")
					obj = new Physijs.BoxMesh(geom, material, def.mass);
				else if (def.collision == "sphere")
					obj = new Physijs.SphereMesh(geom, material, def.mass);
				else if (def.collision == "cylinder")
					obj = new Physijs.CylinderMesh(geom, material, def.mass);
				else if (def.collision == "cone")
					obj = new Physijs.ConeMesh(geom, material, def.mass);
				else if (def.collision == "convex")
					obj = new Physijs.ConvexMesh(geom, material, def.mass);
				else throw "Unsupported collision mesh type " + def.collision;
				self.objects.push(obj);
			} else {
				obj = new THREE.Mesh(geom, def.faceMaterial ? new THREE.MeshFaceMaterial() : geom.materials[0]);
			}
			// Auto-height
			if (y === null) {
				if (!geom.boundingBox) geom.computeBoundingBox();
				y = 0.5 * (geom.boundingBox.max.y - geom.boundingBox.min.y) + 0.001;
			}
			obj.position.set(x, y, z);
			if (!def.noShadows) {
				obj.castShadow = true;
				obj.receiveShadow = true;
			}
			scene.add(obj);
		};
	}

	function getBlockGeometry(materials, sides) {
		return function() {
			return new BlockGeometry(map.gridSize, map.roomHeight, map.gridSize,
				1, 1, 1, materials, sides);
		};
	}

	var cell, cell2, px, nx, pz, nz, py;
	var ambientLight = new THREE.AmbientLight(0xaaaaaa);
	scene.add(ambientLight);

	player.light = new THREE.PointLight(0x88bbff, 1, map.gridSize * 2);
	scene.add(player.light);
	player.shadow = new THREE.SpotLight(player.light.color, player.light.intensity, player.light.distance);
	player.shadow.angle = Math.PI / 4;
	player.shadow.onlyShadow = true;
	player.shadow.castShadow = true;
	player.shadow.shadowCameraNear = 0.1 * UNIT;
	player.shadow.shadowCameraFar = 10 * UNIT;
	player.shadow.shadowCameraFov = 60;
	player.shadow.shadowBias = -0.0002;
	player.shadow.shadowDarkness = 0.3;
	player.shadow.shadowMapWidth = 1024;
	player.shadow.shadowMapHeight = 1024;
	player.shadow.shadowCameraVisible = false;
	scene.add(player.shadow);

	// TODO: Set player rotation
	player.geometry.computeBoundingBox();
	player.position.x = map.start[0] * map.gridSize;
	player.position.y = 0.5 * (player.geometry.boundingBox.max.y - player.geometry.boundingBox.min.y) + 0.001;
	player.position.z = map.start[1] * map.gridSize;

	var geometry = new THREE.Geometry(), light, light2, light_body, obj;
	var sphere = new THREE.SphereGeometry(0.05 * UNIT, 16, 8);

	for (var z = 0; z < this.depth; z++) {
		for (var x = 0; x < this.width; x++) {
			px = nx = pz = nz = py = 0;
			cell = getCell(x, z);
			// TODO: Remove hard coded "#", determine wall from block definitions
			if (cell == "#") {
				cell2 = getCell(x + 1, z);
				px = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x - 1, z);
				nx = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x, z + 1);
				pz = cell2 != "#" ? 1 : 0;
				cell2 = getCell(x, z - 1);
				nz = cell2 != "#" ? 1 : 0;
			} else {
				py = 1;
			}
			var sides = { px: px, nx: nx, py: py, ny: true, pz: pz, nz: nz };
			var cube = cache.getGeometry(cell + "-" + JSON.stringify(sides), getBlockGeometry(materials[cell], sides));
			this.mesh = new THREE.Mesh(cube);
			this.mesh.position.x = x * map.gridSize;
			this.mesh.position.y = 0.5 * map.roomHeight;
			this.mesh.position.z = z * map.gridSize;
			THREE.GeometryUtils.merge(geometry, this.mesh);
			// Collision body for walls
			if (cell == "#") {
				var wallbody = new Physijs.BoxMesh(cube, dummy_material, 0);
				wallbody.position.copy(this.mesh.position);
				wallbody.visible = false;
				scene.add(wallbody);
			}
			// Light
			if (cell == "*") {
				// Actual light
				light = new THREE.PointLight(0xffffaa, 1, 2 * map.gridSize);
				light.position.set(this.mesh.position.x, map.roomHeight - 0.5, this.mesh.position.z);
				scene.add(light);
				lightManager.addLight(light);
				// Shadow casting light
				light2 = new THREE.SpotLight(0xffffaa, light.intensity, light.distance);
				light2.position = light.position; //set(light.position.x, light.position.y, light.position.z);
				light2.target.position.set(light2.position.x, light2.position.y - 1, light2.position.z);
				light2.angle = Math.PI / 2;
				light2.castShadow = true;
				light2.onlyShadow = true;
				light2.shadowCameraNear = 0.1 * UNIT;
				light2.shadowCameraFar = 10 * UNIT;
				light2.shadowCameraFov = 100;
				light2.shadowBias = -0.0002;
				light2.shadowDarkness = 0.3;
				light2.shadowMapWidth = 256;
				light2.shadowMapHeight = 256;
				//light2.shadowCameraVisible = true;
				scene.add(light2);
				lightManager.addShadow(light2);
				// Debug body
				if (DEBUG) {
					light_body = new THREE.Mesh(sphere, new THREE.MeshBasicMaterial({ color: 0xffffaa }));
					light_body.position = light.position;
					scene.add(light_body);
				}
			// Objects
			} else if (map.objects[cell]) {
				obj = map.objects[cell];
				cache.loadModel("assets/models/" + obj.name + "/" + obj.name + ".js",
					getObjectHandler(x * map.gridSize, null, z * map.gridSize, obj));
			}
		}
	}
	geometry.computeTangents();
	this.mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial());
	this.mesh.castShadow = true;
	this.mesh.receiveShadow = true;
	scene.add(this.mesh);

	// Physics plane
	var ground_plane = new Physijs.BoxMesh(
		new THREE.CubeGeometry(map.gridSize * this.width, 1, map.gridSize * this.depth),
		Physijs.createMaterial(dummy_material, 0.9, 0.0), // friction, restitution
		0 // mass
	);
	ground_plane.position = new THREE.Vector3(map.gridSize * this.width * 0.5, -0.5, map.gridSize * this.depth * 0.5);
	ground_plane.visible = false;
	scene.add(ground_plane);

	// Weapon
	/*cache.loadModel("assets/models/knife/knife.js", function(geometry) {
		player.rhand = new THREE.Mesh(geometry, geometry.materials[0]);
		//player.rhand.castShadow = true;
		player.rhand.receiveShadow = true;
		scene.add(player.rhand);
	});*/

	// Items
	//cache.loadModel("assets/models/items/health.js",
	//	getObjectHandler(player.position.x, 2, player.position.z, { faceMaterial: true, noShadows: true }));
	//cache.loadModel("assets/models/items/mana.js",
	//	getObjectHandler(player.position.x + 1, 2, player.position.z, { faceMaterial: true, noShadows: true }));

	// Monster
	/*cache.loadModel("assets/models/shdw3/shdw3.js", function(geometry) {
		geometry.computeMorphNormals();
		var colorMap = geometry.morphColors[ 0 ];
		for (var i = 0; i < colorMap.colors.length; ++i) {
			geometry.faces[i].color = colorMap.colors[i];
		}

		var material = new THREE.MeshPhongMaterial({
			color: 0x222222, specular: 0xffffff, shininess: 10,
			morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors,
			shading: THREE.SmoothShading, perPixel: true
		});

		var monster = new Physijs.CylinderMesh(
			new THREE.CylinderGeometry(0.4 * UNIT, 0.4 * UNIT, 2 * UNIT),
			dummy_material, 100000
		);
		monster.visible = false;
		// TODO: Fix positioning
		monster.position.set(player.position.x + 4, player.position.y - 0.8, player.position.z);
		self.monsters.push(monster);

		monster.mesh = new THREE.MorphAnimMesh(geometry, material);
		monster.mesh.speed = 0.4;
		monster.mesh.duration = 2000;
		monster.mesh.time = 600 * Math.random();
		monster.mesh.castShadow = true;
		monster.mesh.receiveShadow = true;
		monster.add(monster.mesh);
		scene.add(monster);
		monster.setAngularFactor({ x: 0, y: 0, z: 0 });
	});*/

}
<|endoftext|>


<commit_before>// create a method that takes a parameter(string)
// turn string into individual characters that can be manipulated
// reverse the order of the characters
// turn back into a string
// display new string
//

function reverse(x) {
  return x.split('').reverse().join('');
}

reverse("Lucas")<commit_msg>added driver code to return the reverse word if an argument is met.<commit_after>// create a method that takes a parameter(string)
// turn string into individual characters that can be manipulated
// reverse the order of the characters
// turn back into a string
// display new string
//

function reverse(x) {
  return x.split('').reverse().join('');
}

// driver code

// to return reverse of x
console.log(reverse("Lucas"))

// to return the reverve
	if (0 == 0) {
	 console.log(reverse("Lucas"));
}	else {
		console.log ("Something is very wrong in the world");
}<|endoftext|>


<commit_before>import { makeBbox } from './utils';

export function happenedToday(change) {
    return change.neu && (
        new Date(change.neu.timestamp).toDateString() ===
        new Date().toDateString()
    );
}

export function userNotIgnored(change) {
    const ignore = ['bot-mode'];
    return (change.old && ignore.indexOf(change.old.user) === -1)
        || (change.neu && ignore.indexOf(change.neu.user) === -1);
}

export function wayLongEnough(change) {
    return (change.old && change.old.linestring && change.old.linestring.length > 4)
        || (change.neu && change.neu.linestring && change.neu.linestring.length > 4);
}

export function acceptableType(change) {
    return (change.old && change.old.type)
        || (change.neu && change.neu.type) !== 'relation';
}

export function withinBbox(change, bbox) {
    const c = change;
    const type = (c.old && c.old.type) || (c.neu && c.neu.type);
    let within = false;

    if (type == 'way') {
        const bbox_intersects_old = (c.old && c.old.bounds && bbox.intersects(makeBbox(c.old.bounds)));
        const bbox_intersects_new = (c.neu && c.neu.bounds && bbox.intersects(makeBbox(c.neu.bounds)));
        within = (bbox_intersects_old || bbox_intersects_new);
    } else if (type == 'node') {
        const bbox_contains_old = (c.old && c.old.lat && c.old.lon && bbox.contains(new L.LatLng(c.old.lat, c.old.lon)));
        const bbox_contains_new = (c.neu && c.neu.lat && c.neu.lon && bbox.contains(new L.LatLng(c.neu.lat, c.neu.lon)));
        within = (bbox_contains_old || bbox_contains_new);
    } else {
        console.error('no bbox check for this geometry type');
    }

    return within;
}

export function hasTags(change) {
    return (change.neu && Object.keys(change.neu.tags || {}).length > 0)
        || (change.old && Object.keys(change.old.tags || {}).length > 0);
}
<commit_msg>Fix bug that only allowed linestrings<commit_after>import { makeBbox } from './utils';

export function happenedToday(change) {
    return change.neu && (
        new Date(change.neu.timestamp).toDateString() ===
        new Date().toDateString()
    );
}

export function userNotIgnored(change) {
    const ignore = ['bot-mode'];
    return (change.old && ignore.indexOf(change.old.user) === -1)
        || (change.neu && ignore.indexOf(change.neu.user) === -1);
}

export function wayLongEnough(change) {
    const type = (change.old && change.old.type) || (change.neu && change.neu.type);
    if (type !== 'way') return true;

    return (change.old.linestring && change.old.linestring.length > 4)
        || (change.neu.linestring && change.neu.linestring.length > 4);
}

export function acceptableType(change) {
    return (change.old && change.old.type)
        || (change.neu && change.neu.type) !== 'relation';
}

export function withinBbox(change, bbox) {
    const c = change;
    const type = (c.old && c.old.type) || (c.neu && c.neu.type);
    let within = false;

    if (type == 'way') {
        const bbox_intersects_old = (c.old && c.old.bounds && bbox.intersects(makeBbox(c.old.bounds)));
        const bbox_intersects_new = (c.neu && c.neu.bounds && bbox.intersects(makeBbox(c.neu.bounds)));
        within = (bbox_intersects_old || bbox_intersects_new);
    } else if (type == 'node') {
        const bbox_contains_old = (c.old && c.old.lat && c.old.lon && bbox.contains(new L.LatLng(c.old.lat, c.old.lon)));
        const bbox_contains_new = (c.neu && c.neu.lat && c.neu.lon && bbox.contains(new L.LatLng(c.neu.lat, c.neu.lon)));
        within = (bbox_contains_old || bbox_contains_new);
    } else {
        console.error('no bbox check for this geometry type');
    }

    return within;
}

export function hasTags(change) {
    return (change.neu && Object.keys(change.neu.tags || {}).length > 0)
        || (change.old && Object.keys(change.old.tags || {}).length > 0);
}
<|endoftext|>


<commit_before><commit_msg>rm humcog album<commit_after><|endoftext|>


<commit_before>var canvas = document.getElementById("grav-canvas");
var ctx = canvas.getContext("2d");
var width = canvas.width;
var height = canvas.height;
var Speed = 2;
var MaxSize= 30;
var numGrav = 5;
var allParticles=[];
var gravConstant = 50;
var PI = 3.141592;
var maxSpeed = 10;
var maxDist =900;
var collisions=false;

function initializeGrav() {
    for (var i = 0; i < numGrav; i++) {
        var grav = new Object();
	grav.radius = Math.random() * MaxSize;
	grav.mass = Math.pow(grav.radius,2);
        grav.x = (Math.random() * (width-5))+5;
        grav.y = (Math.random() * (height-grav.radius))+grav.radius;
        grav.xSpeed = Math.random() * maxSpeed;
        grav.ySpeed = Math.random() * maxSpeed;
	allParticles.push(grav);
	grav.newYSpeed=grav.ySpeed;
	grav.newXSpeed=grav.xSpeed;
	grav.newY=grav.y;
	grav.newX=grav.x;
    }
}

function bounce(allParticles){
	for (var a = 0; a < allParticles.length; a++) {
		allParticles[a].newYSpeed=allParticles[a].ySpeed;
		allParticles[a].newXSpeed=allParticles[a].xSpeed;
		allParticles[a].newX=allParticles[a].x;
		allParticles[a].newY=allParticles[a].y;
		for (var b = 0; b < allParticles.length; b++) {
			var difX = (allParticles[a].x-allParticles[b].x);
			var difY = (allParticles[a].y-allParticles[b].y);
			var dist =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			var aAngle = 0;
			var bAngle = 0;
			var caAngle = 0;
			var difX2 = (allParticles[a].x-allParticles[b].x);
			var difY2 = (allParticles[a].y-allParticles[b].y);
			var dist2 =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			if(dist!=0&&dist<=(allParticles[a].radius+allParticles[b].radius)){
				var aSpeed = Math.sqrt(Math.pow(allParticles[a].xSpeed,2)+Math.pow(allParticles[a].ySpeed,2));
				var bSpeed = Math.sqrt(Math.pow(allParticles[b].xSpeed,2)+Math.pow(allParticles[b].ySpeed,2));
				while(bSpeed<=aSpeed&&dist2<(allParticles[a].radius+allParticles[b].radius)){
					difX2 = (allParticles[a].newX-allParticles[b].x);
					difY2 = (allParticles[a].newY-allParticles[b].y);
					dist2 =Math.sqrt((Math.pow(difX2,2)+Math.pow(difY2,2)));
					allParticles[a].newX=allParticles[a].newX-allParticles[a].xSpeed/10;
					allParticles[a].newY=allParticles[a].newY-allParticles[a].ySpeed/10;
				}
				aAngle = Math.atan2(allParticles[a].ySpeed,allParticles[a].xSpeed);
				bAngle = Math.atan2(allParticles[b].ySpeed,allParticles[b].xSpeed);
				caAngle = Math.atan2(difY,difX);
				caAngle += Math.PI/2;
				allParticles[a].newYSpeed=(((allParticles[a].ySpeed*(allParticles[a].mass-allParticles[b].mass))+(2*allParticles[b].mass*allParticles[b].ySpeed))/(allParticles[a].mass+allParticles[b].mass));
				allParticles[a].newXSpeed=(((allParticles[a].xSpeed*(allParticles[a].mass-allParticles[b].mass))+(2*allParticles[b].mass*allParticles[b].xSpeed))/(allParticles[a].mass+allParticles[b].mass));
			}
		}
	}
	for (var a = 0; a < allParticles.length; a++) {
		allParticles[a].x=allParticles[a].newX;
		allParticles[a].y=allParticles[a].newY;
		allParticles[a].xSpeed=allParticles[a].newXSpeed;
		allParticles[a].ySpeed=allParticles[a].newYSpeed;
	}
};

function moveGrav(){
	if(collisions){
		bounce(allParticles);
	}
	for (var x = 0; x < allParticles.length; x++) {
		for (var y = x; y < allParticles.length; y++) {
			var difX = (allParticles[x].x-allParticles[y].x);
			var difY = (allParticles[x].y-allParticles[y].y);
			var dist =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			if(dist>5&&dist<maxDist){
				allParticles[x].xSpeed-=(difX*allParticles[y].radius*gravConstant)/Math.pow(dist,3);
				allParticles[x].ySpeed-=(difY*allParticles[y].radius*gravConstant)/Math.pow(dist,3);
				allParticles[y].xSpeed+=(difX*allParticles[x].radius*gravConstant)/Math.pow(dist,3);
				allParticles[y].ySpeed+=(difY*allParticles[x].radius*gravConstant)/Math.pow(dist,3);
			}
		}
	}
	for (var x = 0; x < allParticles.length; x++) {
		if(allParticles[x].xSpeed>maxSpeed){
			allParticles[x].xSpeed=maxSpeed;
		}
		if(allParticles[x].ySpeed>maxSpeed){
			allParticles[x].ySpeed=maxSpeed;
		}
		allParticles[x].x+=allParticles[x].xSpeed;
		allParticles[x].y+=allParticles[x].ySpeed;
		if (allParticles[x].x >= canvas.width-(allParticles[x].radius/2)) {
			allParticles[x].xSpeed=-Math.abs(allParticles[x].xSpeed);
		}
		if(allParticles[x].x <= (allParticles[x].radius)){
			allParticles[x].xSpeed=Math.abs(allParticles[x].xSpeed);
		}
	        if (allParticles[x].y >= canvas.height-(allParticles[x].radius/2)) {
	        	allParticles[x].ySpeed = -Math.abs(allParticles[x].ySpeed);
		}
		if(allParticles[x].y <= (allParticles[x].radius)){
			allParticles[x].ySpeed = Math.abs(allParticles[x].ySpeed);
		}
	}
}

function drawGrav() {
    ctx.fillStyle = "rgba(255,255,255,.2)";
    ctx.fillRect(0, 0, canvas.width, canvas.height);
    for (var i = 0; i < allParticles.length; i++) {
        gravity = allParticles[i];
        ctx.beginPath();
        var colorString = 'rgb(0,0,255)';
        //ctx.fillStyle = colorString;
        ctx.strokeStyle = colorString;
        ctx.arc(gravity.x /*- (charge.radius)*/, gravity.y /*- (charge.radius)*/, gravity.radius, 0, 2 * PI);
        ctx.fill();
        ctx.stroke();
    }
    ctx.fillRect(0, 0, canvas.width, canvas.height);
}
initializeGrav();

$("#controls-submit").click(function() {
numGrav = $("#numparticles").val();
gravConstant = $("#gravstr").val();
collisions = $("#collisions").is(":checked");
allParticles = [];
initializeGrav();
});

function main() {
moveGrav();
drawGrav();
requestAnimationFrame(main);
};
requestAnimationFrame(main);
<commit_msg>refactored code<commit_after>var canvas = document.getElementById("grav-canvas");
var ctx = canvas.getContext("2d");
var width = canvas.width;
var height = canvas.height;
var Speed = 2;
var MaxSize= 30;
var numGrav = 5;
var allParticles=[];
var gravConstant = 50;
var PI = 3.141592;
var maxSpeed = 10;
var maxDist =900;
var collisions=false;

function initializeGrav() {
	for (var i = 0; i < numGrav; i++) {
		var grav = new Object();
		grav.radius = Math.random() * MaxSize;
		grav.mass = Math.pow(grav.radius,2);
		grav.location = new Object();
		grav.velocity = new Object();
		grav.newLocation = new Object();
		grav.newVelocity = new Object();
		grav.location.x = (Math.random() * (width-5))+5;
		grav.location.y = (Math.random() * (height-grav.radius))+grav.radius;
		grav.velocity.x = Math.random() * maxSpeed;
		grav.velocity.y = Math.random() * maxSpeed;
		allParticles.push(grav);
		grav.newVelocity.y=grav.velocity.y;
		grav.newVelocity.x=grav.velocity.x;
		grav.newLocation.y=grav.location.y;
		grav.newLocation.x=grav.location.x;
	}
}

function bounce(allParticles){
	for (var a = 0; a < allParticles.length; a++) {
		allParticles[a].newVelocity.y=allParticles[a].velocity.y;
		allParticles[a].newVelocity.x=allParticles[a].velocity.x;
		allParticles[a].newLocation.x=allParticles[a].location.x;
		allParticles[a].newLocation.y=allParticles[a].location.y;
		for (var b = 0; b < allParticles.length; b++) {
			var difX = (allParticles[a].location.x-allParticles[b].location.x);
			var difY = (allParticles[a].location.y-allParticles[b].location.y);
			var dist =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			var aAngle = 0;
			var bAngle = 0;
			var caAngle = 0;
			var difX2 = (allParticles[a].location.x-allParticles[b].location.x);
			var difY2 = (allParticles[a].location.y-allParticles[b].location.y);
			var dist2 =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			if(dist!=0&&dist<=(allParticles[a].radius+allParticles[b].radius)){
				var aSpeed = Math.sqrt(Math.pow(allParticles[a].velocity.x,2)+Math.pow(allParticles[a].velocity.y,2));
				var bSpeed = Math.sqrt(Math.pow(allParticles[b].velocity.x,2)+Math.pow(allParticles[b].velocity.y,2));
				while(bSpeed<=aSpeed&&dist2<(allParticles[a].radius+allParticles[b].radius)){
					difX2 = (allParticles[a].newLocation.x-allParticles[b].location.x);
					difY2 = (allParticles[a].newLocation.y-allParticles[b].location.y);
					dist2 =Math.sqrt((Math.pow(difX2,2)+Math.pow(difY2,2)));
					allParticles[a].newLocation.x=allParticles[a].newLocation.x-allParticles[a].velocity.x/10;
					allParticles[a].newLocation.y=allParticles[a].newLocation.y-allParticles[a].velocity.y/10;
				}
				aAngle = Math.atan2(allParticles[a].velocity.y,allParticles[a].velocity.x);
				bAngle = Math.atan2(allParticles[b].velocity.y,allParticles[b].velocity.x);
				caAngle = Math.atan2(difY,difX);
				caAngle += Math.PI/2;
				allParticles[a].newVelocity.y=(((allParticles[a].velocity.y*(allParticles[a].mass-allParticles[b].mass))+(2*allParticles[b].mass*allParticles[b].velocity.y))/(allParticles[a].mass+allParticles[b].mass));
				allParticles[a].newVelocity.x=(((allParticles[a].velocity.x*(allParticles[a].mass-allParticles[b].mass))+(2*allParticles[b].mass*allParticles[b].velocity.x))/(allParticles[a].mass+allParticles[b].mass));
			}
		}
	}
	for (var a = 0; a < allParticles.length; a++) {
		allParticles[a].location.x=allParticles[a].newLocation.x;
		allParticles[a].location.y=allParticles[a].newLocation.y;
		allParticles[a].velocity.x=allParticles[a].newVelocity.x;
		allParticles[a].velocity.y=allParticles[a].newVelocity.y;
	}
};

function moveGrav(){
	if(collisions){
		bounce(allParticles);
	}
	for (var x = 0; x < allParticles.length; x++) {
		for (var y = x; y < allParticles.length; y++) {
			var difX = (allParticles[x].location.x-allParticles[y].location.x);
			var difY = (allParticles[x].location.y-allParticles[y].location.y);
			var dist =Math.sqrt((Math.pow(difX,2)+Math.pow(difY,2)));
			if(dist>5&&dist<maxDist){
				allParticles[x].velocity.x-=(difX*allParticles[y].radius*gravConstant)/Math.pow(dist,3);
				allParticles[x].velocity.y-=(difY*allParticles[y].radius*gravConstant)/Math.pow(dist,3);
				allParticles[y].velocity.x+=(difX*allParticles[x].radius*gravConstant)/Math.pow(dist,3);
				allParticles[y].velocity.y+=(difY*allParticles[x].radius*gravConstant)/Math.pow(dist,3);
			}
		}
	}
	for (var x = 0; x < allParticles.length; x++) {
		if(allParticles[x].velocity.x>maxSpeed){
			allParticles[x].velocity.x=maxSpeed;
		}
		if(allParticles[x].velocity.y>maxSpeed){
			allParticles[x].velocity.y=maxSpeed;
		}
		allParticles[x].location.x+=allParticles[x].velocity.x;
		allParticles[x].location.y+=allParticles[x].velocity.y;
		if (allParticles[x].location.x >= canvas.width-(allParticles[x].radius/2)) {
			allParticles[x].velocity.x=-Math.abs(allParticles[x].velocity.x);
		}
		if(allParticles[x].location.x <= (allParticles[x].radius)){
			allParticles[x].velocity.x=Math.abs(allParticles[x].velocity.x);
		}
	        if (allParticles[x].location.y >= canvas.height-(allParticles[x].radius/2)) {
	        	allParticles[x].velocity.y = -Math.abs(allParticles[x].velocity.y);
		}
		if(allParticles[x].location.y <= (allParticles[x].radius)){
			allParticles[x].velocity.y = Math.abs(allParticles[x].velocity.y);
		}
	}
}

function drawGrav() {
	ctx.fillStyle = "rgba(255,255,255,.2)";
	ctx.fillRect(0, 0, canvas.width, canvas.height);
	for (var i = 0; i < allParticles.length; i++) {
		gravity = allParticles[i];
		ctx.beginPath();
		var colorString = 'rgb(0,0,255)';
		//ctx.fillStyle = colorString;
		ctx.strokeStyle = colorString;
		ctx.arc(gravity.location.x /*- (charge.radius)*/, gravity.location.y /*- (charge.radius)*/, gravity.radius, 0, 2 * PI);
		ctx.fill();
		ctx.stroke();
	}
	ctx.fillRect(0, 0, canvas.width, canvas.height);
}

initializeGrav();

$("#controls-submit").click(function() {
	numGrav = $("#numparticles").val();
	gravConstant = $("#gravstr").val();
	collisions = $("#collisions").is(":checked");
	allParticles = [];
	initializeGrav();
});

function main() {
	moveGrav();
	drawGrav();
	requestAnimationFrame(main);
};
requestAnimationFrame(main);
<|endoftext|>


<commit_before>/**
 * A Bot for Slack!
 */

/**
 * Define a function for initiating a conversation on installation
 * With custom integrations, we don't have a way to find out who installed us, so we can't message them :(
 */

function onInstallation(bot, installer) {
    if (installer) {
        bot.startPrivateConversation({user: installer}, function (err, convo) {
            if (err) {
                console.log(err);
            } else {
                convo.say("Hi there, I'm Taylor. I'm a bot that has just joined your team.");
                convo.say('You can now /invite me to a channel so that I can be of use!');
            }
        });
    }
}

// Create a fake http server to bind port
var PORT = (process.env.PORT || 5000)
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Server is running\n');
}).listen(PORT, function(){
    //Callback triggered when server is successfully listening. Hurray!
    console.log("Server listening on: http://localhost:%s", PORT);
});

/**
 * Configure the persistence options
 */

var config = {};
if (process.env.MONGOLAB_URI) {
    var BotkitStorage = require('botkit-storage-mongo');
    config = {
        storage: BotkitStorage({mongoUri: process.env.MONGOLAB_URI}),
    };
} else {
    config = {
        json_file_store: ((process.env.TOKEN)?'./db_taylor_ci/':'./db_slack_bot_a/'), //use a different name if an app or CI
    };
}

/**
 * Are being run as an app or a custom integration? The initialization will differ, depending
 */

if (process.env.TOKEN || process.env.SLACK_TOKEN) {
    //Treat this as a custom integration
    var customIntegration = require('./lib/custom_integrations');
    var token = (process.env.TOKEN) ? process.env.TOKEN : process.env.SLACK_TOKEN;
    var controller = customIntegration.configure(token, config, onInstallation);
} else if (process.env.CLIENT_ID && process.env.CLIENT_SECRET && process.env.PORT) {
    //Treat this as an app
    var app = require('./lib/apps');
    var controller = app.configure(process.env.PORT, process.env.CLIENT_ID, process.env.CLIENT_SECRET, config, onInstallation);
} else {
    console.log('Error: If this is a custom integration, please specify TOKEN in the environment. \
                  If this is an app, please specify CLIENTID, CLIENTSECRET, and PORT in the environment');
    process.exit(1);
}

/**
 * A demonstration for how to handle websocket events. In this case, just log when we have and have not
 * been disconnected from the websocket. In the future, it would be super awesome to be able to specify
 * a reconnect policy, and do reconnections automatically. In the meantime, we aren't going to attempt reconnects,
 * WHICH IS A B0RKED WAY TO HANDLE BEING DISCONNECTED. So we need to fix this.
 *
 * TODO: fixed b0rked reconnect behavior
 */
// Handle events related to the websocket connection to Slack
controller.on('rtm_open', function (bot) {
    console.log('** The RTM api just connected!');
});

controller.on('rtm_close', function (bot) {
    console.log('** The RTM api just closed');
    // you may want to attempt to re-open
});

/**
 * Core bot logic goes here!
 */
// BEGIN EDITING HERE!

controller.on('bot_channel_join', function (bot, message) {
    bot.reply(message, "I'm here!")
});

controller.hears(['hello','hi'],'direct_message,direct_mention,mention',function(bot, message) {

    bot.api.reactions.add({
        timestamp: message.ts,
        channel: message.channel,
        name: 'robot_face',
    },function(err, res) {
        if (err) {
            bot.botkit.log('Failed to add emoji reaction :(',err);
        }
    });

    controller.storage.users.get(message.user,function(err, user) {
        if (user && user.name) {
            bot.reply(message,'Hello ' + user.name + '!!');
        } else {
            bot.reply(message,'Hello.');
        }
    });
});

controller.hears(['call me (.*)'],'direct_message,direct_mention,mention',function(bot, message) {
    var matches = message.text.match(/call me (.*)/i);
    var name = matches[1];
    controller.storage.users.get(message.user,function(err, user) {
        if (!user) {
            user = {
                id: message.user,
            };
        }
        user.name = name;
        controller.storage.users.save(user,function(err, id) {
            bot.reply(message,'Got it. I will call you ' + user.name + ' from now on.');
        });
    });
});

controller.hears(['what is my name','who am i'],'direct_message,direct_mention,mention',function(bot, message) {

    controller.storage.users.get(message.user,function(err, user) {
        if (user && user.name) {
            bot.reply(message,'Your name is ' + user.name);
        } else {
            bot.reply(message,'I don\'t know yet!');
        }
    });
});

controller.hears(['shutdown'],'direct_message,direct_mention,mention',function(bot, message) {

    bot.startConversation(message,function(err, convo) {

        convo.ask('Are you sure you want me to shutdown?',[
            {
                pattern: bot.utterances.yes,
                callback: function(response, convo) {
                    convo.say('Bye!');
                    convo.next();
                    setTimeout(function() {
                        process.exit();
                    },3000);
                }
            },
        {
            pattern: bot.utterances.no,
            default: true,
            callback: function(response, convo) {
                convo.say('*Phew!*');
                convo.next();
            }
        }
        ]);
    });
});

controller.hears(['uptime','identify yourself',
                  'who are you','what is your name'],
                  'direct_message,direct_mention,mention',function(bot, message) {
    var uptime = formatUptime(process.uptime());
    bot.reply(message,':robot_face: I am <@' + bot.identity.name + '>. I have been running for ' + uptime + '.');
});

function formatUptime(uptime) {
    var unit = 'second';
    if (uptime > 60) {
        uptime = uptime / 60;
        unit = 'minute';
    }
    if (uptime > 60) {
        uptime = uptime / 60;
        unit = 'hour';
    }
    if (uptime != 1) {
        unit = unit + 's';
    }

    uptime = uptime + ' ' + unit;
    return uptime;
}

/**
API.ai integration for default case.
*/

var apiai = require('apiai');
var apiai_app = apiai(
  process.env.APIAI_ACC, process.env.APIAI_SUB
);
var apiai = require('apiai');
var apiai_app = apiai(
  process.env.APIAI_ACC, process.env.APIAI_SUB
);

// controller.hears(['(.*)'],'direct_message,direct_mention,mention',
//   function(bot, message) {
//     var apiai_request = apiai_app.textRequest(message.text);
//     console.log(message.text)
//     apiai_request.on('response', function(response) {
//         console.log(response.result.fulfillment.speech)
//         bot.reply(message,response.result.fulfillment.speech);
//     });
//     apiai_request.on('error', function(error) {
//       controller.storage.users.get(message.user,function(err, user) {
//           if (user && user.name) {
//               bot.reply(message,'Sorry, I don\'t understand that yet ' + user.name +'.');
//           } else {
//               bot.reply(message,'Sorry, I don\'t understand that yet.');
//           }
//       });
//     });
//     apiai_request.end();
//   }
// );
controller.hears(['.*'],['direct_message','direct_mention','mention', 'ambient'],
  function(bot,message) {
    console.log(message.text);
    if (message.type == "message") {
        if (message.user == bot.identity.id) {
            // message from bot can be skipped
        }
        else {
          bot.say(message, {"type": "typing"});
            var requestText = message.text;
            var request = apiai_app.textRequest(requestText);
            request.on('response', function (response) {
                console.log(response);
                if (response.result) {
                    var responseText = response.result.fulfillment.speech;
                    bot.startConversation(message, function(err,convo){
                        convo.say({"type": "typing"});
                        setTimeout(function(){},1000)
                        convo.say(responseText || "Sorry, I can't answer that right now :(");
                      }
                    );
                    // if (responseText) {
                    //     bot.reply(message, responseText);
                    // }
                }
            });
            request.on('error', function(error) {
              controller.storage.users.get(message.user,function(err, user) {
                  if (user && user.name) {
                      bot.reply(message,'Sorry, I don\'t understand that yet ' + user.name +'.');
                  } else {
                      bot.reply(message,'Sorry, I don\'t understand that yet.');
                  }
              });
            });
            request.end();
        }
    }
  }
);
<commit_msg>Add typing indicator<commit_after>/**
 * A Bot for Slack!
 */

/**
 * Define a function for initiating a conversation on installation
 * With custom integrations, we don't have a way to find out who installed us, so we can't message them :(
 */

function onInstallation(bot, installer) {
    if (installer) {
        bot.startPrivateConversation({user: installer}, function (err, convo) {
            if (err) {
                console.log(err);
            } else {
                convo.say("Hi there, I'm Taylor. I'm a bot that has just joined your team.");
                convo.say('You can now /invite me to a channel so that I can be of use!');
            }
        });
    }
}

// Create a fake http server to bind port
var PORT = (process.env.PORT || 5000)
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Server is running\n');
}).listen(PORT, function(){
    //Callback triggered when server is successfully listening. Hurray!
    console.log("Server listening on: http://localhost:%s", PORT);
});

/**
 * Configure the persistence options
 */

var config = {};
if (process.env.MONGOLAB_URI) {
    var BotkitStorage = require('botkit-storage-mongo');
    config = {
        storage: BotkitStorage({mongoUri: process.env.MONGOLAB_URI}),
    };
} else {
    config = {
        json_file_store: ((process.env.TOKEN)?'./db_taylor_ci/':'./db_slack_bot_a/'), //use a different name if an app or CI
    };
}

/**
 * Are being run as an app or a custom integration? The initialization will differ, depending
 */

if (process.env.TOKEN || process.env.SLACK_TOKEN) {
    //Treat this as a custom integration
    var customIntegration = require('./lib/custom_integrations');
    var token = (process.env.TOKEN) ? process.env.TOKEN : process.env.SLACK_TOKEN;
    var controller = customIntegration.configure(token, config, onInstallation);
} else if (process.env.CLIENT_ID && process.env.CLIENT_SECRET && process.env.PORT) {
    //Treat this as an app
    var app = require('./lib/apps');
    var controller = app.configure(process.env.PORT, process.env.CLIENT_ID, process.env.CLIENT_SECRET, config, onInstallation);
} else {
    console.log('Error: If this is a custom integration, please specify TOKEN in the environment. \
                  If this is an app, please specify CLIENTID, CLIENTSECRET, and PORT in the environment');
    process.exit(1);
}

/**
 * A demonstration for how to handle websocket events. In this case, just log when we have and have not
 * been disconnected from the websocket. In the future, it would be super awesome to be able to specify
 * a reconnect policy, and do reconnections automatically. In the meantime, we aren't going to attempt reconnects,
 * WHICH IS A B0RKED WAY TO HANDLE BEING DISCONNECTED. So we need to fix this.
 *
 * TODO: fixed b0rked reconnect behavior
 */
// Handle events related to the websocket connection to Slack
controller.on('rtm_open', function (bot) {
    console.log('** The RTM api just connected!');
});

controller.on('rtm_close', function (bot) {
    console.log('** The RTM api just closed');
    // you may want to attempt to re-open
});

/**
 * Core bot logic goes here!
 */
// BEGIN EDITING HERE!

controller.on('bot_channel_join', function (bot, message) {
    bot.reply(message, "I'm here!")
});

controller.hears(['hello','hi'],'direct_message,direct_mention,mention',function(bot, message) {

    bot.api.reactions.add({
        timestamp: message.ts,
        channel: message.channel,
        name: 'robot_face',
    },function(err, res) {
        if (err) {
            bot.botkit.log('Failed to add emoji reaction :(',err);
        }
    });

    controller.storage.users.get(message.user,function(err, user) {
        if (user && user.name) {
            bot.reply(message,'Hello ' + user.name + '!!');
        } else {
            bot.reply(message,'Hello.');
        }
    });
});

controller.hears(['call me (.*)'],'direct_message,direct_mention,mention',function(bot, message) {
    var matches = message.text.match(/call me (.*)/i);
    var name = matches[1];
    controller.storage.users.get(message.user,function(err, user) {
        if (!user) {
            user = {
                id: message.user,
            };
        }
        user.name = name;
        controller.storage.users.save(user,function(err, id) {
            bot.reply(message,'Got it. I will call you ' + user.name + ' from now on.');
        });
    });
});

controller.hears(['what is my name','who am i'],'direct_message,direct_mention,mention',function(bot, message) {

    controller.storage.users.get(message.user,function(err, user) {
        if (user && user.name) {
            bot.reply(message,'Your name is ' + user.name);
        } else {
            bot.reply(message,'I don\'t know yet!');
        }
    });
});

controller.hears(['shutdown'],'direct_message,direct_mention,mention',function(bot, message) {

    bot.startConversation(message,function(err, convo) {

        convo.ask('Are you sure you want me to shutdown?',[
            {
                pattern: bot.utterances.yes,
                callback: function(response, convo) {
                    convo.say('Bye!');
                    convo.next();
                    setTimeout(function() {
                        process.exit();
                    },3000);
                }
            },
        {
            pattern: bot.utterances.no,
            default: true,
            callback: function(response, convo) {
                convo.say('*Phew!*');
                convo.next();
            }
        }
        ]);
    });
});

controller.hears(['uptime','identify yourself',
                  'who are you','what is your name'],
                  'direct_message,direct_mention,mention',function(bot, message) {
    var uptime = formatUptime(process.uptime());
    bot.reply(message,':robot_face: I am <@' + bot.identity.name + '>. I have been running for ' + uptime + '.');
});

function formatUptime(uptime) {
    var unit = 'second';
    if (uptime > 60) {
        uptime = uptime / 60;
        unit = 'minute';
    }
    if (uptime > 60) {
        uptime = uptime / 60;
        unit = 'hour';
    }
    if (uptime != 1) {
        unit = unit + 's';
    }

    uptime = uptime + ' ' + unit;
    return uptime;
}

/**
API.ai integration for default case.
*/

var apiai = require('apiai');
var apiai_app = apiai(
  process.env.APIAI_ACC, process.env.APIAI_SUB
);
var apiai = require('apiai');
var apiai_app = apiai(
  process.env.APIAI_ACC, process.env.APIAI_SUB
);

// controller.hears(['(.*)'],'direct_message,direct_mention,mention',
//   function(bot, message) {
//     var apiai_request = apiai_app.textRequest(message.text);
//     console.log(message.text)
//     apiai_request.on('response', function(response) {
//         console.log(response.result.fulfillment.speech)
//         bot.reply(message,response.result.fulfillment.speech);
//     });
//     apiai_request.on('error', function(error) {
//       controller.storage.users.get(message.user,function(err, user) {
//           if (user && user.name) {
//               bot.reply(message,'Sorry, I don\'t understand that yet ' + user.name +'.');
//           } else {
//               bot.reply(message,'Sorry, I don\'t understand that yet.');
//           }
//       });
//     });
//     apiai_request.end();
//   }
// );
controller.hears(['.*'],['direct_message','direct_mention','mention', 'ambient'],
  function(bot,message) {
    console.log(message.text);
    if (message.type == "message") {
        if (message.user == bot.identity.id) {
            // message from bot can be skipped
        }
        else {
          bot.say(message, {"type": "typing"});
            var requestText = message.text;
            var request = apiai_app.textRequest(requestText);
            request.on('response', function (response) {
                console.log(response);
                if (response.result) {
                    var responseText = response.result.fulfillment.speech;
                    bot.replyWithTyping(message, responseText||"Sorry, I can't answer that right now :(" );
                }
            });
            request.on('error', function(error) {
              controller.storage.users.get(message.user,function(err, user) {
                  if (user && user.name) {
                      bot.reply(message,'Sorry, I don\'t understand that yet ' + user.name +'.');
                  } else {
                      bot.reply(message,'Sorry, I don\'t understand that yet.');
                  }
              });
            });
            request.end();
        }
    }
  }
);
<|endoftext|>


<commit_before>//
// Copyright (c) 2017 DrSmugleaf
//

// "use strict"
// const _ = require("underscore")
// const Discord = require("discord.js")
// const winston = require("winston")
//
// module.exports = class AutoChannel {
//   constructor(discord) {
//     this.discord = discord
//
//     this.channelName = (name) => `BB-${name}`
//     this.threshold = 2
//     this.games = new Discord.Collection()
//     this.previousGame = new Object()
//
//     this.discord.guilds.forEach((guild) => {
//       guild.presences.forEach((presence, id) => {
//         this.processPresence(guild, presence, id)
//       })
//       this.setupChannels(guild)
//     })
//
//     this.discord.on("presenceUpdate", (oldMember, newMember) => {
//       this.processPresence(newMember.guild, newMember.presence, newMember.id, true)
//     })
//
//     this.discord.on("voiceStateUpdate", (oldMember, newMember) => {
//       if(oldMember.voiceChannel === newMember.voiceChannel) return
//       this.processPresence(newMember.guild, newMember.presence, newMember.id, true)
//     })
//   }
//
//   processPresence(guild, presence, id, setup = false) {
//     if(!guild.member(guild.client.user).hasPermission("MANAGE_CHANNELS")) return
//     var guildGames = this.games.get(guild.id) || {}
//
//     if(presence.game && presence.game.name && presence.game.name !== this.previousGame[id]) {
//       if(!guildGames.hasOwnProperty(presence.game.name)) guildGames[presence.game.name] = []
//       if(!guildGames[presence.game.name].includes(id)) guildGames[presence.game.name].push(id)
//     } else {
//       if(this.previousGame[id]) {
//         winston.info(guildGames[this.previousGame[id]])
//         guildGames[this.previousGame[id]] = _.pull(guildGames[presence.game.name], id)
//         winston.info(guildGames[this.previousGame[id]])
//       }
//       this.previousGame[id] = null
//     }
//
//     this.games.set(guild.id, guildGames)
//     if(setup) this.setupChannels(guild)
//   }
//
//   setupChannels(guild) {
//     const guildGames = this.games.get(guild.id)
//
//     guild.channels.filter((channel) => {
//       return channel.name.includes("BB-") && channel.type === "voice"
//     }).forEach((channel) => {
//       const gameInObject = guildGames ? guildGames[channel.name.replace("BB-", "")] : null
//
//       if(channel.members.size < 1 && (!gameInObject || gameInObject.length < this.threshold)) {
//         if(channel) channel.delete().catch(winston.error)
//       }
//     })
//
//     if(!guildGames) return
//     for(const game in guildGames) {
//       if(guildGames.hasOwnProperty(game)) {
//         if(guildGames[game].length >= this.threshold && !guild.channels.exists((channel) => {
//           return channel.name === this.channelName(game) && channel.type === "voice"
//         })) {
//           guild.createChannel(this.channelName(game), "voice").catch(winston.error)
//         }
//       }
//     }
//   }
// }
<commit_msg>Cleanup<commit_after><|endoftext|>


<commit_before>// CKEditor TeXZilla Plugin
// Copyright (C) 2014  Raniere Silva
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

CKEDITOR.dialog.add('texzillaDialog', function( editor ) {
    return {
        title: 'TeXZilla Edit Box',
        minWidth: 300,
        minHeight: 300,
        contents: [
            {
                id: 'basic',
                label: 'Basic Settings',
                elements: [
                    {
                        id: 'tex',
                        type: 'textarea',
                        label: '(La)TeX code (Click outside the textarea to update the preview)',
                        setup: function(insertMode, element) {
                            if (!insertMode)
                                this.setValue(TeXZilla.getTeXSource(element.$));
                        },
                        onChange: function() {
                            var preview = document.getElementById('Preview');
                            // Clean previous preview
                            var previous = preview.childNodes;
                            for(i = 0; i < previous.length; i++) {
                                preview.removeChild(previous[i]);
                            }
                            var mathElement = TeXZilla.toMathML(this.getValue());

                            // Check for error
                            var has_error = false;
                            for (var i = 0; i < mathElement.lastElementChild.childElementCount; i++) {
                                if (mathElement.lastElementChild.children[i].localName === 'merror') {
                                    has_error = true;
                                }
                            }

                            var dialog = CKEDITOR.dialog.getCurrent();
                            // Disable button if errer
                            if (has_error === true) {
                                dialog.disableButton("ok");
                            }
                            else {
                                dialog.enableButton("ok");
                            }
                            preview.appendChild(mathElement);
                        }
                    },
                    {
                        id: 'display',
                        type: 'checkbox',
                        label: 'Display',
                        setup: function(insertMode, element) {
                            var display = element.getAttribute("display");
                            if (display === 'block') {
                                this.setValue(true);
                            }
                            else {
                                this.setValue(false);
                            }
                        }
                    },
                    {
                        id: 'direction',
                        type: 'checkbox',
                        label: 'RTL',
                        setup: function(insertMode, element) {
                            var direction = element.getAttribute("dir");
                            if (direction === 'rtl') {
                                this.setValue(true);
                            }
                            else {
                                this.setValue(false);
                            }
                        }
                    },
                    {
                        id: 'preview',
                        type: 'html',
                        label: 'Preview',
                        html: '

Preview:

',
                        setup: function(insertMode, element) {
                            var preview = document.getElementById('Preview');
                            // Clean previous preview
                            var previous = preview.childNodes;
                            for(i = 0; i < previous.length; i++) {
                                preview.removeChild(previous[i]);
                            }
                            if (!insertMode)
                                preview.appendChild(element.$.cloneNode(true));
                        }
                    }
                ]
            }
        ],
        onShow: function() {
            var selection = editor.getSelection();
            var element = selection.getStartElement();
            // Try to locate a `math` or `body` tag.
            while (element.getName() != 'math' &&
                    element.getName() != 'body') {
                element = element.getParent();
            }
            if (!element || element.getName() != 'math') {
                this.insertMode = true;
            }
            else {
                this.insertMode = false;
                this.mathRoot = element;
            }
            // invoke the setup functions for the element
            this.setupContent( this.insertMode, element );
        },
        onOk: function() {
          var dialog = this;

          // This is the better way to insert the MathML, although we got
          //
          //     TypeError: element.getName is not a function
          //
          // when using it.
          //
          // var mathElement = TeXZilla.toMathML(dialog.getValueOf('basic', 'tex'));

          // This is a hack found at
          // http://stackoverflow.com/a/17339275/1802726.
          var math = TeXZilla.toMathMLString(
                  dialog.getValueOf('basic', 'tex'),
                  dialog.getValueOf('basic', 'display'),
                  dialog.getValueOf('basic', 'direction'));
          var mathElement = CKEDITOR.dom.element.createFromHtml(math, editor.document);

          if(!this.insertMode) {
              // Remove old equation
              this.mathRoot.$.parentNode.removeChild(this.mathRoot.$);
          }
          editor.insertElement(mathElement);
        }
    };
} );
<commit_msg>Fix width from error message<commit_after>// CKEditor TeXZilla Plugin
// Copyright (C) 2014  Raniere Silva
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

CKEDITOR.dialog.add('texzillaDialog', function( editor ) {
    return {
        title: 'TeXZilla Edit Box',
        minWidth: 300,
        minHeight: 300,
        contents: [
            {
                id: 'basic',
                label: 'Basic Settings',
                elements: [
                    {
                        id: 'tex',
                        type: 'textarea',
                        label: '(La)TeX code (Click outside the textarea to update the preview)',
                        setup: function(insertMode, element) {
                            if (!insertMode)
                                this.setValue(TeXZilla.getTeXSource(element.$));
                        },
                        onChange: function() {
                            var preview = document.getElementById('Preview');
                            // Clean previous preview
                            var previous = preview.childNodes;
                            for(i = 0; i < previous.length; i++) {
                                preview.removeChild(previous[i]);
                            }
                            var mathElement = TeXZilla.toMathML(this.getValue());

                            // Check for error
                            var has_error = false;
                            for (var i = 0; i < mathElement.lastElementChild.childElementCount; i++) {
                                if (mathElement.lastElementChild.children[i].localName === 'merror') {
                                    has_error = true;
                                }
                            }

                            var dialog = CKEDITOR.dialog.getCurrent();
                            // Disable button if errer
                            if (has_error === true) {
                                dialog.disableButton("ok");
                            }
                            else {
                                dialog.enableButton("ok");
                            }
                            preview.appendChild(mathElement);
                        }
                    },
                    {
                        id: 'display',
                        type: 'checkbox',
                        label: 'Display',
                        setup: function(insertMode, element) {
                            var display = element.getAttribute("display");
                            if (display === 'block') {
                                this.setValue(true);
                            }
                            else {
                                this.setValue(false);
                            }
                        }
                    },
                    {
                        id: 'direction',
                        type: 'checkbox',
                        label: 'RTL',
                        setup: function(insertMode, element) {
                            var direction = element.getAttribute("dir");
                            if (direction === 'rtl') {
                                this.setValue(true);
                            }
                            else {
                                this.setValue(false);
                            }
                        }
                    },
                    {
                        id: 'preview',
                        type: 'html',
                        label: 'Preview',
                        // Width of the preview box is based on the minWidth of the dialog window.
                        html: '

Preview:

',
                        setup: function(insertMode, element) {
                            var preview = document.getElementById('Preview');
                            // Clean previous preview
                            var previous = preview.childNodes;
                            for(i = 0; i < previous.length; i++) {
                                preview.removeChild(previous[i]);
                            }
                            if (!insertMode)
                                preview.appendChild(element.$.cloneNode(true));
                        }
                    }
                ]
            }
        ],
        onShow: function() {
            var selection = editor.getSelection();
            var element = selection.getStartElement();
            // Try to locate a `math` or `body` tag.
            while (element.getName() != 'math' &&
                    element.getName() != 'body') {
                element = element.getParent();
            }
            if (!element || element.getName() != 'math') {
                this.insertMode = true;
            }
            else {
                this.insertMode = false;
                this.mathRoot = element;
            }
            // invoke the setup functions for the element
            this.setupContent( this.insertMode, element );
        },
        onOk: function() {
          var dialog = this;

          // This is the better way to insert the MathML, although we got
          //
          //     TypeError: element.getName is not a function
          //
          // when using it.
          //
          // var mathElement = TeXZilla.toMathML(dialog.getValueOf('basic', 'tex'));

          // This is a hack found at
          // http://stackoverflow.com/a/17339275/1802726.
          var math = TeXZilla.toMathMLString(
                  dialog.getValueOf('basic', 'tex'),
                  dialog.getValueOf('basic', 'display'),
                  dialog.getValueOf('basic', 'direction'));
          var mathElement = CKEDITOR.dom.element.createFromHtml(math, editor.document);

          if(!this.insertMode) {
              // Remove old equation
              this.mathRoot.$.parentNode.removeChild(this.mathRoot.$);
          }
          editor.insertElement(mathElement);
        }
    };
} );
<|endoftext|>