<commit_before>/**
 * UI Menu Context Class
 * @class UI.Menu.Context
 * @extends {UI.Menu}
 */
define([
	'UI/Menu/Menu'
], function(
	Menu
) {

	var _log = __debug('ui-menu-context').defineLevel();

	var exports = new Class({

		Extends: Menu,

		name: 'context',

		options: {
			name: 'context',
			scope: $(document.body),
			container: $(document.body),
			trigger: 'contextmenu',
			zIndex: 20,
			underlay: false
		},

		/**
		 * initialize
		 * @param  {Object} options
		 * @return {Object}
		 */
		initialize: function(options) {
			_log.debug('initialize', options);

			this.parent(options);
			var opts = this.options;
			if (opts.underlay) {
				this._initUnderlay();
			}

			this.element.inject(opts.container);
			this._initContext();

			return this;
		},

		/**
		 * Call UI.Component _initElement,
		 * then create a menu wrapper
		 * @return {void}
		 */
		_initElement: function() {
			_log.debug('_initElement');

			var self = this;
			var opts = this.options;

			this.element = new Element('div', {
				'class': 'ui-context',
				styles: {
					zIndex: opts.zIndex + 10
				}
			}).addEvents({
				mousediown: function(e) {
					self.fireEvent('mousedown');
					e.stop();
				}
			});

			this.element.addClass('context-' + opts.name);

			if (opts.klss) {
				this.element.addClass(opts.klss);
			}

			if (opts.type) {
				this.element.addClass('type-' + opts.type);
			}

			this._initHead(opts.head);

			this.content = new Element('ul', {
				'class': 'menu-list'
			}).inject(this.element);

			this.addEvents({
				show: function() {
					_log.debug('show');
					self.content.getStyle('display', 'block');
				},
				hide: function() {
					_log.debug('hide');
					self.content.getStyle('display', 'none');
				}
			});

			this.element.addEvent('click', function(e) {
				e.stop();
			});

			this.element.hide();
		},

		/**
		 * init context
		 * @return {Object}
		 */
		_initContext: function() {
			var self = this;
			var opts = this.options;
			var scope = opts.scope || opts.container;

			scope.getElements(opts.target).each(function(el) {
				//_log.debug(el);
				self.addTarget(el);
			});

			// self.element.addEvent('contextmenu', function(e){
			// 	e.stop();
			// });

			return this;
		},

		/**
		 * init underlay
		 * @return {void}
		 */
		_initUnderlay: function() {
			var self = this;
			var opts = this.options;

			var underlay = this.underlay = new Element('div', {
				'class': 'context-underlay',
				styles: {
					zIndex: opts.zIndex
				}
			}).addEvents({
				click: function() {
					_log.debug('click');
					underlay.setStyle('display', 'none');
					self.element.hide();
				}
			}).inject(opts.container);

			this.addEvents({
				show: function() {
					_log.debug('show');
					underlay.setStyle('display', 'block');
				}
			});
		},

		/**
		 * @ignore
		 */
		addList: function() {

		},

		/**
		 * add target
		 * @param {DOMElement} el
		 */
		addTarget: function(el) {
			var self = this;

			el.addEvent(self.options.trigger, function(e) {
				e.stop();
				e.preventDefault();

				self.target = e.target;

				//_log.debug(e.target);

				//.hide(0);
				//self.buildMenu(context.menu);
				self.show(e);
			});
		},

		/**
		 * remove list
		 * @return {void}
		 */
		removeList: function() {

		},

		/**
		 * init events
		 * @return {void}
		 */
		_initEvents: function() {
			this.parent();

			this.addEvents({
				show: function() {
					_log.debug('show');
					//ui.menu.hideAll();
				},
				hide: function() {
					_log.debug('hide');
				}
			});
		},

		/**
		 * Remove context to elements (defined by target)
		 * @return {Object}
		 */
		removeContexts: function() {
			//_log.debug('removeContext',this.options.scope);
			this.els.each(function(el) {
				el.removeEvents('contextmenu');
			});

			/*this.options.contexts.each(function(context){
				this.options.scope.getElements(context.target).each(function(el){
					//_log.debug(context.target,el);
					el.removeEvents('contextmenu');
				},this);
			},this);*/

			return this;
		},

		/**
		 * Overwrite the setPosition method of UI.Menu to use mouse coordinates to set menu location
		 * @param {integer} x X mouse's coordinates
		 * @param {integer} y Y mouse's coordinates
		 */
		setPosition: function(x, y) {
			var opts = this.options;
			var container = opts.container;

			if ((x === null) || (y === null)) {
				return;
			}

			var ctop = container.getPosition().y;

			var coor = this.element.getCoordinates();
			var top = y - ctop;
			var left = x + container.getScrollLeft();

			if ((x + coor.width) > container.getWidth()) {
				left = left - coor.width;
			}
			if ((y + coor.height) > container.getHeight()) {
				//_log.debug('top', top);
				top = top - coor.height;
			}

			this.element.setStyles({
				'top': top,
				'left': left
			});
		},

		/**
		 * hide
		 * @return {void}
		 */
		hide: function() {
			_log.debug('hide');

			clearTimeout(this.timer);
			this.timer = (function() {
				this.close();
			}).delay(this.options.timerOnHide, this);
		},

		/**
		 * hideNow
		 * @return {void}
		 */
		hideNow: function() {
			this.element.hide();
		},

		/**
		 * Overwrite the show method of UI.Menu to use mouse coordinates
		 * @param  {Object} e
		 * @return {Object}
		 */
		show: function(e) {
			_log.debug('show', this);

			this.fireEvent('show', e.target);

			this.element.show();

			//var coord = this.content.getCoordinates();
			//this.setSize(coord.width, coord.height);
			this.setPosition(e.client.x, e.client.y);

			return this;
		}

	});

	return exports;

});
<commit_msg>fix set position in menu context<commit_after>/**
 * UI Menu Context Class
 * @class UI.Menu.Context
 * @extends {UI.Menu}
 */
define([
	'UI/Menu/Menu'
], function(
	Menu
) {

	var _log = __debug('ui-menu-context').defineLevel();

	var exports = new Class({

		Extends: Menu,

		name: 'context',

		options: {
			name: 'context',
			scope: $(document.body),
			container: $(document.body),
			trigger: 'contextmenu',
			zIndex: 20,
			underlay: false
		},

		/**
		 * initialize
		 * @param  {Object} options
		 * @return {Object}
		 */
		initialize: function(options) {
			_log.debug('initialize', options);

			this.parent(options);
			var opts = this.options;
			if (opts.underlay) {
				this._initUnderlay();
			}

			this.element.inject(opts.container);
			this._initContext();

			return this;
		},

		/**
		 * Call UI.Component _initElement,
		 * then create a menu wrapper
		 * @return {void}
		 */
		_initElement: function() {
			_log.debug('_initElement');

			var self = this;
			var opts = this.options;

			this.element = new Element('div', {
				'class': 'ui-context',
				styles: {
					zIndex: opts.zIndex + 10
				}
			}).addEvents({
				mousediown: function(e) {
					self.fireEvent('mousedown');
					e.stop();
				}
			});

			this.element.addClass('context-' + opts.name);

			if (opts.klss) {
				this.element.addClass(opts.klss);
			}

			if (opts.type) {
				this.element.addClass('type-' + opts.type);
			}

			this._initHead(opts.head);

			this.content = new Element('ul', {
				'class': 'menu-list'
			}).inject(this.element);

			this.addEvents({
				show: function() {
					_log.debug('show');
					self.content.getStyle('display', 'block');
				},
				hide: function() {
					_log.debug('hide');
					self.content.getStyle('display', 'none');
				}
			});

			this.element.addEvent('click', function(e) {
				e.stop();
			});

			this.element.hide();
		},

		/**
		 * init context
		 * @return {Object}
		 */
		_initContext: function() {
			var self = this;
			var opts = this.options;
			var scope = opts.scope || opts.container;

			scope.getElements(opts.target).each(function(el) {
				//_log.debug(el);
				self.addTarget(el);
			});

			// self.element.addEvent('contextmenu', function(e){
			// 	e.stop();
			// });

			return this;
		},

		/**
		 * init underlay
		 * @return {void}
		 */
		_initUnderlay: function() {
			var self = this;
			var opts = this.options;

			var underlay = this.underlay = new Element('div', {
				'class': 'context-underlay',
				styles: {
					zIndex: opts.zIndex
				}
			}).addEvents({
				click: function() {
					_log.debug('click');
					underlay.setStyle('display', 'none');
					self.element.hide();
				}
			}).inject(opts.container);

			this.addEvents({
				show: function() {
					_log.debug('show');
					underlay.setStyle('display', 'block');
				}
			});
		},

		/**
		 * @ignore
		 */
		addList: function() {

		},

		/**
		 * add target
		 * @param {DOMElement} el
		 */
		addTarget: function(el) {
			var self = this;

			el.addEvent(self.options.trigger, function(e) {
				e.stop();
				e.preventDefault();

				self.target = e.target;

				//_log.debug(e.target);

				//.hide(0);
				//self.buildMenu(context.menu);
				self.show(e);
			});
		},

		/**
		 * remove list
		 * @return {void}
		 */
		removeList: function() {

		},

		/**
		 * init events
		 * @return {void}
		 */
		_initEvents: function() {
			this.parent();

			this.addEvents({
				show: function() {
					_log.debug('show');
					//ui.menu.hideAll();
				},
				hide: function() {
					_log.debug('hide');
				}
			});
		},

		/**
		 * Remove context to elements (defined by target)
		 * @return {Object}
		 */
		removeContexts: function() {
			//_log.debug('removeContext',this.options.scope);
			this.els.each(function(el) {
				el.removeEvents('contextmenu');
			});

			/*this.options.contexts.each(function(context){
				this.options.scope.getElements(context.target).each(function(el){
					//_log.debug(context.target,el);
					el.removeEvents('contextmenu');
				},this);
			},this);*/

			return this;
		},

		/**
		 * Overwrite the setPosition method of UI.Menu
		 * to use mouse coordinates to set menu location
		 * @param {integer} x X mouse's coordinates
		 * @param {integer} y Y mouse's coordinates
		 */
		setPosition: function(x, y) {
			var opts = this.options;
			var container = opts.container;

			if ((x === null) || (y === null)) {
				return;
			}

			var ctop = container.getPosition().y;

			var coor = this.element.getCoordinates();
			var top = y - ctop;
			var left = x - container.getPosition().x;

			if ((x + coor.width) > container.getWidth()) {
				left = left - coor.width;
			}
			if ((y + coor.height) > container.getHeight()) {
				//_log.debug('top', top);
				top = top - coor.height;
			}

			this.element.setStyles({
				'top': top,
				'left': left
			});
		},

		/**
		 * hide
		 * @return {void}
		 */
		hide: function() {
			_log.debug('hide');

			clearTimeout(this.timer);
			this.timer = (function() {
				this.close();
			}).delay(this.options.timerOnHide, this);
		},

		/**
		 * hideNow
		 * @return {void}
		 */
		hideNow: function() {
			this.element.hide();
		},

		/**
		 * Overwrite the show method of UI.Menu to use mouse coordinates
		 * @param  {Object} e
		 * @return {Object}
		 */
		show: function(e) {
			_log.debug('show', this);

			this.fireEvent('show', e.target);

			this.element.show();

			//var coord = this.content.getCoordinates();
			//this.setSize(coord.width, coord.height);
			this.setPosition(e.client.x, e.client.y);

			return this;
		}

	});

	return exports;

});
<|endoftext|>


