text:
    /**
    * o------------------------------------------------------------------------------o
    * | This file is part of the RGraph package - you can learn more at:             |
    * |                                                                              |
    * |                          http://www.rgraph.net                               |
    * |                                                                              |
    * | This package is licensed under the RGraph license. For all kinds of business |
    * | purposes there is a small one-time licensing fee to pay and for non          |
    * | commercial  purposes it is free to use. You can read the full license here:  |
    * |                                                                              |
    * |                      http://www.rgraph.net/license                           |
    * o------------------------------------------------------------------------------o
    */

    if (typeof(RGraph) == 'undefined') RGraph = {};

    /**
    * The constructor
    *
    * @param object id    The canvas tag ID
    * @param array  min   The minimum value
    * @param array  max   The maximum value
    * @param array  value The indicated value
    */
    RGraph.CornerGauge = function (id, min, max, value)
    {
        // Get the canvas and context objects
        this.id                = id;
        this.canvas            = document.getElementById(id);
        this.context           = this.canvas.getContext ? this.canvas.getContext("2d") : null;
        this.canvas.__object__ = this;
        this.type              = 'cornergauge';
        this.min               = min;
        this.max               = max;
        this.value             = value;
        this.angles            = {};
        this.angles.needle     = [];
        this.centerpin         = {};
        this.isRGraph          = true;
        this.currentValue      = null;
        this.uid               = RGraph.CreateUID();
        this.canvas.uid        = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();

        /**
        * Range checking
        */
        if (typeof(this.value) == 'object') {
            for (var i=0; i<this.value.length; ++i) {
                if (this.value[i] > this.max) this.value[i] = max;
                if (this.value[i] < this.min) this.value[i] = min;
            }
        } else {
            if (this.value > this.max) this.value = max;
            if (this.value < this.min) this.value = min;
        }

        /**
        * Compatibility with older browsers
        */
        RGraph.OldBrowserCompat(this.context);

        // Various config type stuff
        this.properties = {
                            'chart.centerx':        null,
                            'chart.centery':        null,
                            'chart.radius':         null,
                            'chart.gutter.left':    25,
                            'chart.gutter.right':   25,
                            'chart.gutter.top':     25,
                            'chart.gutter.bottom':  25,
                            'chart.strokestyle':    'black',
                            'chart.linewidth':      2,
                            'chart.title':          '',
                            'chart.title.vpos':     0.5,
                            'chart.title.size':     null,
                            'chart.title.x':        null,
                            'chart.title.y':        null,
                            'chart.title.bold':     true,
                            'chart.text.font':      'Arial',
                            'chart.text.color':     '#666',
                            'chart.text.size':      10,
                            'chart.background.gradient.color1': '#ddd',
                            'chart.background.gradient.color2': 'white',
                            'chart.shadow':           true,
                            'chart.shadow.color':     'gray',
                            'chart.shadow.offsetx':   0,
                            'chart.shadow.offsety':   0,
                            'chart.shadow.blur':      15,
                            'chart.scale.decimals': 0,
                            'chart.scale.point':    '.',
                            'chart.scale.thousand': ',',
                            'chart.units.pre':      '',
                            'chart.units.post':     '',
                            'chart.resizable':       false,
                            'chart.chart.resize.handle.background':       null,
                            'chart.adjustable':       false,
                            'chart.annotatable':      false,
                            'chart.annotate.color':       'black',
                            'chart.colors.ranges':    null,
                            'chart.red.start':        min + (0.9 * (this.max - min)),
                            'chart.green.end':        min + (0.7 * (this.max - min)),
                            'chart.red.color':        'red',
                            'chart.yellow.color':     'yellow',
                            'chart.green.color':      '#0f0',
                            'chart.value.text':       true,
                            'chart.value.text.units.pre':  '',
                            'chart.value.text.units.post': '',
                            'chart.value.text.boxed': true,
                            'chart.value.text.font': 'Arial',
                            'chart.value.text.size': null,
                            'chart.value.text.bold': false,
                            'chart.value.text.decimals': 0,
                            'chart.centerpin.stroke':  'rgba(0,0,0,0)',
                            'chart.centerpin.fill':    null, // Set in the DrawCenterpin function
                            'chart.centerpin.color':    'blue',
                            'chart.needle.colors':   ['#ccc', '#D5604D', 'red', 'green', 'yellow'],
                            'chart.zoom.factor':            1.5,
                            'chart.zoom.fade.in':           true,
                            'chart.zoom.fade.out':          true,
                            'chart.zoom.hdir':              'right',
                            'chart.zoom.vdir':              'down',
                            'chart.zoom.frames':            25,
                            'chart.zoom.delay':             16.666,
                            'chart.zoom.shadow':            true,
                            'chart.zoom.background':        true
        }

        /**
        * Register the object
        */
        RGraph.Register(this);
    }

    /**
    * An all encompassing accessor
    *
    * @param string name The name of the property
    * @param mixed value The value of the property
    */
    RGraph.CornerGauge.prototype.Set = function (name, value)
    {
        name = name.toLowerCase();

        /**
        * This should be done first - prepend the property name with "chart." if necessary
        */
        if (name.substr(0,6) != 'chart.') {
            name = 'chart.' + name;
        }

        this.properties[name] = value;
    }

    /**
    * An all encompassing accessor
    *
    * @param string name The name of the property
    */
    RGraph.CornerGauge.prototype.Get = function (name)
    {
        /**
        * This should be done first - prepend the property name with "chart." if necessary
        */
        if (name.substr(0,6) != 'chart.') {
            name = 'chart.' + name;
        }

        return this.properties[name];
    }

    /**
    * The function you call to draw the line chart
    */
    RGraph.CornerGauge.prototype.Draw = function ()
    {
        /**
        * Fire the onbeforedraw event
        */
        RGraph.FireCustomEvent(this, 'onbeforedraw');

        /**
        * Store the value (for animation primarily
        */
        this.currentValue = this.value;

        this.gutterLeft   = this.properties['chart.gutter.left'];
        this.gutterRight  = this.properties['chart.gutter.right'];
        this.gutterTop    = this.properties['chart.gutter.top'];
        this.gutterBottom = this.properties['chart.gutter.bottom'];

        /**
        * Work out the radius first
        */
        this.radius  = Math.min(
                                ((this.canvas.width - this.gutterLeft - this.gutterRight)),
                                ((this.canvas.height - this.gutterTop - this.gutterBottom))
                               );

        if (typeof(this.properties['chart.radius']) == 'number')  this.radius  = this.properties['chart.radius'];

        /**
        * Now use the radius in working out the centerX/Y
        */
        this.centerx = (this.canvas.width / 2) - (this.radius / 2) + Math.max(30, this.radius * 0.1);
        this.centery = (this.canvas.height / 2) + (this.radius / 2) - (this.radius * 0.1);

        if (typeof(this.properties['chart.centerx']) == 'number') this.centerx = this.properties['chart.centerx'];
        if (typeof(this.properties['chart.centery']) == 'number') this.centery = this.properties['chart.centery'];

        /**
        * Parse the colors for gradients. Its down here so that the center X/Y can be used
        */
        if (!this.colorsParsed) {

            this.parseColors();

            // Don't want to do this again
            this.colorsParsed = true;
        }

        /**
        * Start with the background
        */
        this.DrawBackGround();

        /**
        * Draw the tickmarks
        */
        this.DrawTickmarks();

        /**
        * Draw the color bands
        */
        this.DrawColorBands();

        /**
        * Draw the label/value in text
        */
        this.DrawLabel();

        /**
        * Start with the labels/scale
        */
        this.DrawLabels();

        /**
        * Draw the needle(s)
        */
        if (typeof(this.value) == 'object') {

            for (var i=0; i<this.value.length; ++i) {
                this.DrawNeedle(
                                i,
                                this.value[i],
                                this.radius - 65
                               );
            }
        } else {
            this.DrawNeedle(0, this.value, this.radius - 65);
        }

        /**
        * Draw the centerpin of the needle
        */
        this.DrawCenterpin();

        /**
        * Draw the title
        */
        var size = this.properties['chart.title.size'] ? this.properties['chart.title.size'] : this.Get('chart.text.size') + 2
        this.properties['chart.title.y'] = this.centery + 20 - this.radius - ((1.5 * size) / 2);
        RGraph.DrawTitle(this,
                         this.properties['chart.title'],
                         this.guttertop,
                         this.centerx + (this.radius / 2),
                         size);

        /**
        * Setup the context menu if required
        */
        if (this.properties['chart.contextmenu']) {
            RGraph.ShowContext(this);
        }

        /**
        * This function enables resizing
        */
        if (this.properties['chart.resizable']) {
            RGraph.AllowResizing(this);
        }

        /**
        * This installs the event listeners
        */
        RGraph.InstallEventListeners(this);

        /**
        * Fire the RGraph ondraw event
        */
        RGraph.FireCustomEvent(this, 'ondraw');
    }

    /**
    * Draw the background
    */
    RGraph.CornerGauge.prototype.DrawBackGround = function ()
    {
        if (this.properties['chart.shadow']) {
            RGraph.SetShadow(this, this.properties['chart.shadow.color'], this.properties['chart.shadow.offsetx'], this.properties['chart.shadow.offsety'], this.properties['chart.shadow.blur']);
        }

        this.context.strokeStyle = this.properties['chart.strokestyle'];
        this.context.lineWidth   = this.properties['chart.linewidth'] ? this.properties['chart.linewidth'] : 0.0001;

        /**
        * Draw the corner circle first
        */
        this.context.beginPath();
            this.context.arc(this.centerx,this.centery,30,0,TWOPI,false);
        this.context.stroke();

        /**
        * Draw the quarter circle background
        */
        this.context.beginPath();
            this.context.moveTo(this.centerx - 20, this.centery + 20);
            this.context.arc(this.centerx - 20,this.centery + 20,this.radius,PI + HALFPI,TWOPI,false);
        this.context.closePath();
        this.context.fill();
        this.context.stroke();

        // ==================================================================================================================== //

        RGraph.NoShadow(this);

        this.context.strokeStyle = this.properties['chart.strokestyle'];
        this.context.lineWidth   = this.properties['chart.linewidth'] ? this.properties['chart.linewidth'] : 0.0001;

        /**
        * Draw the quarter circle background
        */
        this.context.beginPath();
            this.context.moveTo(this.centerx - 20, this.centery + 20);
            this.context.arc(this.centerx - 20,this.centery + 20,this.radius,PI + HALFPI,TWOPI,false);
        this.context.closePath();
        this.context.stroke();

        // ==================================================================================================================== //

        /**
        * Draw the background background again but with no shadow on
        */
        RGraph.NoShadow(this);

        this.context.lineWidth = 0;
        this.context.fillStyle = RGraph.RadialGradient(this, this.centerx,this.centery, 0,
                                                             this.centerx, this.centery, this.radius * 0.5,
                                                             this.properties['chart.background.gradient.color1'],
                                                             this.properties['chart.background.gradient.color2']);

        // Go over the bulge again in the gradient
        this.context.beginPath();
            this.context.moveTo(this.centerx, this.centery);
            this.context.arc(this.centerx,this.centery,30,0,TWOPI,0);
        this.context.closePath();
        this.context.fill();

        // Go over the main part of the gauge with just the fill
        this.context.beginPath();
            this.context.moveTo(this.centerx - 20, this.centery + 20);
            this.context.lineTo(this.centerx - 20, this.centery + 20 - this.radius);
            this.context.arc(this.centerx - 20,this.centery + 20,this.radius,PI + HALFPI,TWOPI,false);
        this.context.closePath();
        this.context.fill();

        // Draw the gray background lines.
        this.context.beginPath();
            this.context.lineWidth = 1;
            this.context.strokeStyle = '#eee';
            for (var i=0; i<=5; ++i) {
                var p1 = RGraph.getRadiusEndPoint(this.centerx, this.centery, (HALFPI / 5 * i) + PI + HALFPI, 30);
                var p2 = RGraph.getRadiusEndPoint(this.centerx, this.centery, (HALFPI / 5 * i) + PI + HALFPI, this.radius - 90);

                this.context.moveTo(p1[0], p1[1]);
                this.context.lineTo(p2[0], p2[1]);
            }

        this.context.stroke();
    }

    /**
    * Draw the needle
    */
    RGraph.CornerGauge.prototype.DrawNeedle = function (index, value, radius)
    {
        var grad = RGraph.RadialGradient(this, this.centerx, this.centery, 0,
                                               this.centerx, this.centery, 20,
                                               'rgba(0,0,0,0)', this.properties['chart.needle.colors'][index])

        this.angles.needle[index] = (((value - this.min) / (this.max - this.min)) * HALFPI) + PI + HALFPI;
        this.context.lineWidth    = 1
        this.context.strokeStyle  = 'rgba(0,0,0,0)';
        this.context.fillStyle    = grad;

        this.context.beginPath();

            this.context.moveTo(this.centerx, this.centery);

            this.context.arc(this.centerx,
                             this.centery,
                             10,
                             this.angles.needle[index] - HALFPI,
                             this.angles.needle[index] - HALFPI + 0.000001,
                             false);

            this.context.arc(this.centerx,
                             this.centery,
                             radius - 30,
                             this.angles.needle[index],
                             this.angles.needle[index] + 0.000001,
                             false);

            this.context.arc(this.centerx,
                             this.centery,
                             10,
                             this.angles.needle[index] + HALFPI,
                             this.angles.needle[index] + HALFPI + 0.000001,
                             false);

        this.context.stroke();
        this.context.fill();

    }

    /**
    * Draw the centerpin for the needle
    */
    RGraph.CornerGauge.prototype.DrawCenterpin = function ()
    {

        if (!this.properties['chart.centerpin.fill']) {
            this.properties['chart.centerpin.fill'] = RGraph.RadialGradient(this, this.centerx + 5,
                                                                                this.centery - 5,
                                                                                0,
                                                                                this.centerx + 5,
                                                                                this.centery - 5,
                                                                                20,
                                                                                'white',
                                                                                this.properties['chart.centerpin.color'])
        }

        this.context.strokeStyle = this.properties['chart.centerpin.stroke'];
        this.context.fillStyle   = this.properties['chart.centerpin.fill'];

        this.context.beginPath();
            this.context.lineWidth = 2;
            this.context.arc(this.centerx,this.centery, 15,0,TWOPI,false);
        this.context.stroke();
        this.context.fill();
    }

    /**
    * Drawthe labels
    */
    RGraph.CornerGauge.prototype.DrawLabels = function ()
    {
        var numLabels = 5;

        this.context.fillStyle = this.properties['chart.text.color'];

        for (var i=0; i<numLabels; ++i) {
            this.context.beginPath();

                var num  = Number(this.min + ((this.max - this.min) * (i / (numLabels - 1)))).toFixed(this.properties['chart.scale.decimals']);
                    num = RGraph.number_format(this, num, this.properties['chart.units.pre'], this.properties['chart.units.post']);
                var angle = (i * 22.5) / (180 / PI);

                RGraph.Text(this.context,
                            this.properties['chart.text.font'],
                            this.properties['chart.text.size'],
                            this.centerx + Math.sin(angle) * (this.radius - 53),
                            this.centery - Math.cos(angle) * (this.radius - 53),
                            String(num),
                            'top',
                            'center',
                            null,
                            90 * (i / (numLabels - 1)));
            this.context.fill();
        }
    }

    /**
    * Drawthe tickmarks
    */
    RGraph.CornerGauge.prototype.DrawTickmarks = function ()
    {
        var bigTicks   = 5;
        var smallTicks = 25;

        /**
        * Draw the smaller tickmarks
        */
        for (var i=0; i<smallTicks; ++i) {
            this.context.beginPath();
            var angle = (HALFPI / (smallTicks - 1)) * i
            this.context.lineWidth = 1;

            this.context.arc(this.centerx,
                             this.centery,
                             this.radius - 44,
                             PI + HALFPI + angle,
                             PI + HALFPI + angle + 0.0001,
                             false);
            this.context.arc(this.centerx,
                             this.centery,
                             this.radius - 46,
                             PI + HALFPI + angle,
                             PI + HALFPI + angle + 0.0001,
                             false);
            this.context.stroke();
        }

        /**
        * Now draw the larger tickmarks
        */
        for (var i=0; i<bigTicks; ++i) {
            this.context.beginPath();
            var angle = (HALFPI / (bigTicks - 1)) * i
            this.context.lineWidth = 1;
            this.context.arc(this.centerx,
                             this.centery,
                             this.radius - 43,
                             PI + HALFPI + angle,
                             PI + HALFPI + angle + 0.0001,
                             false);
            this.context.arc(this.centerx,
                             this.centery,
                             this.radius - 47,
                             PI + HALFPI + angle,
                             PI + HALFPI + angle + 0.0001,
                             false);
            this.context.stroke();
        }
    }

    /**
    * This draws the green background to the tickmarks
    */
    RGraph.CornerGauge.prototype.DrawColorBands = function ()
    {
        if (RGraph.is_array(this.Get('chart.colors.ranges'))) {

            var ranges = this.Get('chart.colors.ranges');

            for (var i=0; i<ranges.length; ++i) {

                this.context.fillStyle = ranges[i][2];
                this.context.lineWidth = 0;

                this.context.beginPath();
                    this.context.arc(this.centerx,
                                     this.centery,
                                     this.radius - 54 - (this.Get('chart.text.size') * 1.5),
                                     (((ranges[i][0] - this.min) / (this.max - this.min)) * HALFPI) + (PI + HALFPI),
                                     (((ranges[i][1] - this.min) / (this.max - this.min)) * HALFPI) + (PI + HALFPI),
                                     false);

                    this.context.arc(this.centerx,
                                     this.centery,
                                     this.radius - 54 - 10 - (this.Get('chart.text.size') * 1.5),
                                     (((ranges[i][1] - this.min) / (this.max - this.min)) * HALFPI) + (PI + HALFPI),
                                     (((ranges[i][0] - this.min) / (this.max - this.min)) * HALFPI) + (PI + HALFPI),
                                     true);
                this.context.closePath();
                this.context.fill();
            }

            return;
        }

        /**
        * Draw the GREEN region
        */
        this.context.strokeStyle = this.Get('chart.green.color');
        this.context.fillStyle = this.Get('chart.green.color');

        var greenStart = PI + HALFPI;
        var greenEnd   = greenStart + (TWOPI - greenStart) * ((this.Get('chart.green.end') - this.min) / (this.max - this.min))

        this.context.beginPath();
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5), greenStart, greenEnd, false);
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5) - 10, greenEnd, greenStart, true);
        this.context.fill();

        /**
        * Draw the YELLOW region
        */
        this.context.strokeStyle = this.Get('chart.yellow.color');
        this.context.fillStyle = this.Get('chart.yellow.color');

        var yellowStart = greenEnd;
        var yellowEnd   = (((this.Get('chart.red.start') - this.min) / (this.max - this.min)) * HALFPI) + PI + HALFPI;

        this.context.beginPath();
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5), yellowStart, yellowEnd, false);
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5) - 10, yellowEnd, yellowStart, true);
        this.context.fill();

        /**
        * Draw the RED region
        */
        this.context.strokeStyle = this.Get('chart.red.color');
        this.context.fillStyle = this.Get('chart.red.color');

        var redStart = yellowEnd;
        var redEnd   = TWOPI;

        this.context.beginPath();
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5), redStart, redEnd, false);
            this.context.arc(this.centerx, this.centery, this.radius - 54 - (this.Get('chart.text.size') * 1.5) - 10, redEnd, redStart, true);
        this.context.fill();
    }

    /**
    * Draw the value in text
    */
    RGraph.CornerGauge.prototype.DrawLabel = function ()
    {
        if (this.properties['chart.value.text']) {

            this.context.strokeStyle = this.properties['chart.text.color'];
            this.context.fillStyle   = this.properties['chart.text.color'];

            var value = typeof(this.value) == 'number' ? this.value.toFixed(this.properties['chart.value.text.decimals']) : this.value;

            if (typeof(value) == 'object') {
                for (var i=0; i<value.length; ++i) {
                    value[i] = Number(value[i]).toFixed(this.properties['chart.value.text.decimals']);
                }

                value = value.toString();
            }

            RGraph.Text(this.context,
                        this.properties['chart.value.text.font'],
                        typeof(this.properties['chart.value.text.size']) == 'number' ? this.properties['chart.value.text.size'] : this.properties['chart.text.size'],
                        this.centerx + (Math.cos((PI / 180) * 45) * (this.radius / 3)),
                        this.centery - (Math.sin((PI / 180) * 45) * (this.radius / 3)),
                        RGraph.number_format(this, String(value), this.properties['chart.value.text.units.pre'], this.properties['chart.value.text.units.post']),
                        'center',
                        'center',
                        this.properties['chart.value.text.boxed'] ? true : false,
                        null,
                        null,
                        this.properties['chart.value.text.bold'],
                        false);
        }
    }

    /**
    * A placeholder function
    *
    * @param object The event object
    */
    RGraph.CornerGauge.prototype.getShape = function (e)
    {
    }

    /**
    * A getValue method
    *
    * @param object e An event object
    */
    RGraph.CornerGauge.prototype.getValue = function (e)
    {
        var mouseXY = RGraph.getMouseXY(e);
        var mouseX  = mouseXY[0];
        var mouseY  = mouseXY[1];

        var angle = RGraph.getAngleByXY(this.centerx, this.centery, mouseX, mouseY);

        if (angle > TWOPI && angle < (PI + HALFPI)) {
            return null;
        }

        var value = ((angle - (PI + HALFPI)) / (TWOPI - (PI + HALFPI))) * (this.max - this.min);
            value = value + this.min;

        if (value < this.min) {
            value = this.min
        }

        if (value > this.max) {
            value = this.max
        }

        // Special case for this chart
        if (mouseX > this.centerx && mouseY > this.centery) {
            value = this.max;
        }

        return value;
    }

    /**
    * The getObjectByXY() worker method. Don't call this call:
    *
    * RGraph.ObjectRegistry.getObjectByXY(e)
    *
    * @param object e The event object
    */
    RGraph.CornerGauge.prototype.getObjectByXY = function (e)
    {
        var mouseXY = RGraph.getMouseXY(e);

        if (
               mouseXY[0] > (this.centerx - 5)
            && mouseXY[0] < (this.centerx + this.radius)
            && mouseXY[1] > (this.centery - this.radius)
            && mouseXY[1] < (this.centery + 5)
            && RGraph.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]) <= this.radius
            ) {
            return this;
        }
    }

    /**
    * This method handles the adjusting calculation for when the mouse is moved
    *
    * @param object e The event object
    */
    RGraph.CornerGauge.prototype.Adjusting_mousemove = function (e)
    {
        /**
        * Handle adjusting for the Bar
        */
        if (RGraph.Registry.Get('chart.adjusting') && RGraph.Registry.Get('chart.adjusting').uid == this.uid) {
            this.value = this.getValue(e);
            RGraph.Clear(this.canvas);
            RGraph.RedrawCanvas(this.canvas);
            RGraph.FireCustomEvent(this, 'onadjust');
        }
    }

    /**
    * This method returns the appropriate angle for a value
    *
    * @param number value The value to get the angle for
    */
    RGraph.CornerGauge.prototype.getAngle = function (value)
    {
        if (value < this.min || value > this.max) {
            return null;
        }

        var angle  = ((value - this.min) / (this.max - this.min)) * HALFPI
            angle += (PI + HALFPI);

        return angle;
    }

    /**
    * This allows for easy specification of gradients
    */
    RGraph.CornerGauge.prototype.parseColors = function ()
    {
        var props = this.properties;

        if (!RGraph.is_null(this.properties['chart.colors.ranges'])) {
            for (var i=0; i<this.properties['chart.colors.ranges'].length; ++i) {
                this.properties['chart.colors.ranges'][i][2] = this.parseSingleColorForGradient(this.properties['chart.colors.ranges'][i][2]);
            }
        } else {
            this.properties['chart.green.color']  = this.parseSingleColorForGradient(this.properties['chart.green.color']);
            this.properties['chart.yellow.color'] = this.parseSingleColorForGradient(this.properties['chart.yellow.color']);
            this.properties['chart.red.color']    = this.parseSingleColorForGradient(this.properties['chart.red.color']);
        }
    }

    /**
    * This parses a single color value
    */
    RGraph.CornerGauge.prototype.parseSingleColorForGradient = function (color)
    {
        var canvas  = this.canvas;
        var context = this.context;

        if (!color || typeof(color) != 'string') {
            return color;
        }

        if (color.match(/^gradient\((.*)\)$/i)) {

            var parts = RegExp.$1.split(':');

            var radius_start = this.radius - 54 - this.properties['chart.text.size'];
            var radius_end   = radius_start - 15;

            // Create the gradient
            var grad = context.createRadialGradient(
                                                    this.centerx,
                                                    this.centery,
                                                    radius_start,
                                                    this.centerx,
                                                    this.centery,
                                                    radius_end
                                                   );

            var diff = 1 / (parts.length - 1);

            grad.addColorStop(0, RGraph.trim(parts[0]));

            for (var j=1; j<parts.length; ++j) {
                grad.addColorStop(j * diff, RGraph.trim(parts[j]));
            }
        }

        return grad ? grad : color;
    }


