<commit_before>;(function (window, document, undefined) {
    "use strict";

    // Dependencies
    if (jQuery === undefined) {
        throw "jQuery should be defined to use liveSortable";
    }
    if (jQuery().sortable === undefined) {
        throw "jQuery UIs sortable should be defined to use liveSortable";
    }

    var pluginName = "liveSortable",
        pluginDataName = "plugin_" + pluginName;

    // LiveSortable Defaults
    var defaults = {
            // Realtime options
            cancelRealtime: false,
            cancelSedingInRealtime: false,

            // MouseMove event delay
            delay: 0,

            // Custom modificable events mostly used to send custom information in the socket
            events: {
                start: function() {},
                beforeStop: function() {},
                stop: function() {},
                mousemove: function() {}
            },

            // jQuery UI options
            sortable: {
                helper: "clone",
                start: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);
                    var socket = liveSortable.getSocket();

                    var data = liveSortable.events.start(event, ui, liveSortable) || { id: ui.item.get(0).id };

                    socket.emit( eventNamesFactory.addSufix("broadcast_move_started"), data );

                    liveSortable.isBeingDragged = true;
                },
                beforeStop: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);
                    var socket = liveSortable.getSocket();

                    var data = liveSortable.events.beforeStop(event, ui, liveSortable);

                    if(!data) {
                        // Provide the next and previous id of the element being dragged
                        var item = ui.item;
                        var next = item.next().get(0);
                        var prev = item.prev().get(0);
                        data = {
                            id:   item.get(0).id,
                            next: next && next.id,
                            prev: prev && prev.id
                        };
                    }

                    socket.emit( eventNamesFactory.addSufix("broadcast_move_ended"), data );
                },
                stop: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);

                    liveSortable.events.stop(event, ui, liveSortable);

                    liveSortable.isBeingDragged = false;
                }
            }
        };

    /* ==============================================
        eventNamesFactory
       ============================================== */

    // Creates new event names in the plugin namespace
    var eventNamesFactory = {
        sufix: "." + pluginName,
        addSufix: function(eventName) {
            return eventName + eventNamesFactory.sufix;
        },
        create: function(liveSortable) {
            var eventNames = ["move_element", "move_started", "move_ended"];

            // If realtime is canceled, delete the move_element event
            if(liveSortable.options.cancelRealtime) {
                eventNames = eventNames.slice(1);
            }
            return jQuery.map(eventNames, this.addSufix);
        }
    }

    /* ==============================================
        SocketEventer Class
       ============================================== */

    // Class to handle the Socket events, add and remove them
    function SocketEventer(liveSortable) {
        var self = this;

        this.$element = liveSortable.$element;

        if(liveSortable.options.socket === undefined) {
            throw "A socket must be passed as an argument to use liveSortable.";
        }

        this.socket = liveSortable.options.socket;

        // Listen every event on the socket and trigger it on the stored element
        jQuery.each(liveSortable.customEvents, function(index, customEvent) {
            self.addEvent( customEvent );
        });

        return this;
    };
    SocketEventer.prototype = {
        eventHandlers: {},
        addEvent: function(eventName) {
            // We support only a default handler (for now)
            var self = this;
            var handler = function(data) {
                self.$element.trigger(eventName, data);
            };

            this.eventHandlers[eventName] = handler;
            this.socket.on(eventName, handler);
        },
        removeEvent: function(eventName) {
            this.socket.removeListener(eventName, this.eventHandlers[eventName]);
        },
        removeAllEvents: function() {
            this.socket.removeAllListeners();
        }
    };

    /* ==============================================
        LiveSortable Class
       ============================================== */

    function LiveSortable( jqueryInstance, options ) {
        this.$element = jqueryInstance;

        // Plugin defaults
        this.options = jQuery.extend({}, defaults, options);

        // Custom events
        this.events = jQuery.extend({}, defaults.events, this.options.events);

        // Sortable defaults
        this.sortableOptions = jQuery.extend({}, defaults.sortable, this.options.sortable);

        // Start jqueryui sortable
        this.$element.sortable(this.sortableOptions);

        // Create the event names
        this.customEvents = eventNamesFactory.create(this);

        // Create a new (private) SocketEventer, and a getter for the socket itself
        this._socketEventer = new SocketEventer(this);
        this.getSocket = function() {
            return this._socketEventer.socket;
        }

        // Mousemove event
        if(!this.options.cancelSedingInRealtime) {
            this.addMousemoveHandler();
        }

        return this;
    };

    LiveSortable.prototype = {
        isBeingDragged: false,
        addMousemoveHandler: function() {
            var self = this;

            return this.$element.on(eventNamesFactory.addSufix("mousemove"), function(event) {
                if(self.isBeingDragged) {
                    var data = self.events.mousemove(event, self);

                    if(!data) {
                        var elem = self.$element.children(".ui-sortable-helper").get(0);
                        data = {
                            id:   elem.id,
                            top:  elem.style.top,
                            left: elem.style.left
                        };
                    }

                    self._socketEventer.socket.emit(eventNamesFactory.addSufix("broadcast_moving_element"), data);

                    if(self.options.delay > 0) {
                        // This is not abstracted to a different function (sadly) so we retain the outer scope for the setTimeout // and "minimize" complexity for performance.
                        self.removeMousemoveHandler();
                        setTimeout(function() { self.addMousemoveHandler(); }, self.options.delay);
                    }
                }
            });
        },
        removeMousemoveHandler: function() {
            return this.$element.off(eventNamesFactory.addSufix("mousemove"));
        },
        remove: function() {
            this.$element.removeData(pluginDataName).off(eventNamesFactory.sufix);
            this._socketEventer.removeAllEvents();
            return this.$element;
        },
        toggleOption: function(option) {
            this.options[option] = !this.options[option];
            return this.options[option];
        },
        toggleRealtime: function() {
            var realtimeEventName = eventNamesFactory.addSufix("move_element");

            if( this.toggleOption("cancelRealtime") ) {
                this._socketEventer.removeEvent(realtimeEventName);
            } else {
                this._socketEventer.addEvent(realtimeEventName);
            }
        },
        toggleRealtimeSending: function() {
            if( this.toggleOption("cancelSedingInRealtime") ) {
                this.removeMousemoveHandler();
            } else {
                this.addMousemoveHandler();
            }
        },
        delay: function(time) {
            this.options.delay = time;
        }
    };

    LiveSortable.getInstanceFrom = function(element) {
        return jQuery(element).data(pluginDataName);
    };

    /* ==============================================
        jQuery Plugin initialization
       ============================================== */

    jQuery.fn[pluginName] = function ( options ) {
        var isMethod = typeof options === 'string';
        if(isMethod) {
            var methodArguments = Array.prototype.slice.call(arguments, 1);
        }

        return this.each(function() {
            var $this = jQuery(this);

            // When the first argument is a string, call a method on the instance with that string as the method name
            // Otherwise instantiate the plugin
            if (isMethod) {
                var instance = $this.data(pluginDataName);
                if (!instance) {
                    throw "Method called on liveSortable before instantiation";
                }
                if ( !jQuery.isFunction(instance[options]) ) {
                    throw "The method: " + options + " was not found in liveSortable";
                }

                var returnValue = instance[options].apply(instance, methodArguments);

                if (returnValue !== undefined) {
                    return returnValue;
                }
            } else {
                $this.data(pluginDataName, new LiveSortable($this, options));
            }
        });
    };

})(window, document);<commit_msg>Name changes<commit_after>;(function ($, undefined) {
    "use strict";

    // Dependencies
    if ($ === undefined) {
        throw "jQuery should be defined to use liveSortable";
    }
    if (!"sortable" in $.fn) {
        throw "jQuery UIs sortable should be defined to use liveSortable";
    }

    var pluginName = "liveSortable",
        pluginDataName = "plugin_" + pluginName;

    // LiveSortable Defaults
    var defaults = {
            // Realtime options
            cancelRealtime: false,
            cancelSedingInRealtime: false,

            // MouseMove event delay
            delay: 0,

            // Custom modificable events mostly used to send custom information in the socket
            events: {
                start: function() {},
                beforeStop: function() {},
                stop: function() {},
                mousemove: function() {}
            },

            // jQuery UI options
            sortable: {
                helper: "clone",
                start: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);
                    var socket = liveSortable.getSocket();

                    var data = liveSortable.events.start(event, ui, liveSortable) || { id: ui.item.get(0).id };

                    socket.emit( eventNamesFactory.addSufix("broadcast_move_started"), data );

                    liveSortable.isBeingDragged = true;
                },
                beforeStop: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);
                    var socket = liveSortable.getSocket();

                    var data = liveSortable.events.beforeStop(event, ui, liveSortable);

                    if(!data) {
                        // Provide the next and previous id of the element being dragged
                        var item = ui.item;
                        var next = item.next().get(0);
                        var prev = item.prev().get(0);
                        data = {
                            id:   item.get(0).id,
                            next: next && next.id,
                            prev: prev && prev.id
                        };
                    }

                    socket.emit( eventNamesFactory.addSufix("broadcast_move_ended"), data );
                },
                stop: function(event, ui) {
                    var liveSortable = LiveSortable.getInstanceFrom(this);

                    liveSortable.events.stop(event, ui, liveSortable);

                    liveSortable.isBeingDragged = false;
                }
            }
        };

    /* ==============================================
        eventNamesFactory
       ============================================== */

    // Creates new event names in the plugin namespace
    var eventNamesFactory = {
        sufix: "." + pluginName,
        addSufix: function(eventName) {
            return eventName + eventNamesFactory.sufix;
        },
        create: function(liveSortable) {
            var eventNames = ["move_element", "move_started", "move_ended"];

            // If realtime is canceled, delete the move_element event
            if(liveSortable.options.cancelRealtime) {
                eventNames = eventNames.slice(1);
            }
            return $.map(eventNames, this.addSufix);
        }
    }

    /* ==============================================
        SocketEventer Class
       ============================================== */

    // Class to handle the Socket events, add and remove them
    function SocketEventer(liveSortable) {
        var self = this;

        this.$element = liveSortable.$element;

        if(liveSortable.options.socket === undefined) {
            throw "A socket must be passed as an argument to use liveSortable.";
        }

        this.socket = liveSortable.options.socket;

        // Listen every event on the socket and trigger it on the stored element
        $.each(liveSortable.customEvents, function(index, customEvent) {
            self.addEvent( customEvent );
        });

        return this;
    };
    SocketEventer.prototype = {
        eventHandlers: {},
        addEvent: function(eventName) {
            // We support only a default handler (for now)
            var self = this;
            var handler = function(data) {
                self.$element.trigger(eventName, data);
            };

            this.eventHandlers[eventName] = handler;
            this.socket.on(eventName, handler);
        },
        removeEvent: function(eventName) {
            this.socket.removeListener(eventName, this.eventHandlers[eventName]);
        },
        removeAllEvents: function() {
            this.socket.removeAllListeners();
        }
    };

    /* ==============================================
        LiveSortable Class
       ============================================== */

    function LiveSortable( jqueryInstance, options ) {
        this.$element = jqueryInstance;

        // Plugin defaults
        this.options = $.extend({}, defaults, options);

        // Custom events
        this.events = $.extend({}, defaults.events, this.options.events);

        // Sortable defaults
        this.sortableOptions = $.extend({}, defaults.sortable, this.options.sortable);

        // Start jqueryui sortable
        this.$element.sortable(this.sortableOptions);

        // Create the event names
        this.customEvents = eventNamesFactory.create(this);

        // Create a new (private) SocketEventer, and a getter for the socket itself
        this._socketEventer = new SocketEventer(this);
        this.getSocket = function() {
            return this._socketEventer.socket;
        }

        // Mousemove event
        if(!this.options.cancelSedingInRealtime) {
            this.addMousemoveHandler();
        }

        return this;
    };

    LiveSortable.prototype = {
        isBeingDragged: false,
        addMousemoveHandler: function() {
            var self = this;

            return this.$element.on(eventNamesFactory.addSufix("mousemove"), function(event) {
                if(self.isBeingDragged) {
                    var data = self.events.mousemove(event, self);

                    if(!data) {
                        var elem = self.$element.children(".ui-sortable-helper").get(0);
                        data = {
                            id:   elem.id,
                            top:  elem.style.top,
                            left: elem.style.left
                        };
                    }

                    self._socketEventer.socket.emit(eventNamesFactory.addSufix("broadcast_moving_element"), data);

                    if(self.options.delay > 0) {
                        // This is not abstracted to a different function (sadly) so we retain the outer scope for the setTimeout // and "minimize" complexity for performance.
                        self.removeMousemoveHandler();
                        setTimeout(function() { self.addMousemoveHandler(); }, self.options.delay);
                    }
                }
            });
        },
        removeMousemoveHandler: function() {
            return this.$element.off(eventNamesFactory.addSufix("mousemove"));
        },
        remove: function() {
            this.$element.removeData(pluginDataName).off(eventNamesFactory.sufix);
            this._socketEventer.removeAllEvents();
            return this.$element;
        },
        toggleOption: function(option) {
            this.options[option] = !this.options[option];
            return this.options[option];
        },
        toggleRealtime: function() {
            var realtimeEventName = eventNamesFactory.addSufix("move_element");

            if( this.toggleOption("cancelRealtime") ) {
                this._socketEventer.removeEvent(realtimeEventName);
            } else {
                this._socketEventer.addEvent(realtimeEventName);
            }
        },
        toggleRealtimeSending: function() {
            if( this.toggleOption("cancelSedingInRealtime") ) {
                this.removeMousemoveHandler();
            } else {
                this.addMousemoveHandler();
            }
        },
        delay: function(time) {
            this.options.delay = time;
        }
    };

    LiveSortable.getInstanceFrom = function(element) {
        return $(element).data(pluginDataName);
    };

    /* ==============================================
        jQuery Plugin initialization
       ============================================== */

    $.fn[pluginName] = function ( options ) {
        var isMethod = typeof options === 'string';
        if(isMethod) {
            var methodArguments = Array.prototype.slice.call(arguments, 1);
        }

        return this.each(function() {
            var $this = $(this);

            // When the first argument is a string, call a method on the instance with that string as the method name
            // Otherwise instantiate the plugin
            if (isMethod) {
                var instance = $this.data(pluginDataName);
                if (!instance) {
                    throw "Method called on liveSortable before instantiation";
                }
                if ( !$.isFunction(instance[options]) ) {
                    throw "The method: " + options + " was not found in liveSortable";
                }

                var returnValue = instance[options].apply(instance, methodArguments);

                if (returnValue !== undefined) {
                    return returnValue;
                }
            } else {
                $this.data(pluginDataName, new LiveSortable($this, options));
            }
        });
    };

})( jQuery );<|endoftext|>