<commit_before>/*
  Setup user details for exception handling
 */

App.then(function(app) {
    App.CurrentUser.find('current').then(function(user) {
        if (typeof Raven == 'object') {
            Raven.setUser({
                id: user.get('id_for_ember'),
                name: user.get('full_name'),
                email: user.get('email')
            });
        }
    });

    // This is called from the router automatically if the route being loaded
    // has a googleConversion property, otherwise it can be called manually.
    // Pass Google conversion code - 'gc'
    app.trackConversion = function (gc) {
        Ember.run.next(function() {
            if (gc &! DEBUG) {
                var google_conversion_id = gc.id || 986941294;
                var google_conversion_language = gc.language || 'en';
                var google_conversion_format = gc.format || '3';
                var google_conversion_color = gc.color || 'ffffff';
                var google_conversion_label = gc.label;
                var google_remarketing_only = false;
                $.getScript("https://www.googleadservices.com/pagead/conversion.js");
            }
        });
    };

    // Override the BB project / status search list
    // TODO: we should just define the 'list' when initializing
    //       and then BB should use it when setting up the list
    App.ProjectPhase.find().then(function(data){
        var list = [
            {id: 5, name: gettext("Running Campaigns")},
            {id: [7,8], name: gettext("Finished Campaigns")}
        ];
        App.ProjectPhaseSelectView.reopen({
            content: list
        });
    });

    // Facebook API ID
    if (FACEBOOK_AUTH_ID)
        App.set('appId', FACEBOOK_AUTH_ID);

    app.fbLogin = function (fbResponse) {

        var _this = this,
            currentUsercontroller = App.__container__.lookup('controller:currentUser');

        // Clear any existing tokens which might be present but expired. clearJwtToken action is on the App.ApplicationRoute
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        // currentUsercontroller.send('clearJwtToken');
        delete localStorage.jwtToken;
        App.set('jwtToken', null);

        return Ember.RSVP.Promise(function (resolve, reject) {
            var hash = {
              url: "/api/social-login/facebook/",
              dataType: "json",
              type: 'post',
              data: fbResponse
            };

            hash.success = function (response) {

                App.AuthJwt.processSuccessResponse(response).then(function (user) {

                    // If success
                    currentUsercontroller.set('model', user);

                    // For some reason the currentUserController keeps failing to have a reference to 'tracker'
                    var loginController = App.__container__.lookup('controller:login'),
                        tracker = loginController.get('tracker');

                    if (tracker) {
                        if (user.get('firstLogin')) {
                            tracker.alias(user.get('id_for_ember'));
                        } else {
                            tracker.identify(user.get('id_for_ember'));
                        }

                        tracker.peopleSet({
                            "$first_name": user.get('first_name'),
                            "$last_name": user.get('last_name'),
                            "$email": user.get('email'),
                            has_facebook: "yes",
                            last_login_type: "facebook"
                        });

                    }

                    if (user.get('firstLogin')) {
                        currentUsercontroller.send('setFlash', currentUsercontroller.get('welcomeMessage'));
                        // Register the successful Facebook signup with Mixpanel
                        if (tracker) {
                            tracker.trackEvent("Signup", {"type": "facebook"});
                            tracker.peopleSet({
                                facebook_shares: 0,
                                twitter_shares: 0
                            });
                        }
                    } else {
                        // Register the successful Facebook signin with Mixpanel
                        if (tracker) {
                            tracker.trackEvent("Login", {"type": "facebook"});
                            tracker.peopleSet({has_facebook: "yes"});
                        }
                    }

                    Ember.run(null, resolve, user);

                    // Trigger next transition in case a user was accesing a restricted page
                    currentUsercontroller.send('loadNextTransition');

                    if (FBApp.get('callingController')._handleSignupSuccess) {
                        FBApp.get('callingController')._handleSignupSuccess();
                    } else if (FBApp.get('callingController')._handleLoginSuccess) {
                        FBApp.get('callingController')._handleLoginSuccess();
                    } else {
                        currentUsercontroller.send('close');
                    }

                 }, function (error) {
                    // If Facebook login succeeded but something goes wrong on the token side we end up here
                    currentUsercontroller.send('setFlash', error, 'error');
                    Ember.run(null, reject, error);
                });
            };

            hash.error = function (response) {

                currentUsercontroller.send('setFlash', gettext('There was an error connecting Facebook'), 'error');
                var error = JSON.parse(response.responseText);
                Ember.run(null, reject, error);
            };

            Ember.$.ajax(hash);
        });
    };
});

/*
  Bluebottle Route Overrides
 */

App.ApplicationRoute.reopen(App.LogoutJwtMixin, {
    actions: {
        logout: function (redirect) {
            // call the standard logout code => clear JWT token etc
            this._super(redirect);

            // If the has logged in via FB, eg there is a FBUser then they should
            // be logged out so that the user can log in with user/email
            if (typeof FB == 'object' && !Em.isEmpty(FB.getUserID()))
                FB.logout();
        },
    }
});

/*
  Bluebottle Controller Overrides
 */
App.ApplicationController.reopen({
    needs: ['myProjectList'],
    missingCurrentUser: function () {
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        delete localStorage.jwtToken;
        App.set('jwtToken', null);
    }
});

App.EventMixin = Em.Mixin.create({

  bindScrolling: function(opts) {
    var onScroll, self = this;

    onScroll = function() {
      var scrollTop = $(this).scrollTop();
      return self.scrolled(scrollTop);
    };

    $(window).bind('scroll', onScroll);
    $(document).bind('touchmove', onScroll);
  },

  startStopScrolling: function(elm, nameClass) {
    var lastScroll = 0,
        st, startScroll;

    startScroll = function() {
        st = $(this).scrollTop();

        if (st > lastScroll) {
            $(elm).removeClass(nameClass);
        } else {
            $(elm).addClass(nameClass);
        }

        lastScroll = st;
    };

    $(window).bind('scroll', startScroll);
    $(document).bind('touchmove', startScroll);
  },

  unbindScrolling: function () {
    $(window).unbind('scroll');
    $(document).unbind('touchmove');
  },

  bindMobileClick: function() {
    toggleMenu = function() {
      $('.mobile-nav-holder').toggleClass('is-active');
    };

    closeMenu = function(event) {
      $('.mobile-nav-holder').removeClass('is-active');
    };

    $('.mobile-nav-btn').bind('click', toggleMenu);
    $('#content').bind('hover', closeMenu);
  }
});

Ember.View.reopen({
    touchStart: Ember.alias('click')
})

/*
  Bluebottle View Overrides
*/

App.ApplicationView.reopen(App.EventMixin, {
    setBindScrolling: function() {
        this.bindScrolling();
        this.startStopScrolling('#cheetah-header', 'is-active');
    }.on('didInsertElement'),

    setUnbindScrolling: function() {
        this.unbindScrolling();
    }.on('didInsertElement'),

    setBindClick: function() {
        this.bindMobileClick();
    }.on('didInsertElement'),

    scrolled: function(dist) {
        top = $('#content').offset();
        elm = top.screen.availTop;

        if (dist <= 53) {
            $('#header').removeClass('is-scrolled');
            $('.nav-member-dropdown').removeClass('is-scrolled');
            $('.mobile-nav-holder').removeClass('is-scrolled');
            //$('#content').append('

');
        } else {
            $('#header').addClass('is-scrolled');
            $('.nav-member-dropdown').addClass('is-scrolled');
            $('.mobile-nav-holder').addClass('is-scrolled');
        }
    }
});

// Enable Google Ad Words with Ember
App.Router.reopen({

    // If you want to add Google conversion codes to a route just add:
    // googleConversion: {
    //      label: 'my_page_label'
    // }

    didTransition: function(infos) {
        this._super(infos);

        var currentRoute = infos.get('lastObject').handler,
            gc = currentRoute.get('googleConversion');

        if (gc) App.trackConversion(gc);
    },
});

// Order login controller needs the jwt mixin
App.OrderLoginController.reopen(App.AuthJwtMixin, {});
<commit_msg>update deprecated alias method<commit_after>/*
  Setup user details for exception handling
 */