text:
<?xml version="1.0" encoding="utf-8"?>
<Roots >
  <Roots.Interfaces>
    <RootInterface FullName="Windows.UI.Xaml.Data.IValueConverter" />
  </Roots.Interfaces>
  <Roots.PropertyPathNames>
    <RootPropertyPathName Name="BorderBrush" />
    <RootPropertyPathName Name="Opacity" />
    <RootPropertyPathName Name="CheckedBrush" />
    <RootPropertyPathName Name="Margin" />
    <RootPropertyPathName Name="PressedBrush" />
    <RootPropertyPathName Name="AnimationDuration" />
    <RootPropertyPathName Name="UncheckedOpacity" />
    <RootPropertyPathName Name="CheckedOpacity" />
  </Roots.PropertyPathNames>
  <Roots.RootTypes>
    <RootType FullName="Windows.UI.Xaml.ResourceDictionary" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.Converters.SolidColorBrushToColorConverter" />
    <RootType FullName="Windows.UI.Xaml.Media.SolidColorBrush">
      <RootProperty Name="Color" />
    </RootType>
    <RootType FullName="System.Double" />
    <RootType FullName="Windows.UI.Xaml.Media.FontFamily" />
    <RootType FullName="Windows.UI.Xaml.Thickness" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ProgressOverlay" />
    <RootType FullName="Windows.UI.Xaml.Controls.Control">
      <RootProperty Name="Background" />
      <RootProperty Name="Template" />
      <RootProperty Name="Foreground" />
      <RootProperty Name="FontFamily" />
      <RootProperty Name="FontSize" />
      <RootProperty Name="BorderBrush" />
      <RootProperty Name="BorderThickness" />
      <RootProperty Name="Padding" />
      <RootProperty Name="HorizontalContentAlignment" />
      <RootProperty Name="FontWeight" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.ColorPicker" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ColorSliderThumb" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.SuperSlider">
      <RootProperty Name="Orientation" />
      <RootProperty Name="Foreground" />
      <RootProperty Name="Minimum" />
      <RootProperty Name="Maximum" />
      <RootProperty Name="Thumb" />
      <RootProperty Name="Style" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.ColorSlider">
      <RootProperty Name="Width" />
      <RootProperty Name="Margin" />
      <RootProperty Name="IsColorVisible" />
      <RootProperty Name="Thumb" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.TextBlock">
      <RootProperty Name="FontSize" />
      <RootProperty Name="Text" />
      <RootProperty Name="Margin" />
      <RootProperty Name="TextWrapping" />
      <RootProperty Name="FontFamily" />
      <RootProperty Name="FontWeight" />
      <RootProperty Name="Style" />
      <RootProperty Name="Name" />
      <RootProperty Name="Visibility" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="HorizontalAlignment" />
      <RootProperty Name="Padding" />
      <RootProperty Name="Foreground" />
      <RootProperty Name="Opacity" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.FrameworkElement">
      <RootProperty Name="Margin" />
      <RootProperty Name="HorizontalAlignment" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="Height" />
      <RootProperty Name="MinWidth" />
      <RootProperty Name="MinHeight" />
      <RootProperty Name="Width" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Shapes.Rectangle">
      <RootProperty Name="Name" />
      <RootProperty Name="Fill" />
      <RootProperty Name="RadiusX" />
      <RootProperty Name="RadiusY" />
      <RootProperty Name="Style" />
      <RootProperty Name="Visibility" />
      <RootProperty Name="Stroke" />
      <RootProperty Name="StrokeThickness" />
      <RootProperty Name="Margin" />
      <RootProperty Name="Height" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Shapes.Shape">
      <RootProperty Name="Fill" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.UIElement">
      <RootProperty Name="Opacity" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.Image">
      <RootProperty Name="Stretch" />
      <RootProperty Name="Name" />
      <RootProperty Name="Margin" />
      <RootProperty Name="Visibility" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="Width" />
      <RootProperty Name="Height" />
      <RootProperty Name="Source" />
      <RootProperty Name="Opacity" />
      <RootProperty Name="Style" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.Panel">
      <RootProperty Name="Background" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.MetroFlowItem">
      <RootProperty Name="Title" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.MetroFlow" />
    <RootType FullName="Windows.UI.Xaml.Controls.ControlTemplate">
      <RootProperty Name="TargetType" />
      <RootProperty Name="Template" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.ContentControl">
      <RootProperty Name="Margin" />
      <RootProperty Name="Content" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="HorizontalAlignment" />
      <RootProperty Name="Name" />
      <RootProperty Name="HorizontalContentAlignment" />
      <RootProperty Name="VerticalContentAlignment" />
      <RootProperty Name="FontSize" />
      <RootProperty Name="FontFamily" />
      <RootProperty Name="FontWeight" />
      <RootProperty Name="Padding" />
      <RootProperty Name="Foreground" />
      <RootProperty Name="Style" />
      <RootProperty Name="BorderThickness" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.OpacityToggleButton" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ToggleButtonBase">
      <RootProperty Name="ButtonWidth" />
      <RootProperty Name="ButtonHeight" />
      <RootProperty Name="CheckedBrush" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.RoundButton">
      <RootProperty Name="PressedBrush" />
      <RootProperty Name="ButtonWidth" />
      <RootProperty Name="ButtonHeight" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.RoundToggleButton" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ChatBubble" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ChatBubbleTextBox" />
    <RootType FullName="Windows.UI.Xaml.Controls.ScrollViewer">
      <RootProperty Name="Margin" />
      <RootProperty Name="Content" />
      <RootProperty Name="Name" />
      <RootProperty Name="Foreground" />
      <RootProperty Name="HorizontalScrollMode" />
      <RootProperty Name="HorizontalScrollBarVisibility" />
      <RootProperty Name="IsTabStop" />
      <RootProperty Name="IsHorizontalRailEnabled" />
      <RootProperty Name="IsVerticalRailEnabled" />
      <RootProperty Name="IsDeferredScrollingEnabled" />
      <RootProperty Name="Padding" />
      <RootProperty Name="VerticalScrollBarVisibility" />
      <RootProperty Name="VerticalScrollMode" />
      <RootProperty Name="ZoomMode" />
      <RootMethod Name="GetHorizontalScrollBarVisibility" />
      <RootMethod Name="SetHorizontalScrollBarVisibility" />
      <RootMethod Name="GetVerticalScrollBarVisibility" />
      <RootMethod Name="SetVerticalScrollBarVisibility" />
      <RootMethod Name="GetIsDeferredScrollingEnabled" />
      <RootMethod Name="SetIsDeferredScrollingEnabled" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.ColorHexagonPicker" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.ImageTile" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.SuperImage" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.Tile" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.TileNotification" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.PasswordInputPrompt" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.PopUp`2[[System.String, System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Coding4Fun.Toolkit.Controls.PopUpResult, Coding4Fun.Toolkit.Controls, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]">
      <RootProperty Name="Overlay" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.ToastPrompt" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.AboutPrompt" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.PopUp`2[[System.Object, System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Coding4Fun.Toolkit.Controls.PopUpResult, Coding4Fun.Toolkit.Controls, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]">
      <RootProperty Name="Overlay" />
    </RootType>
    <RootType FullName="Coding4Fun.Toolkit.Controls.AboutPromptItem" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.MessagePrompt" />
    <RootType FullName="Coding4Fun.Toolkit.Controls.InputPrompt" />
    <RootType FullName="Windows.UI.Xaml.Setter">
      <RootProperty Name="Property" />
      <RootProperty Name="Value" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.Grid">
      <RootProperty Name="Name" />
      <RootProperty Name="RowDefinitions" />
      <RootProperty Name="Children" />
      <RootProperty Name="Margin" />
      <RootProperty Name="Resources" />
      <RootProperty Name="ColumnDefinitions" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="Background" />
      <RootProperty Name="Width" />
      <RootProperty Name="Height" />
      <RootProperty Name="Style" />
      <RootProperty Name="HorizontalAlignment" />
      <RootMethod Name="GetRow" />
      <RootMethod Name="SetRow" />
      <RootMethod Name="GetColumn" />
      <RootMethod Name="SetColumn" />
      <RootMethod Name="GetColumnSpan" />
      <RootMethod Name="SetColumnSpan" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.VisualStateManager">
      <RootMethod Name="GetVisualStateGroups" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.RowDefinition">
      <RootProperty Name="Height" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.VisualStateGroup">
      <RootProperty Name="States" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.VisualState">
      <RootProperty Name="Storyboard" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Media.Animation.Storyboard">
      <RootProperty Name="Children" />
      <RootMethod Name="GetTargetProperty" />
      <RootMethod Name="SetTargetProperty" />
      <RootMethod Name="GetTargetName" />
      <RootMethod Name="SetTargetName" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Media.Animation.ObjectAnimationUsingKeyFrames">
      <RootProperty Name="KeyFrames" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Media.Animation.DiscreteObjectKeyFrame">
      <RootProperty Name="KeyTime" />
      <RootProperty Name="Value" />
    </RootType>
    <RootType FullName="Microsoft.Xaml.Tools.DirectUI.ProxyTypes.StaticResourceExtension" />
    <RootType FullName="Windows.UI.Xaml.Controls.Border">
      <RootProperty Name="Margin" />
      <RootProperty Name="Child" />
      <RootProperty Name="VerticalAlignment" />
      <RootProperty Name="Background" />
      <RootProperty Name="BorderThickness" />
      <RootProperty Name="BorderBrush" />
      <RootProperty Name="Opacity" />
      <RootProperty Name="Name" />
      <RootProperty Name="Padding" />
      <RootProperty Name="Height" />
      <RootProperty Name="Width" />
      <RootProperty Name="Visibility" />
    </RootType>
    <RootType FullName="Microsoft.Xaml.Tools.DirectUI.ProxyTypes.TemplateBindingExtension" />
    <RootType FullName="Windows.UI.Xaml.Controls.ContentPresenter">
      <RootProperty Name="Content" />
      <RootProperty Name="Margin" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.StackPanel">
      <RootProperty Name="Margin" />
      <RootProperty Name="Children" />
      <RootProperty Name="Name" />
      <RootProperty Name="Orientation" />
      <RootProperty Name="HorizontalAlignment" />
      <RootProperty Name="VerticalAlignment" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.TextBox">
      <RootProperty Name="Name" />
      <RootProperty Name="InputScope" />
      <RootProperty Name="Text" />
      <RootProperty Name="Margin" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.ColumnDefinition">
      <RootProperty Name="Width" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Visibility" />
    <RootType FullName="Windows.UI.Xaml.Media.Animation.DoubleAnimation">
      <RootProperty Name="Duration" />
      <RootProperty Name="To" />
      <RootProperty Name="From" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Shapes.Path">
      <RootProperty Name="Name" />
      <RootProperty Name="Data" />
      <RootProperty Name="Fill" />
      <RootProperty Name="Opacity" />
      <RootProperty Name="Stretch" />
      <RootProperty Name="Margin" />
      <RootProperty Name="Height" />
      <RootProperty Name="Width" />
      <RootProperty Name="Visibility" />
      <RootProperty Name="HorizontalAlignment" />
      <RootProperty Name="VerticalAlignment" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Data.Binding">
      <RootProperty Name="ElementName" />
      <RootProperty Name="Path" />
      <RootProperty Name="RelativeSource" />
      <RootProperty Name="Source" />
      <RootProperty Name="Converter" />
      <RootProperty Name="ConverterParameter" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Controls.Button">
      <RootProperty Name="Name" />
      <RootProperty Name="Style" />
      <RootProperty Name="BorderThickness" />
      <RootProperty Name="FontSize" />
      <RootProperty Name="IsTabStop" />
      <RootProperty Name="Visibility" />
      <RootProperty Name="VerticalAlignment" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Data.RelativeSource" />
    <RootType FullName="Windows.UI.Xaml.Shapes.Ellipse">
      <RootProperty Name="Stroke" />
      <RootProperty Name="Margin" />
      <RootProperty Name="StrokeThickness" />
      <RootProperty Name="Fill" />
      <RootProperty Name="Height" />
      <RootProperty Name="Width" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Media.LinearGradientBrush">
      <RootProperty Name="StartPoint" />
      <RootProperty Name="EndPoint" />
      <RootProperty Name="GradientStops" />
    </RootType>
    <RootType FullName="Windows.UI.Xaml.Media.GradientStop">
      <RootProperty Name="Offset" />
      <RootProperty Name="Color" />
    </RootType>
  </Roots.RootTypes>
</Roots>

redpajama_set_name: RedPajamaGithub


text:
/* eslint-disable
    consistent-return,
    func-names,
    max-len,
    no-multi-assign,
    no-nested-ternary,
    no-param-reassign,
    no-return-assign,
    no-undef,
    no-underscore-dangle,
    no-use-before-define,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
 * decaffeinate suggestions:
 * DS102: Remove unnecessary code created because of implicit returns
 * DS103: Rewrite code to no longer use __guard__
 * DS206: Consider reworking classes to avoid initClass
 * DS207: Consider shorter variations of null checks
 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
 */
//
// A heads-up-display (HUD) for showing Vimium page operations.
// Note: you cannot interact with the HUD until document.body is available.
//
const HUD = {
  tween: null,
  hudUI: null,
  findMode: null,
  abandon() { return (this.hudUI != null ? this.hudUI.hide(false) : undefined); },

  pasteListener: null, // Set by @pasteFromClipboard to handle the value returned by pasteResponse

  // This HUD is styled to precisely mimick the chrome HUD on Mac. Use the "has_popup_and_link_hud.html"
  // test harness to tweak these styles to match Chrome's. One limitation of our HUD display is that
  // it doesn't sit on top of horizontal scrollbars like Chrome's HUD does.

  init() {
    if (this.hudUI == null) { this.hudUI = new UIComponent('pages/hud.html', 'vimiumHUDFrame', ({ data }) => (typeof this[data.name] === 'function' ? this[data.name](data) : undefined)); }
    return this.tween != null ? this.tween : (this.tween = new Tween('iframe.vimiumHUDFrame.vimiumUIComponentVisible', this.hudUI.shadowDOM));
  },

  showForDuration(text, duration) {
    this.show(text);
    return this._showForDurationTimerId = setTimeout((() => this.hide()), duration);
  },

  show(text) {
    return DomUtils.documentComplete(() => {
      this.init();
      clearTimeout(this._showForDurationTimerId);
      this.hudUI.activate({ name: 'show', text });
      return this.tween.fade(1.0, 150);
    });
  },

  showFindMode(findMode = null) {
    this.findMode = findMode;
    return DomUtils.documentComplete(() => {
      this.init();
      this.hudUI.toggleIframeElementClasses('vimiumUIComponentHidden', 'vimiumUIComponentVisible');
      this.hudUI.activate({ name: 'showFindMode' });
      return this.tween.fade(1.0, 150);
    });
  },

  search(data) {
    // NOTE(mrmr1993): On Firefox, window.find moves the window focus away from the HUD. We use postFindFocus
    // to put it back, so the user can continue typing.
    this.findMode.findInPlace(data.query, { postFindFocus: this.hudUI.iframeElement.contentWindow });

    // Show the number of matches in the HUD UI.
    const matchCount = FindMode.query.parsedQuery.length > 0 ? FindMode.query.matchCount : 0;
    const showMatchText = FindMode.query.rawQuery.length > 0;
    return this.hudUI.postMessage({ name: 'updateMatchesCount', matchCount, showMatchText });
  },

  // Hide the HUD.
  // If :immediate is falsy, then the HUD is faded out smoothly (otherwise it is hidden immediately).
  // If :updateIndicator is truthy, then we also refresh the mode indicator.  The only time we don't update the
  // mode indicator, is when hide() is called for the mode indicator itself.
  hide(immediate, updateIndicator) {
    if (immediate == null) { immediate = false; }
    if (updateIndicator == null) { updateIndicator = true; }
    if ((this.hudUI != null) && (this.tween != null)) {
      clearTimeout(this._showForDurationTimerId);
      this.tween.stop();
      if (immediate) {
        if (updateIndicator) { return Mode.setIndicator(); } return this.hudUI.hide();
      }
      return this.tween.fade(0, 150, () => this.hide(true, updateIndicator));
    }
  },

  // These parameters describe the reason find mode is exiting, and come from the HUD UI component.
  hideFindMode({ exitEventIsEnter, exitEventIsEscape }) {
    let postExit;
    this.findMode.checkReturnToViewPort();

    // An element won't receive a focus event if the search landed on it while we were in the HUD iframe. To
    // end up with the correct modes active, we create a focus/blur event manually after refocusing this
    // window.
    window.focus();

    const focusNode = DomUtils.getSelectionFocusElement();
    if (document.activeElement != null) {
      document.activeElement.blur();
    }
    __guardMethod__(focusNode, 'focus', (o) => o.focus());

    if (exitEventIsEnter) {
      FindMode.handleEnter();
      if (FindMode.query.hasResults) {
        postExit = () => new PostFindMode();
      }
    } else if (exitEventIsEscape) {
      // We don't want FindMode to handle the click events that FindMode.handleEscape can generate, so we
      // wait until the mode is closed before running it.
      postExit = FindMode.handleEscape;
    }

    this.findMode.exit();
    return (typeof postExit === 'function' ? postExit() : undefined);
  },

  // These commands manage copying and pasting from the clipboard in the HUD frame.
  // NOTE(mrmr1993): We need this to copy and paste on Firefox:
  // * an element can't be focused in the background page, so copying/pasting doesn't work
  // * we don't want to disrupt the focus in the page, in case the page is listening for focus/blur events.
  // * the HUD shouldn't be active for this frame while any of the copy/paste commands are running.
  copyToClipboard(text) {
    return DomUtils.documentComplete(() => {
      this.init();
      // Chrome 74 only acknowledges text selection when a frame has been visible. See more in #3277 .
      this.hudUI.toggleIframeElementClasses('vimiumUIComponentHidden', 'vimiumUIComponentVisible');
      return this.hudUI.postMessage({ name: 'copyToClipboard', data: text });
    });
  },

  pasteFromClipboard(pasteListener) {
    this.pasteListener = pasteListener;
    return DomUtils.documentComplete(() => {
      this.init();
      // Show the HUD frame, so Firefox will actually perform the paste.
      this.hudUI.toggleIframeElementClasses('vimiumUIComponentHidden', 'vimiumUIComponentVisible');
      this.tween.fade(0, 0);
      return this.hudUI.postMessage({ name: 'pasteFromClipboard' });
    });
  },

  pasteResponse({ data }) {
    // Hide the HUD frame again.
    this.hudUI.toggleIframeElementClasses('vimiumUIComponentVisible', 'vimiumUIComponentHidden');
    this.unfocusIfFocused();
    return this.pasteListener(data);
  },

  unfocusIfFocused() {
    // On Firefox, if an <iframe> disappears when it's focused, then it will keep "focused",
    // which means keyboard events will always be dispatched to the HUD iframe
    if (this.hudUI != null ? this.hudUI.showing : undefined) {
      this.hudUI.iframeElement.blur();
      return window.focus();
    }
  },
};

class Tween {
  static initClass() {
    this.prototype.opacity = 0;
    this.prototype.intervalId = -1;
    this.prototype.styleElement = null;
  }

  constructor(cssSelector, insertionPoint) {
    this.cssSelector = cssSelector;
    if (insertionPoint == null) { insertionPoint = document.documentElement; }
    this.styleElement = DomUtils.createElement('style');

    if (!this.styleElement.style) {
      // We're in an XML document, so we shouldn't inject any elements. See the comment in UIComponent.
      Tween.prototype.fade = (Tween.prototype.stop = (Tween.prototype.updateStyle = function () {}));
      return;
    }

    this.styleElement.type = 'text/css';
    this.styleElement.innerHTML = '';
    insertionPoint.appendChild(this.styleElement);
  }

  fade(toAlpha, duration, onComplete) {
    clearInterval(this.intervalId);
    const startTime = (new Date()).getTime();
    const fromAlpha = this.opacity;
    const alphaStep = toAlpha - fromAlpha;

    const performStep = () => {
      const elapsed = (new Date()).getTime() - startTime;
      if (elapsed >= duration) {
        clearInterval(this.intervalId);
        this.updateStyle(toAlpha);
        return (typeof onComplete === 'function' ? onComplete() : undefined);
      }
      const value = ((elapsed / duration) * alphaStep) + fromAlpha;
      return this.updateStyle(value);
    };

    this.updateStyle(this.opacity);
    return this.intervalId = setInterval(performStep, 50);
  }

  stop() { return clearInterval(this.intervalId); }

  updateStyle(opacity) {
    this.opacity = opacity;
    return this.styleElement.innerHTML = `\
${this.cssSelector} {
  opacity: ${this.opacity};
}\
`;
  }
}
Tween.initClass();

const root = typeof exports !== 'undefined' && exports !== null ? exports : (window.root != null ? window.root : (window.root = {}));
root.HUD = HUD;
if (typeof exports === 'undefined' || exports === null) { extend(window, root); }

function __guardMethod__(obj, methodName, transform) {
  if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
    return transform(obj, methodName);
  }
  return undefined;
}