<commit_before>var debug = process.env.NODE_ENV !== "production",
    webpack = require('webpack');

module.exports = {
    context: __dirname + "/public/src",
    devtool: debug ? "inline-sourcemap" : null,
    entry: "./js/client.js",
    module: {
        loaders: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015'],
                    plugins: ['transform-class-properties', "react-html-attrs"]
                }
            }
        ]
    },
    output: {
        path: __dirname + "/public/",
        filename: "client.min.js"
    },
    plugins: debug ? [] : [
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false})
    ]
};<commit_msg>added new package conf<commit_after>var debug = process.env.NODE_ENV !== "production",
    webpack = require('webpack');

module.exports = {
    context: __dirname + "/public/src",
    devtool: debug ? "inline-sourcemap" : null,
    entry: "./js/client.js",
    module: {
        loaders: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-0'],
                    plugins: ['transform-class-properties', "react-html-attrs", "transform-decorators-legacy"]
                }
            }
        ]
    },
    output: {
        path: __dirname + "/static/",
        filename: "client.min.js"
    },
    plugins: debug ? [] : [
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false})
    ]
};
<|endoftext|>


<commit_before>var field = {
	login   : null,
	updated : new Date().getTime(),
	targets : []
};

$('.peering ul:even a').each(function() {

	var link = $(this);
	var text = link.text();
	if (text !== 'avez donné la note' && text != 'devez noter')
	{
		text = text.replace(/.* (.*)$/, '$1');
		chrome.extension.sendMessage({ type: 'getData', uid: text }, function (response) {
			if (response.host === 'Logged out') {
				link.after(' (Logged out)');
			}
			else {
				link.after(' (' + response.host + ')');
			}
		});
	}
});

$('.peering ul:odd a[title]').each(function() {

	var link = $(this);
	chrome.extension.sendMessage({ type: 'getData', uid: link.text() }, function (response) {
		if (response.host === 'Logged out') {
			link.after(' (Logged out)');
		}
		else {
			link.after(' (' + response.host + ')');
		}
	});
});