App.then(function(app) {
    App.CurrentUser.find('current').then(function(user) {
        if (typeof Raven == 'object') {
            Raven.setUser({
                id: user.get('id_for_ember'),
                name: user.get('full_name'),
                email: user.get('email')
            });
        }
    });

    // This is called from the router automatically if the route being loaded
    // has a googleConversion property, otherwise it can be called manually.
    // Pass Google conversion code - 'gc'
    app.trackConversion = function (gc) {
        Ember.run.next(function() {
            if (gc &! DEBUG) {
                var google_conversion_id = gc.id || 986941294;
                var google_conversion_language = gc.language || 'en';
                var google_conversion_format = gc.format || '3';
                var google_conversion_color = gc.color || 'ffffff';
                var google_conversion_label = gc.label;
                var google_remarketing_only = false;
                $.getScript("https://www.googleadservices.com/pagead/conversion.js");
            }
        });
    };

    // Override the BB project / status search list
    // TODO: we should just define the 'list' when initializing
    //       and then BB should use it when setting up the list
    App.ProjectPhase.find().then(function(data){
        var list = [
            {id: 5, name: gettext("Running Campaigns")},
            {id: [7,8], name: gettext("Finished Campaigns")}
        ];
        App.ProjectPhaseSelectView.reopen({
            content: list
        });
    });

    // Facebook API ID
    if (FACEBOOK_AUTH_ID)
        App.set('appId', FACEBOOK_AUTH_ID);

    app.fbLogin = function (fbResponse) {

        var _this = this,
            currentUsercontroller = App.__container__.lookup('controller:currentUser');

        // Clear any existing tokens which might be present but expired. clearJwtToken action is on the App.ApplicationRoute
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        // currentUsercontroller.send('clearJwtToken');
        delete localStorage.jwtToken;
        App.set('jwtToken', null);

        return Ember.RSVP.Promise(function (resolve, reject) {
            var hash = {
              url: "/api/social-login/facebook/",
              dataType: "json",
              type: 'post',
              data: fbResponse
            };

            hash.success = function (response) {

                App.AuthJwt.processSuccessResponse(response).then(function (user) {

                    // If success
                    currentUsercontroller.set('model', user);

                    // For some reason the currentUserController keeps failing to have a reference to 'tracker'
                    var loginController = App.__container__.lookup('controller:login'),
                        tracker = loginController.get('tracker');

                    if (tracker) {
                        if (user.get('firstLogin')) {
                            tracker.alias(user.get('id_for_ember'));
                        } else {
                            tracker.identify(user.get('id_for_ember'));
                        }

                        tracker.peopleSet({
                            "$first_name": user.get('first_name'),
                            "$last_name": user.get('last_name'),
                            "$email": user.get('email'),
                            has_facebook: "yes",
                            last_login_type: "facebook"
                        });

                    }

                    if (user.get('firstLogin')) {
                        currentUsercontroller.send('setFlash', currentUsercontroller.get('welcomeMessage'));
                        // Register the successful Facebook signup with Mixpanel
                        if (tracker) {
                            tracker.trackEvent("Signup", {"type": "facebook"});
                            tracker.peopleSet({
                                facebook_shares: 0,
                                twitter_shares: 0
                            });
                        }
                    } else {
                        // Register the successful Facebook signin with Mixpanel
                        if (tracker) {
                            tracker.trackEvent("Login", {"type": "facebook"});
                            tracker.peopleSet({has_facebook: "yes"});
                        }
                    }

                    Ember.run(null, resolve, user);

                    // Trigger next transition in case a user was accesing a restricted page
                    currentUsercontroller.send('loadNextTransition');

                    if (FBApp.get('callingController')._handleSignupSuccess) {
                        FBApp.get('callingController')._handleSignupSuccess();
                    } else if (FBApp.get('callingController')._handleLoginSuccess) {
                        FBApp.get('callingController')._handleLoginSuccess();
                    } else {
                        currentUsercontroller.send('close');
                    }

                 }, function (error) {
                    // If Facebook login succeeded but something goes wrong on the token side we end up here
                    currentUsercontroller.send('setFlash', error, 'error');
                    Ember.run(null, reject, error);
                });
            };

            hash.error = function (response) {

                currentUsercontroller.send('setFlash', gettext('There was an error connecting Facebook'), 'error');
                var error = JSON.parse(response.responseText);
                Ember.run(null, reject, error);
            };

            Ember.$.ajax(hash);
        });
    };
});

/*
  Bluebottle Route Overrides
 */

App.ApplicationRoute.reopen(App.LogoutJwtMixin, {
    actions: {
        logout: function (redirect) {
            // call the standard logout code => clear JWT token etc
            this._super(redirect);

            // If the has logged in via FB, eg there is a FBUser then they should
            // be logged out so that the user can log in with user/email
            if (typeof FB == 'object' && !Em.isEmpty(FB.getUserID()))
                FB.logout();
        },
    }
});

/*
  Bluebottle Controller Overrides
 */
App.ApplicationController.reopen({
    needs: ['myProjectList'],
    missingCurrentUser: function () {
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        delete localStorage.jwtToken;
        App.set('jwtToken', null);
    }
});

App.EventMixin = Em.Mixin.create({

  bindScrolling: function(opts) {
    var onScroll, self = this;

    onScroll = function() {
      var scrollTop = $(this).scrollTop();
      return self.scrolled(scrollTop);
    };

    $(window).bind('scroll', onScroll);
    $(document).bind('touchmove', onScroll);
  },

  startStopScrolling: function(elm, nameClass) {
    var lastScroll = 0,
        st, startScroll;

    startScroll = function() {
        st = $(this).scrollTop();

        if (st > lastScroll) {
            $(elm).removeClass(nameClass);
        } else {
            $(elm).addClass(nameClass);
        }

        lastScroll = st;
    };

    $(window).bind('scroll', startScroll);
    $(document).bind('touchmove', startScroll);
  },

  unbindScrolling: function () {
    $(window).unbind('scroll');
    $(document).unbind('touchmove');
  },

  bindMobileClick: function() {
    toggleMenu = function() {
      $('.mobile-nav-holder').toggleClass('is-active');
    };

    closeMenu = function(event) {
      $('.mobile-nav-holder').removeClass('is-active');
    };

    $('.mobile-nav-btn').bind('click', toggleMenu);
    $('#content').bind('hover', closeMenu);
  }
});

Ember.View.reopen({
    touchStart: Ember.computed.alias('click')
})

/*
  Bluebottle View Overrides
*/

App.ApplicationView.reopen(App.EventMixin, {
    setBindScrolling: function() {
        this.bindScrolling();
        this.startStopScrolling('#cheetah-header', 'is-active');
    }.on('didInsertElement'),

    setUnbindScrolling: function() {
        this.unbindScrolling();
    }.on('didInsertElement'),

    setBindClick: function() {
        this.bindMobileClick();
    }.on('didInsertElement'),

    scrolled: function(dist) {
        top = $('#content').offset();
        elm = top.screen.availTop;

        if (dist <= 53) {
            $('#header').removeClass('is-scrolled');
            $('.nav-member-dropdown').removeClass('is-scrolled');
            $('.mobile-nav-holder').removeClass('is-scrolled');
            //$('#content').append('

');
        } else {
            $('#header').addClass('is-scrolled');
            $('.nav-member-dropdown').addClass('is-scrolled');
            $('.mobile-nav-holder').addClass('is-scrolled');
        }
    }
});

// Enable Google Ad Words with Ember
App.Router.reopen({

    // If you want to add Google conversion codes to a route just add:
    // googleConversion: {
    //      label: 'my_page_label'
    // }

    didTransition: function(infos) {
        this._super(infos);

        var currentRoute = infos.get('lastObject').handler,
            gc = currentRoute.get('googleConversion');

        if (gc) App.trackConversion(gc);
    },
});

// Order login controller needs the jwt mixin
App.OrderLoginController.reopen(App.AuthJwtMixin, {});
<|endoftext|>


<commit_before>/*
  Setup user details for exception handling
 */

App.then(function(app) {
    App.CurrentUser.find('current').then(function(user) {
        if (typeof Raven == 'object') {
            Raven.setUser({
                id: user.get('id_for_ember'),
                name: user.get('full_name'),
                email: user.get('email'),
            });
        }
    });

    // Override the BB project / status search list
    // TODO: we should just define the 'list' when initializing
    //       and then BB should use it when setting up the list
    App.ProjectPhase.find().then(function(data){
        var list = [
            {id: 5, name: gettext("Running campaigns")},
            {id: [7,8], name: gettext("Finished campaigns")}
        ];
        App.ProjectPhaseSelectView.reopen({
            content: list
        });
    });

    // Facebook API ID
    if (FACEBOOK_AUTH_ID)
        App.set('appId', FACEBOOK_AUTH_ID);

    app.appLogin = function (fbResponse) {
        var _this = this,
            currentUsercontroller = App.__container__.lookup('controller:currentUser');

        // Clear any existing tokens which might be present but expired. clearJwtToken action is on the App.ApplicationRoute
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        // currentUsercontroller.send('clearJwtToken');
        delete localStorage['jwtToken'];
        App.set('jwtToken', null);

        return Ember.RSVP.Promise(function (resolve, reject) {
            var hash = {
              url: "/api/social-login/facebook/",
              dataType: "json",
              type: 'post',
              data: fbResponse
            };

            hash.success = function (response) {

                App.AuthJwt.processSuccessResponse(response).then(function (user) {

                    // If success
                    currentUsercontroller.set('model', user);
                    currentUsercontroller.send('close');
                    if (user.get('last_login') == user.get('date_joined')) {
                        currentUsercontroller.send('setFlash', gettext('Welcome to the 1%Club'));
                    }

                    Ember.run(null, resolve, user);
                 }, function (error) {
                    // If failed

                    Ember.run(null, reject, error);
                });
            };

            hash.error = function (response) {

                currentUsercontroller.send('setFlash', gettext('Something went wrong :-('), 'error');
                var error = JSON.parse(response.responseText);
                Ember.run(null, reject, error);
            };

            Ember.$.ajax(hash);
        });
    };
});

/*
  Bluebottle Route Overrides
 */