text: Microblog 是一个基于Node + express + mongodb开发的微博。


text:
package com.github.mikephil.charting.renderer;

import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.View;

import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.interfaces.ChartInterface;
import com.github.mikephil.charting.utils.Utils;

import java.util.ArrayList;

/**
 * Transformer class that contains all matrices and is responsible for
 * transforming values into pixels on the screen and backwards.
 *
 * @author Philipp Jahoda
 */
public class Transformer {

    /** matrix to map the values to the screen pixels */
    protected Matrix mMatrixValueToPx = new Matrix();

    /** matrix for handling the different offsets of the chart */
    protected Matrix mMatrixOffset = new Matrix();

    /** matrix used for touch events */
    protected final Matrix mMatrixTouch = new Matrix();

    /** if set to true, the y-axis is inverted and low values start at the top */
    private boolean mInvertYAxis = false;

    /** minimum scale value on the y-axis */
    private float mMinScaleY = 1f;

    /** minimum scale value on the x-axis */
    private float mMinScaleX = 1f;

    /** contains the current scale factor of the x-axis */
    private float mScaleX = 1f;

    /** contains the current scale factor of the y-axis */
    private float mScaleY = 1f;

    /** offset that allows the chart to be dragged over its bounds on the x-axis */
    private float mTransOffsetX = 0f;

