<commit_before>/**
 * jQuery Noty Plugin v0.1
 * Authors: Nedim Arabacı (http://ned.im), Muhittin Özer (http://muhittinozer.com)
 *
 * http://needim.github.com/noty/
 *
 * Licensed under the MIT licenses:
 * http://www.opensource.org/licenses/mit-license.php
 *
 **/
(function($) {
	$.noty = function(options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		base.init = function() {

			base.options = $.extend({}, $.noty.defaultOptions, options);

			// Push notification to queue
			if (base.options.layout != 'topLeft' && base.options.layout != 'topRight') {
				if (base.options.force) {
					$.noty.queue.unshift({options: base.options});
				} else {
					$.noty.queue.push({options: base.options});
				}

				base.render();
				$.noty.available = false;

			} else {
				$.noty.available = true;
				base.render({options: base.options});
			}

		};

		// Render the queue
		base.render = function(noty) {

			if ($.noty.available) {

				// Get noty from queue
				var notification = (jQuery.type(noty) === 'object') ? noty : $.noty.queue.shift();

				if (jQuery.type(notification) === 'object') {

					// Layout spesific container settings
					if (notification.options.layout == "topLeft" || notification.options.layout == "topRight") {
						if ($("ul.noty_container."+notification.options.layout).length > 0) {
							base.$noty_container = $("ul.noty_container."+notification.options.layout);
						} else {
							base.$noty_container = $('<ul/>').addClass('noty_container').addClass(notification.options.layout);
							$("body").prepend(base.$noty_container);
						}
						base.$notyContainer = $('<li/>');
						base.$noty_container.prepend(base.$notyContainer);

					} else {
						base.$notyContainer = $("body");
					}

					base.$bar 		= $('<div/>').addClass('noty_bar');
					base.$message = $('<div/>').addClass('noty_message');
					base.$close 	= $('<div/>').addClass('noty_close');

					base.$bar.append(base.$message).append(base.$close);

					var $noty = base.$bar;
					$noty.data('noty_options', notification.options);

					// Basic layout settings
					$noty.addClass(notification.options.layout).addClass(notification.options.type);

					// Message and style settings
					$noty.find('.noty_message').html(notification.options.text).css({textAlign: notification.options.textAlign});

					// Closable option
					(notification.options.closable) ? $noty.find('.noty_close').show() : $noty.find('.noty_close').remove();

					// Bind close event to button
					$noty.find('.noty_close').bind('click', function() { $noty.trigger('noty.close'); });

					// Close on self click
					if (notification.options.closeOnSelfClick && notification.options.closable) {
						$noty.bind('click', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer');
					}

					// is Modal?
					if (notification.options.modal) {
						$('<div />').addClass('noty_modal').prependTo($('body')).css(notification.options.modalCss).fadeIn('fast');
					}

					// Prepend noty to container
					base.$notyContainer.prepend($noty);

					// Bind close event
					$noty.one('noty.close', function(event, callback) {
						var options = $noty.data('noty_options');
						$noty.stop().animate(
								$noty.data('noty_options').animateClose,
								$noty.data('noty_options').speed,
								$noty.data('noty_options').easing,
								$noty.data('noty_options').onClose)
						.promise().done(function() {

							// Layout spesific cleaning
							if (options.layout == 'topLeft' || options.layout == 'topRight') {
								$noty.parent().remove();
							} else {
								$noty.remove();
							}

							// Modal Cleaning
							if (options.modal) {
								$('.noty_modal').fadeOut('fast', function() { $(this).remove(); });
							}

							// Are we have a callback function?
							if ($.isFunction(callback)) {
								callback.apply();
							}

							// queue render
							if (options.layout != 'topLeft' && options.layout != 'topRight') {
								$.noty.available = true;
								base.render();
							}
						});
					});

					// Set buttons if available
					if (notification.options.buttons) {
						$buttons = $('<div/>').addClass('noty_buttons');
						$noty.find('.noty_message').append($buttons);

						$.each(notification.options.buttons, function(i, button) {
							bclass = (button.type) ? button.type : 'gray';
							$('<button/>').addClass(bclass).html(button.text).appendTo($noty.find('.noty_buttons')).one("click", function() { $noty.trigger('noty.close', button.click); });
						});
					}

					// Start the show
					$noty.animate(
							notification.options.animateOpen,
							notification.options.speed,
							notification.options.easing,
							notification.options.onShow);

					// If noty is have a timeout option
					if (notification.options.timeout) {
						$noty.delay(notification.options.timeout).promise().done(function() { $noty.trigger('noty.close'); });
					}

				}

			}
		};

		// Run initializer
		base.init();
	};

	$.noty.queue = [];

	$.noty.clearQueue = function () {
		$.noty.queue = [];
	};

	$.noty.close = function () {
		$('.noty_bar:first').trigger('noty.close');
	};

	$.noty.closeAll = function () {
		$.noty.clearQueue();
		$('.noty_bar').trigger('noty.close');
	};

	$.noty.available = true;
	$.noty.defaultOptions = {
		layout : "top",
		animateOpen : {height: 'toggle'},
		animateClose : {height: 'toggle'},
		easing : 'swing',
		text : "null",
		textAlign : "center",
		type : "alert",
		speed : 500,
		timeout : 5000,
		closable : true,
		closeOnSelfClick : true,
		force : false,
		onShow : false,
		onClose : false,
		buttons : false,
		modal : false,
		modalCss : {'opacity': 0.6}
	};

	$.fn.noty = function(options) {
		return new $.noty(options);
	};

})(jQuery);

// Helper
function noty(options) {
	$.fn.noty(options);
}<commit_msg>Fixes #6 - Modal flicker with the confirm alert<commit_after>/**
 * jQuery Noty Plugin v0.1
 * Authors: Nedim Arabacı (http://ned.im), Muhittin Özer (http://muhittinozer.com)
 *
 * http://needim.github.com/noty/
 *
 * Licensed under the MIT licenses:
 * http://www.opensource.org/licenses/mit-license.php
 *
 **/
(function($) {
	$.noty = function(options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		base.init = function() {

			base.options = $.extend({}, $.noty.defaultOptions, options);

			// Push notification to queue
			if (base.options.layout != 'topLeft' && base.options.layout != 'topRight') {
				if (base.options.force) {
					$.noty.queue.unshift({options: base.options});
				} else {
					$.noty.queue.push({options: base.options});
				}

				base.render();
				$.noty.available = false;

			} else {
				$.noty.available = true;
				base.render({options: base.options});
			}

		};

		// Render the queue
		base.render = function(noty) {

			if ($.noty.available) {

				// Get noty from queue
				var notification = (jQuery.type(noty) === 'object') ? noty : $.noty.queue.shift();

				if (jQuery.type(notification) === 'object') {

					// Layout spesific container settings
					if (notification.options.layout == "topLeft" || notification.options.layout == "topRight") {
						if ($("ul.noty_container."+notification.options.layout).length > 0) {
							base.$noty_container = $("ul.noty_container."+notification.options.layout);
						} else {
							base.$noty_container = $('<ul/>').addClass('noty_container').addClass(notification.options.layout);
							$("body").prepend(base.$noty_container);
						}
						base.$notyContainer = $('<li/>');
						base.$noty_container.prepend(base.$notyContainer);

					} else {
						base.$notyContainer = $("body");
					}

					base.$bar 		= $('<div/>').addClass('noty_bar');
					base.$message = $('<div/>').addClass('noty_message');
					base.$close 	= $('<div/>').addClass('noty_close');

					base.$bar.append(base.$message).append(base.$close);

					var $noty = base.$bar;
					$noty.data('noty_options', notification.options);

					// Basic layout settings
					$noty.addClass(notification.options.layout).addClass(notification.options.type);

					// Message and style settings
					$noty.find('.noty_message').html(notification.options.text).css({textAlign: notification.options.textAlign});

					// Closable option
					(notification.options.closable) ? $noty.find('.noty_close').show() : $noty.find('.noty_close').remove();

					// Bind close event to button
					$noty.find('.noty_close').bind('click', function() { $noty.trigger('noty.close'); });

					// Close on self click
					if (notification.options.closeOnSelfClick && notification.options.closable) {
						$noty.bind('click', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer');
					}

					// is Modal?
					if (notification.options.modal) {
						$('<div />').addClass('noty_modal').prependTo($('body')).css(notification.options.modalCss).fadeIn('fast');
					}

					// Prepend noty to container
					base.$notyContainer.prepend($noty);

					// Bind close event
					$noty.one('noty.close', function(event, callback) {
						var options = $noty.data('noty_options');

						// Modal Cleaning
						if (options.modal) {
							$('.noty_modal').fadeOut('fast', function() { $(this).remove(); });
						}

						$noty.stop().animate(
								$noty.data('noty_options').animateClose,
								$noty.data('noty_options').speed,
								$noty.data('noty_options').easing,
								$noty.data('noty_options').onClose)
						.promise().done(function() {

							// Layout spesific cleaning
							if (options.layout == 'topLeft' || options.layout == 'topRight') {
								$noty.parent().remove();
							} else {
								$noty.remove();
							}

							// Are we have a callback function?
							if ($.isFunction(callback)) {
								callback.apply();
							}

							// queue render
							if (options.layout != 'topLeft' && options.layout != 'topRight') {
								$.noty.available = true;
								base.render();
							}
						});
					});

					// Set buttons if available
					if (notification.options.buttons) {
						$buttons = $('<div/>').addClass('noty_buttons');
						$noty.find('.noty_message').append($buttons);

						$.each(notification.options.buttons, function(i, button) {
							bclass = (button.type) ? button.type : 'gray';
							$('<button/>').addClass(bclass).html(button.text).appendTo($noty.find('.noty_buttons')).one("click", function() { $noty.trigger('noty.close', button.click); });
						});
					}

					// Start the show
					$noty.animate(
							notification.options.animateOpen,
							notification.options.speed,
							notification.options.easing,
							notification.options.onShow);

					// If noty is have a timeout option
					if (notification.options.timeout) {
						$noty.delay(notification.options.timeout).promise().done(function() { $noty.trigger('noty.close'); });
					}

				}

			}
		};

		// Run initializer
		base.init();
	};

	$.noty.queue = [];

	$.noty.clearQueue = function () {
		$.noty.queue = [];
	};

	$.noty.close = function () {
		$('.noty_bar:first').trigger('noty.close');
	};

	$.noty.closeAll = function () {
		$.noty.clearQueue();
		$('.noty_bar').trigger('noty.close');
	};

	$.noty.available = true;
	$.noty.defaultOptions = {
		layout : "top",
		animateOpen : {height: 'toggle'},
		animateClose : {height: 'toggle'},
		easing : 'swing',
		text : "null",
		textAlign : "center",
		type : "alert",
		speed : 500,
		timeout : 5000,
		closable : true,
		closeOnSelfClick : true,
		force : false,
		onShow : false,
		onClose : false,
		buttons : false,
		modal : false,
		modalCss : {'opacity': 0.6}
	};

	$.fn.noty = function(options) {
		return new $.noty(options);
	};

})(jQuery);

// Helper
function noty(options) {
	$.fn.noty(options);
}<|endoftext|>


<commit_before>/*
 * QuickBlox JavaScript SDK
 *
 * QuickBlox Utilities
 *
 */

// Browserify exports and dependencies
var config = require('./qbConfig');

exports.randomNonce = function() {
  return Math.round(Math.random() * 10000);
};

exports.unixTime = function() {
  return Math.round(Date.now() / 1000);
};

exports.getUrl = function(base, id) {
  var protocol = config.ssl ? 'https://' : 'http://';
  var resource = id ? '/' + id : '';
  return protocol + config.endpoints.api + '/' + base + resource + config.urls.type;
};
<commit_msg>Round to the floor<commit_after>/*
 * QuickBlox JavaScript SDK
 *
 * QuickBlox Utilities
 *
 */

// Browserify exports and dependencies
var config = require('./qbConfig');

exports.randomNonce = function() {
  return Math.floor(Math.random() * 10000);
};

exports.unixTime = function() {
  return Math.floor(Date.now() / 1000);
};

exports.getUrl = function(base, id) {
  var protocol = config.ssl ? 'https://' : 'http://';
  var resource = id ? '/' + id : '';
  return protocol + config.endpoints.api + '/' + base + resource + config.urls.type;
};
<|endoftext|>


<commit_before>if(typeof Merquery == "undefined" ) {
    Merquery = {};
}

Merquery.Queries = {
    //StandardQuery takes the fieldValue and fieldName and runs another query
    //parameters: {var fieldValue, var fieldName}
    standardQuery: function(fieldValue, fieldName, limit, callback) {
        var formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(fieldName);

        var request = gapi.client.bigquery.jobs.query({
            'projectId': project_id,
            'timeoutMs': '30000',
            /* v1.0 query for old database */
            //'query': 'SELECT * FROM [formal-cascade-571:uci.uci_db] where ' + fieldName + ' like "' + fieldValue + '" Limit ' + selText + ';'

            /* v2.0 Full query format using new database but some searches don't come through therefore commented some out
             * feel free to play around with them and adjust as needed */
            'query': 'SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
                'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
                'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
                'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
                'Campaign.click_count, Campaign.conversion_count ' +

                'FROM (SELECT * FROM [formal-cascade-571:uci.demo_info]) AS Demographics ' +
                'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.address_info]) AS Address ON Address.emailmd5 = Demographics.emailmd5 ' +
                'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 ' +

                'where ' + formattedFieldName + ' like "' + fieldValue +

                '" GROUP BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
                'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
                'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
                'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
                'Campaign.click_count, Campaign.conversion_count ' +

                'ORDER BY Demographics.emailmd5 Limit ' + limit + ';'

        });
        request.execute(callback || Merquery.renderResults);
    },

    //PopUpQuery takes the fieldValue and fieldName and runs another query
    //parameters: {var fieldValue, var fieldName}
    popupQuery: function(fieldValue, fieldName) {
        var formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(fieldName);

        var request = gapi.client.bigquery.jobs.query({
            'projectId': project_id,
            'timeoutMs': '30000',
            /* v1.0 query for old database */
            //'query': 'SELECT * FROM [formal-cascade-571:uci.uci_db] where ' + fieldName + ' like "' + fieldValue + '" Limit ' + selText + ';'

            /* v2.0 Full query format using new database but some searches don't come through therefore commented some out
             * feel free to play around with them and adjust as needed */

            'query': 'SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
            'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
            'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
            'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
            'Campaign.click_count, Campaign.conversion_count ' +

            'FROM (SELECT * FROM [formal-cascade-571:uci.demo_info]) AS Demographics ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.address_info]) AS Address ON Address.emailmd5 = Demographics.emailmd5 ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 ' +

            'where ' + formattedFieldName + ' like "' + fieldValue +

            '" GROUP BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
            'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
            'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
            'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
            'Campaign.click_count, Campaign.conversion_count ' +

            'ORDER BY Demographics.emailmd5 Limit ' + "20" + ';'
        });

        request.execute(Merquery.Popup.renderPopUp);

    },

    //Runs the query when the search button is clicked
    runQuery: function(userInputs) {
        //Merquery.Queries.createQueryArray();

        // For loading indicator
        Merquery.hideNav();
        Merquery.showLoad();
        $('#result').empty();

        var queryString;
        var endString;
        var inputs;

       queryString='SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
                   'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
                   'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
                   'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
                   'Campaign.click_count, Campaign.conversion_count ' +
                   'FROM (SELECT * FROM [formal-cascade-571:uci.demo_info]) AS Demographics ' +
                   'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.address_info]) AS Address ON Address.emailmd5 = Demographics.emailmd5 ' +
                   'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 ' +
                   'where ';

         for(var i=0; i<userInputs.length; i++){
            var formattedFieldName;
            if(i ==0){
                formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(userInputs[i].queryField)
                inputs =  formattedFieldName + ' like "' + userInputs[i].input + '"';
            }
            else if(i>0){
                inputs = inputs + ' AND ';
                formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(userInputs[i].queryField)
                if(userInputs[i].querytype == 'STRING')
                    inputs =  inputs + formattedFieldName + ' like "' + userInputs[i].input + '"';
                else
                    inputs =  inputs + formattedFieldName + ' = ' + userInputs[i].input;
            }
         }

          endString=' GROUP BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
                  'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
                  'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
                  'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
                  'Campaign.click_count, Campaign.conversion_count ' +

                  //'ORDER BY Demographics.emailmd5 Limit ' + "" +Merquery.getLimit() +"" +';'
                  'ORDER BY Demographics.emailmd5 Limit ' + "20" + ';';

                  Merquery.Util.log(queryString + inputs + endString);

        var request = gapi.client.bigquery.jobs.query({

            'projectId': project_id,
            'timeoutMs': '30000',
            /* v1.0 query for old database */
            //'query': 'SELECT * FROM [formal-cascade-571:uci.uci_db] where CRM_city like"' + stringCity + '" Limit ' + selText + ';'

            /* v2.0 Full query format using new database but some searches don't come through therefore commented some out
            * feel free to play around with them and adjust as needed */
            /*'query': 'SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
            'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
            'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
            'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
            'Campaign.click_count, Campaign.conversion_count ' +

            'FROM (SELECT * FROM [formal-cascade-571:uci.demo_info]) AS Demographics ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.address_info]) AS Address ON Address.emailmd5 = Demographics.emailmd5 ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 ' +

            'where Demographics.city like "' +*/

            'query': queryString + inputs + endString

        });
        request.execute(Merquery.renderResults);
    },

};

<commit_msg>Changed queries to show all tables<commit_after>if(typeof Merquery == "undefined" ) {
    Merquery = {};
}

Merquery.Queries = {
    //StandardQuery takes the fieldValue and fieldName and runs another query
    //parameters: {var fieldValue, var fieldName}
    standardQuery: function(fieldValue, fieldName, limit, callback) {
        var formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(fieldName);

        var queryString;
        var endString;

        queryString =  "SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity," +
            " Demographics.sexorient,Demographics.marital, Demographics.children, Address.Address1, Address.Address2, Address.City," +
            " Address.State, Address.Zip, Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name," +
            " Campaign.impression_count, Campaign.click_count, Campaign.conversion_count, Behavior.id, Behavior.name, Behavior.last_seen," +
            " Behavior.count, Device.device_id, Device.device_name, Device.device_type_id, Device.device_type_name, Device.operating_system," +
            " Device.last_seen, Purchase.advertiser_id, Purchase.last_sales_amount, Purchase.last_purchase_date, Purchase.ltv_online," +
            " Purchase.ltv_offline " +

            "FROM (SELECT emailmd5, birthdate,gender, city, ethnicity, sexorient, marital, children FROM [formal-cascade-571:uci.demo_info] " +
            "where emailmd5 is not null ) AS Demographics " +

            "LEFT JOIN EACH (SELECT emailmd5, Address1, Address2, City, State, Zip FROM [formal-cascade-571:uci.address_info]) "+
            "AS Address ON Address.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, advertiser_id, advertiser_name, campaign_id, campaign_name, impression_count, " +
            "click_count, conversion_count FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, id, name, last_seen, count FROM [formal-cascade-571:uci.behavior_info]) " +
            "AS Behavior ON Behavior.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, device_id, device_name, device_type_id, device_type_name, operating_system, " +
            "last_seen FROM [formal-cascade-571:uci.device_info]) AS Device ON Device.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, advertiser_id, last_sales_amount, last_purchase_date, ltv_online, " +
            "ltv_offline FROM [formal-cascade-571:uci.purchase_info]) AS Purchase ON Purchase.emailmd5 = Demographics.emailmd5 " +

        'where ' + formattedFieldName + ' like "' + fieldValue;

        endString = '" GROUP each BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, ' +
            "Demographics.city, Demographics.ethnicity, Demographics.sexorient, Demographics.marital, " +
            "Demographics.children, Address.Address1, Address.Address2, Address.City, Address.State, " +
            "Address.Zip, Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, "+
            "Campaign.campaign_name, Campaign.impression_count,Campaign.click_count, Campaign.conversion_count, " +
            "Behavior.id, Behavior.name, Behavior.last_seen, Behavior.count, " +
            "Device.device_id, Device.device_name, Device.device_type_id, Device.device_type_name, " +
            "Device.operating_system, Device.last_seen, " +
            " Purchase.advertiser_id, Purchase.last_sales_amount, Purchase.last_purchase_date, Purchase.ltv_online, Purchase.ltv_offline " +
            'ORDER BY Demographics.emailmd5 Limit ' + limit + ';';

        var request = gapi.client.bigquery.jobs.query({
            'projectId': project_id,
            'timeoutMs': '30000',
            'query': queryString + endString

        });
        request.execute(callback || Merquery.renderResults);
    },

    //PopUpQuery takes the fieldValue and fieldName and runs another query
    //parameters: {var fieldValue, var fieldName}
    popupQuery: function(fieldValue, fieldName) {
        var formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(fieldName);

        var request = gapi.client.bigquery.jobs.query({
            'projectId': project_id,
            'timeoutMs': '30000',
            /* v1.0 query for old database */
            //'query': 'SELECT * FROM [formal-cascade-571:uci.uci_db] where ' + fieldName + ' like "' + fieldValue + '" Limit ' + selText + ';'

            /* v2.0 Full query format using new database but some searches don't come through therefore commented some out
             * feel free to play around with them and adjust as needed */

            'query': 'SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
            'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
            'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
            'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
            'Campaign.click_count, Campaign.conversion_count ' +

            'FROM (SELECT * FROM [formal-cascade-571:uci.demo_info]) AS Demographics ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.address_info]) AS Address ON Address.emailmd5 = Demographics.emailmd5 ' +
            'JOIN EACH (SELECT * FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 ' +

            'where ' + formattedFieldName + ' like "' + fieldValue +

            '" GROUP BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity, ' +
            'Demographics.sexorient, Demographics.marital, Demographics.children, ' +
            'Address.Address1, Address.Address2, Address.City, Address.State, Address.Zip, ' +
            'Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name, Campaign.impression_count, ' +
            'Campaign.click_count, Campaign.conversion_count ' +

            'ORDER BY Demographics.emailmd5 Limit ' + "20" + ';'
        });

        request.execute(Merquery.Popup.renderPopUp);

    },

    //Runs the query when the search button is clicked
    runQuery: function(userInputs) {
        //Merquery.Queries.createQueryArray();

        // For loading indicator
        Merquery.hideNav();
        Merquery.showLoad();
        $('#result').empty();

        var queryString;
        var endString;
        var inputs;

        queryString =  "SELECT Demographics.emailmd5, Demographics.birthdate, Demographics.gender, Demographics.city, Demographics.ethnicity," +
            " Demographics.sexorient,Demographics.marital, Demographics.children, Address.Address1, Address.Address2, Address.City," +
            " Address.State, Address.Zip, Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, Campaign.campaign_name," +
            " Campaign.impression_count, Campaign.click_count, Campaign.conversion_count, Behavior.id, Behavior.name, Behavior.last_seen," +
            " Behavior.count, Device.device_id, Device.device_name, Device.device_type_id, Device.device_type_name, Device.operating_system," +
            " Device.last_seen, Purchase.advertiser_id, Purchase.last_sales_amount, Purchase.last_purchase_date, Purchase.ltv_online," +
            " Purchase.ltv_offline " +

            "FROM (SELECT emailmd5, birthdate,gender, city, ethnicity, sexorient, marital, children FROM [formal-cascade-571:uci.demo_info] " +
            "where emailmd5 is not null ) AS Demographics " +

            "LEFT JOIN EACH (SELECT emailmd5, Address1, Address2, City, State, Zip FROM [formal-cascade-571:uci.address_info]) "+
            "AS Address ON Address.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, advertiser_id, advertiser_name, campaign_id, campaign_name, impression_count, " +
            "click_count, conversion_count FROM [formal-cascade-571:uci.campaign_info]) AS Campaign ON Campaign.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, id, name, last_seen, count FROM [formal-cascade-571:uci.behavior_info]) " +
            "AS Behavior ON Behavior.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, device_id, device_name, device_type_id, device_type_name, operating_system, " +
            "last_seen FROM [formal-cascade-571:uci.device_info]) AS Device ON Device.emailmd5 = Demographics.emailmd5 " +

            "LEFT JOIN EACH (SELECT emailmd5, advertiser_id, last_sales_amount, last_purchase_date, ltv_online, " +
            "ltv_offline FROM [formal-cascade-571:uci.purchase_info]) AS Purchase ON Purchase.emailmd5 = Demographics.emailmd5 " +

            'where ';

        for(var i=0; i<userInputs.length; i++){
            var formattedFieldName;
            if(i ==0){
                formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(userInputs[i].queryField)
                inputs =  formattedFieldName + ' like "' + userInputs[i].input + '"';
            }
            else if(i>0){
                inputs = inputs + ' AND ';
                formattedFieldName = Merquery.TableAndFieldsFormatter.formatFieldName(userInputs[i].queryField)
                if(userInputs[i].querytype == 'STRING')
                    inputs =  inputs + formattedFieldName + ' like "' + userInputs[i].input + '"';
                else
                    inputs =  inputs + formattedFieldName + ' = ' + userInputs[i].input;
            }
        }

        endString = " GROUP each BY Demographics.emailmd5, Demographics.birthdate, Demographics.gender, " +
            "Demographics.city, Demographics.ethnicity, Demographics.sexorient, Demographics.marital, " +
            "Demographics.children, Address.Address1, Address.Address2, Address.City, Address.State, " +
            "Address.Zip, Campaign.advertiser_id, Campaign.advertiser_name, Campaign.campaign_id, "+
            "Campaign.campaign_name, Campaign.impression_count,Campaign.click_count, Campaign.conversion_count, " +
            "Behavior.id, Behavior.name, Behavior.last_seen, Behavior.count, " +
            "Device.device_id, Device.device_name, Device.device_type_id, Device.device_type_name, " +
            "Device.operating_system, Device.last_seen, " +
            " Purchase.advertiser_id, Purchase.last_sales_amount, Purchase.last_purchase_date, Purchase.ltv_online, Purchase.ltv_offline " +
            'Limit ' + "20" + ';';

                  Merquery.Util.log(queryString + inputs + endString);

        var request = gapi.client.bigquery.jobs.query({

            'projectId': project_id,
            'timeoutMs': '30000',
            'query': queryString + inputs + endString

        });
        request.execute(Merquery.renderResults);
    },

};

<|endoftext|>


<commit_before>var levelE;
var levelSelectState = {
	preload: function(){

	},
	create: function(){

		var lvlSelBg = game.add.tileSprite(0,0,450,750,'bg3');
		filter = game.add.filter('Fire', 450, 750);
		filter.alpha = 0.0;
		lvlSelBg.filters = [filter];

		var back = game.add.text(game.width / 2, 650, "BACK", {font: '30px Arial', fill: '#ffffff'});
		back.anchor.setTo(0.5,0.5);
		back.inputEnabled = true;

	//	var door1 = game.add.sprite(game.camera.width/2, game.camera.height/2,'door');
	//	door1.anchor.setTo(0.5);
	//	var level = game.add.sprite(game.width/2, game.height/3,'fml1');
	//	level.anchor.setTo(0.5);
	//	level.animations.add('loopingFire',[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,311,32,33,34]);
	//	level.animations.play('loopingFire',1080,true);
	//	i wasted 2 hours on something that didnt work, GG;

		back.events.onInputOver.add(this.over, this);
		back.events.onInputOut.add(this.out, this);
		back.events.onInputDown.add(this.down, this);
		back.events.onInputUp.add(this.back, this);

		levelE = game.add.group();

		var no1 = game.add.sprite((game.width/2 - 100),game.height*2/8,'no1');
		// no1.tint = 0x000000;
		no1.anchor.setTo(0.5);
		no1.inputEnabled = true;
		no1.events.onInputOver.add(this.imageover, this);
		no1.events.onInputOut.add(this.imageout, this);
		no1.events.onInputDown.add(this.imagedown, this);
		no1.events.onInputUp.add(this.lvl1Start,this);

		var no2 = game.add.sprite((game.width/2 + 100),game.height*2.5/8,'no2');
		no2.tint = 0x000000;
		no2.anchor.setTo(0.5);
		no2.inputEnabled = false;
		no2.events.onInputOver.add(this.imageover, this);
		no2.events.onInputOut.add(this.imageout, this);
		no2.events.onInputDown.add(this.imagedown, this);
		no2.events.onInputUp.add(this.lvl2Start,this);

		var no3 = game.add.sprite((game.width/2)-100,game.height*1/2,'no3');
		no3.anchor.setTo(0.5);
		no3.tint = 0x000000;
		no3.inputEnabled = false;

//		levelE.inputEnabled = true;no3.events.onInputOver.add(this.imageover, this);
		no3.events.onInputOut.add(this.imageout, this);
		no3.events.onInputDown.add(this.imagedown, this);
//		levelE.events.onInputOver.add(this.imageover, this);
//		levelE.events.onInputOut.add(this.imageout, this);
//		levelE.events.onInputDown.add(this.imagedown, this);
//		levelE.anchor.setTo(0.5);
		if(lvlsUnlocked >= 2){
			no2.inputEnabled = true;
			no2.tint = 0xffffff;
		} else{
			no2.inputEnabled = false;
		}
	},

	imageover: function(item){
		this.add.tween(item.scale).to({x:1.3,y:1.3},300, null, true,1,0,false);
		item.tint = 0xffffff
	},

	imageout: function(item) {
		this.add.tween(item.scale).to({x:1.0,y:1.0},300,null,true,1,0,false);
	},

	imagedown: function(item) {
		item.tint = 0xff0000;
	},
	over: function(item) {
		item.fill = '#FFF066';
		item.fontSize += 5;
	},

	out: function(item) {
		item.fill = '#FFFFFF';
		item.fontSize -= 5;
	},
	down: function(item) {
		item.fill = '#FFCC33';
		item.fontSize -= 5;
	},
	back: function(back) {
		game.state.start('menu');
	},
	update: function(){
		filter.update();
	},
	lvl1Start:function(){
		lvlPlaying = 1;

			game.state.start("playlvl1");

	},
	lvl2Start:function(){
		lvlPlaying = 2;
		game.state.start("playlvl2");

	},

}<commit_msg>link intro<commit_after>var levelE;
var levelSelectState = {
	preload: function(){

	},
	create: function(){

		var lvlSelBg = game.add.tileSprite(0,0,450,750,'bg3');
		filter = game.add.filter('Fire', 450, 750);
		filter.alpha = 0.0;
		lvlSelBg.filters = [filter];

		var back = game.add.text(game.width / 2, 650, "BACK", {font: '30px Arial', fill: '#ffffff'});
		back.anchor.setTo(0.5,0.5);
		back.inputEnabled = true;

	//	var door1 = game.add.sprite(game.camera.width/2, game.camera.height/2,'door');
	//	door1.anchor.setTo(0.5);
	//	var level = game.add.sprite(game.width/2, game.height/3,'fml1');
	//	level.anchor.setTo(0.5);
	//	level.animations.add('loopingFire',[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,311,32,33,34]);
	//	level.animations.play('loopingFire',1080,true);
	//	i wasted 2 hours on something that didnt work, GG;

		back.events.onInputOver.add(this.over, this);
		back.events.onInputOut.add(this.out, this);
		back.events.onInputDown.add(this.down, this);
		back.events.onInputUp.add(this.back, this);

		levelE = game.add.group();

		var no1 = game.add.sprite((game.width/2 - 100),game.height*2/8,'no1');
		// no1.tint = 0x000000;
		no1.anchor.setTo(0.5);
		no1.inputEnabled = true;
		no1.events.onInputOver.add(this.imageover, this);
		no1.events.onInputOut.add(this.imageout, this);
		no1.events.onInputDown.add(this.imagedown, this);
		no1.events.onInputUp.add(this.lvl1Start,this);

		var no2 = game.add.sprite((game.width/2 + 100),game.height*2.5/8,'no2');
		no2.tint = 0x000000;
		no2.anchor.setTo(0.5);
		no2.inputEnabled = false;
		no2.events.onInputOver.add(this.imageover, this);
		no2.events.onInputOut.add(this.imageout, this);
		no2.events.onInputDown.add(this.imagedown, this);
		no2.events.onInputUp.add(this.lvl2Start,this);

		var no3 = game.add.sprite((game.width/2)-100,game.height*1/2,'no3');
		no3.anchor.setTo(0.5);
		no3.tint = 0x000000;
		no3.inputEnabled = false;

//		levelE.inputEnabled = true;no3.events.onInputOver.add(this.imageover, this);
		no3.events.onInputOut.add(this.imageout, this);
		no3.events.onInputDown.add(this.imagedown, this);
//		levelE.events.onInputOver.add(this.imageover, this);
//		levelE.events.onInputOut.add(this.imageout, this);
//		levelE.events.onInputDown.add(this.imagedown, this);
//		levelE.anchor.setTo(0.5);
		if(lvlsUnlocked >= 2){
			no2.inputEnabled = true;
			no2.tint = 0xffffff;
		} else{
			no2.inputEnabled = false;
		}
	},

	imageover: function(item){
		this.add.tween(item.scale).to({x:1.3,y:1.3},300, null, true,1,0,false);
		item.tint = 0xffffff
	},

	imageout: function(item) {
		this.add.tween(item.scale).to({x:1.0,y:1.0},300,null,true,1,0,false);
	},

	imagedown: function(item) {
		item.tint = 0xff0000;
	},
	over: function(item) {
		item.fill = '#FFF066';
		item.fontSize += 5;
	},

	out: function(item) {
		item.fill = '#FFFFFF';
		item.fontSize -= 5;
	},
	down: function(item) {
		item.fill = '#FFCC33';
		item.fontSize -= 5;
	},
	back: function(back) {
		game.state.start('menu');
	},
	update: function(){
		filter.update();
	},
	lvl1Start:function(){
		lvlPlaying = 1;

			game.state.start("intro0");

	},
	lvl2Start:function(){
		lvlPlaying = 2;
		game.state.start("playlvl2");

	},

}<|endoftext|>


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

    class LoadingBox{

        static get defaults(){
            return {
                position: 'middle',
                size: 'medium', // material default size: medium
                type: 'circle',
                color: 'blue',
                colors: ['blue', 'red', 'yellow', 'green'],
                progress: 1
            };
        }

        static typeCircle(options){

            let preloaderWrapper = document.createElement('div');
            preloaderWrapper.classList.add('preloader-wrapper');
            preloaderWrapper.classList.add(options.size);
            preloaderWrapper.classList.add('active');

            //we apply spinner-<color>-only class
            let only = '';
            if (options.color != 'flashing'){
                options.colors = [];
                options.colors[0] = options.color;
                only = '-only'
            }
            for (let c in options.colors){
                let spinnerLayer = document.createElement('div');
                spinnerLayer.classList.add('spinner-layer');
                spinnerLayer.classList.add('spinner-'+options.colors[c]+only);
                let clipperLeft = document.createElement('div');
                clipperLeft.classList.add('circle-clipper');
                clipperLeft.classList.add('left');
                let clipperRight = document.createElement('div');
                clipperRight.classList.add('circle-clipper');
                clipperRight.classList.add('right');
                let gapPatch = document.createElement('div');
                gapPatch.classList.add('gap-patch');
                let circle1 = document.createElement('div');
                circle1.classList.add('circle');
                let circle2 = document.createElement('div');
                circle2.classList.add('circle');
                let circle3 = document.createElement('div');
                circle3.classList.add('circle');

                clipperLeft.appendChild(circle1);
                gapPatch.appendChild(circle2);
                clipperRight.appendChild(circle3);
                spinnerLayer.appendChild(clipperLeft);
                spinnerLayer.appendChild(gapPatch);
                spinnerLayer.appendChild(clipperRight);
                preloaderWrapper.appendChild(spinnerLayer);
            }

            return preloaderWrapper;
        }

        static typeLinear(options){
            let progress = document.createElement("div");
            progress.classList.add('progress');
            let element = document.createElement("div");
            if (options.type=='indeterminate') {
                element.classList.add('indeterminate');
            }else {
                element.classList.add('determinate');
                element.style= 'width: ' + options.progress + '%';
                element.setAttribute('id', 'loading-progress');
            }
            element.classList.add(options.color);
            progress.appendChild(element);
            return progress;
        }

        static open(message, options){

            // if the element is already in the document, just we replace
            // the message
            if (document.getElementById('loading-box')!=null){
                return;
            }

            // extend default options
            options = LoadingBox.join(LoadingBox.defaults, options);
            LoadingBox._currentOptions = options;

            let box = document.createElement('div');
            box.setAttribute('id', 'loading-box');
            box.classList.add('card');
            box.classList.add(options.position);
            let boxContent = document.createElement('div');
            boxContent.classList.add('card-content');
            let preloader;
            if (options.type=='determinate' || options.type=='indeterminate'){
                preloader = LoadingBox.typeLinear(options);
            }else {
                preloader = LoadingBox.typeCircle(options);
            }
            let text = document.createElement('p');
            text.setAttribute('id', 'loading-text');
            text.textContent=message;
            boxContent.appendChild(preloader);
            boxContent.appendChild(text);
            box.appendChild(boxContent);
            document.getElementsByTagName('body')[0]
                .appendChild(box);
        }

        static close(){
            if (document.getElementById('loading-box')){
                document.getElementById('loading-box').outerHTML = "";
            }
        }

        static updateText(message){
            if (document.getElementById('loading-box')!=null){
                document.getElementById('loading-text').textContent=message;
            }
        }

        static updateProgress(progress){
            if (LoadingBox._currentOptions.type=='determinate'){
                document.getElementById('loading-progress')
                    .style='width: ' + progress + '%';

                if (LoadingBox._currentOptions.closeOnFinishProgress
                        & progress>=100){
                    LoadingBox.close();
                }
            }
        }

        static join(l1, l2){
            for (let key in l2){
                l1[key] = l2[key];
            }
            return l1;
        }
    }

    LoadingBox._box = null;
    LoadingBox._currentOptions = LoadingBox.defaults;
    window.Materialize.LoadingBox = LoadingBox;

})();
<commit_msg>cambio de circle a circular<commit_after>(function () {
    'use strict';

    class LoadingBox{

        static get defaults(){
            return {
                position: 'middle',
                size: 'medium', // material default size: medium
                type: 'circular',
                color: 'blue',
                colors: ['blue', 'red', 'yellow', 'green'],
                progress: 1
            };
        }

        static typeCircular(options){

            let preloaderWrapper = document.createElement('div');
            preloaderWrapper.classList.add('preloader-wrapper');
            preloaderWrapper.classList.add(options.size);
            preloaderWrapper.classList.add('active');

            //we apply spinner-<color>-only class
            let only = '';
            if (options.color != 'flashing'){
                options.colors = [];
                options.colors[0] = options.color;
                only = '-only'
            }
            for (let c in options.colors){
                let spinnerLayer = document.createElement('div');
                spinnerLayer.classList.add('spinner-layer');
                spinnerLayer.classList.add('spinner-'+options.colors[c]+only);
                let clipperLeft = document.createElement('div');
                clipperLeft.classList.add('circle-clipper');
                clipperLeft.classList.add('left');
                let clipperRight = document.createElement('div');
                clipperRight.classList.add('circle-clipper');
                clipperRight.classList.add('right');
                let gapPatch = document.createElement('div');
                gapPatch.classList.add('gap-patch');
                let circle1 = document.createElement('div');
                circle1.classList.add('circle');
                let circle2 = document.createElement('div');
                circle2.classList.add('circle');
                let circle3 = document.createElement('div');
                circle3.classList.add('circle');

                clipperLeft.appendChild(circle1);
                gapPatch.appendChild(circle2);
                clipperRight.appendChild(circle3);
                spinnerLayer.appendChild(clipperLeft);
                spinnerLayer.appendChild(gapPatch);
                spinnerLayer.appendChild(clipperRight);
                preloaderWrapper.appendChild(spinnerLayer);
            }

            return preloaderWrapper;
        }

        static typeLinear(options){
            let progress = document.createElement("div");
            progress.classList.add('progress');
            let element = document.createElement("div");
            if (options.type=='indeterminate') {
                element.classList.add('indeterminate');
            }else {
                element.classList.add('determinate');
                element.style= 'width: ' + options.progress + '%';
                element.setAttribute('id', 'loading-progress');
            }
            element.classList.add(options.color);
            progress.appendChild(element);
            return progress;
        }

        static open(message, options){

            // if the element is already in the document, just we replace
            // the message
            if (document.getElementById('loading-box')!=null){
                return;
            }

            // extend default options
            options = LoadingBox.join(LoadingBox.defaults, options);
            LoadingBox._currentOptions = options;

            let box = document.createElement('div');
            box.setAttribute('id', 'loading-box');
            box.classList.add('card');
            box.classList.add(options.position);
            let boxContent = document.createElement('div');
            boxContent.classList.add('card-content');
            let preloader;
            if (options.type=='determinate' || options.type=='indeterminate'){
                preloader = LoadingBox.typeLinear(options);
            }else {
                preloader = LoadingBox.typeCircular(options);
            }
            let text = document.createElement('p');
            text.setAttribute('id', 'loading-text');
            text.textContent=message;
            boxContent.appendChild(preloader);
            boxContent.appendChild(text);
            box.appendChild(boxContent);
            document.getElementsByTagName('body')[0]
                .appendChild(box);
        }

        static close(){
            if (document.getElementById('loading-box')){
                document.getElementById('loading-box').outerHTML = "";
            }
        }

        static updateText(message){
            if (document.getElementById('loading-box')!=null){
                document.getElementById('loading-text').textContent=message;
            }
        }

        static updateProgress(progress){
            if (LoadingBox._currentOptions.type=='determinate'){
                document.getElementById('loading-progress')
                    .style='width: ' + progress + '%';

                if (LoadingBox._currentOptions.closeOnFinishProgress
                        & progress>=100){
                    LoadingBox.close();
                }
            }
        }

        static join(l1, l2){
            for (let key in l2){
                l1[key] = l2[key];
            }
            return l1;
        }
    }

    LoadingBox._box = null;
    LoadingBox._currentOptions = LoadingBox.defaults;
    window.Materialize.LoadingBox = LoadingBox;

})();
<|endoftext|>


<commit_before>'use strict';

function Buddy (name,birdOwl,personality) {
  this.name = name;
  this.birdOwl = birdOwl;
  this.personality = personality;
  this.tally = 0;
};

var buddyArray = [];
var user = [];
var kinley = ['Kinley','owl','intro'];
var asha = ['Asha','bird','extro'];
var ariel = ['Ariel','owl','intro'];
var java = ['Java','owl','intro'];
var tiger = ['Tiger','bird','extro'];
var marco = ['Marco','bird','extro'];

var nameArray = [kinley, asha, ariel, java, tiger, marco];

function buddyMaker () {
  for (var i = 0; i < nameArray.length; i++) {
    var buddyName = nameArray[i][0];
    var buddyBirdOwl = nameArray[i][1];
    var buddyPersonality = nameArray[i][2];
    var buddy = new Buddy(buddyName,buddyBirdOwl,buddyPersonality);
    buddyArray.push(buddy);
  };
};

buddyMaker();

function getFromLocal () {
  user = JSON.parse(localStorage.userData);
};

getFromLocal();

function scoreMaker () {
  user = new Buddy(user[0], user[1], user[2]);
  for (var i = 0; i < user.length[i]; i++) {
    if (user.birdOwl === buddyArray[i].birdOwl)
      buddyArray[i].tally++;
    if (user.personality = buddyArray[i].personality)
      buddyArray[i].tally++;
  }
};
<commit_msg>trying to fix score<commit_after>'use strict';

function Buddy (name,birdOwl,personality) {
  this.name = name;
  this.birdOwl = birdOwl;
  this.personality = personality;
  this.tally = 0;
};

var buddyArray = [];
var user = [];
var kinley = ['Kinley','owl','intro'];
var asha = ['Asha','bird','extro'];
var ariel = ['Ariel','owl','intro'];
var java = ['Java','owl','intro'];
var tiger = ['Tiger','bird','extro'];
var marco = ['Marco','bird','extro'];

var nameArray = [kinley, asha, ariel, java, tiger, marco];

function buddyMaker () {
  for (var i = 0; i < nameArray.length; i++) {
    var buddyName = nameArray[i][0];
    var buddyBirdOwl = nameArray[i][1];
    var buddyPersonality = nameArray[i][2];
    var buddy = new Buddy(buddyName,buddyBirdOwl,buddyPersonality);
    buddyArray.push(buddy);
  };
};

buddyMaker();

function getFromLocal () {
  user = JSON.parse(localStorage.userData);
};

getFromLocal();

function scoreMaker () {
  user = new Buddy(user[0], user[1], user[2]);
  for (var i = 0; i < buddyArray.length; i++) {
    if (user.birdOwl === buddyArray[i].birdOwl)
      buddyArray[i].tally++;
    if (user.personality = buddyArray[i].personality)
      buddyArray[i].tally++;
  }
};
<|endoftext|>


<commit_before>/**
* Ridemap
*
* Copyright (C) 2014 Mark T. Sanford
* Licensed under GNU GENERAL PUBLIC LICENSE version 2
* see http://www.gnu.org/licenses/gpl-2.0.txt for more information
*/

$( document ).ready(function() {
	Ridemap.initialize('map-canvas');
});

var Ridemap = {};

// Ridemap.routes[].status:
// 0 - unloaded
// 1 - load pending
// 2 - loaded

Ridemap.initialize = function(id) {
	Ridemap.params = Ridemap.utils.getUrlParameters(['label', 'tag', 'region', 'wheelzoom']);
	Ridemap.utils.listenMetaKeys();
	Ridemap.routes = [];
	Ridemap.activeRoute = 0;
	Ridemap.element = document.getElementById(id);
	Ridemap.map	= new google.maps.Map(Ridemap.element, { mapTypeId: google.maps.MapTypeId.ROADMAP });

	// The route set to include in the map can be restricted by tag OR by region
	var routeFetchURI = 'getroutes.php'
	        + (Ridemap.params.tag ? ('?tag=' + Ridemap.params.tag) :
		      (Ridemap.params.region ? ('?region=' + Ridemap.params.region) : ''));

	$.ajax({
		url: routeFetchURI,
		dataType: 'json',
		success: Ridemap.onRoutesFetched
	});
};

// Callback when route list is fetched
Ridemap.onRoutesFetched = function(data) {
	// set region of map displayed
	var r = (Ridemap.params.region) ? Ridemap.params.region.split(',')
	        : [ data.bounds.s, data.bounds.w, data.bounds.n, data.bounds.e ];
	Ridemap.map.fitBounds(new google.maps.LatLngBounds(
		new google.maps.LatLng(parseFloat(r[0]), parseFloat(r[1])),
		new google.maps.LatLng(parseFloat(r[2]), parseFloat(r[3]))
	));

	data.routes.forEach(function(route) {
		Ridemap.routes[route.ID] = route;
		route.status = 0;
		route.infoWindow = new google.maps.InfoWindow({
			content: "
loading...
",
		});
		route.marker = new google.maps.Marker({
			position: Ridemap.utils.parseLatLng(route.marker_pos),
			map: Ridemap.map,
			title : route.caption
		});

		Ridemap.setClickListener(route.marker, route.ID);
	});
};

// Set up a click listener for a marker,
// and associate it with a Ridemap.routes[] using
// a closure
Ridemap.setClickListener = function(marker, routeID) {
	var route = Ridemap.routes[routeID];
	google.maps.event.addListener(marker, 'click', function(event) {
		route.infoWindow.open(Ridemap.map, marker);
		if (Ridemap.activeRoute != routeID) {
			if (Ridemap.activeRoute) {
				Ridemap.routes[Ridemap.activeRoute].infoWindow.close();
			}
			if (!Ridemap.utils.ctrlDown) {
				Ridemap.routes.forEach(function(_route) {
					if (_route.ID != routeID && _route.line) {
						_route.line.setVisible(false);
					}
				});
			}
			Ridemap.activeRoute = routeID;
			Ridemap.fullyLoadRoute(routeID, function() {
				route.line.setVisible(true);
			});
		}
	});
};

// Fully load a route (including details & route line), and
// call callback when done.   May ball callback synchronously
// if the route is already loaded.
Ridemap.fullyLoadRoute = function(routeID, callback) {
	var route = Ridemap.routes[routeID];
	if (route.status == 0) {
		route.status = 1;
		$.ajax({
			url: 'getroutes.php?q=' + routeID,
			dataType: 'json',
			success: function(data) {
				$.extend(route, data['routes'][0]);
				route.status = 2;
				route.line = new google.maps.Polyline({
					path: google.maps.geometry.encoding.decodePath(route.encoded_polyline),
					clickable: false,
					draggable: false,
					strokeOpacity: 0.7,
					strokeWeight: 5,
					strokeColor: route.color,
					visible: false,
					map: Ridemap.map
				});
				route.infoWindow.setContent(Ridemap.makeInfoHTML(route));
				callback();
			}
		});
	} else if (Ridemap.routes[routeID].status == 1) {
		// Do nothing.
		// TODO really should cue up callbacks?  Right now just expecting
		// caller to check status before calling
		// and not call if status == 1
	} else {
		// status >= 2, already loaded
		callback();
	}
};

Ridemap.makeInfoHTML = function(route) {
    var html =
        '

CAPTION

'
        + '
DESCRIPTION
'
        + '
';

    html = html.replace(/CAPTION/g, route['caption']);
    html = html.replace(/LINK_URL/g, route['link_url']);
    html = html.replace(/PICTURE_URL/g, route['picture_url']);
    html = html.replace(/PICTURE_WIDTH/g, route['picture_width']);
    html = html.replace(/PICTURE_HEIGHT/g, route['picture_height']);
    html = html.replace(/DESCRIPTION/g, route['description']);

    return html;
};

/*
 *	Misc utility functions
 */

Ridemap.utils = {
	parseLatLng: function(string) {
		var coords = string.split(',');
		return new google.maps.LatLng(parseFloat(coords[0]), parseFloat(coords[1]));
	},
	listenMetaKeys: function() {
		function set(event) {
			Ridemap.utils.ctrlDown = event.ctrlKey;
		}
		$(window).keydown(set).keyup(set);
	},
	ctrlDown: false,
	getUrlParameters: function(params) {
		var values = {};
		params.forEach(function(param) {
			values[param] = Ridemap.utils.getURLParameter(param);
		});
		return values;
	},
	getURLParameter: function(name) {
		return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
	}
};<commit_msg>load/zoom on startup if q or labels specified<commit_after>/**
* Ridemap
*
* Copyright (C) 2014 Mark T. Sanford
* Licensed under GNU GENERAL PUBLIC LICENSE version 2
* see http://www.gnu.org/licenses/gpl-2.0.txt for more information
*
*/

$( document ).ready(function() {
	Ridemap.initialize('map-canvas');
});

var Ridemap = {};

// Ridemap.routes[].status:
// 0 - unloaded
// 1 - load pending
// 2 - loaded

Ridemap.initialize = function(id) {
	Ridemap.params = Ridemap.utils.getUrlParameters(['q', 'label', 'tag', 'region', 'wheelzoom']);
	Ridemap.utils.listenMetaKeys();
	Ridemap.routes = [];
	Ridemap.activeRoute = 0;
	Ridemap.element = document.getElementById(id);
	Ridemap.map	= new google.maps.Map(Ridemap.element, { mapTypeId: google.maps.MapTypeId.ROADMAP });

	// The route set to include in the map can be restricted by tag OR by region
	var routeFetchURI = 'getroutes.php'
	        + (Ridemap.params.tag ? ('?tag=' + Ridemap.params.tag) :
		      (Ridemap.params.region ? ('?region=' + Ridemap.params.region) : ''));

	$.ajax({
		url: routeFetchURI,
		dataType: 'json',
		success: Ridemap.onRoutesFetched
	});
};

// Callback when route list is fetched
Ridemap.onRoutesFetched = function(data) {
	// set region of map displayed
	var r = (Ridemap.params.region) ? Ridemap.params.region.split(',')
	        : [ data.bounds.s, data.bounds.w, data.bounds.n, data.bounds.e ];
	Ridemap.map.fitBounds(new google.maps.LatLngBounds(
		new google.maps.LatLng(parseFloat(r[0]), parseFloat(r[1])),
		new google.maps.LatLng(parseFloat(r[2]), parseFloat(r[3]))
	));

	data.routes.forEach(function(route) {
		Ridemap.routes[route.ID] = route;
		route.status = 0;
		route.infoWindow = new google.maps.InfoWindow({
			content: "
loading...
",
		});
		route.marker = new google.maps.Marker({
			position: Ridemap.utils.parseLatLng(route.marker_pos),
			map: Ridemap.map,
			title : route.caption
		});

		Ridemap.setClickListener(route.marker, route.ID);
	});

	// If label(s) or a specific route ID was specified, fetch those full
	// routes, and the zoom the region and show the route lines
	if (Ridemap.params.label || Ridemap.params.q) {
		var routeFetchURI = 'getroutes.php?mode=full&'
		                     + (Ridemap.params.label ? ('label=' + Ridemap.params.label) : ('q=' + Ridemap.params.q));
	    console.log('zoom: ' + routeFetchURI);
		$.ajax({
			url: routeFetchURI,
			dataType: 'json',
			success: Ridemap.onZoomRoutesFetched
		});
	}
};

// Set up a click listener for a marker,
// and associate it with a Ridemap.routes[] using
// a closure
Ridemap.setClickListener = function(marker, routeID) {
	var route = Ridemap.routes[routeID];
	google.maps.event.addListener(marker, 'click', function(event) {
		route.infoWindow.open(Ridemap.map, marker);
		if (Ridemap.activeRoute != routeID) {
			if (Ridemap.activeRoute) {
				Ridemap.routes[Ridemap.activeRoute].infoWindow.close();
			}
			if (!Ridemap.utils.ctrlDown) {
				Ridemap.routes.forEach(function(_route) {
					if (_route.ID != routeID && _route.line) {
						_route.line.setVisible(false);
					}
				});
			}
			Ridemap.activeRoute = routeID;
			Ridemap.fullyLoadRoute(routeID, function() {
				route.line.setVisible(true);
			});
		}
	});
};

// Fully load a route (including details & route line), and
// call callback when done.   May ball callback synchronously
// if the route is already loaded.
Ridemap.fullyLoadRoute = function(routeID, callback) {
	var route = Ridemap.routes[routeID];
	if (route.status == 0) {
		route.status = 1;
		$.ajax({
			url: 'getroutes.php?q=' + routeID,
			dataType: 'json',
			success: function(data) {
				Ridemap.setFullRoute(route, data['routes'][0]);
				//$.extend(route, data['routes'][0]);
				callback();
			}
		});
	} else if (Ridemap.routes[routeID].status == 1) {
		// Do nothing.
		// TODO really should cue up callbacks?  Right now just expecting
		// caller to check status before calling
		// and not call if status == 1
	} else {
		// status >= 2, already loaded
		callback();
	}
};

// From data fetched from getroutes.php, fill in all the data
// in the route so that it is fully loaded.
Ridemap.setFullRoute = function(route, data) {
	if (route.status == 2) return;
	$.extend(route, data);
	route.status = 2;
	route.line = new google.maps.Polyline({
		path: google.maps.geometry.encoding.decodePath(route.encoded_polyline),
		clickable: false,
		draggable: false,
		strokeOpacity: 0.7,
		strokeWeight: 5,
		strokeColor: route.color,
		visible: false,
		map: Ridemap.map
	});
	route.infoWindow.setContent(Ridemap.makeInfoHTML(route));
};

Ridemap.onZoomRoutesFetched = function(data) {
	console.log(data);
	data.routes.forEach(function(routeData) {
		var route = Ridemap.routes[routeData.ID];
		Ridemap.setFullRoute(route, routeData);
		route.line.setVisible(true);
	});
	Ridemap.map.fitBounds(new google.maps.LatLngBounds(
		new google.maps.LatLng(data.bounds.s, data.bounds.w),
		new google.maps.LatLng(data.bounds.n, data.bounds.e)
	));
};

Ridemap.makeInfoHTML = function(route) {
    var html =
        '

CAPTION

'
        + '
DESCRIPTION
'
        + '
';

    html = html.replace(/CAPTION/g, route['caption']);
    html = html.replace(/LINK_URL/g, route['link_url']);
    html = html.replace(/PICTURE_URL/g, route['picture_url']);
    html = html.replace(/PICTURE_WIDTH/g, route['picture_width']);
    html = html.replace(/PICTURE_HEIGHT/g, route['picture_height']);
    html = html.replace(/DESCRIPTION/g, route['description']);

    return html;
};

/*
 *	Misc utility functions
 */

Ridemap.utils = {
	parseLatLng: function(string) {
		var coords = string.split(',');
		return new google.maps.LatLng(parseFloat(coords[0]), parseFloat(coords[1]));
	},
	listenMetaKeys: function() {
		function set(event) {
			Ridemap.utils.ctrlDown = event.ctrlKey;
		}
		$(window).keydown(set).keyup(set);
	},
	ctrlDown: false,
	getUrlParameters: function(params) {
		var values = {};
		params.forEach(function(param) {
			values[param] = Ridemap.utils.getURLParameter(param);
		});
		return values;
	},
	getURLParameter: function(name) {
		return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
	}
};<|endoftext|>


<commit_before>import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click, findAll } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | api index filter', function (hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function () {
    this.actions = {};
    this.send = (actionName, ...args) =>
      this.actions[actionName].apply(this, args);
  });

  const model = EmberObject.create({
    project: {
      id: 'lolwut',
    },
    projectVersion: {
      version: '2.9',
    },
    name: 'hai',
    file: 'my-class',
    parentClass: {
      file: 'my-class',
    },
    methods: [
      {
        name: 'doSomething',
        route: 'do-something',
        file: 'my-class',
      },
      {
        name: 'doSomething',
        route: 'do-something',
        file: 'my-parent-class',
      },
      {
        name: 'parentDoSomething',
        route: 'parent-do-something',
        inherited: true,
      },
      {
        name: 'doSomethingPrivate',
        route: 'do-something-private',
        access: 'private',
      },
      {
        name: 'doSomethingProtected',
        route: 'do-something-protected',
        access: 'protected',
      },
      {
        name: 'doSomethingDeprecated',
        route: 'do-something-deprecated',
        deprecated: true,
      },
    ],
    properties: [
      {
        name: 'isSomething',
        route: 'is-something',
      },
    ],
    events: [
      {
        name: 'didSomething',
        route: 'did-something',
      },
    ],
  });

  test('clicking inherited shows inherited methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      isDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id=\"private-toggle\"
                     type=\"checkbox\"
                     checked={{sectionData.showPrivate}}
                     onchange={{action \"updateFilter\" \"showPrivate\"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#inherited-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 2 }, 'should display 2 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking private shows private methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData updateFilter=(action "updateFilter") as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 2 }, 'should display 2 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingPrivate', 'should display 1 private method');
  });

  test('clicking private and inherited shows both methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field, value) {
      filterData.set(field, value);
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    await click('#inherited-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 3 }, 'should display 3 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking all toggles shows all methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id="protected-toggle"
                     type="checkbox"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" "showProtected"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id="deprecated-toggle"
                     type="checkbox"
                     checked="{{filterData.showDeprecated}}"
                     onchange={{action "updateFilter" "showDeprecated"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    await click('#inherited-toggle');
    await click('#protected-toggle');
    await click('#deprecated-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 5 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingDeprecated', 'should display 1 deprecated method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[3])
      .hasText('doSomethingProtected', 'should display 1 protected method');
    assert
      .dom(findAll('.method-name')[4])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking all toggles off should only show public', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: true,
      showProtected: true,
      showPrivate: true,
      showDeprecated: true,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id="protected-toggle"
                     type="checkbox"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" "showProtected"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id="deprecated-toggle"
                     type="checkbox"
                     checked="{{filterData.showDeprecated}}"
                     onchange={{action "updateFilter" "showDeprecated"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    assert
      .dom('.method-name')
      .exists({ count: 5 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingDeprecated', 'should display 1 deprecated method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[3])
      .hasText('doSomethingProtected', 'should display 1 protected method');
    assert
      .dom(findAll('.method-name')[4])
      .hasText('parentDoSomething', 'should display 1 inherited method');

    await click('#private-toggle');
    await click('#inherited-toggle');
    await click('#protected-toggle');
    await click('#deprecated-toggle');

    assert
      .dom('.method-name')
      .exists({ count: 1 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
  });

  test('should show only local method implementation when duplicates', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: true,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);
    assert
      .dom('.method-name')
      .exists(
        { count: 2 },
        'should display only the local method and the parent method with a different name'
      );
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });
});
<commit_msg>Fix corresponding test #775<commit_after>import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click, findAll } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | api index filter', function (hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function () {
    this.actions = {};
    this.send = (actionName, ...args) =>
      this.actions[actionName].apply(this, args);
  });

  const model = EmberObject.create({
    project: {
      id: 'lolwut',
    },
    projectVersion: {
      version: '2.9',
    },
    name: 'hai',
    file: 'my-class',
    parentClass: EmberObject.create({
      file: 'my-class',
    }),
    methods: [
      {
        name: 'doSomething',
        route: 'do-something',
        file: 'my-class',
      },
      {
        name: 'doSomething',
        route: 'do-something',
        file: 'my-parent-class',
      },
      {
        name: 'parentDoSomething',
        route: 'parent-do-something',
        inherited: true,
      },
      {
        name: 'doSomethingPrivate',
        route: 'do-something-private',
        access: 'private',
      },
      {
        name: 'doSomethingProtected',
        route: 'do-something-protected',
        access: 'protected',
      },
      {
        name: 'doSomethingDeprecated',
        route: 'do-something-deprecated',
        deprecated: true,
      },
    ],
    properties: [
      {
        name: 'isSomething',
        route: 'is-something',
      },
    ],
    events: [
      {
        name: 'didSomething',
        route: 'did-something',
      },
    ],
  });

  test('clicking inherited shows inherited methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      isDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id=\"private-toggle\"
                     type=\"checkbox\"
                     checked={{sectionData.showPrivate}}
                     onchange={{action \"updateFilter\" \"showPrivate\"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#inherited-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 2 }, 'should display 2 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking private shows private methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData updateFilter=(action "updateFilter") as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 2 }, 'should display 2 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingPrivate', 'should display 1 private method');
  });

  test('clicking private and inherited shows both methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field, value) {
      filterData.set(field, value);
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id=\"protected-toggle\"
                     type=\"checkbox\"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" \"showProtected\"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id=\"deprecated-toggle\"
                     type=\"checkbox\"
                     checked=\"{{sectionData.showDeprecated}}\"
                     onchange={{action \"updateFilter\" \"showDeprecated\"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    await click('#inherited-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 3 }, 'should display 3 methods total');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking all toggles shows all methods', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: false,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id="protected-toggle"
                     type="checkbox"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" "showProtected"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id="deprecated-toggle"
                     type="checkbox"
                     checked="{{filterData.showDeprecated}}"
                     onchange={{action "updateFilter" "showDeprecated"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    await click('#private-toggle');
    await click('#inherited-toggle');
    await click('#protected-toggle');
    await click('#deprecated-toggle');
    assert
      .dom('.method-name')
      .exists({ count: 5 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingDeprecated', 'should display 1 deprecated method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[3])
      .hasText('doSomethingProtected', 'should display 1 protected method');
    assert
      .dom(findAll('.method-name')[4])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });

  test('clicking all toggles off should only show public', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: true,
      showProtected: true,
      showPrivate: true,
      showDeprecated: true,
    });

    this.set('model', model);
    this.set('filterData', filterData);
    this.actions.updateFilter = function (field) {
      filterData.set(field, !filterData.get(field));
    };

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

            Show:

              <input id="inherited-toggle"
                     type="checkbox"
                     checked="{{filterData.showInherited}}"
                     onchange={{action "updateFilter" "showInherited"}}>
              Inherited

              <input id="protected-toggle"
                     type="checkbox"
                     checked={{filterData.showProtected}}
                     onchange={{action "updateFilter" "showProtected"}}>
              Protected

              <input id="private-toggle"
                     type="checkbox"
                     checked={{filterData.showPrivate}}
                     onchange={{action "updateFilter" "showPrivate"}}>
              Private

              <input id="deprecated-toggle"
                     type="checkbox"
                     checked="{{filterData.showDeprecated}}"
                     onchange={{action "updateFilter" "showDeprecated"}}>

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);

    assert
      .dom('.method-name')
      .exists({ count: 5 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('doSomethingDeprecated', 'should display 1 deprecated method');
    assert
      .dom(findAll('.method-name')[2])
      .hasText('doSomethingPrivate', 'should display 1 private method');
    assert
      .dom(findAll('.method-name')[3])
      .hasText('doSomethingProtected', 'should display 1 protected method');
    assert
      .dom(findAll('.method-name')[4])
      .hasText('parentDoSomething', 'should display 1 inherited method');

    await click('#private-toggle');
    await click('#inherited-toggle');
    await click('#protected-toggle');
    await click('#deprecated-toggle');

    assert
      .dom('.method-name')
      .exists({ count: 1 }, 'should display all methods');
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
  });

  test('should show only local method implementation when duplicates', async function (assert) {
    let filterData = EmberObject.create({
      showInherited: true,
      showProtected: false,
      showPrivate: false,
      showDeprecated: false,
    });

    this.set('model', model);
    this.set('filterData', filterData);

    await render(hbs`
      {{#api-index-filter model=model filterData=filterData as |myModel|}}

Methods

          {{#each myModel.methods as |method|}}

{{method.name}}

          {{/each}}
      {{/api-index-filter}}
    `);
    assert
      .dom('.method-name')
      .exists(
        { count: 2 },
        'should display only the local method and the parent method with a different name'
      );
    assert
      .dom(findAll('.method-name')[0])
      .hasText('doSomething', 'should display 1 public method');
    assert
      .dom(findAll('.method-name')[1])
      .hasText('parentDoSomething', 'should display 1 inherited method');
  });
});
<|endoftext|>