App.ApplicationRoute.reopen(App.LogoutJwtMixin, {
    init: function () {
        this._super();

        // Set the facebook appId
        // TODO: move this to the server side settings
        this.set('appId', '1438115069790112');
    },

    actions: {
        logout: function (redirect) {
            // call the standard logout code => clear JWT token etc
            this._super(redirect);

            // If the has logged in via FB, eg there is a FBUser then they should
            // be logged out so that the user can log in with user/email
            if (FB && !Em.isEmpty(FB.getUserID()))
                FB.logout()
        },
        addDonation: function (project, fundraiser) {
            var route = this;
            App.CurrentOrder.find('current').then(function(order) {
                var store = route.get('store');

                var projectHasDonation = order.get('donations').anyBy('project', project);
                var fundraiserHasDonation = false;
                if(fundraiser !== undefined){
                    fundraiserHasDonation = order.get('donations').anyBy('fundraiser', fundraiser);
                }

                // TODO: functional test this.
                // *  Donate directly to project: check if no direct donations exist
                // *  Donate through fundraiser: check if donation for that fundraiser exists
                // *  We can have the same project multiple times, but all different fundraisers

                if (fundraiserHasDonation ||
                    (projectHasDonation && !fundraiserHasDonation && fundraiser === undefined)) {
                    // Donation for this already exists in this order.
                } else {
                    var donation = store.createRecord(App.CurrentOrderDonation);
                    donation.set('project', project);
                    if(fundraiser !== undefined){
                        donation.set('fundraiser', fundraiser);
                    }
                    donation.set('order', order);
                    donation.save();
                }
                route.transitionTo('currentOrder.donationList');
            });
        }
    }
});

/*
  Bluebottle Controller Overrides
 */
App.ApplicationController.reopen({
    needs: ['currentOrder', 'myProjectList'],

    missingCurrentUser: function () {
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        delete localStorage['jwtToken'];
        App.set('jwtToken', null);
    },
});

App.EventMixin = Em.Mixin.create({

  bindScrolling: function(opts) {
    var onScroll, self = this;

    onScroll = function() {
      var scrollTop = $(this).scrollTop();
      return self.scrolled(scrollTop);
    };

    $(window).bind('scroll', onScroll);
    $(document).bind('touchmove', onScroll);
  },

  unbindScrolling: function () {
    $(window).unbind('scroll');
    $(document).unbind('touchmove');
  },

  bindMobileClick: function() {
    toggleMenu = function() {
      $('.mobile-nav-holder').toggleClass('is-active');
    };

    closeMenu = function(event) {
      $('.mobile-nav-holder').removeClass('is-active');
    };

    $('.mobile-nav-btn').bind('click', toggleMenu);
    $('#content').bind('hover', closeMenu);
  }
});

/*
  Bluebottle View Overrides
*/