    /** offset that allows the chart to be dragged over its bounds on the x-axis */
    private float mTransOffsetY = 0f;

    public Transformer() {

    }

    /**
     * Prepares the matrix that transforms values to pixels.
     *
     * @param chart
     */
    public void prepareMatrixValuePx(ChartInterface chart) {

        float scaleX = (float) ((chart.getWidth() - chart.getOffsetRight() - chart
                .getOffsetLeft()) / chart.getDeltaX());
        float scaleY = (float) ((chart.getHeight() - chart.getOffsetTop() - chart
                .getOffsetBottom()) / chart.getDeltaY());

        // setup all matrices
        mMatrixValueToPx.reset();
        mMatrixValueToPx.postTranslate(0, -chart.getYChartMin());
        mMatrixValueToPx.postScale(scaleX, -scaleY);
    }

    /**
     * Prepares the matrix that contains all offsets.
     *
     * @param chart
     */
    public void prepareMatrixOffset(ChartInterface chart) {

        mMatrixOffset.reset();

        // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);

        if (!mInvertYAxis)
            mMatrixOffset.postTranslate(chart.getOffsetLeft(),
                    chart.getHeight() - chart.getOffsetBottom());
        else {
            mMatrixOffset.setTranslate(chart.getOffsetLeft(), -chart.getOffsetTop());
            mMatrixOffset.postScale(1.0f, -1.0f);
        }

        // mMatrixOffset.set(offset);

        // mMatrixOffset.reset();
        //
        // mMatrixOffset.postTranslate(mOffsetLeft, getHeight() -
        // mOffsetBottom);
    }

