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

    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery'], factory);
    }
    else if (typeof exports === 'object') {
        // CommonJS
        factory(require('jquery'));
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function($) {
    'use strict';

    /**
     * Range feature detection
     * @return {Boolean}
     */
    function supportsRange() {
        var input = document.createElement('input');
        input.setAttribute('type', 'range');
        return input.type !== 'text';
    }

    var pluginName = 'rangeslider',
        pluginInstances = [],
        pluginIdentifier = 0,
        inputrange = supportsRange(),
        defaults = {
            polyfill: true,
            rangeClass: 'rangeslider',
            disabledClass: 'rangeslider--disabled',
            fillClass: 'rangeslider__fill',
            handleClass: 'rangeslider__handle',
            startEvent: ['mousedown', 'touchstart', 'pointerdown'],
            moveEvent: ['mousemove', 'touchmove', 'pointermove'],
            endEvent: ['mouseup', 'touchend', 'pointerup']
        };

    /**
     * Delays a function for the given number of milliseconds, and then calls
     * it with the arguments supplied.
     *
     * @param  {Function} fn   [description]
     * @param  {Number}   wait [description]
     * @return {Function}
     */
    function delay(fn, wait) {
        var args = Array.prototype.slice.call(arguments, 2);
        return setTimeout(function(){ return fn.apply(null, args); }, wait);
    }

    /**
     * Returns a debounced function that will make sure the given
     * function is not triggered too much.
     *
     * @param  {Function} fn Function to debounce.
     * @param  {Number}   debounceDuration OPTIONAL. The amount of time in milliseconds for which we will debounce the function. (defaults to 100ms)
     * @return {Function}
     */
    function debounce(fn, debounceDuration) {
        debounceDuration = debounceDuration || 100;
        return function() {
            if (!fn.debouncing) {
                var args = Array.prototype.slice.apply(arguments);
                fn.lastReturnVal = fn.apply(window, args);
                fn.debouncing = true;
            }
            clearTimeout(fn.debounceTimeout);
            fn.debounceTimeout = setTimeout(function(){
                fn.debouncing = false;
            }, debounceDuration);
            return fn.lastReturnVal;
        };
    }

    /**
     * Check if a `element` is visible in the DOM
     *
     * @param  {Element}  element
     * @return {Boolean}
     */
    function isHidden(element) {
        if (element.offsetWidth !== 0 || element.offsetHeight !== 0) {
            return false;
        }
        return true;
    }

    /**
     * Get hidden parentNodes of an `element`
     *
     * @param  {Element} element
     * @return {[type]}
     */
    function getHiddenParentNodes(element) {
        var parents = [],
            node    = element.parentNode;

        while (isHidden(node)) {
            parents.push(node);
            node = node.parentNode;
        }
        return parents;
    }

    /**
     * Returns dimensions for an element even if it is not visible in the DOM.
     *
     * @param  {Element} element
     * @param  {String}  key     (e.g. offsetWidth …)
     * @return {Number}
     */
    function getDimension(element, key) {
        var hiddenParentNodes       = getHiddenParentNodes(element),
            hiddenParentNodesLength = hiddenParentNodes.length,
            displayProperty         = [],
            dimension               = element[key];

        if (hiddenParentNodesLength) {
            for (var i = 0; i < hiddenParentNodesLength; i++) {
                // Cache the display property to restore it later.
                displayProperty[i] = hiddenParentNodes[i].style.display;

                hiddenParentNodes[i].style.display = 'block';
                hiddenParentNodes[i].style.height = '0';
                hiddenParentNodes[i].style.overflow = 'hidden';
                hiddenParentNodes[i].style.visibility = 'hidden';
            }

            dimension = element[key];

            for (var j = 0; j < hiddenParentNodesLength; j++) {
                hiddenParentNodes[j].style.display = displayProperty[j];
                hiddenParentNodes[j].style.height = '';
                hiddenParentNodes[j].style.overflow = '';
                hiddenParentNodes[j].style.visibility = '';
            }
        }
        return dimension;
    }

    /**
     * Plugin
     * @param {String} element
     * @param {Object} options
     */
    function Plugin(element, options) {
        this.$window    = $(window);
        this.$document  = $(document);
        this.$element   = $(element);
        this.options    = $.extend( {}, defaults, options );
        this._defaults  = defaults;
        this._name      = pluginName;
        this.startEvent = this.options.startEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.moveEvent  = this.options.moveEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.endEvent   = this.options.endEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.polyfill   = this.options.polyfill;
        this.onInit     = this.options.onInit;
        this.onSlide    = this.options.onSlide;
        this.onSlideEnd = this.options.onSlideEnd;

        // Plugin should only be used as a polyfill
        if (this.polyfill) {
            // Input range support?
            if (inputrange) { return false; }
        }

        this.identifier = 'js-' + pluginName + '-' +(pluginIdentifier++);
        this.min        = parseFloat(this.$element[0].getAttribute('min') || 0);
        this.max        = parseFloat(this.$element[0].getAttribute('max') || 100);
        this.value      = parseFloat(this.$element[0].value || this.min + (this.max-this.min)/2);
        this.step       = parseFloat(this.$element[0].getAttribute('step') || 1);
        this.$fill      = $('
');
        this.$handle    = $('
');
        this.$range     = $('
').insertAfter(this.$element).prepend(this.$fill, this.$handle);

        // visually hide the input
        this.$element.css({
            'position': 'absolute',
            'width': '1px',
            'height': '1px',
            'overflow': 'hidden',
            'opacity': '0'
        });

        // Store context
        this.handleDown = $.proxy(this.handleDown, this);
        this.handleMove = $.proxy(this.handleMove, this);
        this.handleEnd  = $.proxy(this.handleEnd, this);

        this.init();

        // Attach Events
        var _this = this;
        this.$window.on('resize' + '.' + pluginName, debounce(function() {
            // Simulate resizeEnd event.
            delay(function() { _this.update(); }, 300);
        }, 20));

        this.$document.on(this.startEvent, '#' + this.identifier + ':not(.' + this.options.disabledClass + ')', this.handleDown);

        // Listen to programmatic value changes
        this.$element.on('change' + '.' + pluginName, function(e, data) {
            if (data && data.origin === pluginName) {
                return;
            }

            var value = e.target.value,
                pos = _this.getPositionFromValue(value);
            _this.setPosition(pos);
        });
    }

    Plugin.prototype.init = function() {
        if (this.onInit && typeof this.onInit === 'function') {
            this.onInit();
        }
        this.update();
    };

    Plugin.prototype.update = function() {
        this.handleWidth    = this.$handle[0].offsetWidth;
        this.rangeWidth     = this.$range[0].offsetWidth;
        this.maxHandleX     = this.rangeWidth - this.handleWidth;
        this.grabX          = this.handleWidth / 2;
        this.position       = this.getPositionFromValue(this.value);

        // Consider disabled state
        if (this.$element[0].disabled) {
            this.$range.addClass(this.options.disabledClass);
        } else {
            this.$range.removeClass(this.options.disabledClass);
        }

        this.setPosition(this.position);
    };

    Plugin.prototype.handleDown = function(e) {
        e.preventDefault();
        this.$document.on(this.moveEvent, this.handleMove);
        this.$document.on(this.endEvent, this.handleEnd);

        // If we click on the handle don't set the new position
        if ((' ' + e.target.className + ' ').replace(/[\n\t]/g, ' ').indexOf(this.options.handleClass) > -1) {
            return;
        }

        var posX    = this.getRelativePosition(e),
            rangeX  = this.$range[0].getBoundingClientRect().left,
            handleX = this.getPositionFromNode(this.$handle[0]) - rangeX;

        this.setPosition(posX - this.grabX);

        if (posX >= handleX && posX < handleX + this.handleWidth) {
            this.grabX = posX - handleX;
        }
    };

    Plugin.prototype.handleMove = function(e) {
        e.preventDefault();
        var posX = this.getRelativePosition(e);
        this.setPosition(posX - this.grabX);
    };

    Plugin.prototype.handleEnd = function(e) {
        e.preventDefault();
        this.$document.off(this.moveEvent, this.handleMove);
        this.$document.off(this.endEvent, this.handleEnd);

        if (this.onSlideEnd && typeof this.onSlideEnd === 'function') {
            this.onSlideEnd(this.position, this.value);
        }
    };

    Plugin.prototype.cap = function(pos, min, max) {
        if (pos < min) { return min; }
        if (pos > max) { return max; }
        return pos;
    };

    Plugin.prototype.setPosition = function(pos) {
        var value, left;

        // Snapping steps
        value = (this.getValueFromPosition(this.cap(pos, 0, this.maxHandleX)) / this.step) * this.step;
        left = this.getPositionFromValue(value);

        // Update ui
        this.$fill[0].style.width = (left + this.grabX)  + 'px';
        this.$handle[0].style.left = left + 'px';
        this.setValue(value);

        // Update globals
        this.position = left;
        this.value = value;

        if (this.onSlide && typeof this.onSlide === 'function') {
            this.onSlide(left, value);
        }
    };

    // Returns element position relative to the parent
    Plugin.prototype.getPositionFromNode = function(node) {
        var i = 0;
        while (node !== null) {
            i += node.offsetLeft;
            node = node.offsetParent;
        }
        return i;
    };

    Plugin.prototype.getRelativePosition = function(e) {
        // Get the offset left relative to the viewport
        var rangeX = this.$range[0].getBoundingClientRect().left;
        return (e.pageX || e.originalEvent.clientX || e.originalEvent.touches[0].clientX || e.currentPoint.x) - rangeX;
    };

    Plugin.prototype.getPositionFromValue = function(value) {
        var percentage, pos;
        percentage = (value - this.min)/(this.max - this.min);
        pos = percentage * this.maxHandleX;
        return pos;
    };

    Plugin.prototype.getValueFromPosition = function(pos) {
        var percentage, value;
        percentage = ((pos) / (this.maxHandleX || 1));
        value = this.step * Math.ceil((((percentage) * (this.max - this.min)) + this.min) / this.step);
        return Number((value).toFixed(2));
    };

    Plugin.prototype.setValue = function(value) {
        if (value !== this.value) {
            this.$element.val(value).trigger('change', {origin: pluginName});
        }
    };

    Plugin.prototype.destroy = function() {
        this.$document.off(this.startEvent, '#' + this.identifier, this.handleDown);
        this.$element
            .off('.' + pluginName)
            .removeAttr('style')
            .removeData('plugin_' + pluginName);

        // Remove the generated markup
        if (this.$range && this.$range.length) {
            this.$range[0].parentNode.removeChild(this.$range[0]);
        }

        // Remove global events if there isn't any instance anymore.
        pluginInstances.splice(pluginInstances.indexOf(this.$element[0]),1);
        if (!pluginInstances.length) {
            this.$window.off('.' + pluginName);
        }
    };

    // A really lightweight plugin wrapper around the constructor,
    // preventing against multiple instantiations
    $.fn[pluginName] = function(options) {
        return this.each(function() {
            var $this = $(this),
                data  = $this.data('plugin_' + pluginName);

            // Create a new instance.
            if (!data) {
                $this.data('plugin_' + pluginName, (data = new Plugin(this, options)));
                pluginInstances.push(this);
            }

            // Make it possible to access methods from public.
            // e.g `$element.rangeslider('method');`
            if (typeof options === 'string') {
                data[options]();
            }
        });
    };

}));
<commit_msg>feature: getDimensions for setting handle,range width<commit_after>(function(factory) {
    'use strict';

    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery'], factory);
    }
    else if (typeof exports === 'object') {
        // CommonJS
        factory(require('jquery'));
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function($) {
    'use strict';

    /**
     * Range feature detection
     * @return {Boolean}
     */
    function supportsRange() {
        var input = document.createElement('input');
        input.setAttribute('type', 'range');
        return input.type !== 'text';
    }

    var pluginName = 'rangeslider',
        pluginInstances = [],
        pluginIdentifier = 0,
        inputrange = supportsRange(),
        defaults = {
            polyfill: true,
            rangeClass: 'rangeslider',
            disabledClass: 'rangeslider--disabled',
            fillClass: 'rangeslider__fill',
            handleClass: 'rangeslider__handle',
            startEvent: ['mousedown', 'touchstart', 'pointerdown'],
            moveEvent: ['mousemove', 'touchmove', 'pointermove'],
            endEvent: ['mouseup', 'touchend', 'pointerup']
        };

    /**
     * Delays a function for the given number of milliseconds, and then calls
     * it with the arguments supplied.
     *
     * @param  {Function} fn   [description]
     * @param  {Number}   wait [description]
     * @return {Function}
     */
    function delay(fn, wait) {
        var args = Array.prototype.slice.call(arguments, 2);
        return setTimeout(function(){ return fn.apply(null, args); }, wait);
    }

    /**
     * Returns a debounced function that will make sure the given
     * function is not triggered too much.
     *
     * @param  {Function} fn Function to debounce.
     * @param  {Number}   debounceDuration OPTIONAL. The amount of time in milliseconds for which we will debounce the function. (defaults to 100ms)
     * @return {Function}
     */
    function debounce(fn, debounceDuration) {
        debounceDuration = debounceDuration || 100;
        return function() {
            if (!fn.debouncing) {
                var args = Array.prototype.slice.apply(arguments);
                fn.lastReturnVal = fn.apply(window, args);
                fn.debouncing = true;
            }
            clearTimeout(fn.debounceTimeout);
            fn.debounceTimeout = setTimeout(function(){
                fn.debouncing = false;
            }, debounceDuration);
            return fn.lastReturnVal;
        };
    }

    /**
     * Check if a `element` is visible in the DOM
     *
     * @param  {Element}  element
     * @return {Boolean}
     */
    function isHidden(element) {
        if (element.offsetWidth !== 0 || element.offsetHeight !== 0) {
            return false;
        }
        return true;
    }

    /**
     * Get hidden parentNodes of an `element`
     *
     * @param  {Element} element
     * @return {[type]}
     */
    function getHiddenParentNodes(element) {
        var parents = [],
            node    = element.parentNode;

        while (isHidden(node)) {
            parents.push(node);
            node = node.parentNode;
        }
        return parents;
    }

    /**
     * Returns dimensions for an element even if it is not visible in the DOM.
     *
     * @param  {Element} element
     * @param  {String}  key     (e.g. offsetWidth …)
     * @return {Number}
     */
    function getDimension(element, key) {
        var hiddenParentNodes       = getHiddenParentNodes(element),
            hiddenParentNodesLength = hiddenParentNodes.length,
            displayProperty         = [],
            dimension               = element[key];

        if (hiddenParentNodesLength) {
            for (var i = 0; i < hiddenParentNodesLength; i++) {
                // Cache the display property to restore it later.
                displayProperty[i] = hiddenParentNodes[i].style.display;

                hiddenParentNodes[i].style.display = 'block';
                hiddenParentNodes[i].style.height = '0';
                hiddenParentNodes[i].style.overflow = 'hidden';
                hiddenParentNodes[i].style.visibility = 'hidden';
            }

            dimension = element[key];

            for (var j = 0; j < hiddenParentNodesLength; j++) {
                hiddenParentNodes[j].style.display = displayProperty[j];
                hiddenParentNodes[j].style.height = '';
                hiddenParentNodes[j].style.overflow = '';
                hiddenParentNodes[j].style.visibility = '';
            }
        }
        return dimension;
    }

    /**
     * Plugin
     * @param {String} element
     * @param {Object} options
     */
    function Plugin(element, options) {
        this.$window    = $(window);
        this.$document  = $(document);
        this.$element   = $(element);
        this.options    = $.extend( {}, defaults, options );
        this._defaults  = defaults;
        this._name      = pluginName;
        this.startEvent = this.options.startEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.moveEvent  = this.options.moveEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.endEvent   = this.options.endEvent.join('.' + pluginName + ' ') + '.' + pluginName;
        this.polyfill   = this.options.polyfill;
        this.onInit     = this.options.onInit;
        this.onSlide    = this.options.onSlide;
        this.onSlideEnd = this.options.onSlideEnd;

        // Plugin should only be used as a polyfill
        if (this.polyfill) {
            // Input range support?
            if (inputrange) { return false; }
        }

        this.identifier = 'js-' + pluginName + '-' +(pluginIdentifier++);
        this.min        = parseFloat(this.$element[0].getAttribute('min') || 0);
        this.max        = parseFloat(this.$element[0].getAttribute('max') || 100);
        this.value      = parseFloat(this.$element[0].value || this.min + (this.max-this.min)/2);
        this.step       = parseFloat(this.$element[0].getAttribute('step') || 1);
        this.$fill      = $('
');
        this.$handle    = $('
');
        this.$range     = $('
').insertAfter(this.$element).prepend(this.$fill, this.$handle);

        // visually hide the input
        this.$element.css({
            'position': 'absolute',
            'width': '1px',
            'height': '1px',
            'overflow': 'hidden',
            'opacity': '0'
        });

        // Store context
        this.handleDown = $.proxy(this.handleDown, this);
        this.handleMove = $.proxy(this.handleMove, this);
        this.handleEnd  = $.proxy(this.handleEnd, this);

        this.init();

        // Attach Events
        var _this = this;
        this.$window.on('resize' + '.' + pluginName, debounce(function() {
            // Simulate resizeEnd event.
            delay(function() { _this.update(); }, 300);
        }, 20));

        this.$document.on(this.startEvent, '#' + this.identifier + ':not(.' + this.options.disabledClass + ')', this.handleDown);

        // Listen to programmatic value changes
        this.$element.on('change' + '.' + pluginName, function(e, data) {
            if (data && data.origin === pluginName) {
                return;
            }

            var value = e.target.value,
                pos = _this.getPositionFromValue(value);
            _this.setPosition(pos);
        });
    }

    Plugin.prototype.init = function() {
        if (this.onInit && typeof this.onInit === 'function') {
            this.onInit();
        }
        this.update();
    };

    Plugin.prototype.update = function() {
        this.handleWidth    = getDimension(this.$handle[0], 'offsetWidth');
        this.rangeWidth     = getDimension(this.$range[0], 'offsetWidth');
        this.maxHandleX     = this.rangeWidth - this.handleWidth;
        this.grabX          = this.handleWidth / 2;
        this.position       = this.getPositionFromValue(this.value);

        // Consider disabled state
        if (this.$element[0].disabled) {
            this.$range.addClass(this.options.disabledClass);
        } else {
            this.$range.removeClass(this.options.disabledClass);
        }

        this.setPosition(this.position);
    };

    Plugin.prototype.handleDown = function(e) {
        e.preventDefault();
        this.$document.on(this.moveEvent, this.handleMove);
        this.$document.on(this.endEvent, this.handleEnd);

        // If we click on the handle don't set the new position
        if ((' ' + e.target.className + ' ').replace(/[\n\t]/g, ' ').indexOf(this.options.handleClass) > -1) {
            return;
        }

        var posX    = this.getRelativePosition(e),
            rangeX  = this.$range[0].getBoundingClientRect().left,
            handleX = this.getPositionFromNode(this.$handle[0]) - rangeX;

        this.setPosition(posX - this.grabX);

        if (posX >= handleX && posX < handleX + this.handleWidth) {
            this.grabX = posX - handleX;
        }
    };

    Plugin.prototype.handleMove = function(e) {
        e.preventDefault();
        var posX = this.getRelativePosition(e);
        this.setPosition(posX - this.grabX);
    };

    Plugin.prototype.handleEnd = function(e) {
        e.preventDefault();
        this.$document.off(this.moveEvent, this.handleMove);
        this.$document.off(this.endEvent, this.handleEnd);

        if (this.onSlideEnd && typeof this.onSlideEnd === 'function') {
            this.onSlideEnd(this.position, this.value);
        }
    };

    Plugin.prototype.cap = function(pos, min, max) {
        if (pos < min) { return min; }
        if (pos > max) { return max; }
        return pos;
    };

    Plugin.prototype.setPosition = function(pos) {
        var value, left;

        // Snapping steps
        value = (this.getValueFromPosition(this.cap(pos, 0, this.maxHandleX)) / this.step) * this.step;
        left = this.getPositionFromValue(value);

        // Update ui
        this.$fill[0].style.width = (left + this.grabX)  + 'px';
        this.$handle[0].style.left = left + 'px';
        this.setValue(value);

        // Update globals
        this.position = left;
        this.value = value;

        if (this.onSlide && typeof this.onSlide === 'function') {
            this.onSlide(left, value);
        }
    };

    // Returns element position relative to the parent
    Plugin.prototype.getPositionFromNode = function(node) {
        var i = 0;
        while (node !== null) {
            i += node.offsetLeft;
            node = node.offsetParent;
        }
        return i;
    };

    Plugin.prototype.getRelativePosition = function(e) {
        // Get the offset left relative to the viewport
        var rangeX = this.$range[0].getBoundingClientRect().left;
        return (e.pageX || e.originalEvent.clientX || e.originalEvent.touches[0].clientX || e.currentPoint.x) - rangeX;
    };

    Plugin.prototype.getPositionFromValue = function(value) {
        var percentage, pos;
        percentage = (value - this.min)/(this.max - this.min);
        pos = percentage * this.maxHandleX;
        return pos;
    };

    Plugin.prototype.getValueFromPosition = function(pos) {
        var percentage, value;
        percentage = ((pos) / (this.maxHandleX || 1));
        value = this.step * Math.ceil((((percentage) * (this.max - this.min)) + this.min) / this.step);
        return Number((value).toFixed(2));
    };

    Plugin.prototype.setValue = function(value) {
        if (value !== this.value) {
            this.$element.val(value).trigger('change', {origin: pluginName});
        }
    };

    Plugin.prototype.destroy = function() {
        this.$document.off(this.startEvent, '#' + this.identifier, this.handleDown);
        this.$element
            .off('.' + pluginName)
            .removeAttr('style')
            .removeData('plugin_' + pluginName);

        // Remove the generated markup
        if (this.$range && this.$range.length) {
            this.$range[0].parentNode.removeChild(this.$range[0]);
        }

        // Remove global events if there isn't any instance anymore.
        pluginInstances.splice(pluginInstances.indexOf(this.$element[0]),1);
        if (!pluginInstances.length) {
            this.$window.off('.' + pluginName);
        }
    };

    // A really lightweight plugin wrapper around the constructor,
    // preventing against multiple instantiations
    $.fn[pluginName] = function(options) {
        return this.each(function() {
            var $this = $(this),
                data  = $this.data('plugin_' + pluginName);

            // Create a new instance.
            if (!data) {
                $this.data('plugin_' + pluginName, (data = new Plugin(this, options)));
                pluginInstances.push(this);
            }

            // Make it possible to access methods from public.
            // e.g `$element.rangeslider('method');`
            if (typeof options === 'string') {
                data[options]();
            }
        });
    };

}));
<|endoftext|>


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

    angular.module('chaise.record', [
        'ngSanitize',
        'chaise.errors',
        'chaise.modal',
        'chaise.navbar',
        'chaise.record.display',
        'chaise.record.table',
        'chaise.html',
        'chaise.utils',
        'ermrestjs',
        'ui.bootstrap'
    ])

    // The page info object passed to the table directive
    .factory('pageInfo', [function() {
        return {
            loading: true,
            previousButtonDisabled: true,
            nextButtonDisabled: true,
            pageLimit: 25
        };
    }])

    .run(['DataUtils', 'headInjector', 'ERMrest', 'UriUtils', 'ErrorService', 'pageInfo', '$log', '$rootScope', '$window', function runApp(DataUtils, headInjector, ERMrest, UriUtils, ErrorService, pageInfo, $log, $rootScope, $window) {
        var context = {};
        $rootScope.pageInfo = pageInfo;
        UriUtils.setOrigin();
        headInjector.addTitle();
        headInjector.addCustomCSS();

        try {
            var ermrestUri = UriUtils.chaiseURItoErmrestURI($window.location);

            context = $rootScope.context = UriUtils.parseURLFragment($window.location, context);

            // The context object won't change unless the app is reloaded
            context.appName = "record";

            if (context.filter) {
                ERMrest.resolve(ermrestUri, {cid: context.appName}).then(function getReference(reference) {
                    // $rootScope.reference != reference after contextualization
                    $rootScope.reference = reference.contextualize.detailed;
                    $rootScope.reference.session = $rootScope.session;

                    $log.info("Reference: ", $rootScope.reference);

                    $rootScope.relatedReferences = $rootScope.reference.related;
                    // There should only ever be one entity related to this reference
                    return $rootScope.reference.read(1);
                }).then(function getPage(page) {
                    var tuple = page.tuples[0];
                    // Used directly in the record-display directive
                    $rootScope.recordDisplayname = tuple.displayname;

                    // Collate tuple.isHTML and tuple.values into an array of objects
                    // i.e. {isHTML: false, value: 'sample'}
                    $rootScope.recordValues = [];
                    tuple.values.forEach(function(value, index) {
                        $rootScope.recordValues.push({
                            isHTML: tuple.isHTML[index],
                            value: value
                        });
                    });

                    $rootScope.columns = $rootScope.reference.columns;

                    $rootScope.tableModels = [];

                    for (var i = 0; i < $rootScope.relatedReferences.length; i++) {
                        $rootScope.relatedReferences[i] = $rootScope.relatedReferences[i].contextualize.compactBrief;

                        if ($rootScope.relatedReferences[i].display.defaultPageSize) {
                            pageInfo.pageLimit = $rootScope.relatedReferences[i].display.defaultPageSize;
                        }
                        (function(i) {
                            $rootScope.relatedReferences[i].read(pageInfo.pageLimit).then(function (page) {

                                var model = {
                                    reference: $rootScope.relatedReferences[i],
                                    columns: $rootScope.relatedReferences[i].columns,
                                    page: page,
                                    hasNext: page.hasNext,      // used to determine if a link should be shown
                                    hasLoaded: true,            // used to determine if the current table and next table should be rendered
                                    open: true,                 // to define if the accordion is open or closed
                                    sortby: null,               // column name, user selected or null
                                    sortOrder: null,            // asc (default) or desc
                                    rowValues: []               // array of rows values
                                };
                                model.rowValues = DataUtils.getRowValuesFromPage(page);
                                $rootScope.tableModels[i] = model;
                            });
                        })(i);
                    }

                }, function error(response) {
                    $log.warn(response);
                    throw response;
                }).catch(function genericCatch(exception) {
                    ErrorService.catchAll(exception);
                });
            // No filter defined, redirect to search
            } else {
                // change the path and redirect to search because no id was supplied
                var modifiedPath = $window.location.pathname.replace(context.appName, "search");
                // If default catalog/table are not defined, ...chaiseURItoErmrestURI would have caught that error
                var catalogId = (context.catalogID ? context.catalogID : chaiseConfig.defaultCatalog);
                if (chaiseConfig.defaultTables) {
                    var tableConfig = chaiseConfig.defaultTables[catalogId];
                }
                var schemaTableName = ( (context.schemaName && context.tableName) ? context.schemaName + ':' + context.tableName : tableConfig.schema + ':' + tableConfig.table );
                var modifiedHash = '#' + catalogId + '/' + schemaTableName;

                var message = "No filter was defined. Cannot find a record without a filter.";
                var redirectLink = $window.location.origin + modifiedPath + modifiedHash;
                ErrorService.errorPopup(message, '', "search page", redirectLink);
            }
        // no catalog or schema:table defined, no defaults either, redirect to home page
        } catch (exception) {
            ErrorService.errorPopup(exception.message, exception.code, "home page");
        }
    }]);
})();
<commit_msg>Added jquery document ready handler for recordset app<commit_after>$(function() {
    'use strict';

    angular.module('chaise.record', [
        'ngSanitize',
        'chaise.errors',
        'chaise.modal',
        'chaise.navbar',
        'chaise.record.display',
        'chaise.record.table',
        'chaise.html',
        'chaise.utils',
        'ermrestjs',
        'ui.bootstrap'
    ])

    // The page info object passed to the table directive
    .factory('pageInfo', [function() {
        return {
            loading: true,
            previousButtonDisabled: true,
            nextButtonDisabled: true,
            pageLimit: 25
        };
    }])

    .run(['DataUtils', 'headInjector', 'ERMrest', 'UriUtils', 'ErrorService', 'pageInfo', '$log', '$rootScope', '$window', function runApp(DataUtils, headInjector, ERMrest, UriUtils, ErrorService, pageInfo, $log, $rootScope, $window) {
        var context = {};
        $rootScope.pageInfo = pageInfo;
        UriUtils.setOrigin();
        headInjector.addTitle();
        headInjector.addCustomCSS();

        try {
            var ermrestUri = UriUtils.chaiseURItoErmrestURI($window.location);

            context = $rootScope.context = UriUtils.parseURLFragment($window.location, context);

            // The context object won't change unless the app is reloaded
            context.appName = "record";

            if (context.filter) {
                ERMrest.resolve(ermrestUri, {cid: context.appName}).then(function getReference(reference) {
                    // $rootScope.reference != reference after contextualization
                    $rootScope.reference = reference.contextualize.detailed;
                    $rootScope.reference.session = $rootScope.session;

                    $log.info("Reference: ", $rootScope.reference);

                    $rootScope.relatedReferences = $rootScope.reference.related;
                    // There should only ever be one entity related to this reference
                    return $rootScope.reference.read(1);
                }).then(function getPage(page) {
                    var tuple = page.tuples[0];
                    // Used directly in the record-display directive
                    $rootScope.recordDisplayname = tuple.displayname;

                    // Collate tuple.isHTML and tuple.values into an array of objects
                    // i.e. {isHTML: false, value: 'sample'}
                    $rootScope.recordValues = [];
                    tuple.values.forEach(function(value, index) {
                        $rootScope.recordValues.push({
                            isHTML: tuple.isHTML[index],
                            value: value
                        });
                    });

                    $rootScope.columns = $rootScope.reference.columns;

                    $rootScope.tableModels = [];

                    for (var i = 0; i < $rootScope.relatedReferences.length; i++) {
                        $rootScope.relatedReferences[i] = $rootScope.relatedReferences[i].contextualize.compactBrief;

                        if ($rootScope.relatedReferences[i].display.defaultPageSize) {
                            pageInfo.pageLimit = $rootScope.relatedReferences[i].display.defaultPageSize;
                        }
                        (function(i) {
                            $rootScope.relatedReferences[i].read(pageInfo.pageLimit).then(function (page) {

                                var model = {
                                    reference: $rootScope.relatedReferences[i],
                                    columns: $rootScope.relatedReferences[i].columns,
                                    page: page,
                                    hasNext: page.hasNext,      // used to determine if a link should be shown
                                    hasLoaded: true,            // used to determine if the current table and next table should be rendered
                                    open: true,                 // to define if the accordion is open or closed
                                    sortby: null,               // column name, user selected or null
                                    sortOrder: null,            // asc (default) or desc
                                    rowValues: []               // array of rows values
                                };
                                model.rowValues = DataUtils.getRowValuesFromPage(page);
                                $rootScope.tableModels[i] = model;
                            });
                        })(i);
                    }

                }, function error(response) {
                    $log.warn(response);
                    throw response;
                }).catch(function genericCatch(exception) {
                    ErrorService.catchAll(exception);
                });
            // No filter defined, redirect to search
            } else {
                // change the path and redirect to search because no id was supplied
                var modifiedPath = $window.location.pathname.replace(context.appName, "search");
                // If default catalog/table are not defined, ...chaiseURItoErmrestURI would have caught that error
                var catalogId = (context.catalogID ? context.catalogID : chaiseConfig.defaultCatalog);
                if (chaiseConfig.defaultTables) {
                    var tableConfig = chaiseConfig.defaultTables[catalogId];
                }
                var schemaTableName = ( (context.schemaName && context.tableName) ? context.schemaName + ':' + context.tableName : tableConfig.schema + ':' + tableConfig.table );
                var modifiedHash = '#' + catalogId + '/' + schemaTableName;

                var message = "No filter was defined. Cannot find a record without a filter.";
                var redirectLink = $window.location.origin + modifiedPath + modifiedHash;
                ErrorService.errorPopup(message, '', "search page", redirectLink);
            }
        // no catalog or schema:table defined, no defaults either, redirect to home page
        } catch (exception) {
            ErrorService.errorPopup(exception.message, exception.code, "home page");
        }
    }]);
});
<|endoftext|>


<commit_before>import {colors} from "../color.js";
import {polyline} from "./primitives/polyline.js";
import {isArray, isObject} from "../util.js";
import {isContinuousScale, isDiscreteScale} from "../scales/index.js";
import {getExpressionSources} from "../runtime/expression.js";
import {getValueSources} from "../runtime/value.js";
import {createHashMap} from "../hashmap.js";
import {ticks as generateTicks} from "../math.js";

import {getPanelsLayout} from "./panels.js";

//Available position values
let positionValues = ["top", "bottom", "left", "right"];

//Axis default props
let defaultProps = {
    "line": true,
    "lineColor": "black",
    "lineWidth": "1px",
    "lineOpacity": 1,
    //Labels default attributes
    "label": true,
    "labelColor": "black",
    "labelSize": "11px",
    "labelOpacity": 0.8,
    "labelPadding": 5,
    "labelRotation": 0,
    "labelBaseline": "middle", //hanging|middle|baseline
    "labelAnchor": "middle",   //start|middle|center
    //Default ticks attributes
    "ticks": false,
    "tickCount": 0,
    "tickValues": [],
    "tickColor": "black",
    "tickSize": "11px",
    "tickOpacity": 0.8,
    "tickOffset": 5,
    "tickRotation": 0,
    "tickFormat": null,
    "tickBaseline": "middle",   //hanging|middle|baseline
    "tickAnchor": "middle",     //start|middle|end
    "tickInterval": 0.5,        //Tick interval for interval scales
    "slot": true,    //Display a line indication the tick position
    "slotColor": "black",
    "slotOpacity": 1,
    "slotWidth": "1px",
    //Default grid attributes
    "grid": false,
    "gridColor": "black",
    "gridOpacity": 1,
    "gridWidth": "1px"
};

//Interpolate scale values
let generateValues = function (scale, count) {
    //Check for continuous scale
    if (isContinuousScale(scale) === true) {
        //Get the range values
        let start = Math.min.apply(null, scale.domain); //Get start value
        let end = Math.max.apply(null, scale.domain); //Get end value
        //Return ticks values
        return generateTicks(start, end, count).filter(function (value) {
            return start <= value && value <= end;
        });
    }
    //Check for discrete scale
    else if (isDiscreteScale(scale) === true) {
        return scale.domain;
    }
    //Other scale type: error and return an empty values array
    //TODO
    return [];
};

//Get the display value
//let getDisplayValue = function (context, props, value) {
//    if (typeof props.tickFormat === "string") {
//        return context.expression(props.tickFormat.expr, {
//            "value": value
//        });
//    }
//    //Return the default value
//    return value;
//};

//Get position
let getPosition = function (value) {
    return value.toLowerCase();
};

//Create an axis node
export function createAxisNode (context, index, props) {
    let node = context.addNode({
        "id": `axis:${index}`,
        "props": props, //Object.assign({}, defaultProps, props),
        "type": "axis",
        "targets": null, //createNodeList(),
        "parent": []
    });
    //Add sources fo this axis
    context.panels.targets.add(node.id, node); //Always ad the panels node
    if (typeof node.props.scale === "string") {
        context.scales[node.props.scale].targets.add(node.id, node);
    }
    //Axis position can be extracted from sources
    getValueSources(context, node.props.position).forEach(function (source) {
        source.targets.add(node.id, node);
    });
    //Check if tickformat is a string --> evaluate as an expression
    if (typeof node.props.tickFormat === "strong") {
        getExpressionSources(context, node.props.tickFormat).forEach(function (source) {
            source.targets.add(node.id, node);
        });
    }
    //Render this axis
    //return updateAxis(context, node);
}

//Export axis drawing
export function updateAxisNode (context, node) {
    //let target = node.parent; //parent.append("g");
    let props = node.props; //Object.assign({}, defaultProps, node.props);
    let draw = context.current.draw; //Get current drawing values
    let scale = context.scales[props.scale].value;
    //Axis positions and size
    let axisSize = Math.abs(scale.range[1] - scale.range[0]); //Axis size
    //let axisStart = scale.range[0];
    //let axisEnd = scale.range[1];
    //Axis position
    //let position = context.value(props.position, 0, 0); //defaultProps.position);
    //Get the axis type
    let position = getPosition(props.position);
    let hasAxisLine = context.value(props.line, null, defaultProps.line); //Display axis line
    let isXAxis = position === "top" || position === "bottom";
    let hasAxisTicks = context.value(props.ticks, null, defaultProps.ticks); //Display ticks
    let hasAxisGrid = context.value(props.grid, null, defaultProps.grid); //Display axis grid
    let ticksValues = []; //Values to display
    if (hasAxisTicks === true) {
        if (isArray(props.tickValues) === true) {
            ticksValues = props.ticksValues.map(function (value) {
                return context.value(value, 0, 0);
            });
        }
        else if (isObject(props.tickValues)) {
            tickValues = context.value(props.tickValues, [], []); //Get values from context
        }
        else {
            //Generate values from counts
            ticksValues = generateValues(scale, context.value(props.tickCount, 0, defaultProps.tickCount));
        }
    }
    //Get panels where this axis will be rendered
    getPanelsLayout(context, props.panel).forEach(function (panelItem) {
        let panel = panelItem.panel; //Get panel layout
        let element = panelItem.element; //Get panel element
        context.current.panel = panelItem.panel; //Save current panel
        //Check if there is a group for this axis
        let target = element.selectAll(`g[data-axis='${node.id}']`);
        if (target.length === 0) {
            target = element.append("g").attr("data-axis", node.id); //Create a new axis
        }
        //Remove old children
        target.empty();
        //Calculate the axis positions
        let axisPosition = {};
        //Check for top|bottom axis
        if (isXAxis === true) {
            axisPosition = {
                "x1": 0 + Math.min(scale.range[0], scale.range[1]),
                "x2": 0 + Math.max(scale.range[0], scale.range[1]),
                "y1": (position === "top") ? 0 : panel.height, //draw.height,
                "y2": (position === "top") ? 0 : panel.height, //draw.height
            };
        }
        else {
            axisPosition = {
                "x1": (position === "left") ? 0 : panel.width, //draw.width,
                "x2": (position === "left") ? 0 : panel.width, //draw.width,
                "y1": 0 + Math.min(scale.range[0], scale.range[1]),
                "y2": 0 + Math.max(scale.range[0], scale.range[1])
            };
        }
        //console.log(axisPosition);
        //Display ticks
        //if (props.ticks === true) { // && (typeof props.tickCount === "number" || viz.isArray(props.tickValues))) {
        if (context.value(props.ticks, null, defaultProps.ticks) === true) {
            let angle = context.value(props.tickRotation, null, defaultProps.tickRotation); //Get rotation angle
            let tickOffset = context.value(props.tickOffset, 0, defaultProps.tickOffset); //Get ticks offset
            let tickSlot = context.value(props.slot, null, defaultProps.slot); //Display tick slot
            let tickInterval = (scale.type === "interval") ? context.value(props.tickInterval, null, defaultProps.tickInterval) : 0;
            //Display each label value
            ticksValues.forEach(function (value, index) {
                //Calculate the label positions
                let valuePosition = scale(value, index);
                //console.log(value + " --> " + valuePosition);
                //Check for null value --> not valid label
                if (valuePosition === null || typeof valuePosition === "undefined") {
                    return false;
                }
                //Check for interval scale
                if (scale.type === "interval") {//if (typeof props.scale.step === "number") {
                    valuePosition = valuePosition + scale.step * tickInterval;
                }
                //let labelX = (isXAxis) ? position : props.x - props.labelMargin;
                //let labelY = (props.type === "y") ? position : props.y + props.labelMargin;
                let tickX = 0, tickY = 0; //, tickAnchor = "middle", tickBaseline = "middle";
                let slotLine = null;
                let gridLine = null;
                //let labelAnchor = (props.position === "left") ? "end" : "start";
                //Calculate the label positions
                if (position === "left" || position === "right") {
                    tickX = axisPosition.x1 + (((position === "left") ? -1 : +1) * tickOffset);
                    tickY = valuePosition + 0; //props.y + props.height - position;
                    //Check for displaying the tick slot
                    if (tickSlot === true && hasAxisLine === true) {
                        let px2 = axisPosition.x1 + (((position === "left") ? -1 : +1) * tickOffset / 3);
                        slotLine = target.append("path");
                        slotLine.attr("d", polyline({
                            "points": [
                                [axisPosition.x1, tickY],
                                [px2, tickY]
                            ],
                            "closed": false
                        }));
                    }
                    //Check for displaying the grid line
                    if (hasAxisGrid === true) {
                        gridLine = target.append("path");
                        gridLine.attr("d", polyline({
                            //"points": [[0, tickY], [draw.width, tickY]],
                            "points": [[0, tickY], [panel.width, tickY]],
                            "closed": false
                        }));
                    }
                }
                else {
                    tickX = valuePosition + 0;
                    tickY = axisPosition.y1 + (((position === "top") ? -1 : +1) * tickOffset);
                    //Check for displaying the tick slot
                    //if (props.tickSlot === true && props.line === true) {
                    if (tickSlot === true && hasAxisLine === true) {
                        let py2 = axisPosition.y1 + (((position === "top") ? -1 : +1) * tickOffset / 3);
                        slotLine = target.append("path");
                        slotLine.attr("d", polyline({
                            "points": [
                                [tickX, axisPosition.y1],
                                [tickX, py2]
                            ],
                            "closed": false
                        }));
                    }
                    //Check for displaying the grid line
                    if (hasAxisGrid === true) {
                        gridLine = target.append("path");
                        gridLine.attr("d", polyline({
                            //"points": [[tickX, 0], [tickX, draw.height]],
                            "points": [[tickX, 0], [tickX, panel.height]],
                            "closed": false
                        }));
                    }
                }
                //Check for slot line --> set slot style
                if (slotLine !== null) {
                    slotLine.attr("fill", "none");
                    slotLine.attr("stroke-width", context.value(props.slotWidth, null, defaultProps.slotWidth)); //Default slot width
                    slotLine.attr("stroke", context.value(props.slotColor, null, context.theme.axesSlotColor));
                    slotLine.style("opacity", context.value(props.slotOpacity, 0, defaultProps.slotOpacity));
                }
                //Check for grid line --> set grid line
                if (gridLine !== null) {
                    gridLine.attr("fill", "none");
                    gridLine.attr("stroke-width", context.value(props.gridWidth, null, defaultProps.gridWidth));
                    gridLine.attr("stroke", context.value(props.gridColor, null, context.theme.axesGridColor));
                    gridLine.style("opacity", context.value(props.gridOpacity, 0, defaultProps.gridOpacity));
                }
                //Display the text element
                let text = target.append("text");
                text.text(context.value(props.tickFormat, value, value));
                text.attr("x", tickX);
                text.attr("y", tickY);
                text.attr("text-anchor", context.value(props.tickAnchor, null, defaultProps.tickAnchor));
                text.attr("alignment-baseline", context.value(props.tickBaseline, null, defaultProps.tickBaseline));
                text.attr("transform", `rotate(${angle}, ${tickX}, ${tickY})`);
                //Tick text style
                text.attr("fill", context.value(props.tickColor, null, context.theme.axesTickColor));
                text.style("font-weight", "bold"); //Default font-weight
                text.style("font-size", context.value(props.tickSize, null, defaultProps.tickSize));
                text.style("opacity", context.value(props.tickOpacity, null, defaultProps.tickOpacity));
            });
        }
        //Display the axis edge
        //if (context.value(props.line, null, defaultProps.line) === true) {
        if (hasAxisLine === true) {
            let line = target.append("path");
            line.attr("fill", "none"); //Prevent errors
            line.attr("stroke", context.value(props.lineColor, null, context.theme.axesLineColor));
            line.attr("stroke-width", context.value(props.lineWidth, null, defaultProps.lineWidth));
            line.style("opacity", context.value(props.lineOpacity, null, defaultProps.lineOpacity));
            line.attr("d", polyline({
                "points": [
                    [axisPosition.x1, axisPosition.y1],
                    [axisPosition.x2, axisPosition.y2]
                ],
                "closed": false
            }));
        }
    });
    //Done drawing the axis
    //return target;
    context.current.panel = null; //Reset current panel
}

<commit_msg>render: prevent rendering axes related to an undefined or not valid scale<commit_after>import {colors} from "../color.js";
import {polyline} from "./primitives/polyline.js";
import {isArray, isObject, span} from "../util.js";
import {isContinuousScale, isDiscreteScale} from "../scales/index.js";
import {getExpressionSources} from "../runtime/expression.js";
import {getValueSources} from "../runtime/value.js";
import {createHashMap} from "../hashmap.js";
import {ticks as generateTicks} from "../math.js";

import {getPanelsLayout} from "./panels.js";

//Available position values
let positionValues = ["top", "bottom", "left", "right"];

//Axis default props
let defaultProps = {
    "line": true,
    "lineColor": "black",
    "lineWidth": "1px",
    "lineOpacity": 1,
    //Labels default attributes
    "label": true,
    "labelColor": "black",
    "labelSize": "11px",
    "labelOpacity": 0.8,
    "labelPadding": 5,
    "labelRotation": 0,
    "labelBaseline": "middle", //hanging|middle|baseline
    "labelAnchor": "middle",   //start|middle|center
    //Default ticks attributes
    "ticks": false,
    "tickCount": 0,
    "tickValues": [],
    "tickColor": "black",
    "tickSize": "11px",
    "tickOpacity": 0.8,
    "tickOffset": 5,
    "tickRotation": 0,
    "tickFormat": null,
    "tickBaseline": "middle",   //hanging|middle|baseline
    "tickAnchor": "middle",     //start|middle|end
    "tickInterval": 0.5,        //Tick interval for interval scales
    "slot": true,    //Display a line indication the tick position
    "slotColor": "black",
    "slotOpacity": 1,
    "slotWidth": "1px",
    //Default grid attributes
    "grid": false,
    "gridColor": "black",
    "gridOpacity": 1,
    "gridWidth": "1px"
};

//Interpolate scale values
let generateValues = function (scale, count) {
    //Check for continuous scale
    if (isContinuousScale(scale) === true) {
        //Get the range values
        let start = Math.min.apply(null, scale.domain); //Get start value
        let end = Math.max.apply(null, scale.domain); //Get end value
        //Return ticks values
        return generateTicks(start, end, count).filter(function (value) {
            return start <= value && value <= end;
        });
    }
    //Check for discrete scale
    else if (isDiscreteScale(scale) === true) {
        return scale.domain;
    }
    //Other scale type: error and return an empty values array
    //TODO
    return [];
};

//Get the display value
//let getDisplayValue = function (context, props, value) {
//    if (typeof props.tickFormat === "string") {
//        return context.expression(props.tickFormat.expr, {
//            "value": value
//        });
//    }
//    //Return the default value
//    return value;
//};

//Get position
let getPosition = function (value) {
    return value.toLowerCase();
};

//Create an axis node
export function createAxisNode (context, index, props) {
    let node = context.addNode({
        "id": `axis:${index}`,
        "props": props, //Object.assign({}, defaultProps, props),
        "type": "axis",
        "targets": null, //createNodeList(),
        "parent": []
    });
    //Add sources fo this axis
    context.panels.targets.add(node.id, node); //Always ad the panels node
    if (typeof node.props.scale === "string") {
        context.scales[node.props.scale].targets.add(node.id, node);
    }
    //Axis position can be extracted from sources
    getValueSources(context, node.props.position).forEach(function (source) {
        source.targets.add(node.id, node);
    });
    //Check if tickformat is a string --> evaluate as an expression
    if (typeof node.props.tickFormat === "strong") {
        getExpressionSources(context, node.props.tickFormat).forEach(function (source) {
            source.targets.add(node.id, node);
        });
    }
    //Render this axis
    //return updateAxis(context, node);
}

//Export axis drawing
export function updateAxisNode (context, node) {
    //let target = node.parent; //parent.append("g");
    let props = node.props; //Object.assign({}, defaultProps, node.props);
    let draw = context.current.draw; //Get current drawing values
    let scale = context.scales[props.scale].value;
    //Check for empty scale (no domain provided)
    if (scale === null || scale.domain === null || scale.domain.length < 2 || span(scale.domain) === 0) {
        context.target.selectAll(`g[data-axis='${node.id}']`).empty(); //Clear all axes related to this node
        return null; //Ignore this axis
    }
    //Axis positions and size
    let axisSize = Math.abs(scale.range[1] - scale.range[0]); //Axis size
    //let axisStart = scale.range[0];
    //let axisEnd = scale.range[1];
    //Axis position
    //let position = context.value(props.position, 0, 0); //defaultProps.position);
    //Get the axis type
    let position = getPosition(props.position);
    let hasAxisLine = context.value(props.line, null, defaultProps.line); //Display axis line
    let isXAxis = position === "top" || position === "bottom";
    let hasAxisTicks = context.value(props.ticks, null, defaultProps.ticks); //Display ticks
    let hasAxisGrid = context.value(props.grid, null, defaultProps.grid); //Display axis grid
    let ticksValues = []; //Values to display
    if (hasAxisTicks === true) {
        if (isArray(props.tickValues) === true) {
            ticksValues = props.ticksValues.map(function (value) {
                return context.value(value, 0, 0);
            });
        }
        else if (isObject(props.tickValues)) {
            tickValues = context.value(props.tickValues, [], []); //Get values from context
        }
        else {
            //Generate values from counts
            ticksValues = generateValues(scale, context.value(props.tickCount, 0, defaultProps.tickCount));
        }
    }
    //Get panels where this axis will be rendered
    getPanelsLayout(context, props.panel).forEach(function (panelItem) {
        let panel = panelItem.panel; //Get panel layout
        let element = panelItem.element; //Get panel element
        context.current.panel = panelItem.panel; //Save current panel
        //Check if there is a group for this axis
        let target = element.selectAll(`g[data-axis='${node.id}']`);
        if (target.length === 0) {
            target = element.append("g").attr("data-axis", node.id); //Create a new axis
        }
        //Remove old children
        target.empty();
        //Calculate the axis positions
        let axisPosition = {};
        //Check for top|bottom axis
        if (isXAxis === true) {
            axisPosition = {
                "x1": 0 + Math.min(scale.range[0], scale.range[1]),
                "x2": 0 + Math.max(scale.range[0], scale.range[1]),
                "y1": (position === "top") ? 0 : panel.height, //draw.height,
                "y2": (position === "top") ? 0 : panel.height, //draw.height
            };
        }
        else {
            axisPosition = {
                "x1": (position === "left") ? 0 : panel.width, //draw.width,
                "x2": (position === "left") ? 0 : panel.width, //draw.width,
                "y1": 0 + Math.min(scale.range[0], scale.range[1]),
                "y2": 0 + Math.max(scale.range[0], scale.range[1])
            };
        }
        //console.log(axisPosition);
        //Display ticks
        //if (props.ticks === true) { // && (typeof props.tickCount === "number" || viz.isArray(props.tickValues))) {
        if (context.value(props.ticks, null, defaultProps.ticks) === true) {
            let angle = context.value(props.tickRotation, null, defaultProps.tickRotation); //Get rotation angle
            let tickOffset = context.value(props.tickOffset, 0, defaultProps.tickOffset); //Get ticks offset
            let tickSlot = context.value(props.slot, null, defaultProps.slot); //Display tick slot
            let tickInterval = (scale.type === "interval") ? context.value(props.tickInterval, null, defaultProps.tickInterval) : 0;
            //Display each label value
            ticksValues.forEach(function (value, index) {
                //Calculate the label positions
                let valuePosition = scale(value, index);
                //console.log(value + " --> " + valuePosition);
                //Check for null value --> not valid label
                if (valuePosition === null || typeof valuePosition === "undefined") {
                    return false;
                }
                //Check for interval scale
                if (scale.type === "interval") {//if (typeof props.scale.step === "number") {
                    valuePosition = valuePosition + scale.step * tickInterval;
                }
                //let labelX = (isXAxis) ? position : props.x - props.labelMargin;
                //let labelY = (props.type === "y") ? position : props.y + props.labelMargin;
                let tickX = 0, tickY = 0; //, tickAnchor = "middle", tickBaseline = "middle";
                let slotLine = null;
                let gridLine = null;
                //let labelAnchor = (props.position === "left") ? "end" : "start";
                //Calculate the label positions
                if (position === "left" || position === "right") {
                    tickX = axisPosition.x1 + (((position === "left") ? -1 : +1) * tickOffset);
                    tickY = valuePosition + 0; //props.y + props.height - position;
                    //Check for displaying the tick slot
                    if (tickSlot === true && hasAxisLine === true) {
                        let px2 = axisPosition.x1 + (((position === "left") ? -1 : +1) * tickOffset / 3);
                        slotLine = target.append("path");
                        slotLine.attr("d", polyline({
                            "points": [
                                [axisPosition.x1, tickY],
                                [px2, tickY]
                            ],
                            "closed": false
                        }));
                    }
                    //Check for displaying the grid line
                    if (hasAxisGrid === true) {
                        gridLine = target.append("path");
                        gridLine.attr("d", polyline({
                            //"points": [[0, tickY], [draw.width, tickY]],
                            "points": [[0, tickY], [panel.width, tickY]],
                            "closed": false
                        }));
                    }
                }
                else {
                    tickX = valuePosition + 0;
                    tickY = axisPosition.y1 + (((position === "top") ? -1 : +1) * tickOffset);
                    //Check for displaying the tick slot
                    //if (props.tickSlot === true && props.line === true) {
                    if (tickSlot === true && hasAxisLine === true) {
                        let py2 = axisPosition.y1 + (((position === "top") ? -1 : +1) * tickOffset / 3);
                        slotLine = target.append("path");
                        slotLine.attr("d", polyline({
                            "points": [
                                [tickX, axisPosition.y1],
                                [tickX, py2]
                            ],
                            "closed": false
                        }));
                    }
                    //Check for displaying the grid line
                    if (hasAxisGrid === true) {
                        gridLine = target.append("path");
                        gridLine.attr("d", polyline({
                            //"points": [[tickX, 0], [tickX, draw.height]],
                            "points": [[tickX, 0], [tickX, panel.height]],
                            "closed": false
                        }));
                    }
                }
                //Check for slot line --> set slot style
                if (slotLine !== null) {
                    slotLine.attr("fill", "none");
                    slotLine.attr("stroke-width", context.value(props.slotWidth, null, defaultProps.slotWidth)); //Default slot width
                    slotLine.attr("stroke", context.value(props.slotColor, null, context.theme.axesSlotColor));
                    slotLine.style("opacity", context.value(props.slotOpacity, 0, defaultProps.slotOpacity));
                }
                //Check for grid line --> set grid line
                if (gridLine !== null) {
                    gridLine.attr("fill", "none");
                    gridLine.attr("stroke-width", context.value(props.gridWidth, null, defaultProps.gridWidth));
                    gridLine.attr("stroke", context.value(props.gridColor, null, context.theme.axesGridColor));
                    gridLine.style("opacity", context.value(props.gridOpacity, 0, defaultProps.gridOpacity));
                }
                //Display the text element
                let text = target.append("text");
                text.text(context.value(props.tickFormat, value, value));
                text.attr("x", tickX);
                text.attr("y", tickY);
                text.attr("text-anchor", context.value(props.tickAnchor, null, defaultProps.tickAnchor));
                text.attr("alignment-baseline", context.value(props.tickBaseline, null, defaultProps.tickBaseline));
                text.attr("transform", `rotate(${angle}, ${tickX}, ${tickY})`);
                //Tick text style
                text.attr("fill", context.value(props.tickColor, null, context.theme.axesTickColor));
                text.style("font-weight", "bold"); //Default font-weight
                text.style("font-size", context.value(props.tickSize, null, defaultProps.tickSize));
                text.style("opacity", context.value(props.tickOpacity, null, defaultProps.tickOpacity));
            });
        }
        //Display the axis edge
        //if (context.value(props.line, null, defaultProps.line) === true) {
        if (hasAxisLine === true) {
            let line = target.append("path");
            line.attr("fill", "none"); //Prevent errors
            line.attr("stroke", context.value(props.lineColor, null, context.theme.axesLineColor));
            line.attr("stroke-width", context.value(props.lineWidth, null, defaultProps.lineWidth));
            line.style("opacity", context.value(props.lineOpacity, null, defaultProps.lineOpacity));
            line.attr("d", polyline({
                "points": [
                    [axisPosition.x1, axisPosition.y1],
                    [axisPosition.x2, axisPosition.y2]
                ],
                "closed": false
            }));
        }
    });
    //Done drawing the axis
    //return target;
    context.current.panel = null; //Reset current panel
}

<|endoftext|>


<commit_before>if (App.namespace) {
	App.namespace('Action.Changecolor', function (App) {
		/** @type {App.Module.DataStore} */

		(function (OC, window, $, undefined) {
			'use strict';

			$(document).ready(function () {

				var Usercolors = function (baseUrl) {
					this._baseUrl = baseUrl;
					this._usercolors = [];
					this._activeUsercolor = undefined;
				};

				Usercolors.prototype = {
					getAll: function () {
						return this._usercolors;
					},
					loadAll: function () {
						var deferred = $.Deferred();
						var self = this;
						$.get(this._baseUrl).done(function (usercolors) {
							self._activeUsercolor = undefined;
							self._usercolors = usercolors;
							deferred.resolve();
						}).fail(function () {
							deferred.reject();
						});
						return deferred.promise();
					},
				};

				$('#sidebar_tab_3').click(function () {
					if ($('#userlist').length == 0) {
						var DataStore = App.Module.DataStore;
						var fragment = document.createDocumentFragment();
						var groupsusers = DataStore.get('groupsusers');
						var deprecatedUsers = ['collab_user'];
						var _table = document.createElement('table');
						_table.innerHTML += '

Group-/ Username	Color

';
						_table.innerHTML += '

';
						_table.id = 'userlist';
						_table.width = '100%';
						var _tableRef = _table.getElementsByTagName('tbody')[0];

						for (var groupName in groupsusers) {
							var _lineGroup = document.createElement('div'),
								_lineUsers = document.createElement('div'),
								_inputGroup = document.createElement('input'),
								_inputLabel = document.createElement('label'),
								_inputSpan = document.createElement('span'),
								users = groupsusers[groupName],
								usersCount = users.length;
							_inputGroup.name = String(groupName).trim();
							_inputGroup.type = 'checkbox';
							_inputGroup.className = 'group';
							_inputGroup.setAttribute('data-type', 'group');
							_lineGroup.appendChild(_inputGroup);
							_inputLabel.appendChild(_inputSpan);
							_lineGroup.appendChild(_inputLabel);
							_inputGroup.id = 'group' + groupName;
							_inputLabel.setAttribute('for', 'group' + groupName);
							_inputLabel.innerHTML += ' ' + Util.ucfirst(groupName) + '';
							var rowCount = _tableRef.rows.length;
							var row = _tableRef.insertRow(rowCount);
							var colorId = 'col_g_' + groupName;
							row.insertCell(0).innerHTML = '' + Util.ucfirst(groupName) + '';
							row.insertCell(1).innerHTML = '<input type="text" id="' + colorId + '" />';

							for (var i = 0; i < usersCount; i++) {
								if (deprecatedUsers.indexOf(users[i]['uid']) !== -1) continue;
								var _inlineUser = document.createElement('span'),
									_inputUser = document.createElement('input'),
									_inputUserLabel = document.createElement('label'),
									_inputUserSpan = document.createElement('span');
								_inputUser.name = users[i]['uid'];
								_inputUser.type = 'checkbox';
								_inputUser.className = 'user';
								_inputUser.setAttribute('data-type', 'user');
								_inputUser.setAttribute('data-gid', users[i]['gid']);
								_inputUser.id = 'u_' + users[i]['uid'];
								_inputUserLabel.setAttribute('for', 'u_' + users[i]['uid']);
								_inputUserLabel.appendChild(_inputUserSpan);
								_inputUserLabel.innerHTML += users[i]['uid'];
								_inlineUser.appendChild(_inputUser);
								_inlineUser.appendChild(_inputUserLabel);
								_lineUsers.appendChild(_inlineUser);
								var rowCount = _tableRef.rows.length;
								var row = _tableRef.insertRow(rowCount);
								var uid = users[i]['uid'];
								var colorId = 'col_u_' + uid;
								row.insertCell(0).innerHTML = uid;
								row.insertCell(1).innerHTML = '<input type="text" id="' + colorId + '" />';
							}
							$('#chart_coloring').append(_table);
						}
					}

					$.fn.renderColors = function() {
						for (var groupName in groupsusers) {
							var users = groupsusers[groupName],
								usersCount = users.length;

							$("#col_g_" + groupName).spectrum({
								color: "rgb(244, 204, 204)",
								showPaletteOnly: true,
								palette: [
									["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
										"rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"],
									["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
										"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
									["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
										"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
										"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
										"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
										"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
										"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
										"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
										"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
										"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
										"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
								]
							});

							for (var i = 0; i < usersCount; i++) {
								if (deprecatedUsers.indexOf(users[i]['uid']) !== -1) continue;
								var uid = users[i]['uid'];
								var cindex = usercolors._usercolors.indexOf(uid);
								console.log(cindex);
								$("#col_u_" + uid).spectrum({
									color: "rgb(244, 204, 204)",
									showPaletteOnly: true,
									palette: [
										["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
											"rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"],
										["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
											"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
										["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
											"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
											"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
											"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
											"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
											"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
											"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
											"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
											"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
											"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
									]
								});
							}
						}
					});
			}

				var baseUrl = OC.generateUrl('apps/owncollab_chart');
			var usercolor = {
				user: 'new user',
				colorcode: 'rgb(255, 255, 255)'
			};

			var usercolors = new Usercolors(OC.generateUrl('/apps/owncollab_chart/colors'));
			usercolors.loadAll().done(function () {
				renderColors();
				$.each(usercolors._usercolors, function (i, data) {
					console.log('username: ' + data.user + ' color: ' + data.colorcode);
				});
			}).fail(function () {
				alert('Could not load usercolors');
			});
			//				console.log(baseUrl);
			//				$.getJSON(baseUrl + '/colors', function(result){
			//					var items="";
			//					$.each(result, function(i, data){
			//						console.log('uid:' + data.user + ' color:' + data.colorcode)
			//					});
			//				});

		});
	})(OC, window, jQuery);
})
}
<commit_msg>Revert "added missing ="<commit_after>if (App.namespace) {
	App.namespace('Action.Changecolor', function (App) {
		/** @type {App.Module.DataStore} */

		(function (OC, window, $, undefined) {
			'use strict';

			$(document).ready(function () {

				var Usercolors = function (baseUrl) {
					this._baseUrl = baseUrl;
					this._usercolors = [];
					this._activeUsercolor = undefined;
				};

				Usercolors.prototype = {
					getAll: function () {
						return this._usercolors;
					},
					loadAll: function () {
						var deferred = $.Deferred();
						var self = this;
						$.get(this._baseUrl).done(function (usercolors) {
							self._activeUsercolor = undefined;
							self._usercolors = usercolors;
							deferred.resolve();
						}).fail(function () {
							deferred.reject();
						});
						return deferred.promise();
					},
				};

				$('#sidebar_tab_3').click(function () {
					if ($('#userlist').length == 0) {
						var DataStore = App.Module.DataStore;
						var fragment = document.createDocumentFragment();
						var groupsusers = DataStore.get('groupsusers');
						var deprecatedUsers = ['collab_user'];
						var _table = document.createElement('table');
						_table.innerHTML += '

Group-/ Username	Color

';
						_table.innerHTML += '

';
						_table.id = 'userlist';
						_table.width = '100%';
						var _tableRef = _table.getElementsByTagName('tbody')[0];

						for (var groupName in groupsusers) {
							var _lineGroup = document.createElement('div'),
								_lineUsers = document.createElement('div'),
								_inputGroup = document.createElement('input'),
								_inputLabel = document.createElement('label'),
								_inputSpan = document.createElement('span'),
								users = groupsusers[groupName],
								usersCount = users.length;
							_inputGroup.name = String(groupName).trim();
							_inputGroup.type = 'checkbox';
							_inputGroup.className = 'group';
							_inputGroup.setAttribute('data-type', 'group');
							_lineGroup.appendChild(_inputGroup);
							_inputLabel.appendChild(_inputSpan);
							_lineGroup.appendChild(_inputLabel);
							_inputGroup.id = 'group' + groupName;
							_inputLabel.setAttribute('for', 'group' + groupName);
							_inputLabel.innerHTML += ' ' + Util.ucfirst(groupName) + '';
							var rowCount = _tableRef.rows.length;
							var row = _tableRef.insertRow(rowCount);
							var colorId = 'col_g_' + groupName;
							row.insertCell(0).innerHTML = '' + Util.ucfirst(groupName) + '';
							row.insertCell(1).innerHTML = '<input type="text" id="' + colorId + '" />';

							for (var i = 0; i < usersCount; i++) {
								if (deprecatedUsers.indexOf(users[i]['uid']) !== -1) continue;
								var _inlineUser = document.createElement('span'),
									_inputUser = document.createElement('input'),
									_inputUserLabel = document.createElement('label'),
									_inputUserSpan = document.createElement('span');
								_inputUser.name = users[i]['uid'];
								_inputUser.type = 'checkbox';
								_inputUser.className = 'user';
								_inputUser.setAttribute('data-type', 'user');
								_inputUser.setAttribute('data-gid', users[i]['gid']);
								_inputUser.id = 'u_' + users[i]['uid'];
								_inputUserLabel.setAttribute('for', 'u_' + users[i]['uid']);
								_inputUserLabel.appendChild(_inputUserSpan);
								_inputUserLabel.innerHTML += users[i]['uid'];
								_inlineUser.appendChild(_inputUser);
								_inlineUser.appendChild(_inputUserLabel);
								_lineUsers.appendChild(_inlineUser);
								var rowCount = _tableRef.rows.length;
								var row = _tableRef.insertRow(rowCount);
								var uid = users[i]['uid'];
								var colorId = 'col_u_' + uid;
								row.insertCell(0).innerHTML = uid;
								row.insertCell(1).innerHTML = '<input type="text" id="' + colorId + '" />';
							}
							$('#chart_coloring').append(_table);
						}
					}

					$.fn.renderColors function() {
						for (var groupName in groupsusers) {
							var users = groupsusers[groupName],
								usersCount = users.length;

							$("#col_g_" + groupName).spectrum({
								color: "rgb(244, 204, 204)",
								showPaletteOnly: true,
								palette: [
									["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
										"rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"],
									["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
										"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
									["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
										"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
										"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
										"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
										"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
										"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
										"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
										"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
										"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
										"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
								]
							});

							for (var i = 0; i < usersCount; i++) {
								if (deprecatedUsers.indexOf(users[i]['uid']) !== -1) continue;
								var uid = users[i]['uid'];
								var cindex = usercolors._usercolors.indexOf(uid);
								console.log(cindex);
								$("#col_u_" + uid).spectrum({
									color: "rgb(244, 204, 204)",
									showPaletteOnly: true,
									palette: [
										["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
											"rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"],
										["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
											"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
										["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
											"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
											"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
											"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
											"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
											"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
											"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
											"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
											"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
											"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
									]
								});
							}
						}
					});
			}

				var baseUrl = OC.generateUrl('apps/owncollab_chart');
			var usercolor = {
				user: 'new user',
				colorcode: 'rgb(255, 255, 255)'
			};

			var usercolors = new Usercolors(OC.generateUrl('/apps/owncollab_chart/colors'));
			usercolors.loadAll().done(function () {
				renderColors();
				$.each(usercolors._usercolors, function (i, data) {
					console.log('username: ' + data.user + ' color: ' + data.colorcode);
				});
			}).fail(function () {
				alert('Could not load usercolors');
			});
			//				console.log(baseUrl);
			//				$.getJSON(baseUrl + '/colors', function(result){
			//					var items="";
			//					$.each(result, function(i, data){
			//						console.log('uid:' + data.user + ' color:' + data.colorcode)
			//					});
			//				});

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