App.ApplicationView.reopen(App.EventMixin, {
    setBindScrolling: function() {
        this.bindScrolling();
    }.on('didInsertElement'),

    setUnbindScrolling: function() {
        this.unbindScrolling();
    }.on('didInsertElement'),

    setBindClick: function() {
        this.bindMobileClick();
    }.on('didInsertElement'),

    scrolled: function(dist) {
        top = $('#content').offset();
        elm = top.screen.availTop;

        if (dist <= 53) {
            $('#header').removeClass('is-scrolled');
            $('.nav-member-dropdown').removeClass('is-scrolled');
            $('.mobile-nav-holder').removeClass('is-scrolled');
            $('#content').append('

');
        } else {
            $('#header').addClass('is-scrolled');
            $('.nav-member-dropdown').addClass('is-scrolled');
            $('.mobile-nav-holder').addClass('is-scrolled');
        }
    }
});
<commit_msg>add firstLogni check<commit_after>/*
  Setup user details for exception handling
 */

App.then(function(app) {
    App.CurrentUser.find('current').then(function(user) {
        if (typeof Raven == 'object') {
            Raven.setUser({
                id: user.get('id_for_ember'),
                name: user.get('full_name'),
                email: user.get('email'),
            });
        }
    });

    // Override the BB project / status search list
    // TODO: we should just define the 'list' when initializing
    //       and then BB should use it when setting up the list
    App.ProjectPhase.find().then(function(data){
        var list = [
            {id: 5, name: gettext("Running campaigns")},
            {id: [7,8], name: gettext("Finished campaigns")}
        ];
        App.ProjectPhaseSelectView.reopen({
            content: list
        });
    });

    // Facebook API ID
    if (FACEBOOK_AUTH_ID)
        App.set('appId', FACEBOOK_AUTH_ID);

    app.appLogin = function (fbResponse) {
        var _this = this,
            currentUsercontroller = App.__container__.lookup('controller:currentUser');

        // Clear any existing tokens which might be present but expired. clearJwtToken action is on the App.ApplicationRoute
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        // currentUsercontroller.send('clearJwtToken');
        delete localStorage['jwtToken'];
        App.set('jwtToken', null);

        return Ember.RSVP.Promise(function (resolve, reject) {
            var hash = {
              url: "/api/social-login/facebook/",
              dataType: "json",
              type: 'post',
              data: fbResponse
            };

            hash.success = function (response) {

                App.AuthJwt.processSuccessResponse(response).then(function (user) {

                    // If success
                    currentUsercontroller.set('model', user);
                    currentUsercontroller.send('close');

                    if (user.get('firstLogin')) {
                        currentUsercontroller.send('setFlash', gettext('Welcome to the 1%Club'));
                    }

                    Ember.run(null, resolve, user);
                 }, function (error) {
                    // If failed

                    Ember.run(null, reject, error);
                });
            };

            hash.error = function (response) {

                currentUsercontroller.send('setFlash', gettext('Something went wrong :-('), 'error');
                var error = JSON.parse(response.responseText);
                Ember.run(null, reject, error);
            };

            Ember.$.ajax(hash);
        });
    };
});

/*
  Bluebottle Route Overrides
 */

App.ApplicationRoute.reopen(App.LogoutJwtMixin, {
    init: function () {
        this._super();

        // Set the facebook appId
        // TODO: move this to the server side settings
        this.set('appId', '1438115069790112');
    },

    actions: {
        logout: function (redirect) {
            // call the standard logout code => clear JWT token etc
            this._super(redirect);

            // If the has logged in via FB, eg there is a FBUser then they should
            // be logged out so that the user can log in with user/email
            if (FB && !Em.isEmpty(FB.getUserID()))
                FB.logout()
        },
        addDonation: function (project, fundraiser) {
            var route = this;
            App.CurrentOrder.find('current').then(function(order) {
                var store = route.get('store');

                var projectHasDonation = order.get('donations').anyBy('project', project);
                var fundraiserHasDonation = false;
                if(fundraiser !== undefined){
                    fundraiserHasDonation = order.get('donations').anyBy('fundraiser', fundraiser);
                }

                // TODO: functional test this.
                // *  Donate directly to project: check if no direct donations exist
                // *  Donate through fundraiser: check if donation for that fundraiser exists
                // *  We can have the same project multiple times, but all different fundraisers

                if (fundraiserHasDonation ||
                    (projectHasDonation && !fundraiserHasDonation && fundraiser === undefined)) {
                    // Donation for this already exists in this order.
                } else {
                    var donation = store.createRecord(App.CurrentOrderDonation);
                    donation.set('project', project);
                    if(fundraiser !== undefined){
                        donation.set('fundraiser', fundraiser);
                    }
                    donation.set('order', order);
                    donation.save();
                }
                route.transitionTo('currentOrder.donationList');
            });
        }
    }
});

/*
  Bluebottle Controller Overrides
 */
App.ApplicationController.reopen({
    needs: ['currentOrder', 'myProjectList'],

    missingCurrentUser: function () {
        // FIXME: should call the clearJwtToken action here but it isn't being called.
        delete localStorage['jwtToken'];
        App.set('jwtToken', null);
    },
});

App.EventMixin = Em.Mixin.create({

  bindScrolling: function(opts) {
    var onScroll, self = this;

    onScroll = function() {
      var scrollTop = $(this).scrollTop();
      return self.scrolled(scrollTop);
    };

    $(window).bind('scroll', onScroll);
    $(document).bind('touchmove', onScroll);
  },

  unbindScrolling: function () {
    $(window).unbind('scroll');
    $(document).unbind('touchmove');
  },

  bindMobileClick: function() {
    toggleMenu = function() {
      $('.mobile-nav-holder').toggleClass('is-active');
    };

    closeMenu = function(event) {
      $('.mobile-nav-holder').removeClass('is-active');
    };

    $('.mobile-nav-btn').bind('click', toggleMenu);
    $('#content').bind('hover', closeMenu);
  }
});

/*
  Bluebottle View Overrides
*/

App.ApplicationView.reopen(App.EventMixin, {
    setBindScrolling: function() {
        this.bindScrolling();
    }.on('didInsertElement'),

    setUnbindScrolling: function() {
        this.unbindScrolling();
    }.on('didInsertElement'),

    setBindClick: function() {
        this.bindMobileClick();
    }.on('didInsertElement'),

    scrolled: function(dist) {
        top = $('#content').offset();
        elm = top.screen.availTop;

        if (dist <= 53) {
            $('#header').removeClass('is-scrolled');
            $('.nav-member-dropdown').removeClass('is-scrolled');
            $('.mobile-nav-holder').removeClass('is-scrolled');
            $('#content').append('

');
        } else {
            $('#header').addClass('is-scrolled');
            $('.nav-member-dropdown').addClass('is-scrolled');
            $('.mobile-nav-holder').addClass('is-scrolled');
        }
    }
});
<|endoftext|>


<commit_before>define([
    'jquery',
    'backbone',
    'arches',
    'models/concept',
    'models/value',
    'models/concept-parents',
    'views/rdm/modals/value-form',
    'views/rdm/modals/related-concept-form',
    'views/rdm/modals/related-member-form',
    'views/rdm/modals/manage-parent-form',
    'views/rdm/modals/import-concept-form',
    'views/rdm/modals/add-child-form',
    'views/rdm/modals/add-image-form',
    'views/concept-graph',
    'viewmodels/alert',
    'viewmodels/alert-json',
], function ($, Backbone, arches, ConceptModel, ValueModel, ConceptParentModel, ValueEditor,
    RelatedConcept, RelatedMember, ManageParentForm, ImportConcept, AddChildForm,
    AddImageForm, ConceptGraph, AlertViewModel, JsonErrorAlertViewModel) {
    return Backbone.View.extend({
        events: {
            'click .concept-report-content *[data-action="viewconcept"]': 'conceptSelected',
            'click .concept-report-content *[data-action="viewddconcept"]': 'dropdownConceptSelected',
            'click .concept-report-content *[data-action="delete-relationship"]': 'deleteClicked',
            'click .concept-report-content *[data-action="delete-value"]': 'deleteClicked',
            'click .concept-report-content *[data-action="delete-concept"]': 'deleteClicked',
            'click a.add-image-link': 'addImageClicked',
            'click a.edit-value': 'editValueClicked',
            'click .confirm-delete-yes': 'deleteConfirmed',
            'click a[data-toggle="#related-concept-form"]': 'addRelatedConceptClicked',
            'click a[data-toggle="#related-member-form"]': 'addRelatedMemberClicked',
            'click a[data-toggle="#add-concept-form"]': 'addChildConcept',
            'click a[data-toggle="#add-top-concept-form"]': 'addChildConcept',
            'click a[data-toggle="#manage-parent-form"]': 'manageParentConcepts',
            'click a[data-toggle="#import-concept-form"]': 'importConcept',
            'click a[data-toggle="#make-collection"]': 'makeCollection',
        },

        initialize: function(options) {
            this.viewModel = options.viewModel;
            this.render();
        },

        render: function() {
            var self = this;
            var conceptid = this.model.get('id');
            var showGraph = self.$el.find(".concept-graph").is(":visible");

            self.$el.find('.concept-report-loading').removeClass('hidden');
            self.$el.find('.concept-report-content').addClass('hidden');

            if (this.xhr){
                this.xhr.abort();
            }

            this.xhr = $.ajax({
                url: arches.urls.concept.replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', conceptid),
                data: {
                    'f': 'html',
                    'mode': this.mode
                },
                success: function(response) {
                    self.$el.find('.concept-report-loading').addClass('hidden');
                    self.$el.html(response);

                    var data = self.$el.find('div[name="modeldata"]').data();
                    self.model.set(data);

                    if (self.model.get('id')) {
                        if (self.$el.find(".concept-graph").length > 0) {
                            //Toggle Concept Heirarchy.
                            self.$el.find(".graph-toggle").click(function(){
                                self.$el.find(".concept-tree").toggle(300);
                                self.$el.find(".concept-graph").toggle(300);
                                self.$el.find(".graph-toggle").toggle();
                            });
                            new ConceptGraph({
                                el: self.$el.find(".concept-graph")
                            });
                            if (showGraph) {
                                self.$el.find(".graph-toggle").toggle();
                                self.$el.find(".concept-tree").toggle(0);
                                self.$el.find(".concept-graph").toggle(0);
                            }
                        }
                    }
                }
            });
        },

        deleteClicked: function(e) {
            var self = this;
            var data = $(e.target).data();

            this.confirm_delete_modal = this.$el.find('.confirm-delete-modal');
            this.confirm_delete_modal_yes = this.confirm_delete_modal.find('.confirm-delete-yes');
            this.confirm_delete_modal_yes.removeAttr('disabled');
            this.confirm_delete_modal_yes.data('id', data.id);
            this.confirm_delete_modal_yes.data('nodetype', data.nodetype);
            this.confirm_delete_modal_yes.data('action', data.action);
            this.confirm_delete_modal_yes.data('category', data.category);

            this.confirm_delete_modal.find('.modal-title').text($(e.target).attr('title'));
            this.confirm_delete_modal.find('.modal-body [name="warning-text"]').text(data.message);
            this.confirm_delete_modal.find('.modal-body [name="additional-info"]').text('');
            this.confirm_delete_modal.modal('show');

            if (data.action === 'delete-concept'){
                this.confirm_delete_modal_yes.attr('disabled', 'disabled');
                $.ajax({
                    url: arches.urls.confirm_delete.replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', data.id),
                    success: function(response) {
                        self.confirm_delete_modal_yes.removeAttr('disabled');
                        self.confirm_delete_modal.find('.modal-body [name="additional-info"]').html(response);
                    }
                });
            }

        },

        conceptSelected: function(e) {
            var data = $(e.target).data();
            this.trigger('conceptSelected', data.conceptid);
        },

        dropdownConceptSelected: function(e) {
            var data = $(e.target).data();
            this.trigger('dropdownConceptSelected', data.conceptid);
        },

        addChildConcept: function(e){
            this.model.reset();
            var form = new AddChildForm({
                el: $('#add-child-form')[0],
                model: this.model
            });

            form.modal.modal('show');
        },

        addRelatedConceptClicked: function(e){
            this.model.reset();
            var modal = new RelatedConcept({
                el: $('#related-concept-form')[0],
                model: this.model
            });
            modal.modal.modal('show');
        },

        addRelatedMemberClicked: function(e){
            this.model.reset();
            var modal = new RelatedMember({
                el: $('#related-member-form')[0],
                model: this.model
            });
            modal.modal.modal('show');
        },

        manageParentConcepts: function(e){
            var self = this;
            var parentmodel = new ConceptParentModel();
            parentmodel.set('id', this.model.get('id'));

            var modal = new ManageParentForm({
                el: $('#manage-parent-form')[0],
                model: parentmodel
            });
            modal.modal.modal('show');

            parentmodel.on({
                'save': function(){
                    self.trigger('parentsChanged');
                }
            });
        },

        makeCollection: function(e){
            this.model.makeCollection(function(response, status){
                if (status === 'success') {
                    this.viewModel.alert(new AlertViewModel('ep-alert-blue', response.responseJSON.title, response.responseJSON.message));
                }
                if (status === 'error') {
                    this.viewModel.alert(new JsonErrorAlertViewModel('ep-alert-red', response.responseJSON));
                }
            }, this);
        },

        importConcept: function(e){
            var self = this;
            this.model.reset();
            var modal = new ImportConcept({
                el: $('#import-concept-form')[0],
                model: this.model
            });
            modal.modal.modal('show');

            modal.on({
                'conceptsImported': function(){
                    self.trigger('conceptsImported');
                }
            });
        },

        addImageClicked: function (e) {
            this.model.reset();
            var self = this;
            var form = new AddImageForm({
                el: this.$el.find('#add-image-form')[0],
                model: this.model
            });

            form.on('dataChanged', function () {
                self.render();
            });
        },

        editValueClicked: function(e) {
            this.model.reset();
            var data = $.extend({
                    conceptid: this.model.get('id')
                },
                $(e.target).data()
            );
            this.model.set('values', [new ValueModel(data)]);
            var editor = new ValueEditor({
                el: this.$el.find('#value-form')[0],
                model: this.model
            });
        },

        deleteConfirmed: function(e) {
            var self = this;
            var data = $(e.target).data();
            var modal = self.$el.find('.confirm-delete-modal');
            var title = modal.find('.modal-title').text();
            this.model.reset();

            if (data.action === 'delete-concept') {
                modal.find('h4').text(' ' + title);
                modal.find('.modal-title').addClass('loading');

                model = new ConceptModel(data)
                self.model.set('subconcepts', [model]);

                self.model.delete(function(response, status){
                    modal.find('h4').text(title);
                    modal.find('.modal-title').removeClass('loading');
                    modal.modal('hide');
                    $('.modal-backdrop.fade.in').remove();  // a hack for now
                    if(!!response.responseJSON.in_use){
                        self.viewModel.alert(new AlertViewModel('ep-alert-blue', response.responseJSON.title, response.responseJSON.message));
                    }
                }, self);
            }else{
                modal.on('hidden.bs.modal', function () {
                    var model;

                    if (data.action === 'delete-value') {
                        model = new ValueModel(data);
                        model.delete(self.render, self);
                    }
                    if (data.action === 'delete-relationship') {
                        model = new ConceptModel(data);
                        self.model.set('relatedconcepts', [model]);
                        self.model.delete();
                    }

                });
                modal.modal('hide');
            }
        }
    });
});<commit_msg>lints<commit_after>define([
    'jquery',
    'backbone',
    'arches',
    'models/concept',
    'models/value',
    'models/concept-parents',
    'views/rdm/modals/value-form',
    'views/rdm/modals/related-concept-form',
    'views/rdm/modals/related-member-form',
    'views/rdm/modals/manage-parent-form',
    'views/rdm/modals/import-concept-form',
    'views/rdm/modals/add-child-form',
    'views/rdm/modals/add-image-form',
    'views/concept-graph',
    'viewmodels/alert',
    'viewmodels/alert-json',
], function($, Backbone, arches, ConceptModel, ValueModel, ConceptParentModel, ValueEditor,
    RelatedConcept, RelatedMember, ManageParentForm, ImportConcept, AddChildForm,
    AddImageForm, ConceptGraph, AlertViewModel, JsonErrorAlertViewModel) {
    return Backbone.View.extend({
        events: {
            'click .concept-report-content *[data-action="viewconcept"]': 'conceptSelected',
            'click .concept-report-content *[data-action="viewddconcept"]': 'dropdownConceptSelected',
            'click .concept-report-content *[data-action="delete-relationship"]': 'deleteClicked',
            'click .concept-report-content *[data-action="delete-value"]': 'deleteClicked',
            'click .concept-report-content *[data-action="delete-concept"]': 'deleteClicked',
            'click a.add-image-link': 'addImageClicked',
            'click a.edit-value': 'editValueClicked',
            'click .confirm-delete-yes': 'deleteConfirmed',
            'click a[data-toggle="#related-concept-form"]': 'addRelatedConceptClicked',
            'click a[data-toggle="#related-member-form"]': 'addRelatedMemberClicked',
            'click a[data-toggle="#add-concept-form"]': 'addChildConcept',
            'click a[data-toggle="#add-top-concept-form"]': 'addChildConcept',
            'click a[data-toggle="#manage-parent-form"]': 'manageParentConcepts',
            'click a[data-toggle="#import-concept-form"]': 'importConcept',
            'click a[data-toggle="#make-collection"]': 'makeCollection',
        },

        initialize: function(options) {
            this.viewModel = options.viewModel;
            this.render();
        },

        render: function() {
            var self = this;
            var conceptid = this.model.get('id');
            var showGraph = self.$el.find(".concept-graph").is(":visible");

            self.$el.find('.concept-report-loading').removeClass('hidden');
            self.$el.find('.concept-report-content').addClass('hidden');

            if (this.xhr){
                this.xhr.abort();
            }

            this.xhr = $.ajax({
                url: arches.urls.concept.replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', conceptid),
                data: {
                    'f': 'html',
                    'mode': this.mode
                },
                success: function(response) {
                    self.$el.find('.concept-report-loading').addClass('hidden');
                    self.$el.html(response);

                    var data = self.$el.find('div[name="modeldata"]').data();
                    self.model.set(data);

                    if (self.model.get('id')) {
                        if (self.$el.find(".concept-graph").length > 0) {
                            //Toggle Concept Heirarchy.
                            self.$el.find(".graph-toggle").click(function(){
                                self.$el.find(".concept-tree").toggle(300);
                                self.$el.find(".concept-graph").toggle(300);
                                self.$el.find(".graph-toggle").toggle();
                            });
                            new ConceptGraph({
                                el: self.$el.find(".concept-graph")
                            });
                            if (showGraph) {
                                self.$el.find(".graph-toggle").toggle();
                                self.$el.find(".concept-tree").toggle(0);
                                self.$el.find(".concept-graph").toggle(0);
                            }
                        }
                    }
                }
            });
        },

        deleteClicked: function(e) {
            var self = this;
            var data = $(e.target).data();

            this.confirm_delete_modal = this.$el.find('.confirm-delete-modal');
            this.confirm_delete_modal_yes = this.confirm_delete_modal.find('.confirm-delete-yes');
            this.confirm_delete_modal_yes.removeAttr('disabled');
            this.confirm_delete_modal_yes.data('id', data.id);
            this.confirm_delete_modal_yes.data('nodetype', data.nodetype);
            this.confirm_delete_modal_yes.data('action', data.action);
            this.confirm_delete_modal_yes.data('category', data.category);

            this.confirm_delete_modal.find('.modal-title').text($(e.target).attr('title'));
            this.confirm_delete_modal.find('.modal-body [name="warning-text"]').text(data.message);
            this.confirm_delete_modal.find('.modal-body [name="additional-info"]').text('');
            this.confirm_delete_modal.modal('show');

            if (data.action === 'delete-concept'){
                this.confirm_delete_modal_yes.attr('disabled', 'disabled');
                $.ajax({
                    url: arches.urls.confirm_delete.replace('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', data.id),
                    success: function(response) {
                        self.confirm_delete_modal_yes.removeAttr('disabled');
                        self.confirm_delete_modal.find('.modal-body [name="additional-info"]').html(response);
                    }
                });
            }

        },

        conceptSelected: function(e) {
            var data = $(e.target).data();
            this.trigger('conceptSelected', data.conceptid);
        },

        dropdownConceptSelected: function(e) {
            var data = $(e.target).data();
            this.trigger('dropdownConceptSelected', data.conceptid);
        },

        addChildConcept: function(e){
            this.model.reset();
            var form = new AddChildForm({
                el: $('#add-child-form')[0],
                model: this.model
            });

            form.modal.modal('show');
        },

        addRelatedConceptClicked: function(e){
            this.model.reset();
            var modal = new RelatedConcept({
                el: $('#related-concept-form')[0],
                model: this.model
            });
            modal.modal.modal('show');
        },

        addRelatedMemberClicked: function(e){
            this.model.reset();
            var modal = new RelatedMember({
                el: $('#related-member-form')[0],
                model: this.model
            });
            modal.modal.modal('show');
        },

        manageParentConcepts: function(e){
            var self = this;
            var parentmodel = new ConceptParentModel();
            parentmodel.set('id', this.model.get('id'));

            var modal = new ManageParentForm({
                el: $('#manage-parent-form')[0],
                model: parentmodel
            });
            modal.modal.modal('show');

            parentmodel.on({
                'save': function(){
                    self.trigger('parentsChanged');
                }
            });
        },

        makeCollection: function(e){
            this.model.makeCollection(function(response, status){
                if (status === 'success') {
                    this.viewModel.alert(new AlertViewModel('ep-alert-blue', response.responseJSON.title, response.responseJSON.message));
                }
                if (status === 'error') {
                    this.viewModel.alert(new JsonErrorAlertViewModel('ep-alert-red', response.responseJSON));
                }
            }, this);
        },

        importConcept: function(e){
            var self = this;
            this.model.reset();
            var modal = new ImportConcept({
                el: $('#import-concept-form')[0],
                model: this.model
            });
            modal.modal.modal('show');

            modal.on({
                'conceptsImported': function(){
                    self.trigger('conceptsImported');
                }
            });
        },

        addImageClicked: function (e) {
            this.model.reset();
            var self = this;
            var form = new AddImageForm({
                el: this.$el.find('#add-image-form')[0],
                model: this.model
            });

            form.on('dataChanged', function() {
                self.render();
            });
        },

        editValueClicked: function(e) {
            this.model.reset();
            var data = $.extend({
                conceptid: this.model.get('id')
            },
            $(e.target).data()
            );
            this.model.set('values', [new ValueModel(data)]);
            var editor = new ValueEditor({
                el: this.$el.find('#value-form')[0],
                model: this.model
            });
        },

        deleteConfirmed: function(e) {
            var self = this;
            var data = $(e.target).data();
            var modal = self.$el.find('.confirm-delete-modal');
            var title = modal.find('.modal-title').text();
            this.model.reset();

            if (data.action === 'delete-concept') {
                modal.find('h4').text(' ' + title);
                modal.find('.modal-title').addClass('loading');

                var model = new ConceptModel(data);
                self.model.set('subconcepts', [model]);

                self.model.delete(function(response, status){
                    modal.find('h4').text(title);
                    modal.find('.modal-title').removeClass('loading');
                    modal.modal('hide');
                    $('.modal-backdrop.fade.in').remove();  // a hack for now
                    if(!!response.responseJSON.in_use){
                        self.viewModel.alert(new AlertViewModel('ep-alert-blue', response.responseJSON.title, response.responseJSON.message));
                    }
                }, self);
            }else{
                modal.on('hidden.bs.modal', function () {
                    var model;

                    if (data.action === 'delete-value') {
                        model = new ValueModel(data);
                        model.delete(self.render, self);
                    }
                    if (data.action === 'delete-relationship') {
                        model = new ConceptModel(data);
                        self.model.set('relatedconcepts', [model]);
                        self.model.delete();
                    }

                });
                modal.modal('hide');
            }
        }
    });
});
<|endoftext|>


<commit_before> function AppComponent() {
        this.notes = [];
        this.addTodo = function(note) {

				this.notes.push(note.value);
            			note.value = null;

            return false;
        }

    }

	function removeTodo(el)
	{

    el.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
	}
    AppComponent.annotations = [
      new angular.ComponentAnnotation({
        selector: 'sticky'
      }),
      new angular.ViewAnnotation({
        template:'

<form (submit)="addTodo(notetext)"><input id="input_text" type="text" maxlength="20" placeholder="enter the note title" #notetext>

<button class="btn waves-effect waves-light orange accent-3" type="submit">+</button></form>

' +
                 '

<input value="{{ note }}" type="text" placeholder="note title">

<button class="btn-floating btn-small waves-effect waves-light orange accent-3" onclick="removeTodo(this)">X</button>

<textarea id="textarea1" class="materialize-textarea" placeholder="notes here"></textarea>

',
        directives: [angular.NgFor]
      })
    ];

    document.addEventListener('DOMContentLoaded', function() {
      angular.bootstrap(AppComponent);
    });
<commit_msg>Update index.js<commit_after> function AppComponent() {
        this.notes = [];
        this.addTodo = function(note) {

				this.notes.push(note.value);
            			note.value = null;

            return false;
        }

    }

	function removeTodo(el)
	{

    el.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
	}
    AppComponent.annotations = [
      new angular.ComponentAnnotation({
        selector: 'sticky'
      }),
      new angular.ViewAnnotation({
        template:'

<form (submit)="addTodo(notetext)"><input id="input_text" type="text" maxlength="20" placeholder="enter the note title" #notetext><button class="btn waves-effect waves-light orange accent-3" type="submit">+</button></form>

' +
                 '

<input value="{{ note }}" type="text" placeholder="note title">

<button class="btn-floating btn-small waves-effect waves-light orange accent-3" onclick="removeTodo(this)">X</button>

<textarea id="textarea1" class="materialize-textarea" placeholder="notes here"></textarea>

',
        directives: [angular.NgFor]
      })
    ];

    document.addEventListener('DOMContentLoaded', function() {
      angular.bootstrap(AppComponent);
    });
<|endoftext|>


<commit_before>var playTable = new Array();

for ( var row = 0 ; row < 4 ; row++) {

    playTable[row] = new Array();
    for ( var col = 0 ; col < 4; col++) {
        playTable[row][col]=0;
    }
}

var rowPosit, colPosit, playElementValue, sorted = 0;

for( var elementCount = 0 ; elementCount < 8 ; elementCount++) {

    sorted = 0;

    do {
        rowPosit = Math.floor((Math.random() * 4) + 1) - 1;
        colPosit = Math.floor((Math.random() * 4) + 1) - 1;
    } while ( playTable[rowPosit][colPosit] == 0 );

    do {

        sorted = 0;
        playElementValue = Math.floor((Math.random() * 4) + 1);

        // check if the randow generated number is NOT in the row already
        for ( row = rowPosit, col = 0 ; col < 4 ; col++) {
            if( playTable[row][col] == playElementValue && row != rowPosit && col != colPosit ) {
                sorted = 1;
            }
            continue;
        }

        // check if the randow generated number is NOT in the col already
        for ( col = colPosit, row = 0 ; row < 4 ; row++) {
            if( playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                sorted = 1;
            }
            continue;
        }

        //4 checks for each 2x2 block in the 4x4 playtable - check if the number is already there
        if( rowPosit <= 1 && colPosit <=1 ) {
            for ( row = 0 ; row < 2 ; row++) {
                for( col = 0 ; col < 2 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                    continue;
                }
            }
        }

        if( rowPosit <= 1 && colPosit <= 3 ) {
            for ( row = 0 ; row < 2 ; row++) {
                for( col = 2 ; col < 4 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                    continue;
                }
            }
        }

        if( rowPosit <= 3 && colPosit <= 1 ) {
            for ( row = 2 ; row < 4 ; row++) {
                for( col = 0 ; col < 2 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                    continue;
                }
            }
        }

        if( rowPosit <= 3 && colPosit <= 3 ) {
            for ( row = 2 ; row < 4 ; row++) {
                for( col = 2 ; col < 4 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                    continue;
                }
            }
        }

    } while( sorted == 1 );

    playTable[rowPosit][colPosit] = playElementValue;
}

<commit_msg>Update sudokuAlg.js<commit_after>var playTable = new Array();

for ( var row = 0 ; row < 4 ; row++) {

    playTable[row] = new Array();
    for ( var col = 0 ; col < 4; col++ ) {
        playTable[row][col] = 0;
    }
}

var rowPosit, colPosit, playElementValue, sorted = 0;

for( var elementCount = 0 ; elementCount < 8 ; elementCount++) {

    sorted = 0;

    do {
        rowPosit = Math.floor((Math.random() * 4) + 1) - 1;
        colPosit = Math.floor((Math.random() * 4) + 1) - 1;
    } while ( playTable[rowPosit][colPosit] == 0 );

    do {

        sorted = 0;
        playElementValue = Math.floor((Math.random() * 4) + 1);

        // check if the randow generated number is NOT in the row already
        for ( row = rowPosit, col = 0 ; col < 4 ; col++) {
            if( playTable[row][col] == playElementValue && row != rowPosit && col != colPosit ) {
                sorted = 1;
            }
            continue;
        }

        // check if the randow generated number is NOT in the col already
        for ( col = colPosit, row = 0 ; row < 4 ; row++) {
            if( playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                sorted = 1;
            }
            continue;
        }

        //4 checks for each 2x2 block in the 4x4 playtable - check if the number is already there
        if( rowPosit <= 1 && colPosit <=1 ) {
            for ( row = 0 ; row < 2 ; row++) {
                for( col = 0 ; col < 2 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                }
            }
        }

        if( rowPosit <= 1 && colPosit <= 3 ) {
            for ( row = 0 ; row < 2 ; row++) {
                for( col = 2 ; col < 4 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                }
            }
        }

        if( rowPosit <= 3 && colPosit <= 1 ) {
            for ( row = 2 ; row < 4 ; row++) {
                for( col = 0 ; col < 2 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                }
            }
        }

        if( rowPosit <= 3 && colPosit <= 3 ) {
            for ( row = 2 ; row < 4 ; row++) {
                for( col = 2 ; col < 4 ; col++ ) {
                    if (playTable[row][col] == playElementValue && row != rowPosit && col != colPosit) {
                        sorted = 1;
                    }
                }
            }
        }

    } while( sorted == 1 );

    playTable[rowPosit][colPosit] = playElementValue;
}

<|endoftext|>


<commit_before>var dgram = require('dgram');
var nconf = require('nconf');

//Stuff
var frame = [];
var IntervalIDs = [];

nconf.use('file', { file: './config.json' });
nconf.load();

//Export functions
  exports.resetInterval = resetInterval;
  exports.setColor = setColor;
  exports.setPattern = setPattern;

  function resetInterval(device) {
  	if (IntervalIDs[device]) {
  		clearInterval(IntervalIDs[device]);
  		IntervalIDs[device] = false;
  	}
  }

function setPattern(pattern, device, color, speed) {
	frame[device] = 0;
	var delay = (1/speed)*3000;
	switch(pattern) {
		case "blink":
			setPatternBlink(device, color, delay);
		break;
		case "runningLight":
			setPatternRunningLight(device, color, delay);
		break;
	}
}

function setPatternBlink(device, color, delay) {
	IntervalIDs[device] = setInterval(function() {
		if (frame[device] == 0) {
			setColor("000000", device);
			frame[device]++
		}
		else {
			setColor(color, device);
			frame[device] = 0;
		}
	}, delay);
}

function setPatternRunningLight(device, color, delay) {
	IntervalIDs[device] = setInterval(function() {
			console.log("Device: " + device);
			var ledCount = getLedCount(device);
			if (frame[device] == ledCount)
				frame[device] = 0;
			console.log("LedCount: " + ledCount + " framedev: " + frame[device]);
			var bufstring = "000000".repeat(frame[device])
						+ color + "000000".repeat(ledCount-frame[device]-1);
			sendToDevice(device, bufstring);
			frame[device]++;
	}, delay);
}

function setColor(colorHex, device) {
	console.log("Setting Color: " + colorHex);
	var bufstring = colorHex.repeat(getLedCount(device));
	sendToDevice(device, bufstring);
}

function sendToDevice(device, bufstring) {
	console.log("Sending: " + bufstring);
	sendUDP(bufstring, getIP(device), getPort(device));
}

function sendUDP(bufstring, ip, port) {
	console.log("Sending to " + ip + ":" + port);
	var client = dgram.createSocket('udp4');
	var buf = Buffer.from("000000" + bufstring, "hex"); // Initial 3 bytes are ignored
	client.send(buf, 0, buf.length, port, ip, function(err, bytes) {
		if (err) throw err;
		console.log('Sent.');
		client.close();
	}
);
}

function getIP(device) {
	return nconf.get('devices:'+device+':ip');
}

function getPort(device) {
	return nconf.get('devices:'+device+':port');
}

function getLedCount(device) {
	console.log("LedCount: " + nconf.get('devices:'+device+':ledCount'));
	return nconf.get('devices:'+device+':ledCount');
}
<commit_msg>Added filling pattern<commit_after>var dgram = require('dgram');
var nconf = require('nconf');

//Stuff
var frame = [];
var IntervalIDs = [];

nconf.use('file', { file: './config.json' });
nconf.load();

//Export functions
  exports.resetInterval = resetInterval;
  exports.setColor = setColor;
  exports.setPattern = setPattern;

  function resetInterval(device) {
  	if (IntervalIDs[device]) {
  		clearInterval(IntervalIDs[device]);
  		IntervalIDs[device] = false;
  	}
  }

function setPattern(pattern, device, color, speed) {
	frame[device] = 0;
	var delay = (1/speed)*3000;
	switch(pattern) {
		case "blink":
			setPatternBlink(device, color, delay);
		break;
		case "runningLight":
			setPatternRunningLight(device, color, delay);
		break;
    case "filling":
      setPatternFilling(device, color, delay);
    break;
	}
}

function setPatternBlink(device, color, delay) {
	IntervalIDs[device] = setInterval(function() {
		if (frame[device] == 0) {
			setColor("000000", device);
			frame[device]++
		}
		else {
			setColor(color, device);
			frame[device] = 0;
		}
	}, delay);
}

function setPatternRunningLight(device, color, delay) {
	IntervalIDs[device] = setInterval(function() {
			console.log("Device: " + device);
			var ledCount = getLedCount(device);
			if (frame[device] == ledCount)
				frame[device] = 0;
			console.log("LedCount: " + ledCount + " framedev: " + frame[device]);
			var bufstring = "000000".repeat(frame[device])
						+ color + "000000".repeat(ledCount-frame[device]-1);
			sendToDevice(device, bufstring);
			frame[device]++;
	}, delay);
}

function setPatternFilling(device, color, delay) {
  IntervalIDs[device] = setInterval(function() {
      console.log("Device: " + device);
      var ledCount = getLedCount(device);
      if (frame[device] == ledCount)
        frame[device] = 0;
      console.log("LedCount: " + ledCount + " framedev: " + frame[device]);
      var bufstring = color.repeat(frame[device])
            + "000000".repeat(ledCount-frame[device]);
      sendToDevice(device, bufstring);
      frame[device]++;
  }, delay);
}

function setColor(colorHex, device) {
	console.log("Setting Color: " + colorHex);
	var bufstring = colorHex.repeat(getLedCount(device));
	sendToDevice(device, bufstring);
}

function sendToDevice(device, bufstring) {
	console.log("Sending: " + bufstring);
	sendUDP(bufstring, getIP(device), getPort(device));
}

function sendUDP(bufstring, ip, port) {
	console.log("Sending to " + ip + ":" + port);
	var client = dgram.createSocket('udp4');
	var buf = Buffer.from("000000" + bufstring, "hex"); // Initial 3 bytes are ignored
	client.send(buf, 0, buf.length, port, ip, function(err, bytes) {
		if (err) throw err;
		console.log('Sent.');
		client.close();
	}
);
}

function getIP(device) {
	return nconf.get('devices:'+device+':ip');
}

function getPort(device) {
	return nconf.get('devices:'+device+':port');
}

function getLedCount(device) {
	console.log("LedCount: " + nconf.get('devices:'+device+':ledCount'));
	return nconf.get('devices:'+device+':ledCount');
}
<|endoftext|>


<commit_before>var wordTypes = ['adjective', 'adverb', 'definitive article', 'noun', 'number', 'preposition', 'verb'];

var words = [
  {
    'word': 'backstairs',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'bank',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'verb',
        'score': 25
      }
    ]
  },
  {
    'word': 'black',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'adjective',
        'score': 25
      }
    ]
  },
  {
    'word': 'brickbat',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'b',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'campcraft',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'catachresis',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'centipede',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'company',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'contract',
    'types': [
      {
        'type': 'noun',
        'score': 65
      },
      {
        'type': 'adjective',
        'score': 25
      },
      {
        'type': 'verb',
        'score': 10
      }
    ]
  },
  {
    'word': 'credit',
    'types': [
      {
        'type': 'noun',
        'score': 50
      },
      {
        'type': 'verb',
        'score': 50
      }
    ]
  },
  {
    'word': 'cup',
    'types': [
      {
        'type': 'noun',
        'score': 85
      },
      {
        'type': 'verb',
        'score': 15
      }
    ]
  },
  {
    'word': 'debonair',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'edentate',
    'types': [
      {
        'type': 'adjective',
        'score': 65
      },
      {
        'type': 'noun',
        'score': 35
      }
    ]
  },
  {
    'word': 'exchange',
    'types': [
      {
        'type': 'verb',
        'score': 65
      },
      {
        'type': 'noun',
        'score': 35
      }
    ]
  },
  {
    'word': 'extemporaneous',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'financial',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'farouche',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'five',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'fizgig',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'for',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'four',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'good',
    'types': [
      {
        'type': 'adjective',
        'score': 90
      },
      {
        'type': 'noun',
        'score': 10
      }
    ]
  },
  {
    'word': 'in',
    'types': [
      {
        'type': 'preposition',
        'score': 87
      },
      {
        'type': 'adverb',
        'score': 10
      },
      {
        'type': 'adjective',
        'score': 3
      }
    ]
  },
  {
    'word': 'kindly',
    'types': [
      {
        'type': 'adverb',
        'score': 100
      }
    ]
  },
  {
    'word': 'management',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'mondegreen',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'nine',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'mnemonic',
    'types': [
      {
        'type': 'adjective',
        'score': 50
      },
      {
        'type': 'noun',
        'score': 50
      }
    ]
  },
  {
    'word': 'of',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'on',
    'types': [
      {
        'type': 'adjective',
        'score': 33
      },
      {
        'type': 'adverb',
        'score': 33
      },
      {
        'type': 'noun',
        'score': 1
      },
      {
        'type': 'preposition',
        'score': 33
      }
    ]
  },
  {
    'word': 'one',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'pellucid',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'portfolio',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'protean',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'quiddity',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'red',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'adjective',
        'score': 25
      }
    ]
  },
  {
    'word': 'say',
    'types': [
      {
        'type': 'verb',
        'score': 95
      },
      {
        'type': 'adverb',
        'score': 5
      }
    ]
  },
  {
    'word': 'scupper',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'security',
    'types': [
      {
        'type': 'noun',
        'score': 80
      },
      {
        'type': 'adjective',
        'score': 20
      }
    ]
  },
  {
    'word': 'serotinal',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'sit',
    'types': [
      {
        'type': 'verb',
        'score': 100
      }
    ]
  },
  {
    'word': 'six',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'snowflake',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'soup',
    'types': [
      {
        'type': 'noun',
        'score': 92
      },
      {
        'type': 'verb',
        'score': 8
      }
    ]
  },
  {
    'word': 'summerize',
    'types': [
      {
        'type': 'verb',
        'score': 100
      }
    ]
  },
  {
    'word': 'the',
    'types': [
      {
        'type': 'definitive article',
        'score': 99
      },
      {
        'type': 'adverb',
        'score': 1
      }
    ]
  },
  {
    'word': 'three',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'time',
    'types': [
      {
        'type': 'noun',
        'score': 80
      },
      {
        'type': 'adjective',
        'score': 8
      },
      {
        'type': 'verb',
        'score': 12
      }
    ]
  },
  {
    'word': 'to',
    'types': [
      {
        'type': 'preposition',
        'score': 92
      },
      {
        'type': 'adverb',
        'score': 8
      }
    ]
  },
  {
    'word': 'two',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'up',
    'types': [
      {
        'type': 'adverb',
        'score': 65
      },
      {
        'type': 'preposition',
        'score': 25
      },
      {
        'type': 'adjective',
        'score': 7
      },
      {
        'type': 'noun',
        'score': 3
      }
    ]
  },
  {
    'word': 'wig',
    'types': [
      {
        'type': 'noun',
        'score': 95
      },
      {
        'type': 'verb',
        'score': 5
      }
    ]
  },
  {
    'word': 'with',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'xeriscaping',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  }
];