    /**
     * Transforms an arraylist of Entry into a float array containing the x and
     * y values transformed with all matrices for the LINECHART or SCATTERCHART.
     *
     * @param entries
     * @return
     */
    public float[] generateTransformedValuesLineScatter(ArrayList<? extends Entry> entries,
            float phaseY) {

        float[] valuePoints = new float[entries.size() * 2];

        for (int j = 0; j < valuePoints.length; j += 2) {

            Entry e = entries.get(j / 2);

            valuePoints[j] = e.getXIndex();
            valuePoints[j + 1] = e.getVal() * phaseY;
        }

        pointValuesToPixel(valuePoints);

        return valuePoints;
    }

    /**
     * Transforms an arraylist of Entry into a float array containing the x and
     * y values transformed with all matrices for the BARCHART.
     *
     * @param entries
     * @param dataSet the dataset index
     * @return
     */
    public float[] generateTransformedValuesBarChart(ArrayList<? extends Entry> entries,
            int dataSet, BarData bd, float phaseY) {

        float[] valuePoints = new float[entries.size() * 2];

        int setCount = bd.getDataSetCount();
        float space = bd.getGroupSpace();

        for (int j = 0; j < valuePoints.length; j += 2) {

            Entry e = entries.get(j / 2);

            // calculate the x-position, depending on datasetcount
            float x = e.getXIndex() + (j / 2 * (setCount - 1)) + dataSet + 0.5f + space * (j / 2)
                    + space / 2f;
            float y = e.getVal();

            valuePoints[j] = x;
            valuePoints[j + 1] = y * phaseY;
        }

        pointValuesToPixel(valuePoints);

        return valuePoints;
    }

    /**
     * transform a path with all the given matrices VERY IMPORTANT: keep order
     * to value-touch-offset
     *
     * @param path
     */
    public void pathValueToPixel(Path path) {

        path.transform(mMatrixValueToPx);
        path.transform(mMatrixTouch);
        path.transform(mMatrixOffset);
    }

    /**
     * Transforms multiple paths will all matrices.
     *
     * @param paths
     */
    public void pathValuesToPixel(ArrayList<Path> paths) {

        for (int i = 0; i < paths.size(); i++) {
            pathValueToPixel(paths.get(i));
        }
    }

    /**
     * Transform an array of points with all matrices. VERY IMPORTANT: Keep
     * matrix order "value-touch-offset" when transforming.
     *
     * @param pts
     */
    public void pointValuesToPixel(float[] pts) {

        mMatrixValueToPx.mapPoints(pts);
        mMatrixTouch.mapPoints(pts);
        mMatrixOffset.mapPoints(pts);
    }

    /**
     * Transform a rectangle with all matrices.
     *
     * @param r
     */
    public void rectValueToPixel(RectF r) {

        mMatrixValueToPx.mapRect(r);
        mMatrixTouch.mapRect(r);
        mMatrixOffset.mapRect(r);
    }

    /**
     * Transform a rectangle with all matrices with potential animation phases.
     *
     * @param r
     * @param phaseY
     */
    public void rectValueToPixel(RectF r, float phaseY) {

        // multiply the height of the rect with the phase
        if (r.top > 0)
            r.top *= phaseY;
        else
            r.bottom *= phaseY;

        mMatrixValueToPx.mapRect(r);
        mMatrixTouch.mapRect(r);
        mMatrixOffset.mapRect(r);
    }

    /**
     * transforms multiple rects with all matrices
     *
     * @param rects
     */
    public void rectValuesToPixel(ArrayList<RectF> rects) {

        for (int i = 0; i < rects.size(); i++)
            rectValueToPixel(rects.get(i));
    }