/* Debug when no eval process */
$('.peering').html('
bgronon

mpillet

fbeck

janteuni

hmassing
');

$('.peering .user').each(function() {
	var link = $(this);
	var login = $(this).text();
	if (field.targets.indexOf(login) == -1) {
		field.targets.push(login);
	}
});

field.login = $('#identification .infos .title span:first-child').attr('title');

if (field.login) {
	chrome.extension.sendMessage({ type: 'postField', data: field }, function (response) {
		console.log(response.state);
	});
}

/* */

$(document).on('DOMNodeInserted', function(e) {

	var that = e.target.firstChild;
	$('.ncompletion').css('height', '');
	$('.ncompletion').css('max-height', '300px');
	if (that && that.className == 'col1 login')
	{
		$('.ncompletion').css('width', '400px');
		var text = that.innerText;
		var magic = text.match(/^.*\((.*)\)/);
		chrome.extension.sendMessage({ type: 'getData', uid: magic[1] }, function (response) {
			if (response.host === 'Logged out') {
				$(that).html(text + ' (x)');
			}
			else {
				$(that).html(text + '
(' + response.host + ')');
			}
		});
	}

});
<commit_msg>removing mock<commit_after>var field = {
	login   : null,
	updated : new Date().getTime(),
	targets : []
};

$('.peering ul:even a').each(function() {

	var link = $(this);
	var text = link.text();
	if (text !== 'avez donné la note' && text != 'devez noter')
	{
		text = text.replace(/.* (.*)$/, '$1');
		chrome.extension.sendMessage({ type: 'getData', uid: text }, function (response) {
			if (response.host === 'Logged out') {
				link.after(' (Logged out)');
			}
			else {
				link.after(' (' + response.host + ')');
			}
		});
	}
});

$('.peering ul:odd a[title]').each(function() {

	var link = $(this);
	var login = link.text();
	if (field.targets.indexOf(login) == -1) {
		field.targets.push(login);
	}
	chrome.extension.sendMessage({ type: 'getData', uid: login }, function (response) {
		if (response.host === 'Logged out') {
			link.after(' (Logged out)');
		}
		else {
			link.after(' (' + response.host + ')');
		}
	});
});

/* Debug when no eval process
$('.peering').html('
bgronon

mpillet

fbeck

janteuni

hmassing
');

$('.peering .user').each(function() {
	var link = $(this);
	var login = $(this).text();
	if (field.targets.indexOf(login) == -1) {
		field.targets.push(login);
	}
});
*/

field.login = $('#identification .infos .title span:first-child').attr('title');

if (field.login) {
	chrome.extension.sendMessage({ type: 'postField', data: field }, function (response) {
		console.log(response.state);
	});
}

$(document).on('DOMNodeInserted', function(e) {

	var that = e.target.firstChild;
	$('.ncompletion').css('height', '');
	$('.ncompletion').css('max-height', '300px');
	if (that && that.className == 'col1 login')
	{
		$('.ncompletion').css('width', '400px');
		var text = that.innerText;
		var magic = text.match(/^.*\((.*)\)/);
		chrome.extension.sendMessage({ type: 'getData', uid: magic[1] }, function (response) {
			if (response.host === 'Logged out') {
				$(that).html(text + ' (x)');
			}
			else {
				$(that).html(text + '
(' + response.host + ')');
			}
		});
	}

});
<|endoftext|>


<commit_before>/**
 * jQuery Plugin to create a deck of cards.
 * This can be used to play standard card games (which could be additional rule modules attached to this set)
 *
 * usage: $("#cardTable").playingCards();
 * override defaults for playingCards() and for card() with
 *    $.playingCards.defaults
 *    $.playingCards.card.defaults
 *
 * @author Adam Eivy (antic | atomantic)
 * @license MIT (do what you like but keep the license)
 */
 (function($) {

    $.fn.playingCards = function(conf) {
        var o = $.extend({},
        $.fn.playingCards.defaults, conf);

        this.cards = [];
		var l;
        // populate draw pile
        for (var i = 0; i < o.decks; i++) {
			// standard
            for (var s in o.suits) {
                for (var r in o.ranks) {
					l = this.cards.length;
                    this.cards[l] = new $.fn.playingCards.card(r, o.ranks[r], s, o.suits[s]);

					// debugging design mode (just laying out all the cards in order)
					this.append(this.cards[l].getHTML());
                }
            }
			// jokers
			for (i=0;i<o.jokers;i++){
					l = this.cards.length;
					// suit will always be 1 or 2
                    this.cards[l] = new $.fn.playingCards.card("N", o.jokerText, (i%2)+1, '');

					// debugging design mode (just laying out all the cards in order)
					this.append(this.cards[l].getHTML());
			}
        }
        this.draw = function() {
            return this.cards.length > 0 ? this.cards.shift() : null;
        };
        this.addCard = function(card) {
            this.cards.push(card);
        };
        this.count = function() {
            return this.cards.length;
        };

        return this;
    };
	$.fn.playingCards.prototype.shuffle = function(n) {
        var r;
        // random #
        var tmp;
        // tmp holder
        var l = this.cards.length;

        for (var i = 0; i < n; i++) {
            for (var j = 0; j < l; j++) {
                r = Math.floor(Math.random() * l);
                tmp = this.cards[j];
                this.cards[j] = this.cards[r];
                this.cards[r] = tmp;
            }
        }
    };
    $.fn.playingCards.defaults = {
        "decks": 1,
		"renderMode": 'css', // TODO: enable 'font' option -- loading cards.ttf
		"jokers":2,
		"jokerText":"Joker",
        "ranks": {
            "2": "Two",
            "3": "Three",
            "4": "Four",
            "5": "Five",
            "6": "Six",
            "7": "Seven",
            "8": "Eight",
            "9": "Nine",
            "10": "Ten",
            "J": "Jack",
            "Q": "Queen",
            "K": "King",
            "A": "Ace"
        },
        "suits": {
            "S": "Spades",
            "D": "Diamonds",
            "C": "Clubs",
            "H": "Hearts"
        }
    };
    /**
	 * create a playing card
	 *
	 * @param string rank The numeric or letter value of the card (short value)
	 * @param string rankString The full text representation of the rank (localized)
	 * @param string suit The letter value of the suite (short value)
	 * @param string suitString The full text representation of the suit (localized)
	 * @param obj conf Overriding configuration
	 *
	 * @return object The card object
	 */
    $.fn.playingCards.card = function(rank, rankString, suit, suitString, conf) {
        if (! (this instanceof arguments.callee)) {
            return new arguments.callee(rank, rankString, suit, suitString);
        }

	    this.conf = $.extend({},$.fn.playingCards.card.defaults,conf);

        this.rank = rank;
        this.rankString = rankString;
        this.suit = suit;
        this.suitString = suitString;
        return this;
    };
	$.fn.playingCards.card.defaults = {
		"singleFace":false // false will use a different image for each suit/face, true will use diamond image for all
	};
    $.fn.playingCards.card.prototype.toString = function() {
        // TODO: localize "of"
        return this.suitString!=="" ? this.rankString + " of " + this.suitString : this.rankString;
    };
    $.fn.playingCards.card.prototype.getHTML = function() {
		if(this.html){
			return this.html;
		}
        this.suitCode = " ";
        this.colorCls = '';
        switch (this.suit) {
        case "S":
            this.suitCode = "♠";
            break;
        case "D":
            this.colorCls = "red";
            this.suitCode = "♦";
            break;
        case "C":
            this.suitCode = "♣";
            break;
        case "H":
            this.colorCls = "red";
            this.suitCode = "♥";
            break;
        }

        // concatenating strings with "+" is slow, using array join is faster: http://code.google.com/speed/articles/optimizing-javascript.html
        // TODO: run perf test to be sure that in this case we are getting better perf in IE
		var txt = this.rank;
		if(this.rank==="N"){
			txt = this.rankString.split('').join('
');
		}
        var strBuild = ['

', txt, '
', this.suitCode, '
'];
        strBuild = strBuild.concat(this.buildIconHTML());
        strBuild = strBuild.concat('
', txt, '
', this.suitCode, '

');
		this.html = strBuild.join('');
        return this.html;
    };
    $.fn.playingCards.card.prototype.buildIconHTML = function() {
        // TODO: could we optimize this with a for loop that breaks/continues to named positions?
        if (this.rank === "A") {
            return ['
', this.suitCode, '
'];
        }
        if (this.rank === "J" || this.rank === "Q" || this.rank === "K"  || this.rank === "N") {
			var n = 'D';
			if(!this.conf.singleFace){
				n = this.suit;
			}
            return [
            '
', this.suitCode, '
',
            '',
            '
', this.suitCode, '
'
            ];
        }
        var ret = [];
        var list = ['4', '5', '6', '7', '8', '9', '10'];
        // all of these will have A1, A5, C1, C5 icons
        // using jquery's inArray(). If we make a non-jquery version,
        // we will have to include an in_array proto on array (or change the way this is built)
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['2', '3'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['3', '5', '9'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['6', '7', '8'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['7', '8', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['8', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['9', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        return ret;
    };
})(jQuery);<commit_msg>adding quick flip demo (just toggles card face div for now)<commit_after>/**
 * jQuery Plugin to create a deck of cards.
 * This can be used to play standard card games (which could be additional rule modules attached to this set)
 *
 * usage: $("#cardTable").playingCards();
 * override defaults for playingCards() and for card() with
 *    $.playingCards.defaults
 *    $.playingCards.card.defaults
 *
 * @author Adam Eivy (antic | atomantic)
 * @license MIT (do what you like but keep the license)
 */
 (function($) {

    $.fn.playingCards = function(conf) {
        var o = $.extend({},
        $.fn.playingCards.defaults, conf);

        this.cards = [];
		var l;
        // populate draw pile
        for (var i = 0; i < o.decks; i++) {
			// standard
            for (var s in o.suits) {
                for (var r in o.ranks) {
					l = this.cards.length;
                    this.cards[l] = new $.fn.playingCards.card(r, o.ranks[r], s, o.suits[s]);

					// debugging design mode (just laying out all the cards in order)
					this.append(this.cards[l].getHTML());
                }
            }
			// jokers
			for (i=0;i<o.jokers;i++){
					l = this.cards.length;
					// suit will always be 1 or 2
                    this.cards[l] = new $.fn.playingCards.card("N", o.jokerText, (i%2)+1, '');

					// debugging design mode (just laying out all the cards in order)
					this.append(this.cards[l].getHTML());
			}
        }
		/* demo flip*/
		this.find('.playingCard').click(function(){
			$(this).find('.front').toggle();
		});
        this.draw = function() {
            return this.cards.length > 0 ? this.cards.shift() : null;
        };
        this.addCard = function(card) {
            this.cards.push(card);
        };
        this.count = function() {
            return this.cards.length;
        };

        return this;
    };
	$.fn.playingCards.prototype.shuffle = function(n) {
        var r;
        // random #
        var tmp;
        // tmp holder
        var l = this.cards.length;

        for (var i = 0; i < n; i++) {
            for (var j = 0; j < l; j++) {
                r = Math.floor(Math.random() * l);
                tmp = this.cards[j];
                this.cards[j] = this.cards[r];
                this.cards[r] = tmp;
            }
        }
    };
    $.fn.playingCards.defaults = {
        "decks": 1,
		"renderMode": 'css', // TODO: enable 'font' option -- loading cards.ttf
		"jokers":2,
		"jokerText":"Joker",
        "ranks": {
            "2": "Two",
            "3": "Three",
            "4": "Four",
            "5": "Five",
            "6": "Six",
            "7": "Seven",
            "8": "Eight",
            "9": "Nine",
            "10": "Ten",
            "J": "Jack",
            "Q": "Queen",
            "K": "King",
            "A": "Ace"
        },
        "suits": {
            "S": "Spades",
            "D": "Diamonds",
            "C": "Clubs",
            "H": "Hearts"
        }
    };
    /**
	 * create a playing card
	 *
	 * @param string rank The numeric or letter value of the card (short value)
	 * @param string rankString The full text representation of the rank (localized)
	 * @param string suit The letter value of the suite (short value)
	 * @param string suitString The full text representation of the suit (localized)
	 * @param obj conf Overriding configuration
	 *
	 * @return object The card object
	 */
    $.fn.playingCards.card = function(rank, rankString, suit, suitString, conf) {
        if (! (this instanceof arguments.callee)) {
            return new arguments.callee(rank, rankString, suit, suitString);
        }

	    this.conf = $.extend({},$.fn.playingCards.card.defaults,conf);

        this.rank = rank;
        this.rankString = rankString;
        this.suit = suit;
        this.suitString = suitString;
        return this;
    };
	$.fn.playingCards.card.defaults = {
		"singleFace":false // false will use a different image for each suit/face, true will use diamond image for all
	};
    $.fn.playingCards.card.prototype.toString = function() {
        // TODO: localize "of"
        return this.suitString!=="" ? this.rankString + " of " + this.suitString : this.rankString;
    };
    $.fn.playingCards.card.prototype.getHTML = function() {
		if(this.html){
			return this.html;
		}
        this.suitCode = " ";
        this.colorCls = '';
        switch (this.suit) {
        case "S":
            this.suitCode = "♠";
            break;
        case "D":
            this.colorCls = "red";
            this.suitCode = "♦";
            break;
        case "C":
            this.suitCode = "♣";
            break;
        case "H":
            this.colorCls = "red";
            this.suitCode = "♥";
            break;
        }

        // concatenating strings with "+" is slow, using array join is faster: http://code.google.com/speed/articles/optimizing-javascript.html
        // TODO: run perf test to be sure that in this case we are getting better perf in IE
		var txt = this.rank;
		if(this.rank==="N"){
			txt = this.rankString.split('').join('
');
		}
        var strBuild = ['

', txt, '
', this.suitCode, '
'];
        strBuild = strBuild.concat(this.buildIconHTML());
        strBuild = strBuild.concat('
', txt, '
', this.suitCode, '

');
		this.html = strBuild.join('');
        return this.html;
    };
    $.fn.playingCards.card.prototype.buildIconHTML = function() {
        // TODO: could we optimize this with a for loop that breaks/continues to named positions?
        if (this.rank === "A") {
            return ['
', this.suitCode, '
'];
        }
        if (this.rank === "J" || this.rank === "Q" || this.rank === "K"  || this.rank === "N") {
			var n = 'D';
			if(!this.conf.singleFace){
				n = this.suit;
			}
            return [
            '
', this.suitCode, '
',
            '',
            '
', this.suitCode, '
'
            ];
        }
        var ret = [];
        var list = ['4', '5', '6', '7', '8', '9', '10'];
        // all of these will have A1, A5, C1, C5 icons
        // using jquery's inArray(). If we make a non-jquery version,
        // we will have to include an in_array proto on array (or change the way this is built)
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['2', '3'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['3', '5', '9'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['6', '7', '8'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        list = ['7', '8', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['8', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
'
            ]);
        }
        list = ['9', '10'];
        if ($.inArray(this.rank, list)!==-1) {
            ret = ret.concat([
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
',
            '
', this.suitCode, '
'
            ]);
        }
        return ret;
    };
})(jQuery);<|endoftext|>


<commit_before>const pkg = require('./package.json');

const fs = require('fs');
const path = require('path');

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const SassLintPlugin = require('sasslint-webpack-plugin');
const UnminifiedWebpackPlugin = require('unminified-webpack-plugin');

const archiver = require('archiver');

const extractSrc = new ExtractTextPlugin('dist/vizabi.css');
const extractPreview = new ExtractTextPlugin('preview/assets/css/main.css');

const __PROD__ = process.env.NODE_ENV === 'production';
const __FAST__ = !!process.env.FAST;
const timestamp = new Date();

const sep = '\\' + path.sep;
const stats = {
  colors: true,
  hash: false,
  version: false,
  timings: true,
  assets: false,
  chunks: false,
  modules: false,
  reasons: true,
  children: false,
  source: false,
  errors: true,
  errorDetails: true,
  warnings: false,
  publicPath: false
};

function AfterBuildPlugin(callback) {
  this.callback = callback;
}
AfterBuildPlugin.prototype.apply = function (compiler) {
  compiler.plugin('done', this.callback);
};

const plugins = [
  new CleanWebpackPlugin(['build']),
  extractSrc,
  extractPreview,
  new CopyWebpackPlugin([
    {
      from: '.data/',
      to: 'preview/data/'
    },
    {
      from: 'preview/assets/js/',
      to: 'preview/assets/js/'
    },
    {
      from: 'src/assets/translation/',
      to: 'preview/assets/translation/'
    }
  ]),
  new CopyWebpackPlugin([
    {
      from: 'src/assets/translation/',
      to: 'dist/assets/translation/'
    },
    {
      from: 'src/assets/cursors/',
      to: 'dist/assets/cursors/'
    }
  ]),
  new OpenBrowserPlugin({
    url: 'http://localhost:8080/preview/'
  }),
  new SassLintPlugin({
    quiet: false,
    syntax: 'scss',
    glob: 'src/**/*.s?(a|c)ss',
    ignorePlugins: ['extract-text-webpack-plugin']
  }),
  new webpack.DefinePlugin({
    __VERSION: JSON.stringify(pkg.version),
    __BUILD: +timestamp
  })
];

if (__PROD__) {
  plugins.push(
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compressor: {
        screw_ie8: true,
        warnings: false
      },
      mangle: {
        screw_ie8: true
      },
      output: {
        comments: false,
        screw_ie8: true
      }
    }),
    new UnminifiedWebpackPlugin(),
    new AfterBuildPlugin(() => {
      fs.mkdirSync(path.resolve(__dirname, 'build', 'download'));

      const archive = archiver('zip');
      const files = [
        'vizabi.css',
        'vizabi.min.js',
        'vizabi.js'
      ];

      files.forEach(name =>
        archive.append(
          fs.createReadStream(path.resolve('build', 'dist', name)),
          { name }
        )
      );

      archive.pipe(
        fs.createWriteStream(path.resolve('build', 'download', 'vizabi.zip'))
      );
      archive.glob("**/*", { cwd: 'src/assets/cursors', dot: true }, { prefix: 'assets/cursors' });
      archive.glob("en.json", { cwd: 'src/assets/translation', dot: true }, { prefix: 'assets/translation' });
      archive.finalize();
    }),
    new webpack.BannerPlugin({
      banner: [
        '/**',
        ' * ' + pkg.name + ' - ' + pkg.description,
        ' * @version v' + pkg.version,
        ' * @build timestamp ' + timestamp,
        ' * @link ' + pkg.homepage,
        ' * @license ' + pkg.license,
        ' */',
        ''
      ].join('\n'),
      raw: true
    })
  )
}

const loaders = [
  {
    test: /\.scss$/,
    include: [
      path.resolve(__dirname, 'src')
    ],
    loader: extractSrc.extract([{
                loader: "css-loader",
                options: {
                       minimize: __PROD__,
                       sourceMap: true
                }
            }, {
              loader: 'sass-loader'
            }])
    },
  {
    test: /\.scss$/,
    include: [
      path.resolve(__dirname, 'preview')
    ],
    loader: extractPreview.extract(['css-loader', 'sass-loader'])
  },
  {
    test: /\.cur$/,
    loader: 'file-loader',
    query: {
      publicPath: path => path.split('/').slice(1).join('/'),
      name: 'preview/assets/cursors/[name].[ext]'
    }
  },
  {
    test: /\.pug$/,
    loaders: [
      'file-loader?name=[path][name].html',
      'pug-html-loader?exports=false'
    ]
  },
  {
    test: /\.css$/,
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/css/[name].[ext]'
    }
  },
  {
    test: /\.(otf|eot|svg|ttf|woff2?)$/,
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/fonts/[name].[ext]'
    }
  },
  {
    test: /(d3|\.web)\.js$/, // TODO: we need another way to extract vendor files
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/js/[1]/[name].[ext]',
      regExp: new RegExp(`${sep}node_modules${sep}([^${sep}]+?)${sep}`)
    }
  },
  {
    test: /\.html$/,
    include: [path.resolve(__dirname, 'src')],
    loader: 'html-loader'
  }
];

if (!__FAST__) {
  loaders.push({
    test: /\.js$/,
    exclude: /node_modules/,
    loader: 'babel-loader',
    query: {
      cacheDirectory: !__PROD__,
      presets: ['es2015']
    }
  });
}

module.exports = {
  devtool: 'source-map',

  entry: {
    'dist/vizabi': './src/vizabi-gapminder',
    'preview': './preview/index'
  },

  output: {
    path: path.resolve(__dirname, 'build'),
    filename: __PROD__ ? '[name].min.js' : '[name].js',
    library: 'Vizabi',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },

  resolve: {
    modules: [
      path.resolve(__dirname, 'src'),
      'node_modules'
    ]
  },

  module: {
    loaders
  },

  plugins,

  stats,
  devServer: {
    stats,
    host: '0.0.0.0'
  }
};
<commit_msg>Remove whitespace<commit_after>const pkg = require('./package.json');

const fs = require('fs');
const path = require('path');

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const SassLintPlugin = require('sasslint-webpack-plugin');
const UnminifiedWebpackPlugin = require('unminified-webpack-plugin');

const archiver = require('archiver');

const extractSrc = new ExtractTextPlugin('dist/vizabi.css');
const extractPreview = new ExtractTextPlugin('preview/assets/css/main.css');

const __PROD__ = process.env.NODE_ENV === 'production';
const __FAST__ = !!process.env.FAST;
const timestamp = new Date();

const sep = '\\' + path.sep;
const stats = {
  colors: true,
  hash: false,
  version: false,
  timings: true,
  assets: false,
  chunks: false,
  modules: false,
  reasons: true,
  children: false,
  source: false,
  errors: true,
  errorDetails: true,
  warnings: false,
  publicPath: false
};

function AfterBuildPlugin(callback) {
  this.callback = callback;
}
AfterBuildPlugin.prototype.apply = function (compiler) {
  compiler.plugin('done', this.callback);
};

const plugins = [
  new CleanWebpackPlugin(['build']),
  extractSrc,
  extractPreview,
  new CopyWebpackPlugin([
    {
      from: '.data/',
      to: 'preview/data/'
    },
    {
      from: 'preview/assets/js/',
      to: 'preview/assets/js/'
    },
    {
      from: 'src/assets/translation/',
      to: 'preview/assets/translation/'
    }
  ]),
  new CopyWebpackPlugin([
    {
      from: 'src/assets/translation/',
      to: 'dist/assets/translation/'
    },
    {
      from: 'src/assets/cursors/',
      to: 'dist/assets/cursors/'
    }
  ]),
  new OpenBrowserPlugin({
    url: 'http://localhost:8080/preview/'
  }),
  new SassLintPlugin({
    quiet: false,
    syntax: 'scss',
    glob: 'src/**/*.s?(a|c)ss',
    ignorePlugins: ['extract-text-webpack-plugin']
  }),
  new webpack.DefinePlugin({
    __VERSION: JSON.stringify(pkg.version),
    __BUILD: +timestamp
  })
];

if (__PROD__) {
  plugins.push(
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compressor: {
        screw_ie8: true,
        warnings: false
      },
      mangle: {
        screw_ie8: true
      },
      output: {
        comments: false,
        screw_ie8: true
      }
    }),
    new UnminifiedWebpackPlugin(),
    new AfterBuildPlugin(() => {
      fs.mkdirSync(path.resolve(__dirname, 'build', 'download'));

      const archive = archiver('zip');
      const files = [
        'vizabi.css',
        'vizabi.min.js',
        'vizabi.js'
      ];

      files.forEach(name =>
        archive.append(
          fs.createReadStream(path.resolve('build', 'dist', name)),
          { name }
        )
      );

      archive.pipe(
        fs.createWriteStream(path.resolve('build', 'download', 'vizabi.zip'))
      );
      archive.glob("**/*", { cwd: 'src/assets/cursors', dot: true }, { prefix: 'assets/cursors' });
      archive.glob("en.json", { cwd: 'src/assets/translation', dot: true }, { prefix: 'assets/translation' });
      archive.finalize();
    }),
    new webpack.BannerPlugin({
      banner: [
        '/**',
        ' * ' + pkg.name + ' - ' + pkg.description,
        ' * @version v' + pkg.version,
        ' * @build timestamp ' + timestamp,
        ' * @link ' + pkg.homepage,
        ' * @license ' + pkg.license,
        ' */',
        ''
      ].join('\n'),
      raw: true
    })
  )
}

const loaders = [
  {
    test: /\.scss$/,
    include: [
      path.resolve(__dirname, 'src')
    ],
    loader: extractSrc.extract([{
        loader: "css-loader",
        options: {
          minimize: __PROD__,
          sourceMap: true
        }
      }, {
        loader: 'sass-loader'
      }])
    },
  {
    test: /\.scss$/,
    include: [
      path.resolve(__dirname, 'preview')
    ],
    loader: extractPreview.extract(['css-loader', 'sass-loader'])
  },
  {
    test: /\.cur$/,
    loader: 'file-loader',
    query: {
      publicPath: path => path.split('/').slice(1).join('/'),
      name: 'preview/assets/cursors/[name].[ext]'
    }
  },
  {
    test: /\.pug$/,
    loaders: [
      'file-loader?name=[path][name].html',
      'pug-html-loader?exports=false'
    ]
  },
  {
    test: /\.css$/,
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/css/[name].[ext]'
    }
  },
  {
    test: /\.(otf|eot|svg|ttf|woff2?)$/,
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/fonts/[name].[ext]'
    }
  },
  {
    test: /(d3|\.web)\.js$/, // TODO: we need another way to extract vendor files
    include: [
      path.resolve(__dirname, 'node_modules')
    ],
    loader: 'file-loader',
    query: {
      name: 'preview/assets/vendor/js/[1]/[name].[ext]',
      regExp: new RegExp(`${sep}node_modules${sep}([^${sep}]+?)${sep}`)
    }
  },
  {
    test: /\.html$/,
    include: [path.resolve(__dirname, 'src')],
    loader: 'html-loader'
  }
];

if (!__FAST__) {
  loaders.push({
    test: /\.js$/,
    exclude: /node_modules/,
    loader: 'babel-loader',
    query: {
      cacheDirectory: !__PROD__,
      presets: ['es2015']
    }
  });
}

module.exports = {
  devtool: 'source-map',

  entry: {
    'dist/vizabi': './src/vizabi-gapminder',
    'preview': './preview/index'
  },

  output: {
    path: path.resolve(__dirname, 'build'),
    filename: __PROD__ ? '[name].min.js' : '[name].js',
    library: 'Vizabi',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },

  resolve: {
    modules: [
      path.resolve(__dirname, 'src'),
      'node_modules'
    ]
  },

  module: {
    loaders
  },

  plugins,

  stats,
  devServer: {
    stats,
    host: '0.0.0.0'
  }
};
<|endoftext|>


<commit_before>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Node for showing and scrolling between kits.
 *
 * @author John Blanco
 * @author Sam Reid
 */

define( function( require ) {
  'use strict';

  // Imports
  var inherit = require( 'PHET_CORE/inherit' );
  var Dimension2 = require( 'DOT/Dimension2' );
  var KitControlNodeSides = require( 'SCENERY_PHET/KitControlNodeSides' );
  var KitControlNodeTop = require( 'SCENERY_PHET/KitControlNodeTop' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Shape = require( 'KITE/Shape' );
  var Timer = require( 'JOIST/Timer' );

  // Constants
  var SLOT_CHANGE_TIME = 0.35; // In seconds

  /**
   * @param {Property} selectedKit
   * @param {Array} kits
   * @param {Object} options
   * @constructor
   */
  function KitSelectionNode( selectedKit, kits, options ) {
    Node.call( this );
    var thisNode = this;

    options = _.extend(
      {
        // Defaults
        titleNode: null,
        selectorPosition: 'sides' // Valid values are 'sides' and 'top'
      }, options
    );

    // Make the selected kit property visible externally.
    thisNode.selectedKit = selectedKit;

    // Determine the max size of all the kit contents for layout purposes.
    var maxKitContentSize = new Dimension2( 0, 0 );
    var maxKitTitleSize = new Dimension2( 0, 0 );
    kits.forEach( function( kit ) {
      maxKitContentSize.width = Math.max( maxKitContentSize.width, kit.content.width );
      maxKitContentSize.height = Math.max( maxKitContentSize.height, kit.content.height );
      maxKitTitleSize.width = Math.max( maxKitTitleSize.width, kit.title.width );
      maxKitTitleSize.height = Math.max( maxKitTitleSize.height, kit.title.height );
    } );

    var controlNode;
    if ( options.selectorPosition === 'top' ) {
      controlNode = new KitControlNodeTop( kits.length, selectedKit, { titleNode: options.titleNode, minButtonXSpace: 70 } );
    }
    else if ( options.selectorPosition === 'sides' ) {
      controlNode = new KitControlNodeSides( kits.length, selectedKit, maxKitContentSize.width * 1.2 );
    }
    else {
      throw new Error( 'Unknown selector position option: ' + options.selectorPosition );
    }

    // Construct and add the background.  Make it big enough to hold the largest kit.
    thisNode.selectorSize = new Dimension2( Math.max( Math.max( maxKitContentSize.width, maxKitTitleSize.width ), controlNode.width ),
        controlNode.height + maxKitContentSize.height + maxKitTitleSize.height );

    // Create the layer that contains all the kits, and add the kits side by
    // side spaced by the distance of the background so only 1 kit will be
    // visible at a time.
    thisNode.kitLayer = new Node();

    // Add the kits to the kit layer, spacing them out so they don't overlap.
    var x = 0;
    kits.forEach( function( kit ) {
      // Put the title centered at the top and the content node centered in the
      // available space beneath.
      if ( kit.title ) {
        kit.title.centerX = x + thisNode.selectorSize.width / 2;
        kit.title.top = 0;
        thisNode.kitLayer.addChild( kit.title );
      }

      kit.content.centerX = x + thisNode.selectorSize.width / 2;
      kit.content.centerY = kit.title.bottom + maxKitContentSize.height / 2;
      thisNode.kitLayer.addChild( kit.content );

      // Move over to the next kit
      x += thisNode.selectorSize.width;
    } );

    // Clip the kits so that the unselected ones are invisible.
    thisNode.clipArea = new Shape.rect( 0, 0, thisNode.selectorSize.width, thisNode.selectorSize.height );

    // Add the remaining nodes.
    thisNode.addChild( thisNode.kitLayer );
    thisNode.addChild( controlNode );

    // Layout
    if ( options.selectorPosition === 'top ' ) {
      controlNode.top = 0;
      controlNode.centerX = thisNode.selectorSize.width / 2;
      thisNode.kitLayer.top = controlNode.height;
    }
    else { // control node at sides
//      debugger;
      controlNode.centerX = thisNode.selectorSize.width / 2;
//      controlNode.centerY = thisNode.selectorSize.height / 2;
      controlNode.centerY = thisNode.bounds.height / 2;
//      controlNode.top = t;
      thisNode.kitLayer.top = 0;
    }

    // Set up an observer to set visibility of the selected kit.
    selectedKit.link( function( kit ) {
      thisNode.scrollTo( kit );
    } );

    // Set up the timer and function that will animate the carousel position.
    var motionVelocity = thisNode.selectorSize.width / SLOT_CHANGE_TIME;
    thisNode.kitLayerTargetX = thisNode.kitLayer.x;
    Timer.addStepListener( function( dt ) {
      if ( thisNode.kitLayer.x !== thisNode.kitLayerTargetX ) {
        var dx = dt * motionVelocity * ( thisNode.kitLayerTargetX < thisNode.kitLayer.x ? -1 : 1 );
        if ( Math.abs( thisNode.kitLayer.x - thisNode.kitLayerTargetX ) <= Math.abs( dx ) ) {
          thisNode.kitLayer.x = thisNode.kitLayerTargetX;
        }
        else {
          thisNode.kitLayer.x += dx;
        }
      }
    } );

    // Pass through any options intended for Node.
    thisNode.mutate( options );
  }

  return inherit( Node, KitSelectionNode, {
    scrollTo: function( kitNumber ) {
      this.kitLayerTargetX = -kitNumber * this.selectorSize.width;
    }
  } );
} );
<commit_msg>Minor cleanup.<commit_after>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Node for showing and scrolling between kits.
 *
 * @author John Blanco
 * @author Sam Reid
 */

define( function( require ) {
  'use strict';

  // Imports
  var inherit = require( 'PHET_CORE/inherit' );
  var Dimension2 = require( 'DOT/Dimension2' );
  var KitControlNodeSides = require( 'SCENERY_PHET/KitControlNodeSides' );
  var KitControlNodeTop = require( 'SCENERY_PHET/KitControlNodeTop' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Shape = require( 'KITE/Shape' );
  var Timer = require( 'JOIST/Timer' );

  // Constants
  var SLOT_CHANGE_TIME = 0.35; // In seconds

  /**
   * @param {Property} selectedKit
   * @param {Array} kits
   * @param {Object} options
   * @constructor
   */
  function KitSelectionNode( selectedKit, kits, options ) {
    Node.call( this );
    var thisNode = this;

    options = _.extend(
      {
        // Defaults
        titleNode: null,
        selectorPosition: 'sides' // Valid values are 'sides' and 'top'
      }, options
    );

    // Make the selected kit property visible externally.
    thisNode.selectedKit = selectedKit;

    // Determine the max size of all the kit contents for layout purposes.
    var maxKitContentSize = new Dimension2( 0, 0 );
    var maxKitTitleSize = new Dimension2( 0, 0 );
    kits.forEach( function( kit ) {
      maxKitContentSize.width = Math.max( maxKitContentSize.width, kit.content.width );
      maxKitContentSize.height = Math.max( maxKitContentSize.height, kit.content.height );
      maxKitTitleSize.width = Math.max( maxKitTitleSize.width, kit.title.width );
      maxKitTitleSize.height = Math.max( maxKitTitleSize.height, kit.title.height );
    } );

    var controlNode;
    if ( options.selectorPosition === 'top' ) {
      controlNode = new KitControlNodeTop( kits.length, selectedKit, { titleNode: options.titleNode, minButtonXSpace: 70 } );
    }
    else if ( options.selectorPosition === 'sides' ) {
      controlNode = new KitControlNodeSides( kits.length, selectedKit, maxKitContentSize.width * 1.2 );
    }
    else {
      throw new Error( 'Unknown selector position option: ' + options.selectorPosition );
    }

    // Construct and add the background.  Make it big enough to hold the largest kit.
    thisNode.selectorSize = new Dimension2( Math.max( Math.max( maxKitContentSize.width, maxKitTitleSize.width ), controlNode.width ),
      controlNode.height + maxKitContentSize.height + maxKitTitleSize.height );

    // Create the layer that contains all the kits, and add the kits side by
    // side spaced by the distance of the background so only 1 kit will be
    // visible at a time.
    thisNode.kitLayer = new Node();

    // Add the kits to the kit layer, spacing them out so they don't overlap.
    var x = 0;
    kits.forEach( function( kit ) {
      // Put the title centered at the top and the content node centered in the
      // available space beneath.
      if ( kit.title ) {
        kit.title.centerX = x + thisNode.selectorSize.width / 2;
        kit.title.top = 0;
        thisNode.kitLayer.addChild( kit.title );
      }

      kit.content.centerX = x + thisNode.selectorSize.width / 2;
      kit.content.centerY = kit.title.bottom + maxKitContentSize.height / 2;
      thisNode.kitLayer.addChild( kit.content );

      // Move over to the next kit
      x += thisNode.selectorSize.width;
    } );

    // Clip the kits so that the unselected ones are invisible.
    thisNode.clipArea = new Shape.rect( 0, 0, thisNode.selectorSize.width, thisNode.selectorSize.height );

    // Add the remaining nodes.
    thisNode.addChild( thisNode.kitLayer );
    thisNode.addChild( controlNode );

    // Layout
    if ( options.selectorPosition === 'top ' ) {
      controlNode.top = 0;
      controlNode.centerX = thisNode.selectorSize.width / 2;
      thisNode.kitLayer.top = controlNode.height;
    }
    else { // control node at sides
      controlNode.centerX = thisNode.selectorSize.width / 2;
      controlNode.centerY = thisNode.bounds.height / 2;
      thisNode.kitLayer.top = 0;
    }

    // Set up an observer to set visibility of the selected kit.
    selectedKit.link( function( kit ) {
      thisNode.scrollTo( kit );
    } );

    // Set up the timer and function that will animate the carousel position.
    var motionVelocity = thisNode.selectorSize.width / SLOT_CHANGE_TIME;
    thisNode.kitLayerTargetX = thisNode.kitLayer.x;
    Timer.addStepListener( function( dt ) {
      if ( thisNode.kitLayer.x !== thisNode.kitLayerTargetX ) {
        var dx = dt * motionVelocity * ( thisNode.kitLayerTargetX < thisNode.kitLayer.x ? -1 : 1 );
        if ( Math.abs( thisNode.kitLayer.x - thisNode.kitLayerTargetX ) <= Math.abs( dx ) ) {
          thisNode.kitLayer.x = thisNode.kitLayerTargetX;
        }
        else {
          thisNode.kitLayer.x += dx;
        }
      }
    } );

    // Pass through any options intended for Node.
    thisNode.mutate( options );
  }

  return inherit( Node, KitSelectionNode, {
    scrollTo: function( kitNumber ) {
      this.kitLayerTargetX = -kitNumber * this.selectorSize.width;
    }
  } );
} );
<|endoftext|>


<commit_before>///
/// Hints and trick for the client. Think AmiGO::Aid.
///

// // Support CommonJS if it looks like that's how we're rolling.
// if( typeof(exports) != 'undefined' ){
//     var
// }

/*
 * Constructor: bbop_mme_context
 *
 * Initial take from AmiGO/Aid.pm
 *
 * Arguments:
 *  n/a
 *
 * Returns:
 *  aiding object
 */
var bbop_mme_context = function(){

    // Relations.
    // Colors are X11: http://cng.seas.rochester.edu/CNG/docs/x11color.html
    var entities = {
	'instance_of':
	{
	    readable: 'activity',
	    priority: 8,
	    aliases: [
		'activity'
	    ],
	    color: '#FFFAFA' // snow
	},
	'BFO:0000050':
	{
	    readable: 'part of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000050',
		//'http://purl.obolibrary.org/obo/part_of',
		'BFO_0000050',
		'part of',
		'part_of'
	    ],
	    color: '#add8e6' // light blue
	},
	'BFO:0000051':
	{
	    readable: 'has part',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000051',
		'has part',
		'has_part'
	    ],
	    color: '#6495ED' // cornflower blue
	},
	'BFO:0000066':
	{
	    readable: 'occurs in',
	    priority: 2,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000066',
		//'BFO_0000066',
		'occurs in',
		'occurs_in'
	    ],
	    color: '#66CDAA' // medium aquamarine
	},
	'RO:0002202':
	{
	    readable: 'develops from',
	    priority: 0,
	    aliases: [
		'develops from',
		'develops_from'
	    ],
	    color: '#A52A2A' // brown
	},
	'RO:0002211':
	{
	    readable: 'regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002211'
		'regulates'
	    ],
	    color: '#2F4F4F' // dark slate grey
	},
	'RO:0002212':
	{
	    readable: 'negatively regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002212'
		'negatively regulates',
		'negatively_regulates'
	    ],
	    color: '#FF0000' // red
	},
	'RO:0002213':
	{
	    readable: 'positively regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002213'
		'positively regulates',
		'positively_regulates'
	    ],
	    color: '#008000' //green
	},
	'RO:0002330':
	{
	    readable: 'genomically related to',
	    priority: 0,
	    aliases: [
		'genomically related to',
		'genomically_related_to'
	    ],
	    color: '#9932CC' // darkorchid
	},
	'RO:0002331':
	{
	    readable: 'involved in',
	    priority: 3,
	    aliases: [
		'involved in',
		'involved_in'
	    ],
	    color: '#E9967A' // darksalmon
	},
	'RO:0002332':
	{
	    readable: 'regulates level of',
	    priority: 0,
	    aliases: [
		'regulates level of',
		'regulates_level_of'
	    ],
	    color: '#556B2F' // darkolivegreen
	},
	'RO:0002333':
	{
	    readable: 'enabled by',
	    priority: 9,
	    aliases: [
		'RO_0002333',
		'enabled by',
		'enabled_by'
	    ],
	    color: '#B8860B' // darkgoldenrod
	},
	'activates':
	{
	    readable: 'activates',
	    priority: 0,
	    aliases: [
		'http://purl.obolibrary.org/obo/activates'
	    ],
	    color: '#8FBC8F' // darkseagreen
	},
	'directly_activates':
	{
	    readable: 'directly activates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/directly_activates',
		'directly activates',
		'directly_activates'
	    ],
	    color: '#2F4F4F' // darkslategray
	},
	'upstream_of':
	{
	    readable: 'upstream of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/upstream_of'
		'upstream of',
		'upstream_of'
	    ],
	    color: '#FF1493' // deeppink
	},
	'directly_inhibits':
	{
	    readable: 'directly inhibits',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/directly_inhibits'
		'directly inhibits',
		'directly_inhibits'
	    ],
	    color: '#7FFF00' // chartreuse
	},
	'indirectly_disables_action_of':
	{
	    readable: 'indirectly disables action of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/indirectly_disables_action_of'
		'indirectly disables action of',
		'indirectly_disables_action_of'
	    ],
	    color: '#483D8B' // darkslateblue
	}
    };

    // Compile entity aliases.
    var entity_aliases = {};
    bbop.core.each(entities,
		   function(ekey, eobj){
		       entity_aliases[ekey] = ekey; // identity
		       bbop.core.each(eobj['aliases'],
				      function(alias){
					  entity_aliases[alias] = ekey;
				      });
		   });

    // The
    var suggested_stack_order = [
	'RO:0002333', // enabled by
	'instance_of', // activity
	'',
	'BFO:0000066' // occurs in
    ];

    // Helper fuction to go from unknown id -> alias -> data structure.
    this._dealias_data = function(id){

	var ret = null;
	if( id ){
	    if( entity_aliases[id] ){ // directly pull
		var tru_id = entity_aliases[id];
		ret = entities[tru_id];
	    }
	}

	return ret;
    };

    /*
     * Function: readable
     *
     * Returns a human readable form of the inputted string.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  readable string or original string
     */
    this.readable = function(ind){
	var ret = ind;

	var data = this._dealias_data(ind);
	if( data && data['readable'] ){
	    ret = data['readable'];
	}

	return ret;
    };

    /*
     * Function: color
     *
     * Return the string of a color of a rel.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  appropriate color string or 'grey'
     */
    this.color = function(ind){

	var ret = '#808080'; // grey

	var data = this._dealias_data(ind);
	if( data && data['color'] ){
	    ret = data['color'];
	}

	return ret;
    };

    /*
     * Function: priority
     *
     * Return a number representing the relative priority of the
     * entity under consideration.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  appropriate integer or 0
     */
    this.priority = function(ind){

	var ret = 0;

	var data = this._dealias_data(ind);
	if( data && data['priority'] ){
	    ret = data['priority'];
	}

	return ret;
    };

    /*
     * Function: all_entities
     *
     * Return a list of the currently known entities.
     *
     * Parameters:
     *  n/a
     *
     * Returns:
     *  list
     */
    this.all_entities = function(){
	var rls = bbop.core.get_keys(entities);
	return rls;
    };

    /*
     * Function: all_known
     *
     * Return a list of the currently known entities and their aliases.
     *
     * Parameters:
     *  n/a
     *
     * Returns:
     *  list
     */
    this.all_known = function(){
	var rls = bbop.core.get_keys(entity_aliases);
	return rls;
    };

    /*
     * Function: categorize
     *
     * Try to put an intstance type into some kind of rendering
     * category.
     *
     * Parameters:
     *  in_type - instance type as returned by JSON-LD service
     *
     * Returns:
     *  string (default 'unknown')
     */
    this.categorize = function(in_type){

	var ret = 'unknown';

	var t = in_type['type'];
	if( t == 'Class' ){
	    ret = 'instance_of';
	}else if( t == 'Restriction' ){
	    ret = in_type['onProperty']['id'];
	}else{
	    // use default
	}

	return ret;
    };

    /*
     * Function: cleanse
     *
     * Turn ID strings into something standard:
     *  ':' -> '_' and 'http://foo/bar' -> 'bar'.
     *
     * NOTE: Cleanse currently does nothing.
     *
     * Parameters:
     *  id_string - the string to cleanse
     *
     * Returns:
     *  string
     */
    this.cleanse = function(id_string){

    	var retstr = id_string;

    	// // 'http://foo/bar' -> 'bar'
    	// retstr = retstr.substring(retstr.lastIndexOf("/") + 1, retstr.length);

    	// // ':' -> '_'
    	// retstr = retstr.replace(':', '_');

    	// //
    	// if( ! retstr || retstr == '' ){
    	//     throw new Error('cleanse: entered with: ' +
    	// 		    retstr + ' ; nothing left');
    	//     retstr = id_string;
    	// }

    	return retstr;
    };
};

var bme_categorize = function(in_type){

    var ret = {
	category: 'unknown',
	text: '???'
    };

    var t = in_type['type'];
    if( t == 'Class' ){
	var i = in_type['id'];
	var l = in_type['label'];
	ret['category'] = 'instance_of';
	ret['text'] = l + ' (' + i + ')';
    }else if( t == 'Restriction' ){
	var thing = in_type['someValuesFrom']['id'];
	var thing_rel = in_type['onProperty']['id'];
	ret['category'] = thing_rel;
	ret['text'] = thing_rel + ' (' + thing + ')';
    }

    return ret;
};

/*
 *
 */
var bme_type_to_text = function(in_type, aid){

    var text = '???';

    var t = in_type['type'];
    if( t == 'Class' ){
	var i = in_type['id'];
	var l = in_type['label'] || i;
	text = '' +
	    l + '';
    }else if( t == 'Restriction' ){
	var thing = in_type['someValuesFrom']['label'] ||
	    in_type['someValuesFrom']['id'];
	var thing_rel = in_type['onProperty']['label'] ||
	    in_type['onProperty']['id'];
	//text = thing_rel + '(' + thing + ')';
	text = '' +
	    thing + '';
    }

    return text;
};
          // {
          //   "type": "Class",
          //   "label": "phosphatase activity",
          //   "id": "GO_0016791"
          // },
          // {
          //   "someValuesFrom": {
          //     "type": "Class",
          //     "id": "WB_WBGene00000913"
          //   },
          //   "type": "Restriction",
          //   "onProperty": {
          //     "type": "ObjectProperty",
          //     "id": "enabled_by"
          //   }

// Support CommonJS if it looks like that's how we're rolling.
if( typeof(exports) != 'undefined' ){
    exports.bbop_mme_context = bbop_mme_context;
    exports.bbop_type_to_tcell = bbop_type_to_tcell;
}

<commit_msg>fix for chris label<commit_after>///
/// Hints and trick for the client. Think AmiGO::Aid.
///

// // Support CommonJS if it looks like that's how we're rolling.
// if( typeof(exports) != 'undefined' ){
//     var
// }

/*
 * Constructor: bbop_mme_context
 *
 * Initial take from AmiGO/Aid.pm
 *
 * Arguments:
 *  n/a
 *
 * Returns:
 *  aiding object
 */
var bbop_mme_context = function(){

    // Relations.
    // Colors are X11: http://cng.seas.rochester.edu/CNG/docs/x11color.html
    var entities = {
	'instance_of':
	{
	    readable: 'activity',
	    priority: 8,
	    aliases: [
		'activity'
	    ],
	    color: '#FFFAFA' // snow
	},
	'BFO:0000050':
	{
	    readable: 'part of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000050',
		//'http://purl.obolibrary.org/obo/part_of',
		'BFO_0000050',
		'part of',
		'part_of'
	    ],
	    color: '#add8e6' // light blue
	},
	'BFO:0000051':
	{
	    readable: 'has part',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000051',
		'has part',
		'has_part'
	    ],
	    color: '#6495ED' // cornflower blue
	},
	'BFO:0000066':
	{
	    readable: 'occurs in',
	    priority: 2,
	    aliases: [
		//'http://purl.obolibrary.org/obo/BFO_0000066',
		//'BFO_0000066',
		'occurs in',
		'occurs_in'
	    ],
	    color: '#66CDAA' // medium aquamarine
	},
	'RO:0002202':
	{
	    readable: 'develops from',
	    priority: 0,
	    aliases: [
		'develops from',
		'develops_from'
	    ],
	    color: '#A52A2A' // brown
	},
	'RO:0002211':
	{
	    readable: 'regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002211'
		'regulates'
	    ],
	    color: '#2F4F4F' // dark slate grey
	},
	'RO:0002212':
	{
	    readable: 'negatively regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002212'
		'negatively regulates',
		'negatively_regulates'
	    ],
	    color: '#FF0000' // red
	},
	'RO:0002213':
	{
	    readable: 'positively regulates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/RO_0002213'
		'positively regulates',
		'positively_regulates'
	    ],
	    color: '#008000' //green
	},
	'RO:0002330':
	{
	    readable: 'genomically related to',
	    priority: 0,
	    aliases: [
		'genomically related to',
		'genomically_related_to'
	    ],
	    color: '#9932CC' // darkorchid
	},
	'RO:0002331':
	{
	    readable: 'involved in',
	    priority: 3,
	    aliases: [
		'involved in',
		'involved_in'
	    ],
	    color: '#E9967A' // darksalmon
	},
	'RO:0002332':
	{
	    readable: 'regulates level of',
	    priority: 0,
	    aliases: [
		'regulates level of',
		'regulates_level_of'
	    ],
	    color: '#556B2F' // darkolivegreen
	},
	'RO:0002333':
	{
	    readable: 'enabled by',
	    priority: 9,
	    aliases: [
		'RO_0002333',
		'enabled by',
		'enabled_by'
	    ],
	    color: '#B8860B' // darkgoldenrod
	},
	'activates':
	{
	    readable: 'activates',
	    priority: 0,
	    aliases: [
		'http://purl.obolibrary.org/obo/activates'
	    ],
	    color: '#8FBC8F' // darkseagreen
	},
	'directly_activates':
	{
	    readable: 'directly activates',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/directly_activates',
		'directly activates',
		'directly_activates'
	    ],
	    color: '#2F4F4F' // darkslategray
	},
	'upstream_of':
	{
	    readable: 'upstream of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/upstream_of'
		'upstream of',
		'upstream_of'
	    ],
	    color: '#FF1493' // deeppink
	},
	'directly_inhibits':
	{
	    readable: 'directly inhibits',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/directly_inhibits'
		'directly inhibits',
		'directly_inhibits'
	    ],
	    color: '#7FFF00' // chartreuse
	},
	'indirectly_disables_action_of':
	{
	    readable: 'indirectly disables action of',
	    priority: 0,
	    aliases: [
		//'http://purl.obolibrary.org/obo/indirectly_disables_action_of'
		'indirectly disables action of',
		'indirectly_disables_action_of'
	    ],
	    color: '#483D8B' // darkslateblue
	},
	'provides_input_for':
	{
	    readable: 'provides input for',
	    priority: 0,
	    aliases: [
		'GOREL_provides_input_for',
		'http://purl.obolibrary.org/obo/GOREL_provides_input_for'
	    ],
	    color: '#483D8B' // darkslateblue
	}
    };

    // Compile entity aliases.
    var entity_aliases = {};
    bbop.core.each(entities,
		   function(ekey, eobj){
		       entity_aliases[ekey] = ekey; // identity
		       bbop.core.each(eobj['aliases'],
				      function(alias){
					  entity_aliases[alias] = ekey;
				      });
		   });

    // The
    var suggested_stack_order = [
	'RO:0002333', // enabled by
	'instance_of', // activity
	'',
	'BFO:0000066' // occurs in
    ];

    // Helper fuction to go from unknown id -> alias -> data structure.
    this._dealias_data = function(id){

	var ret = null;
	if( id ){
	    if( entity_aliases[id] ){ // directly pull
		var tru_id = entity_aliases[id];
		ret = entities[tru_id];
	    }
	}

	return ret;
    };

    /*
     * Function: readable
     *
     * Returns a human readable form of the inputted string.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  readable string or original string
     */
    this.readable = function(ind){
	var ret = ind;

	var data = this._dealias_data(ind);
	if( data && data['readable'] ){
	    ret = data['readable'];
	}

	return ret;
    };

    /*
     * Function: color
     *
     * Return the string of a color of a rel.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  appropriate color string or 'grey'
     */
    this.color = function(ind){

	var ret = '#808080'; // grey

	var data = this._dealias_data(ind);
	if( data && data['color'] ){
	    ret = data['color'];
	}

	return ret;
    };

    /*
     * Function: priority
     *
     * Return a number representing the relative priority of the
     * entity under consideration.
     *
     * Parameters:
     *  ind - incoming data id
     *
     * Returns:
     *  appropriate integer or 0
     */
    this.priority = function(ind){

	var ret = 0;

	var data = this._dealias_data(ind);
	if( data && data['priority'] ){
	    ret = data['priority'];
	}

	return ret;
    };

    /*
     * Function: all_entities
     *
     * Return a list of the currently known entities.
     *
     * Parameters:
     *  n/a
     *
     * Returns:
     *  list
     */
    this.all_entities = function(){
	var rls = bbop.core.get_keys(entities);
	return rls;
    };

    /*
     * Function: all_known
     *
     * Return a list of the currently known entities and their aliases.
     *
     * Parameters:
     *  n/a
     *
     * Returns:
     *  list
     */
    this.all_known = function(){
	var rls = bbop.core.get_keys(entity_aliases);
	return rls;
    };

    /*
     * Function: categorize
     *
     * Try to put an intstance type into some kind of rendering
     * category.
     *
     * Parameters:
     *  in_type - instance type as returned by JSON-LD service
     *
     * Returns:
     *  string (default 'unknown')
     */
    this.categorize = function(in_type){

	var ret = 'unknown';

	var t = in_type['type'];
	if( t == 'Class' ){
	    ret = 'instance_of';
	}else if( t == 'Restriction' ){
	    ret = in_type['onProperty']['id'];
	}else{
	    // use default
	}

	return ret;
    };

    /*
     * Function: cleanse
     *
     * Turn ID strings into something standard:
     *  ':' -> '_' and 'http://foo/bar' -> 'bar'.
     *
     * NOTE: Cleanse currently does nothing.
     *
     * Parameters:
     *  id_string - the string to cleanse
     *
     * Returns:
     *  string
     */
    this.cleanse = function(id_string){

    	var retstr = id_string;

    	// // 'http://foo/bar' -> 'bar'
    	// retstr = retstr.substring(retstr.lastIndexOf("/") + 1, retstr.length);

    	// // ':' -> '_'
    	// retstr = retstr.replace(':', '_');

    	// //
    	// if( ! retstr || retstr == '' ){
    	//     throw new Error('cleanse: entered with: ' +
    	// 		    retstr + ' ; nothing left');
    	//     retstr = id_string;
    	// }

    	return retstr;
    };
};

