From b1b6f4700731c7cecef0a22ba7aec4e5bb287887 Mon Sep 17 00:00:00 2001 From: toorshia Date: Fri, 23 Sep 2016 00:42:42 +0200 Subject: [PATCH] Added prototype.destroy() --- examples/object-destroy.html | 75 ++++++++++++++++++++++ examples/text-renderer-2.html | 114 ++++++++++++++++++++++++++++++++++ justgage.js | 17 +++-- 3 files changed, 196 insertions(+), 10 deletions(-) create mode 100644 examples/object-destroy.html create mode 100644 examples/text-renderer-2.html diff --git a/examples/object-destroy.html b/examples/object-destroy.html new file mode 100644 index 0000000..e221181 --- /dev/null +++ b/examples/object-destroy.html @@ -0,0 +1,75 @@ + + + + + + Object destroy + + + + + +
+
+ Create object + +
+ + + + + + diff --git a/examples/text-renderer-2.html b/examples/text-renderer-2.html new file mode 100644 index 0000000..bee69e5 --- /dev/null +++ b/examples/text-renderer-2.html @@ -0,0 +1,114 @@ + + + + + + Custom Render Function + + + + +
+ Random Refresh + + + + + + diff --git a/justgage.js b/justgage.js index ba554cf..8963035 100644 --- a/justgage.js +++ b/justgage.js @@ -857,20 +857,11 @@ JustGage = function(config) { }; /** Refresh gauge level */ -JustGage.prototype.refresh = function(val, max, config) { +JustGage.prototype.refresh = function(val, max) { var obj = this; var displayVal, color, max = max || null; - if(config && (typeof config === "object")) { - for(var key in config) { - if(!config.hasOwnProperty(key)) { - continue; - } - obj.config[key] = config[key]; - } - } - // set new max if (max !== null) { obj.config.max = max; @@ -935,6 +926,7 @@ JustGage.prototype.refresh = function(val, max, config) { if (obj.config.reverse) { rvl = (obj.config.max * 1) + (obj.config.min * 1) - (obj.config.value * 1); } + obj.level.animate({ pki: [ rvl, @@ -971,6 +963,11 @@ JustGage.prototype.refresh = function(val, max, config) { obj, displayVal, color, max = null; }; +/** Update gauge object */ +JustGage.prototype.destroy = function() { + document.getElementById(this.config.id).innerHTML = ''; +}; + /** Generate shadow */ JustGage.prototype.generateShadow = function(svg, defs) {