    /**
     * Transforms the given array of touch positions (pixels) (x, y, x, y, ...)
     * into values on the chart.
     *
     * @param pixels
     */
    public void pixelsToValue(float[] pixels) {

        Matrix tmp = new Matrix();

        // invert all matrixes to convert back to the original value
        mMatrixOffset.invert(tmp);
        tmp.mapPoints(pixels);

        mMatrixTouch.invert(tmp);
        tmp.mapPoints(pixels);

        mMatrixValueToPx.invert(tmp);
        tmp.mapPoints(pixels);
    }

    /**
     * ################ ################ ################ ################
     */
    /** CODE BELOW THIS RELATED TO SCALING AND GESTURES */

    /**
     * Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom
     * center.
     *
     * @param x
     * @param y
     */
    public Matrix zoomIn(float x, float y) {

        Matrix save = new Matrix();
        save.set(mMatrixTouch);

        save.postScale(1.4f, 1.4f, x, y);

        return save;
    }

    /**
     * Zooms out by 0.7f, x and y are the coordinates (in pixels) of the zoom
     * center.
     */
    public Matrix zoomOut(float x, float y) {

        Matrix save = new Matrix();
        save.set(mMatrixTouch);

        save.postScale(0.7f, 0.7f, x, y);

        return save;
    }

    /**
     * Zooms in or out by the given scale factor. x and y are the coordinates
     * (in pixels) of the zoom center.
     *
     * @param scaleX if < 1f --> zoom out, if > 1f --> zoom in
     * @param scaleY if < 1f --> zoom out, if > 1f --> zoom in
     * @param x
     * @param y
     */
    public Matrix zoom(float scaleX, float scaleY, float x, float y) {

        Matrix save = new Matrix();
        save.set(mMatrixTouch);

        // Log.i(LOG_TAG, "Zooming, x: " + x + ", y: " + y);

        save.postScale(scaleX, scaleY, x, y);

        return save;
    }

    /**
     * Resets all zooming and dragging and makes the chart fit exactly it's
     * bounds.
     */
    public Matrix fitScreen() {

        Matrix save = new Matrix();
        save.set(mMatrixTouch);

        float[] vals = new float[9];

        save.getValues(vals);

        // reset all translations and scaling
        vals[Matrix.MTRANS_X] = 0f;
        vals[Matrix.MTRANS_Y] = 0f;
        vals[Matrix.MSCALE_X] = 1f;
        vals[Matrix.MSCALE_Y] = 1f;

        save.setValues(vals);

        return save;
    }

    /**
     * If this is set to true, the y-axis is inverted which means that low
     * values are on top of the chart, high values on bottom.
     *
     * @param enabled
     */
    public void setInvertYAxisEnabled(boolean enabled) {
        mInvertYAxis = enabled;
    }

    /**
     * If this returns true, the y-axis is inverted.
     *
     * @return
     */
    public boolean isInvertYAxisEnabled() {
        return mInvertYAxis;
    }

    /**
     * Centers the viewport around the specified position (x-index and y-value)
     * in the chart. Centering the viewport outside the bounds of the chart is
     * not possible. Makes most sense in combination with the
     * setScaleMinima(...) method.
     *
     * @param pts the position to center view viewport to
     * @param chart
     * @return save
     */
    public synchronized void centerViewPort(final float[] pts, final ChartInterface chart) {

        final View v = chart.getChartView();

        v.post(new Runnable() {

            @Override
            public void run() {
                Matrix save = new Matrix();
                save.set(mMatrixTouch);

                pointValuesToPixel(pts);

                final float x = pts[0] - chart.getOffsetLeft();
                final float y = pts[1] - chart.getOffsetTop();

                save.postTranslate(-x, -y);

                refresh(save, chart);
            }
        });
    }

    /**
     * call this method to refresh the graph with a given matrix
     *
     * @param newMatrix
     * @return
     */
    public Matrix refresh(Matrix newMatrix, ChartInterface chart) {

        mMatrixTouch.set(newMatrix);

        // make sure scale and translation are within their bounds
        limitTransAndScale(mMatrixTouch, chart.getContentRect());

        chart.getChartView().invalidate();

        newMatrix.set(mMatrixTouch);
        return newMatrix;
    }

    /**
     * limits the maximum scale and X translation of the given matrix
     *
     * @param matrix
     */
    private void limitTransAndScale(Matrix matrix, RectF content) {

        float[] vals = new float[9];
        matrix.getValues(vals);

        float curTransX = vals[Matrix.MTRANS_X];
        float curScaleX = vals[Matrix.MSCALE_X];

        float curTransY = vals[Matrix.MTRANS_Y];
        float curScaleY = vals[Matrix.MSCALE_Y];

        // min scale-x is 1f
        mScaleX = Math.max(mMinScaleX, curScaleX);

        // min scale-y is 1f
        mScaleY = Math.max(mMinScaleY, curScaleY);

        float width = 0f;
        float height = 0f;

        if (content != null) {
            width = content.width();
            height = content.height();
        }

        float maxTransX = -width * (mScaleX - 1f);
        float newTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);

        // if(curScaleX < mMinScaleX) {
        // newTransX = (-width * (mScaleX - 1f)) / 2f;
        // }

        float maxTransY = height * (mScaleY - 1f);
        float newTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);

        // if(curScaleY < mMinScaleY) {
        // newTransY = (height * (mScaleY - 1f)) / 2f;
        // }

        vals[Matrix.MTRANS_X] = newTransX;
        vals[Matrix.MSCALE_X] = mScaleX;

        vals[Matrix.MTRANS_Y] = newTransY;
        vals[Matrix.MSCALE_Y] = mScaleY;

        matrix.setValues(vals);
    }

    /**
     * Sets the minimum scale values for both axes. This limits the extent to
     * which the user can zoom-out.
     *
     * @param scaleXmin
     * @param scaleYmin
     */
    public void setScaleMinima(float scaleXmin, float scaleYmin, ChartInterface chart) {

        if (scaleXmin < 1f)
            scaleXmin = 1f;
        if (scaleYmin < 1f)
            scaleYmin = 1f;

        mMinScaleX = scaleXmin;
        mMinScaleY = scaleYmin;

        Matrix save = zoom(mMinScaleX, mMinScaleY, 0f, 0f);
        refresh(save, chart);
    }

    // /**
    // * transforms the given rect objects with the touch matrix only
    // *
    // * @param paths
    // */
    // public void transformRectsTouch(ArrayList<RectF> rects) {
    // for (int i = 0; i < rects.size(); i++) {
    // mMatrixTouch.mapRect(rects.get(i));
    // }
    // }
    //
    // /**
    // * transforms the given path objects with the touch matrix only
    // *
    // * @param paths
    // */
    // public void transformPathsTouch(ArrayList<Path> paths) {
    // for (int i = 0; i < paths.size(); i++) {
    // paths.get(i).transform(mMatrixTouch);
    // }
    // }

    public Matrix getTouchMatrix() {
        return mMatrixTouch;
    }

    public Matrix getValueMatrix() {
        return mMatrixValueToPx;
    }

    public Matrix getOffsetMatrix() {
        return mMatrixOffset;
    }

    /**
     * returns the current x-scale factor
     */
    public float getScaleX() {
        return mScaleX;
    }

    /**
     * returns the current y-scale factor
     */
    public float getScaleY() {
        return mScaleY;
    }

    /**
     * if the chart is fully zoomed out, return true
     *
     * @return
     */
    public boolean isFullyZoomedOut() {

        if (isFullyZoomedOutX() && isFullyZoomedOutY())
            return true;
        else
            return false;
    }

    /**
     * Returns true if the chart is fully zoomed out on it's y-axis (vertical).
     *
     * @return
     */
    public boolean isFullyZoomedOutY() {
        if (mScaleY > mMinScaleY || mMinScaleY > 1f)
            return false;
        else
            return true;
    }

    /**
     * Returns true if the chart is fully zoomed out on it's x-axis
     * (horizontal).
     *
     * @return
     */
    public boolean isFullyZoomedOutX() {
        if (mScaleX > mMinScaleX || mMinScaleX > 1f)
            return false;
        else
            return true;
    }

    /**
     * Set an offset in dp that allows the user to drag the chart over it's
     * bounds on the x-axis.
     *
     * @param offset
     */
    public void setDragOffsetX(float offset) {
        mTransOffsetX = Utils.convertDpToPixel(offset);
    }

    /**
     * Set an offset in dp that allows the user to drag the chart over it's
     * bounds on the y-axis.
     *
     * @param offset
     */
    public void setDragOffsetY(float offset) {
        mTransOffsetY = Utils.convertDpToPixel(offset);
    }

    /**
     * Returns true if both drag offsets (x and y) are zero or smaller.
     *
     * @return
     */
    public boolean hasNoDragOffset() {
        return mTransOffsetX <= 0 && mTransOffsetY <= 0 ? true : false;
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/group_back"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingBottom="5dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="5dp" >

        <TextView
            android:id="@+id/text"
            style="@style/progit_chapter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="The fox quickly jumps over the lazy dog"
            android:gravity="center_vertical" />

        <ImageView
            android:id="@+id/indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/button_tab_to_open" />
    </LinearLayout>
    <LinearLayout android:id="@+id/sub_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone">

	    <ListView android:id="@+id/sub_list"
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:focusable="false"
	        android:focusableInTouchMode="false" />
    </LinearLayout>
</LinearLayout>


text:
package org.rythmengine.internal.fifo;

import java.util.LinkedList;
import java.util.List;

public class LinkedFIFO<T> implements FIFO<T> {
    private List<T> backed;

    public LinkedFIFO() {
        backed = new LinkedList<>();
    }

    @Override
    public void push(T t) {
        backed.add(t);
    }

    @Override
    public T pop() {
        if (backed.size() == 0) {
            return null;
        }
        final T t = this.backed.get(0);
        backed.remove(0);
        return t;
    }

    @Override
    public T pop(int idx) {
        if (backed.size() < idx) {
            return null;
        }
        T t = backed.get(idx);
        backed.remove(idx);
        return t;
    }

    @Override
    public T peek() {
        return backed.size() == 0 ? null : this.backed.get(0);
    }

    @Override
    public T peek(int idx) {
        if (backed.size() < idx) {
            return null;
        }
        return backed.get(idx);
    }

    @Override
    public int size() {
        return backed.size();
    }

    @Override
    public void clear() {
        backed.clear();
    }
}


text:
'use strict';

const random = require('../util/random');
const arr = require('../util/arr');
const wordSeed = require('./word');
const {wrap} = require('../util/hooks');

let email = wrap(function () {
    return wordSeed() + '@' + arr(random.int(2, 4), () => wordSeed()).join('.');
});

module.exports = email;


text:
layout: page
title: Young 50th Anniversary
date: 2016-05-24
author: Wayne Waters
tags: weekly links, java
status: published
summary: Suspendisse ornare dui nec nisl aliquet.
banner: images/banner/meeting-01.jpg
booking:
  startDate: 01/10/2019
  endDate: 01/12/2019
  ctyhocn: FTPHSHX
  groupCode: Y5A
published: true
---
Ut sed consequat est. Etiam elementum maximus sapien, nec luctus quam sollicitudin a. In nec sapien ac erat eleifend consectetur id nec mauris. Sed lorem purus, ornare id nisl eu, faucibus scelerisque urna. Morbi volutpat vitae magna eget facilisis. Nunc tempus mauris urna, nec pretium quam dignissim a. Aenean commodo molestie pretium. Nam suscipit, velit quis porttitor aliquam, massa neque tempor dolor, id scelerisque turpis erat id nunc. Cras scelerisque diam nec luctus dignissim. Aliquam turpis sapien, commodo ac sagittis bibendum, mollis pharetra mauris.
Nam leo dolor, tincidunt ut ultrices vitae, fringilla eu orci. Curabitur vestibulum, felis vel dignissim tempus, odio sem dapibus odio, sagittis sodales erat arcu in erat. Aliquam facilisis ac ipsum vitae suscipit. Etiam in ante libero. Quisque lobortis ex lectus, pulvinar facilisis massa condimentum at. Vivamus commodo tempus sapien eu egestas. Donec consequat eu metus volutpat aliquet. Suspendisse eleifend ullamcorper diam nec mattis. Proin id mauris diam. Vestibulum neque orci, interdum nec velit in, efficitur vulputate dolor.

* Nunc sit amet erat at nulla accumsan mollis
* Vivamus fringilla ex sit amet diam bibendum euismod
* Mauris sed leo vitae diam ornare varius.

Morbi vulputate porttitor efficitur. Proin tellus lectus, congue ornare odio eget, venenatis fermentum elit. Aliquam pellentesque in felis ut finibus. Donec vitae mattis neque. Nulla a placerat turpis. Maecenas vel euismod metus. Nunc sit amet tincidunt quam. Fusce sem magna, scelerisque imperdiet tincidunt vel, interdum a dui.


text:
use std::collections::{HashMap, HashSet};
use std::rc::Rc;

use crate::class::{Class, ClassId};
use crate::error::msg::SemError;
use crate::vm::{FctId, VM};

pub fn check<'ast>(vm: &mut VM<'ast>) {
    let mut abstract_methods: HashMap<ClassId, Rc<Vec<FctId>>> = HashMap::new();

    for cls in vm.classes.iter() {
        let cls = cls.read();

        // we are only interested in non-abstract classes
        // with abstract super classes

        if cls.is_abstract {
            continue;
        }

        if let Some(parent_class) = cls.parent_class {
            let super_cls_id = parent_class.cls_id(vm).expect("no class");
            let super_cls = vm.classes.idx(super_cls_id);
            let super_cls = super_cls.read();

            if super_cls.is_abstract {
                check_abstract(vm, &*cls, &*super_cls, &mut abstract_methods);
            }
        }
    }
}