var bme_categorize = function(in_type){

    var ret = {
	category: 'unknown',
	text: '???'
    };

    var t = in_type['type'];
    if( t == 'Class' ){
	var i = in_type['id'];
	var l = in_type['label'];
	ret['category'] = 'instance_of';
	ret['text'] = l + ' (' + i + ')';
    }else if( t == 'Restriction' ){
	var thing = in_type['someValuesFrom']['id'];
	var thing_rel = in_type['onProperty']['id'];
	ret['category'] = thing_rel;
	ret['text'] = thing_rel + ' (' + thing + ')';
    }

    return ret;
};

/*
 *
 */
var bme_type_to_text = function(in_type, aid){

    var text = '???';

    var t = in_type['type'];
    if( t == 'Class' ){
	var i = in_type['id'];
	var l = in_type['label'] || i;
	text = '' +
	    l + '';
    }else if( t == 'Restriction' ){
	var thing = in_type['someValuesFrom']['label'] ||
	    in_type['someValuesFrom']['id'];
	var thing_rel = in_type['onProperty']['label'] ||
	    in_type['onProperty']['id'];
	//text = thing_rel + '(' + thing + ')';
	text = '' +
	    thing + '';
    }

    return text;
};
          // {
          //   "type": "Class",
          //   "label": "phosphatase activity",
          //   "id": "GO_0016791"
          // },
          // {
          //   "someValuesFrom": {
          //     "type": "Class",
          //     "id": "WB_WBGene00000913"
          //   },
          //   "type": "Restriction",
          //   "onProperty": {
          //     "type": "ObjectProperty",
          //     "id": "enabled_by"
          //   }

