PageSourceSearch

https://mstoryhub.com/plugin/mongtree/admin/assets/vendor/gauge/gauge.js

js mstoryhub.com collected 2026-09-30 12:09:25 UTC 24,225 bytes, 773 lines download raw bytes

1// Generated by CoffeeScript 1.6.3
2(function() {
3  var AnimatedText, AnimatedTextFactory, Bar, BaseDonut, BaseGauge, Donut, Gauge, GaugePointer, TextRenderer, ValueUpdater, addCommas, cutHex, formatNumber, mergeObjects, secondsToString, updateObjectValues, _ref, _ref1,
4    __hasProp = {}.hasOwnProperty,
5    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
7  (function() {
8    var browserRequestAnimationFrame, isCancelled, lastId, vendor, vendors, _i, _len;
9    vendors = ['ms', 'moz', 'webkit', 'o'];
10    for (_i = 0, _len = vendors.length; _i < _len; _i++) {
11      vendor = vendors[_i];
12      if (window.requestAnimationFrame) {
13        break;
14      }
15      window.requestAnimationFrame = window[vendor + 'RequestAnimationFrame'];
16      window.cancelAnimationFrame = window[vendor + 'CancelAnimationFrame'] || window[vendor + 'CancelRequestAnimationFrame'];
17    }
18    browserRequestAnimationFrame = null;
19    lastId = 0;
20    isCancelled = {};
21    if (!requestAnimationFrame) {
22      window.requestAnimationFrame = function(callback, element) {
23        var currTime, id, lastTime, timeToCall;
24        currTime = new Date().getTime();
25        timeToCall = Math.max(0, 16 - (currTime - lastTime));
26        id = window.setTimeout(function() {
27          return callback(currTime + timeToCall);
28        }, timeToCall);
29        lastTime = currTime + timeToCall;
30        return id;
31      };
32      return window.cancelAnimationFrame = function(id) {
33        return clearTimeout(id);
34      };
35    } else if (!window.cancelAnimationFrame) {
36      browserRequestAnimationFrame = window.requestAnimationFrame;
37      window.requestAnimationFrame = function(callback, element) {
38        var myId;
39        myId = ++lastId;
40        browserRequestAnimationFrame(function() {
41          if (!isCancelled[myId]) {
42            return callback();
43          }
44        }, element);
45        return myId;
46      };
47      return window.cancelAnimationFrame = function(id) {
48        return isCancelled[id] = true;
49      };
50    }
51  })();
52
53  String.prototype.hashCode = function() {
54    var char, hash, i, _i, _ref;
55    hash = 0;
56    if (this.length === 0) {
57      return hash;
58    }
59    for (i = _i = 0, _ref = this.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
60      char = this.charCodeAt(i);
61      hash = ((hash << 5) - hash) + char;
62      hash = hash & hash;
63    }
64    return hash;
65  };
66
67  secondsToString = function(sec) {
68    var hr, min;
69    hr = Math.floor(sec / 3600);
70    min = Math.floor((sec - (hr * 3600)) / 60);
71    sec -= (hr * 3600) + (min * 60);
72    sec += '';
73    min += '';
74    while (min.length < 2) {
75      min = '0' + min;
76    }
77    while (sec.length < 2) {
78      sec = '0' + sec;
79    }
80    hr = hr ? hr + ':' : '';
81    return hr + min + ':' + sec;
82  };
83
84  formatNumber = function(num) {
85    return addCommas(num.toFixed(0));
86  };
87
88  updateObjectValues = function(obj1, obj2) {
89    var key, val;
90    for (key in obj2) {
91      if (!__hasProp.call(obj2, key)) continue;
92      val = obj2[key];
93      obj1[key] = val;
94    }
95    return obj1;
96  };
97
98  mergeObjects = function(obj1, obj2) {
99    var key, out, val;
100    out = {};
101    for (key in obj1) {
102      if (!__hasProp.call(obj1, key)) continue;
103      val = obj1[key];
104      out[key] = val;
105    }
106    for (key in obj2) {
107      if (!__hasProp.call(obj2, key)) continue;
108      val = obj2[key];
109      out[key] = val;
110    }
111    return out;
112  };
113
114  addCommas = function(nStr) {
115    var rgx, x, x1, x2;
116    nStr += '';
117    x = nStr.split('.');
118    x1 = x[0];
119    x2 = '';
120    if (x.length > 1) {
121      x2 = '.' + x[1];
122    }
123    rgx = /(\d+)(\d{3})/;
124    while (rgx.test(x1)) {
125      x1 = x1.replace(rgx, '$1' + ',' + '$2');
126    }
127    return x1 + x2;
128  };
129
130  cutHex = function(nStr) {
131    if (nStr.charAt(0) === "#") {
132      return nStr.substring(1, 7);
133    }
134    return nStr;
135  };
136
137  ValueUpdater = (function() {
138    ValueUpdater.prototype.animationSpeed = 32;
139
140    function ValueUpdater(addToAnimationQueue, clear) {
141      if (addToAnimationQueue == null) {
142        addToAnimationQueue = true;
143      }
144      this.clear = clear != null ? clear : true;
145      if (addToAnimationQueue) {
146        AnimationUpdater.add(this);
147      }
148    }
149
150    ValueUpdater.prototype.update = function(force) {
151      var diff;
152      if (force == null) {
153        force = false;
154      }
155      if (force || this.displayedValue !== this.value) {
156        if (this.ctx && this.clear) {
157          this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
158        }
159        diff = this.value - this.displayedValue;
160        if (Math.abs(diff / this.animationSpeed) <= 0.001) {
161          this.displayedValue = this.value;
162        } else {
163          this.displayedValue = this.displayedValue + diff / this.animationSpeed;
164        }
165        this.render();
166        return true;
167      }
168      return false;
169    };
170
171    return ValueUpdater;
172
173  })();
174
175  BaseGauge = (function(_super) {
176    __extends(BaseGauge, _super);
177
178    function BaseGauge() {
179      _ref = BaseGauge.__super__.constructor.apply(this, arguments);
180      return _ref;
181    }
182
183    BaseGauge.prototype.displayScale = 1;
184
185    BaseGauge.prototype.setTextField = function(textField) {
186      return this.textField = textField instanceof TextRenderer ? textField : new TextRenderer(textField);
187    };
188
189    BaseGauge.prototype.setMinValue = function(minValue, updateStartValue) {
190      var gauge, _i, _len, _ref1, _results;
191      this.minValue = minValue;
192      if (updateStartValue == null) {
193        updateStartValue = true;
194      }
195      if (updateStartValue) {
196        this.displayedValue = this.minValue;
197        _ref1 = this.gp || [];
198        _results = [];
199        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
200          gauge = _ref1[_i];
201          _results.push(gauge.displayedValue = this.minValue);
202        }
203        return _results;
204      }
205    };
206
207    BaseGauge.prototype.setOptions = function(options) {
208      if (options == null) {
209        options = null;
210      }
211      this.options = mergeObjects(this.options, options);
212      if (this.textField) {
213        this.textField.el.style.fontSize = options.fontSize + 'px';
214      }
215      if (this.options.angle > .5) {
216        this.gauge.options.angle = .5;
217      }
218      this.configDisplayScale();
219      return this;
220    };
221
222    BaseGauge.prototype.configDisplayScale = function() {
223      var backingStorePixelRatio, devicePixelRatio, height, prevDisplayScale, width;
224      prevDisplayScale = this.displayScale;
225      if (this.options.highDpiSupport === false) {
226        delete this.displayScale;
227      } else {
228        devicePixelRatio = window.devicePixelRatio || 1;
229        backingStorePixelRatio = this.ctx.webkitBackingStorePixelRatio || this.ctx.mozBackingStorePixelRatio || this.ctx.msBackingStorePixelRatio || this.ctx.oBackingStorePixelRatio || this.ctx.backingStorePixelRatio || 1;
230        this.displayScale = devicePixelRatio / backingStorePixelRatio;
231      }
232      if (this.displayScale !== prevDisplayScale) {
233        width = this.canvas.G__width || this.canvas.width;
234        height = this.canvas.G__height || this.canvas.height;
235        this.canvas.width = width * this.displayScale;
236        this.canvas.height = height * this.displayScale;
237        this.canvas.style.width = "" + width + "px";
238        this.canvas.style.height = "" + height + "px";
239        this.canvas.G__width = width;
240        this.canvas.G__height = height;
241      }
242      return this;
243    };
244
245    return BaseGauge;
246
247  })(ValueUpdater);
248
249  TextRenderer = (function() {
250    function TextRenderer(el) {
251      this.el = el;
252    }
253
254    TextRenderer.prototype.render = function(gauge) {
255      return this.el.innerHTML = formatNumber(gauge.displayedValue);
256    };
257
258    return TextRenderer;
259
260  })();
261
262  AnimatedText = (function(_super) {
263    __extends(AnimatedText, _super);
264
265    AnimatedText.prototype.displayedValue = 0;
266
267    AnimatedText.prototype.value = 0;
268
269    AnimatedText.prototype.setVal = function(value) {
270      return this.value = 1 * value;
271    };
272
273    function AnimatedText(elem, text) {
274      this.elem = elem;
275      this.text = text != null ? text : false;
276      this.value = 1 * this.elem.innerHTML;
277      if (this.text) {
278        this.value = 0;
279      }
280    }
281
282    AnimatedText.prototype.render = function() {
283      var textVal;
284      if (this.text) {
285        textVal = secondsToString(this.displayedValue.toFixed(0));
286      } else {
287        textVal = addCommas(formatNumber(this.displayedValue));
288      }
289      return this.elem.innerHTML = textVal;
290    };
291
292    return AnimatedText;
293
294  })(ValueUpdater);
295
296  AnimatedTextFactory = {
297    create: function(objList) {
298      var elem, out, _i, _len;
299      out = [];
300      for (_i = 0, _len = objList.length; _i < _len; _i++) {
301        elem = objList[_i];
302        out.push(new AnimatedText(elem));
303      }
304      return out;
305    }
306  };
307
308  GaugePointer = (function(_super) {
309    __extends(GaugePointer, _super);
310
311    GaugePointer.prototype.displayedValue = 0;
312
313    GaugePointer.prototype.value = 0;
314
315    GaugePointer.prototype.options = {
316      strokeWidth: 0.035,
317      length: 0.1,
318      color: "#000000"
319    };
320
321    function GaugePointer(gauge) {
322      this.gauge = gauge;
323      this.ctx = this.gauge.ctx;
324      this.canvas = this.gauge.canvas;
325      GaugePointer.__super__.constructor.call(this, false, false);
326      this.setOptions();
327    }
328
329    GaugePointer.prototype.setOptions = function(options) {
330      if (options == null) {
331        options = null;
332      }
333      updateObjectValues(this.options, options);
334      this.length = this.canvas.height * this.options.length;
335      this.strokeWidth = this.canvas.height * this.options.strokeWidth;
336      this.maxValue = this.gauge.maxValue;
337      this.minValue = this.gauge.minValue;
338      this.animationSpeed = this.gauge.animationSpeed;
339      return this.options.angle = this.gauge.options.angle;
340    };
341
342    GaugePointer.prototype.render = function() {
343      var angle, centerX, centerY, endX, endY, startX, startY, x, y;
344      angle = this.gauge.getAngle.call(this, this.displayedValue);
345      centerX = this.canvas.width / 2;
346      centerY = this.canvas.height * 0.9;
347      x = Math.round(centerX + this.length * Math.cos(angle));
348      y = Math.round(centerY + this.length * Math.sin(angle));
349      startX = Math.round(centerX + this.strokeWidth * Math.cos(angle - Math.PI / 2));
350      startY = Math.round(centerY + this.strokeWidth * Math.sin(angle - Math.PI / 2));
351      endX = Math.round(centerX + this.strokeWidth * Math.cos(angle 
351+ Math.PI / 2));
352      endY = Math.round(centerY + this.strokeWidth * Math.sin(angle + Math.PI / 2));
353      this.ctx.fillStyle = this.options.color;
354      this.ctx.beginPath();
355      this.ctx.arc(centerX, centerY, this.strokeWidth, 0, Math.PI * 2, true);
356      this.ctx.fill();
357      this.ctx.beginPath();
358      this.ctx.moveTo(startX, startY);
359      this.ctx.lineTo(x, y);
360      this.ctx.lineTo(endX, endY);
361      return this.ctx.fill();
362    };
363
364    return GaugePointer;
365
366  })(ValueUpdater);
367
368  Bar = (function() {
369    function Bar(elem) {
370      this.elem = elem;
371    }
372
373    Bar.prototype.updateValues = function(arrValues) {
374      this.value = arrValues[0];
375      this.maxValue = arrValues[1];
376      this.avgValue = arrValues[2];
377      return this.render();
378    };
379
380    Bar.prototype.render = function() {
381      var avgPercent, valPercent;
382      if (this.textField) {
383        this.textField.text(formatNumber(this.value));
384      }
385      if (this.maxValue === 0) {
386        this.maxValue = this.avgValue * 2;
387      }
388      valPercent = (this.value / this.maxValue) * 100;
389      avgPercent = (this.avgValue / this.maxValue) * 100;
390      $(".bar-value", this.elem).css({
391        "width": valPercent + "%"
392      });
393      return $(".typical-value", this.elem).css({
394        "width": avgPercent + "%"
395      });
396    };
397
398    return Bar;
399
400  })();
401
402  Gauge = (function(_super) {
403    __extends(Gauge, _super);
404
405    Gauge.prototype.elem = null;
406
407    Gauge.prototype.value = [20];
408
409    Gauge.prototype.maxValue = 80;
410
411    Gauge.prototype.minValue = 0;
412
413    Gauge.prototype.displayedAngle = 0;
414
415    Gauge.prototype.displayedValue = 0;
416
417    Gauge.prototype.lineWidth = 40;
418
419    Gauge.prototype.paddingBottom = 0.1;
420
421    Gauge.prototype.percentColors = null;
422
423    Gauge.prototype.options = {
424      colorStart: "#6fadcf",
425      colorStop: void 0,
426      gradientType: 0,
427      strokeColor: "#e0e0e0",
428      pointer: {
429        length: 0.8,
430        strokeWidth: 0.035
431      },
432      angle: 0.15,
433      lineWidth: 0.44,
434      fontSize: 40,
435      limitMax: false
436    };
437
438    function Gauge(canvas) {
439      this.canvas = canvas;
440      Gauge.__super__.constructor.call(this);
441      this.percentColors = null;
442      if (typeof G_vmlCanvasManager !== 'undefined') {
443        this.canvas = window.G_vmlCanvasManager.initElement(this.canvas);
444      }
445      this.ctx = this.canvas.getContext('2d');
446      this.gp = [new GaugePointer(this)];
447      this.setOptions();
448      this.render();
449    }
450
451    Gauge.prototype.setOptions = function(options) {
452      var gauge, _i, _len, _ref1;
453      if (options == null) {
454        options = null;
455      }
456      Gauge.__super__.setOptions.call(this, options);
457      this.configPercentColors();
458      this.lineWidth = this.canvas.height * (1 - this.paddingBottom) * this.options.lineWidth;
459      this.radius = this.canvas.height * (1 - this.paddingBottom) - this.lineWidth;
460      this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
461      this.render();
462      _ref1 = this.gp;
463      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
464        gauge = _ref1[_i];
465        gauge.setOptions(this.options.pointer);
466        gauge.render();
467      }
468      return this;
469    };
470
471    Gauge.prototype.configPercentColors = function() {
472      var bval, gval, i, rval, _i, _ref1, _results;
473      this.percentColors = null;
474      if (this.options.percentColors !== void 0) {
475        this.percentColors = new Array();
476        _results = [];
477        for (i = _i = 0, _ref1 = this.options.percentColors.length - 1; 0 <= _ref1 ? _i <= _ref1 : _i >= _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
478          rval = parseInt((cutHex(this.options.percentColors[i][1])).substring(0, 2), 16);
479          gval = parseInt((cutHex(this.options.percentColors[i][1])).substring(2, 4), 16);
480          bval = parseInt((cutHex(this.options.percentColors[i][1])).substring(4, 6), 16);
481          _results.push(this.percentColors[i] = {
482            pct: this.options.percentColors[i][0],
483            color: {
484              r: rval,
485              g: gval,
486              b: bval
487            }
488          });
489        }
490        return _results;
491      }
492    };
493
494    Gauge.prototype.set = function(value) {
495      var i, max_hit, val, _i, _j, _len, _ref1;
496      if (!(value instanceof Array)) {
497        value = [value];
498      }
499      if (value.length > this.gp.length) {
500        for (i = _i = 0, _ref1 = value.length - this.gp.length; 0 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
501          this.gp.push(new GaugePointer(this));
502        }
503      }
504      i = 0;
505      max_hit = false;
506      for (_j = 0, _len = value.length; _j < _len; _j++) {
507        val = value[_j];
508        if (val > this.maxValue) {
509          this.maxValue = this.value * 1.1;
510          max_hit = true;
511        }
512        this.gp[i].value = val;
513        this.gp[i++].setOptions({
514          maxValue: this.maxValue,
515          angle: this.options.angle
516        });
517      }
518      this.value = value[value.length - 1];
519      if (max_hit) {
520        if (!this.options.limitMax) {
521          return AnimationUpdater.run();
522        }
523      } else {
524        return AnimationUpdater.run();
525      }
526    };
527
528    Gauge.prototype.getAngle = function(value) {
529      return (1 + this.options.angle) * Math.PI + ((value - this.minValue) / (this.maxValue - this.minValue)) * (1 - this.options.angle * 2) * Math.PI;
530    };
531
532    Gauge.prototype.getColorForPercentage = function(pct, grad) {
533      var color, endColor, i, rangePct, startColor, _i, _ref1;
534      if (pct === 0) {
535        color = this.percentColors[0].color;
536      } else {
537        color = this.percentColors[this.percentColors.length - 1].color;
538        for (i = _i = 0, _ref1 = this.percentColors.length - 1; 0 <= _ref1 ? _i <= _ref1 : _i >= _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
539          if (pct <= this.percentColors[i].pct) {
540            if (grad === true) {
541              startColor = this.percentColors[i - 1];
542              endColor = this.percentColors[i];
543              rangePct = (pct - startColor.pct) / (endColor.pct - startColor.pct);
544              color = {
545                r: Math.floor(startColor.color.r * (1 - rangePct) + endColor.color.r * rangePct),
546                g: Math.floor(startColor.color.g * (1 - rangePct) + endColor.color.g * rangePct),
547                b: Math.floor(startColor.color.b * (1 - rangePct) + endColor.color.b * rangePct)
548              };
549            } else {
550              color = this.percentColors[i].color;
551            }
552            break;
553          }
554        }
555      }
556      return 'rgb(' + [color.r, color.g, color.b].join(',') + ')';
557    };
558
559    Gauge.prototype.getColorForValue = function(val, grad) {
560      var pct;
561      pct = (val - this.minValue) / (this.maxValue - this.minValue);
562      return this.getColorForPercentage(pct, grad);
563    };
564
565    Gauge.prototype.render = function() {
566      var displayedAngle, fillStyle, gauge, h, w, _i, _len, _ref1, _results;
567      w = this.canvas.width / 2;
568      h = this.canvas.height * (1 - this.paddingBottom);
569      displayedAngle = this.getAngle(this.displayedValue);
570      if (this.textField) {
571        this.textField.render(this);
572      }
573      this.ctx.lineCap = "butt";
574      if (this.options.customFillStyle !== void 0) {
575        fillStyle = this.options.customFillStyle(this);
576      } else if (this.percentColors !== null) {
577        fillStyle = this.getColorForValue(this.displayedValue, true);
578      } else if (this.options.colorStop !== void 0) {
579        if (this.options.gradientType === 0) {
580          fillStyle = this.ctx.createRadialGradient(w, h, 9, w, h, 70);
581        } else {
582          fillStyle = this.ctx.createLinearGradient(0, 0, w, 0);
583        }
584        fillStyle.addColorStop(0, this.options.colorStart);
585        fillStyle.addColorStop(1, this.options.colorStop);
586      } else {
587        fillStyle = this.options.colorStart;
588      }
589      this.ctx.strokeStyle = fillStyle;
590      this.ctx.beginPath();
591      this.ctx.arc(w, h, this.radius, (1 + this.options.angle) * Math.PI, displayedAngle, false);
592      this.ctx.lineWidth = this.lineWidth;
593      this.ctx.stroke();
594      this.ctx.strokeStyle = this.options.strokeColor;
595      this.ctx.beginPath();
596      this.ctx.arc(w, h, this.radius, displayedAngle, (2 - this.options.angle) * Math.PI, false);
597      this.ctx.stroke();
598      _ref1 = this.gp;
599      _results = [];
600      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
601        gauge = _ref1[_i];
602        _results.push(gauge.update(true));
603      }
604      return _results;
605    };
606
607    return Gauge;
608
609  })(BaseGauge);
610
611  BaseDonut = (function(_super) {
612    __extends(BaseDonut, _super);
613
614    BaseDonut.prototype.lineWidth = 15;
615
616    BaseDonut.prototype.displayedValue = 0;
617
618    BaseDonut.prototype.value = 33;
619
620    BaseDonut.prototype.maxValue = 80;
621
622    BaseDonut.prototype.minValue = 0;
623
624    BaseDonut.prototype.options = {
625      lineWidth: 0.10,
626      colorStart: "#6f6ea0",
627      colorStop: "#c0c0db",
628      strokeColor: "#eeeeee",
629      shadowColor: "#d5d5d5",
630      angle: 0.35
631    };
632
633    function BaseDonut(canvas) {
634      this.canvas = canvas;
635      BaseDonut.__super__.constructor.call(this);
636      if (typeof G_vmlCanvasManager !== 'undefined') {
637        this.canvas = window.G_vmlCanvasManager.initElement(this.canvas);
638      }
639      this.ctx = this.canvas.getContext('2d');
640      this.setOptions();
641      this.render();
642    }
643
644    BaseDonut.prototype.getAngle = function(value) {
645      return (1 - this.options.angle) * Math.PI + ((value - this.minValue) / (this.maxValue - this.minValue)) * ((2 + this.options.angle) - (1 - this.options.angle)) * Math.PI;
646    };
647
648    BaseDonut.prototype.setOptions = function(options) {
649      if (options == null) {
650        options = null;
651      }
652      BaseDonut.__super__.setOptions.call(this, options);
653      this.lineWidth = this.canvas.height * this.options.lineWidth;
654      this.radius = this.canvas.height / 2 - this.lineWidth / 2;
655      return this;
656    };
657
658    BaseDonut.prototype.set = function(value) {
659      this.value = value;
660      if (this.value > this.maxValue) {
661        this.maxValue = this.value * 1.1;
662      }
663      return AnimationUpdater.run();
664    };
665
666    BaseDonut.prototype.render = function() {
667      var displayedAngle, grdFill, h, start, stop, w;
668      displayedAngle = this.getAngle(this.displayedValue);
669      w = this.canvas.width / 2;
670      h = this.canvas.height / 2;
671      if (this.textField) {
672        this.textField.render(this);
673      }
674      grdFill = this.ctx.createRadialGradient(w, h, 39, w, h, 70);
675      grdFill.addColorStop(0, this.options.colorStart);
676      grdFill.addColorStop(1, this.options.colorStop);
677      start = this.radius - this.lineWidth / 2;
678      stop = this.radius + this.lineWidth / 2;
679      this.ctx.strokeStyle = this.options.strokeColor;
680      this.ctx.beginPath();
681      this.ctx.arc(w, h, this.radius, (1 - this.options.angle) * Math.PI, (2 + this.options.angle) * Math.PI, false);
682      this.ctx.lineWidth = this.lineWidth;
683      this.ctx.lineCap = "round";
684      this.ctx.stroke();
685      this.ctx.strokeStyle = grdFill;
686      this.ctx.beginPath();
687      this.ctx.arc(w, h, this.radius, (1 - this.options.angle) * Math.PI, displayedAngle, false);
688      return this.ctx.stroke();
689    };
690
691    return BaseDonut;
692
693  })(BaseGauge);
694
695  Donut = (function(_super) {
696    __extends(Donut, _super);
697
698    function Donut() {
699      _ref1 = Donut.__super__.constructor.apply(this, arguments);
700      return _ref1;
701    }
702
703    Donut.prototype.strokeGradient = function(w, h, start, stop) {
704      var grd;
705      grd = this.ctx.createRadialGradient(w, h, start, w, h, stop);
706      grd.addColorStop(0, this.options.shadowColor);
707      grd.addColorStop(0.12, this.options._orgStrokeColor);
708      grd.addColorStop(0.88, this.options._orgStrokeColor);
709      grd.addColorStop(1, this.options.shadowColor);
710      return grd;
711    };
712
713    Donut.prototype.setOptions = function(options) {
714      var h, start, stop, w;
715      if (options == null) {
716        options = null;
717      }
718      Donut.__super__.setOptions.call(this, options);
719      w = this.canvas.width / 2;
720      h = this.canvas.height / 2;
721      start = this.radius - this.lineWidth / 2;
722      stop = this.radius + this.lineWidth / 2;
723      this.options._orgStrokeColor = this.options.strokeColor;
724      this.options.strokeColor = this.strokeGradient(w, h, start, stop);
725      return this;
726    };
727
728    return Donut;
729
730  })(BaseDonut);
731
732  window.AnimationUpdater = {
733    elements: [],
734    animId: null,
735    addAll: function(list) {
736      var elem, _i, _len, _results;
737      _results = [];
738      for (_i = 0, _len = list.length; _i < _len; _i++) {
739        elem = list[_i];
740        _results.push(AnimationUpdater.elements.push(elem));
741      }
742      return _results;
743    },
744    add: function(object) {
745      return AnimationUpdater.elements.push(object);
746    },
747    run: function() {
748      var animationFinished, elem, _i, _len, _ref2;
749      animationFinished = true;
750      _ref2 = AnimationUpdater.elements;
751      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
752        elem = _ref2[_i];
753        if (elem.update()) {
754          animationFinished = false;
755        }
756      }
757      if (!animationFinished) {
758        return AnimationUpdater.animId = requestAnimationFrame(AnimationUpdater.run);
759      } else {
760        return cancelAnimationFrame(AnimationUpdater.animId);
761      }
762    }
763  };
764
765  window.Gauge = Gauge;
766
767  window.Donut = Donut;
768
769  window.BaseDonut = BaseDonut;
770
771  window.TextRenderer = TextRenderer;
772
773}).call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.