pub fn check_abstract<'ast>(
    vm: &VM<'ast>,
    cls: &Class,
    super_cls: &Class,
    abstract_methods: &mut HashMap<ClassId, Rc<Vec<FctId>>>,
) {
    assert!(!cls.is_abstract);
    assert!(super_cls.is_abstract);

    let mtds = find_abstract_methods(vm, super_cls, abstract_methods);
    let mut overrides = HashSet::new();

    for &mtd in &cls.methods {
        let mtd = vm.fcts.idx(mtd);
        let mtd = mtd.read();

        if let Some(overrides_mtd) = mtd.overrides {
            overrides.insert(overrides_mtd);
        }
    }

    for &mtd in mtds.iter() {
        if !overrides.contains(&mtd) {
            let mtd = vm.fcts.idx(mtd);
            let mtd = mtd.read();

            let mtd_cls = vm.classes.idx(mtd.parent.cls_id());
            let mtd_cls = mtd_cls.read();
            let cls_name = vm.interner.str(mtd_cls.name).to_string();
            let mtd_name = vm.interner.str(mtd.name).to_string();

            vm.diag.lock().report(
                cls.file,
                cls.pos,
                SemError::MissingAbstractOverride(cls_name, mtd_name),
            );
        }
    }
}

fn find_abstract_methods<'ast>(
    vm: &VM<'ast>,
    cls: &Class,
    abstract_methods: &mut HashMap<ClassId, Rc<Vec<FctId>>>,
) -> Rc<Vec<FctId>> {
    assert!(cls.is_abstract);

    if let Some(mtds) = abstract_methods.get(&cls.id) {
        return mtds.clone();
    }

    let mut abstracts = Vec::new();
    let mut overrides = HashSet::new();

    for &mtd in &cls.methods {
        let mtd = vm.fcts.idx(mtd);
        let mtd = mtd.read();

        if mtd.is_abstract {
            abstracts.push(mtd.id);
        }

        if let Some(override_mtd) = mtd.overrides {
            overrides.insert(override_mtd);
        }
    }

    if let Some(parent_class) = cls.parent_class {
        let super_cls_id = parent_class.cls_id(vm).expect("no class");
        let super_cls = vm.classes.idx(super_cls_id);
        let super_cls = super_cls.read();

        if super_cls.is_abstract {
            let super_abstracts = find_abstract_methods(vm, &*super_cls, abstract_methods);

            for &mtd in super_abstracts.iter() {
                if !overrides.contains(&mtd) {
                    abstracts.push(mtd);
                }
            }
        }
    }

    let ret = Rc::new(abstracts);
    abstract_methods.insert(cls.id, ret.clone());

    ret
}

#[cfg(test)]
mod tests {
    use crate::error::msg::SemError;
    use crate::semck::tests::{err, ok, pos};

    #[test]
    fn test_abstract_class_without_abstract_methods() {
        ok("@open @abstract class A class B: A");
    }