// Support CommonJS if it looks like that's how we're rolling.
if( typeof(exports) != 'undefined' ){
    exports.bbop_mme_context = bbop_mme_context;
    exports.bbop_type_to_tcell = bbop_type_to_tcell;
}

<|endoftext|>


<commit_before>/*
function f_play_detalle(hash, imdb, magnet, title, rating, poster, genre, background, api_url, provider, proxy, content_value) {

    var content_key;
    var parameters;

	switch (provider) {
		case "torrentsapi":			protocol = "https://"; endpoint = "api.torrentsapi.com/list?"; 						content_key = ""; 			break;
		case "ytsag": 				protocol = "https://"; endpoint = "yts.ag/api/v2/movie_details.json?";				content_key = "movie_id="; 	parameters = "&with_images=true&with_cast=true";	break;
		case "ytsis": 				protocol = "https://"; endpoint = "yify.is/index.php/api/v2/movie_details.json?";	content_key = "movie_id="; 	parameters = "&with_images=true&with_cast=true";	break;
		case "ytsli": 				protocol = "https://"; endpoint = "yts.li/api/v2/movie_details.json?";				content_key = "movie_id="; 	parameters = "&with_images=true&with_cast=true";	break;
		case "eztv_popcorntimews": 	protocol = "https://"; endpoint = "popcorntime.ws/api/eztv/shows/";					content_key = ""; 			break;
		case "haruhichan": 			protocol = "http://";  endpoint = "ptp.haruhichan.com/list.php?";					content_key = ""; 			break;
		case "popcornwvnbg7jev": 	protocol = "https://"; endpoint = "popcornwvnbg7jev.onion.to/shows/";				content_key = ""; 			break;
		case "animetorrentsapi": 	protocol = "http://";  endpoint = "api.anime.torrentsapi.com/list?";				content_key = ""; 			break;
		case "waifu": 				protocol = "http://";  endpoint = "anime.waifu.ca/tvshows/all?";					content_key = ""; 			break;
		case "apiprivatetorrents": 	protocol = "http://";  endpoint = "api.apiprivatetorrents.com/movies";				content_key = ""; 			break;
		case "ptapitsxaabevfvk": 	protocol = "https://"; endpoint = "ptapitsxaabevfvk.onion.to/shows/";				content_key = ""; 			break;
		case "butter": 				protocol = "http://";  endpoint = "butter.vodo.net/popcorn";						content_key = ""; 			break;
		case "torrentsapishows": 	protocol = "https://"; endpoint = "api.torrentsapi.com/shows?cb=";					content_key = ""; 			break;
	}

	var content = content_key+content_value;

	var details_url = proxy+protocol+endpoint+content+parameters;
	console.log(details_url);
    $.get(details_url, function (data) {
        console.log(data);
        var repeat = function (s, n, d) {
            return --n ? s + (d || "") + repeat(s, n, d) : "" + s;
        };
        movie_rating_star = '';
        movie_rating_star_empty = '';
        movie_rating = Math.round(rating);
        var html = "";

        html += '';

        // html += '';

        // #ToDo: use the screenshots id4.replace("background.jpg", "large-screenshot1.jpg")
        html += '
';
        // html += '';
        html += '
';
        html += '
';
        html += '
'+title+'
';
        html += '
';
        //html += repeat(movie_rating_star, movie_rating)+repeat(movie_rating_star_empty, (10 - movie_rating));
        html += '
';
        html += '
';
        html += '';
        html +=  '('+data.data.movie.year+') ['+data.data.movie.mpa_rating+'] '+data.data.movie.runtime+' min. - '+genre; // '[R] 95 min - Action | Crime | Sci-Fi - 21 Septermber 2012 (USA)';
        html += '';
        html += '
';
        html += '
';
        html += '
';
        html += '';
        html += '
';

        html += '
';
        html += '
';
        html += '
';
        html += '
';

		html += '
';
		html += '
';
		html += '
';
		html += '
';
		html += '
';
		html += '
'+data.data.movie.description_full+'
';
		html += '
';
		html += '
';
		html += '
';
		html += '
';
        html += '';
        html += '
';
		html += '
';
        html += '
'+data.status+'

'+data.status_message+'

'+data.data.movie.id+'

'+data.data.movie.url+'

'+data.data.movie.imdb_code+'

'+data.data.movie.title+'

'+data.data.movie.title_long+'

'+data.data.movie.slug+'

'+data.data.movie.year+'

'+data.data.movie.rating+'

'+data.data.movie.runtime+'

'+data.data.movie.genres[0]+'

'+data.data.movie.language+'

'+data.data.movie.mpa_rating+'

'+data.data.movie.download_count+'

'+data.data.movie.like_count+'

'+data.data.movie.rt_critics_score+'

'+data.data.movie.rt_critics_rating+'

'+data.data.movie.rt_audience_score+'

'+data.data.movie.rt_audience_rating+'

'+data.data.movie.description_intro+'

'+data.data.movie.description_full+'

'+data.data.movie.yt_trailer_code+'

'+data.data.movie.date_uploaded+'

'+data.data.movie.date_uploaded_unix+'

';
        html += data.data.movie.torrents[0].url;
        html += '
';
        html += data.data.movie.torrents[0].hash;
        html += '
';
        html += data.data.movie.torrents[0].quality;
        html += '
';
        html += data.data.movie.torrents[0].resolution;
        html += '
';
        html += data.data.movie.torrents[0].framerate;
        html += '
';
        html += data.data.movie.torrents[0].seeds;
        html += '
';
        html += data.data.movie.torrents[0].peers;
        html += '
';
        html += data.data.movie.torrents[0].size ;
        html += '
';
        html += data.data.movie.torrents[0].size_bytes;
        html += '
';
        html += data.data.movie.torrents[0].download_count;
        html += '
';
        html += data.data.movie.torrents[0].date_uploaded;
        html += '
';
        html += data.data.movie.torrents[0].date_uploaded_unix;
        html += '
';
        html += data.data.movie.torrents[1];
        html += '
';
        html += data.data.movie.torrents[1].url;
        html += '
';
        html += data.data.movie.torrents[1].hash;
        html += '
';
        html += data.data.movie.torrents[1].quality;
        html += '
';
        html += data.data.movie.torrents[1].resolution;
        html += '
';
        html += data.data.movie.torrents[1].framerate;
        html += '
';
        html += data.data.movie.torrents[1].seeds;
        html += '
';
        html += data.data.movie.torrents[1].peers;
        html += '
';
        html += data.data.movie.torrents[1].size;
        html += '
';
        html += data.data.movie.torrents[1].size_bytes;
        html += '
';
        html += data.data.movie.torrents[1].download_count;
        html += '
';
        html += data.data.movie.torrents[1].date_uploaded;
        html += '
';
        html += data.data.movie.torrents[1].date_uploaded_unix;
        html += '
';

        html += '
';
        html += '
';
		html += '
';
		html += '
';

        $("#images_detalle").html(html);
        $("#fullscreen_detail").attr('class','fullscreen_detail_in');
    });
};
*/
<commit_msg>Delete details.js<commit_after><|endoftext|>