exports.words = words;
exports.wordTypes = wordTypes;<commit_msg>added pernicious to the dictionary<commit_after>var wordTypes = ['adjective', 'adverb', 'definitive article', 'noun', 'number', 'preposition', 'verb'];

var words = [
  {
    'word': 'backstairs',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'bank',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'verb',
        'score': 25
      }
    ]
  },
  {
    'word': 'black',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'adjective',
        'score': 25
      }
    ]
  },
  {
    'word': 'brickbat',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'b',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'campcraft',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'catachresis',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'centipede',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'company',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'contract',
    'types': [
      {
        'type': 'noun',
        'score': 65
      },
      {
        'type': 'adjective',
        'score': 25
      },
      {
        'type': 'verb',
        'score': 10
      }
    ]
  },
  {
    'word': 'credit',
    'types': [
      {
        'type': 'noun',
        'score': 50
      },
      {
        'type': 'verb',
        'score': 50
      }
    ]
  },
  {
    'word': 'cup',
    'types': [
      {
        'type': 'noun',
        'score': 85
      },
      {
        'type': 'verb',
        'score': 15
      }
    ]
  },
  {
    'word': 'debonair',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'edentate',
    'types': [
      {
        'type': 'adjective',
        'score': 65
      },
      {
        'type': 'noun',
        'score': 35
      }
    ]
  },
  {
    'word': 'exchange',
    'types': [
      {
        'type': 'verb',
        'score': 65
      },
      {
        'type': 'noun',
        'score': 35
      }
    ]
  },
  {
    'word': 'extemporaneous',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'financial',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'farouche',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'five',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'fizgig',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'for',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'four',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'good',
    'types': [
      {
        'type': 'adjective',
        'score': 90
      },
      {
        'type': 'noun',
        'score': 10
      }
    ]
  },
  {
    'word': 'in',
    'types': [
      {
        'type': 'preposition',
        'score': 87
      },
      {
        'type': 'adverb',
        'score': 10
      },
      {
        'type': 'adjective',
        'score': 3
      }
    ]
  },
  {
    'word': 'kindly',
    'types': [
      {
        'type': 'adverb',
        'score': 100
      }
    ]
  },
  {
    'word': 'management',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'mondegreen',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'nine',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'mnemonic',
    'types': [
      {
        'type': 'adjective',
        'score': 50
      },
      {
        'type': 'noun',
        'score': 50
      }
    ]
  },
  {
    'word': 'of',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'on',
    'types': [
      {
        'type': 'adjective',
        'score': 33
      },
      {
        'type': 'adverb',
        'score': 33
      },
      {
        'type': 'noun',
        'score': 1
      },
      {
        'type': 'preposition',
        'score': 33
      }
    ]
  },
  {
    'word': 'one',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'pellucid',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'pernicious',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'portfolio',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'protean',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'quiddity',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'red',
    'types': [
      {
        'type': 'noun',
        'score': 75
      },
      {
        'type': 'adjective',
        'score': 25
      }
    ]
  },
  {
    'word': 'say',
    'types': [
      {
        'type': 'verb',
        'score': 95
      },
      {
        'type': 'adverb',
        'score': 5
      }
    ]
  },
  {
    'word': 'scupper',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'security',
    'types': [
      {
        'type': 'noun',
        'score': 80
      },
      {
        'type': 'adjective',
        'score': 20
      }
    ]
  },
  {
    'word': 'serotinal',
    'types': [
      {
        'type': 'adjective',
        'score': 100
      }
    ]
  },
  {
    'word': 'sit',
    'types': [
      {
        'type': 'verb',
        'score': 100
      }
    ]
  },
  {
    'word': 'six',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'snowflake',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  },
  {
    'word': 'soup',
    'types': [
      {
        'type': 'noun',
        'score': 92
      },
      {
        'type': 'verb',
        'score': 8
      }
    ]
  },
  {
    'word': 'summerize',
    'types': [
      {
        'type': 'verb',
        'score': 100
      }
    ]
  },
  {
    'word': 'the',
    'types': [
      {
        'type': 'definitive article',
        'score': 99
      },
      {
        'type': 'adverb',
        'score': 1
      }
    ]
  },
  {
    'word': 'three',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'time',
    'types': [
      {
        'type': 'noun',
        'score': 80
      },
      {
        'type': 'adjective',
        'score': 8
      },
      {
        'type': 'verb',
        'score': 12
      }
    ]
  },
  {
    'word': 'to',
    'types': [
      {
        'type': 'preposition',
        'score': 92
      },
      {
        'type': 'adverb',
        'score': 8
      }
    ]
  },
  {
    'word': 'two',
    'types': [
      {
        'type': 'noun',
        'score': 100
      },
      {
        'type': 'number',
        'score': 100
      }
    ]
  },
  {
    'word': 'up',
    'types': [
      {
        'type': 'adverb',
        'score': 65
      },
      {
        'type': 'preposition',
        'score': 25
      },
      {
        'type': 'adjective',
        'score': 7
      },
      {
        'type': 'noun',
        'score': 3
      }
    ]
  },
  {
    'word': 'wig',
    'types': [
      {
        'type': 'noun',
        'score': 95
      },
      {
        'type': 'verb',
        'score': 5
      }
    ]
  },
  {
    'word': 'with',
    'types': [
      {
        'type': 'preposition',
        'score': 100
      }
    ]
  },
  {
    'word': 'xeriscaping',
    'types': [
      {
        'type': 'noun',
        'score': 100
      }
    ]
  }
];

exports.words = words;
exports.wordTypes = wordTypes;<|endoftext|>