    #[test]
    fn test_override_abstract_method() {
        ok("@open @abstract class A { @abstract fun foo(); }
            class B: A { @override fun foo() {} }");
    }

    #[test]
    fn test_override_abstract_method_in_super_class() {
        ok("@open @abstract class A { @abstract fun foo(); }
            @open @abstract class B: A { @override fun foo() {} }
            class C: B { }");
    }

    #[test]
    fn test_missing_abstract_override() {
        err(
            "@open @abstract class A { @abstract fun foo(); }
            class B: A { }",
            pos(2, 13),
            SemError::MissingAbstractOverride("A".into(), "foo".into()),
        );
    }

    #[test]
    fn test_missing_abstract_override_indirect() {
        err(
            "@open @abstract class A { @abstract fun foo(); }
            @open @abstract class B: A {}
            class C: B { }",
            pos(3, 13),
            SemError::MissingAbstractOverride("A".into(), "foo".into()),
        );
    }
}


text:
    <meta charset="utf-8">
    <title>Facebook - Moco</title>

<button onclick="ign.callbackUrl()">Next</button>

<button onclick="getUserInfo()">Info</button>

<button onclick="Logout()">Logout</button>

<button onclick="getPhoto()">Foto</button>


text:
package org.artifactory.webapp.wicket.page.search.gavc;

import org.apache.wicket.Page;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.artifactory.api.search.ItemSearchResults;
import org.artifactory.api.search.gavc.GavcSearchControls;
import org.artifactory.api.search.gavc.GavcSearchResult;
import org.artifactory.common.wicket.behavior.CssClass;
import org.artifactory.common.wicket.component.help.HelpBubble;
import org.artifactory.common.wicket.component.table.groupable.column.GroupableColumn;
import org.artifactory.webapp.wicket.actionable.column.ActionsColumn;
import org.artifactory.webapp.wicket.page.search.BaseSearchPage;
import org.artifactory.webapp.wicket.page.search.BaseSearchPanel;
import org.artifactory.webapp.wicket.page.search.actionable.ActionableGavcSearchResult;
import org.artifactory.webapp.wicket.page.search.actionable.ActionableSearchResult;

import java.util.List;

import static org.artifactory.common.wicket.util.ComponentPersister.setPersistent;

/**
 * Displays the GAVC searcher
 *
 * @author Noam Tenne
 */
public class GavcSearchPanel extends BaseSearchPanel<GavcSearchResult> {

    private GavcSearchControls searchControls;

    public GavcSearchPanel(final Page parent, String id) {
        super(parent, id);
    }

    @Override
    protected void validateSearchControls() {
        if (searchControls.isEmpty()) {
            throw new IllegalArgumentException("Please specify at least one search term.");
        }
        if (searchControls.isWildcardsOnly()) {
            throw new IllegalArgumentException("Search term containing only wildcards is not permitted");
        }
    }

    @Override
    protected void addSearchComponents(Form form) {
        add(new CssClass("gavc-panel"));
        searchControls = new GavcSearchControls();

        TextField groupIdField = new TextField<>("groupIdField",
                new PropertyModel<String>(searchControls, "groupId"));
        groupIdField.setOutputMarkupId(true);
        setPersistent(groupIdField);
        form.add(groupIdField);
        form.add(new HelpBubble("groupIdHelp", "The Group ID of the artifact. * and ? are accepted."));

        TextField artifactIdField = new TextField<>("artifactIdField",
                new PropertyModel<String>(searchControls, "artifactId"));
        artifactIdField.setOutputMarkupId(true);
        setPersistent(artifactIdField);
        form.add(artifactIdField);
        form.add(new HelpBubble("artifactIdHelp", "The Artifact ID of the artifact. * and ? are accepted."));

        TextField versionField = new TextField<>("versionField",
                new PropertyModel<String>(searchControls, "version"));
        setPersistent(versionField);
        versionField.setOutputMarkupId(true);
        form.add(versionField);
        form.add(new HelpBubble("versionHelp", "The version of the artifact. * and ? are accepted."));

        TextField classifierField = new TextField<>("classifierField",
                new PropertyModel<String>(searchControls, "classifier"));
        classifierField.setOutputMarkupId(true);
        setPersistent(classifierField);
        form.add(classifierField);
        form.add(new HelpBubble("classifierHelp", "The classifier of the artifact. * and ? are accepted."));
    }

    @Override
    protected GavcSearchControls getSearchControls() {
        return searchControls;
    }

    @Override
    protected Class<? extends BaseSearchPage> getMenuPageClass() {
        return GavcSearchPage.class;
    }

    @Override
    protected void addColumns(List<IColumn<ActionableSearchResult<GavcSearchResult>>> columns) {
        columns.add(new ActionsColumn<ActionableSearchResult<GavcSearchResult>>(""));

        columns.add(new BaseSearchPanel.ArtifactNameColumn());
        columns.add(new GroupableColumn<ActionableSearchResult<GavcSearchResult>>(
                Model.of("Group ID"), "searchResult.groupId", "searchResult.groupId"));
        columns.add(new GroupableColumn<ActionableSearchResult<GavcSearchResult>>(
                Model.of("Artifact ID"), "searchResult.artifactId", "searchResult.artifactId"));
        columns.add(new GroupableColumn<ActionableSearchResult<GavcSearchResult>>(
                Model.of("Version"), "searchResult.version", "searchResult.version"));
        columns.add(new GroupableColumn<ActionableSearchResult<GavcSearchResult>>(
                Model.of("Classifier"), "searchResult.classifier", "searchResult.classifier"));
        columns.add(new PropertyColumn<ActionableSearchResult<GavcSearchResult>>(
                Model.of("Repository"), "searchResult.repoKey", "searchResult.repoKey"));
    }

    @Override
    public String getSearchExpression() {
        return searchControls.getSearchExpression();
    }

    @Override
    protected ItemSearchResults<GavcSearchResult> searchArtifacts() {
        return search(searchControls);
    }

    @Override
    protected ItemSearchResults<GavcSearchResult> performLimitlessArtifactSearch() {
        GavcSearchControls controlsCopy = new GavcSearchControls(searchControls);
        controlsCopy.setLimitSearchResults(false);
        return search(controlsCopy);
    }

    @Override
    protected void onNoResults() {
        warnNoArtifacts(searchControls.getSearchExpression());
    }

    @Override
    protected ActionableSearchResult<GavcSearchResult> getActionableResult(GavcSearchResult searchResult) {
        return new ActionableGavcSearchResult(searchResult);
    }

    @Override
    protected boolean isLimitSearchResults() {
        return searchControls.isLimitSearchResults();
    }

    /**
     * Performs the search
     *
     * @param controls Search controls
     * @return List of search results
     */
    private ItemSearchResults<GavcSearchResult> search(GavcSearchControls controls) {
        return searchService.searchGavc(controls);
    }
}


text:
'use strict';
const toString  = Object.prototype.toString,
      keys      = Object.keys;

module.exports = Object.freeze({
    isString,
    isFunction,
    isArray,
    isArrayOfStrings,
    isObject,
    isRegExp,
    isUndefined,
    isNull,
    isEmpty,
    isEmptyArray,
    isEmptyObject,
    noop
});

function isString(arg) {
    return toString.call(arg) === '[object String]' ? true : false;
}

function isFunction(arg) {
    return toString.call(arg) === '[object Function]' ? true : false;
}

function isArray(arg) {
    return arg instanceof Array;
}

function isArrayOfStrings(arg) {
    return allItemsOf(arg, isString);
}

function allItemsOf(array, isType) {
    if (isArray(array)) {
        return array.every(isType);
    }
    return false;
}

function isObject(arg) {
    return toString.call(arg) === '[object Object]' ? true : false;
}

function isUndefined(arg) {
    return toString.call(arg) === '[object Undefined]' ? true : false;
}

function isNull(arg) {
    return toString.call(arg) === '[object Null]' ? true : false;
}

function isRegExp(arg) {
    return toString.call(arg) === '[object RegExp]' ? true : false;
}

function isEmpty(arg) {
    if (arg) {
        if (isObject(arg)) return isEmptyObject(arg);
        if (isArray(arg)) return isEmptyArray(arg);
        return false;
    }
    return true;
}

function isEmptyArray(arg) {
    return arg.length ? true : false;
}

function isEmptyObject(arg) {
    return keys(arg).length ? true : false;
}

function noop() {}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>MessageList (JADE 4.3.1 Sniffer Reference)</title>
<meta name="date" content="2013-12-04">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

jade.tools.sniffer

Class MessageList

java.lang.Object

jade.tools.sniffer.MessageList

All Implemented Interfaces:

java.io.Serializable

public class MessageList
extends java.lang.Object
implements java.io.Serializable

This is the list of the sniffed messages displayed on the Message Canvas as blue arrows.
 Implements Serializable interface for saving object in the binary snapshot file.

See Also:

Serialized Form

Constructor Summary

Constructors

Constructor and Description

MessageList()

Method Summary

Methods

Modifier and Type
Method and Description

void
addMessage(Message mess)

Adds a sniffed message to the list.

java.util.Iterator
getMessages()

Returns the messages vector

void
removeAllMessages()

Clear all messages in the vector.

void
removeMessages(java.lang.String agentName)

Removes a message from the vector

int
size()

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

MessageList

public MessageList()

Method Detail

addMessage

public void addMessage(Message mess)

Adds a sniffed message to the list.

Parameters:

mess - sniffed message to put in the vector

removeMessages

public void removeMessages(java.lang.String agentName)

Removes a message from the vector

Parameters:

agentName - name of the agent to remove from the vector

removeAllMessages

public void removeAllMessages()

Clear all messages in the vector.

getMessages

public java.util.Iterator getMessages()

Returns the messages vector

size

public int size()

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
require 'test_helper'

class MyController < ApplicationController
  include Devise::Controllers::InternalHelpers
end

class HelpersTest < ActionController::TestCase
  tests MyController

  def setup
    @mock_warden = OpenStruct.new
    @controller.request.env['warden'] = @mock_warden
    @controller.request.env['devise.mapping'] = Devise.mappings[:user]
  end

  test 'get resource name from env' do
    assert_equal :user, @controller.resource_name
  end

  test 'get resource class from env' do
    assert_equal User, @controller.resource_class
  end

  test 'get resource instance variable from env' do
    @controller.instance_variable_set(:@user, user = User.new)
    assert_equal user, @controller.resource
  end

  test 'set resource instance variable from env' do
    user = @controller.send(:resource_class).new
    @controller.send(:resource=, user)

    assert_equal user, @controller.send(:resource)
    assert_equal user, @controller.instance_variable_get(:@user)
  end

  test 'resources methods are not controller actions' do
    assert @controller.class.action_methods.empty?
  end

  test 'require no authentication tests current mapping' do
    @mock_warden.expects(:authenticated?).with(:user).returns(true)
    @mock_warden.expects(:user).with(:user).returns(User.new)
    @controller.expects(:redirect_to).with(root_path)
    @controller.send :require_no_authentication
  end

  test 'signed in resource returns signed in resource for current scope' do
    @mock_warden.expects(:authenticate).with(:scope => :user).returns(User.new)
    assert_kind_of User, @controller.signed_in_resource
  end

  test 'is a devise controller' do
    assert @controller.devise_controller?
  end

  test 'does not issue blank flash messages' do
    MyController.send(:public, :set_flash_message)
    I18n.stubs(:t).returns('   ')
    @controller.set_flash_message :notice, :send_instructions
    assert flash[:notice].nil?
    MyController.send(:protected, :set_flash_message)
  end

  test 'issues non-blank flash messages normally' do
    MyController.send(:public, :set_flash_message)
    I18n.stubs(:t).returns('non-blank')
    @controller.set_flash_message :notice, :send_instructions
    assert flash[:notice] == 'non-blank'
    MyController.send(:protected, :set_flash_message)
  end
end


text:
package io.advantageous.qbit.events;

import io.advantageous.qbit.Factory;
import io.advantageous.qbit.QBit;
import io.advantageous.qbit.events.impl.ConditionalEventConnector;
import io.advantageous.qbit.events.spi.EventConnector;
import io.advantageous.qbit.message.Event;
import io.advantageous.qbit.service.stats.StatsCollector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * Builds an event manager and allows you to specify connectors,
 * and connector predicates for said connector.
 */
public class EventManagerBuilder {

    public static EventConnector DEFAULT_NO_EVENT_CONNECTOR = event -> {
    };
    public static StatsCollector DEFAULT_NO_STATS_COLLECTOR = new StatsCollector() {
    };
    private final Logger logger = LoggerFactory.getLogger(EventManagerBuilder.class);
    private EventConnector eventConnector;
    private List<Predicate<Event<Object>>> eventConnectorPredicates = new ArrayList<>();
    private String name;
    private StatsCollector statsCollector;
    private Factory factory;

    public static EventManagerBuilder eventManagerBuilder() {
        return new EventManagerBuilder();
    }

    public Factory getFactory() {
        if (factory == null) {
            factory = QBit.factory();
        }
        return factory;
    }

    public EventManagerBuilder setFactory(Factory factory) {
        this.factory = factory;
        return this;
    }

    public StatsCollector getStatsCollector() {
        if (statsCollector == null) {
            logger.debug("No stats collector registered with event manager, using default NO OP stats collector");
            statsCollector = DEFAULT_NO_STATS_COLLECTOR;
        }
        return statsCollector;
    }

    public EventManagerBuilder setStatsCollector(StatsCollector statsCollector) {
        this.statsCollector = statsCollector;
        return this;
    }

    public String getName() {
        return name;
    }

    public EventManagerBuilder setName(String name) {
        this.name = name;
        return this;
    }

    public EventConnector getEventConnector() {
        if (eventConnector == null) {
            logger.debug("Event Connector is null for {} event bus, creating NoOp Event Connector", getName());
            eventConnector = DEFAULT_NO_EVENT_CONNECTOR;
        }
        return eventConnector;
    }

    public EventManagerBuilder setEventConnector(EventConnector eventConnector) {
        this.eventConnector = eventConnector;
        return this;
    }

    public List<Predicate<Event<Object>>> getEventConnectorPredicates() {
        if (eventConnectorPredicates == null) {
            eventConnectorPredicates = new ArrayList<>();
        }
        return eventConnectorPredicates;
    }

    public EventManagerBuilder setEventConnectorPredicates(List<Predicate<Event<Object>>> eventConnectorPredicates) {
        this.eventConnectorPredicates = eventConnectorPredicates;
        return this;
    }

    public EventManagerBuilder addEventConnectorPredicate(Predicate<Event<Object>> eventConnectorPredicate) {

        getEventConnectorPredicates().add(eventConnectorPredicate);
        return this;
    }

    public EventManager build() {
        return build(getName());
    }

    public EventManager build(final String name) {

        if (eventConnector == null) {
            return getFactory().createEventManager(name, getEventConnector(), getStatsCollector());
        } else {

            if (getEventConnectorPredicates().size() == 0) {
                return getFactory().createEventManager(name, getEventConnector(), getStatsCollector());
            } else {

                Predicate<Event<Object>> mainPredicate = getEventConnectorPredicates().get(0);

                for (int index = 1; index < eventConnectorPredicates.size(); index++) {
                    mainPredicate = mainPredicate.and(eventConnectorPredicates.get(index));
                }
                return getFactory().createEventManager(name,
                        new ConditionalEventConnector(mainPredicate, getEventConnector()), getStatsCollector());
            }

        }
    }

}