dj
Run
Go PRO
Code panel options
Change code languages, preprocessors and plugins
HTML
JavaScript
CSS
Language
HTML
HAML
Doctype
XHTML 1.0 Strict
XHTML 1.0 Transitional
HTML 5
HTML 4.01 Strict
HTML 4.01 Transitional
HTML 4.01 Frameset
Body tag
Language
JavaScript
CoffeeScript
JavaScript 1.7
Babel + JSX
TypeScript
CoffeeScript 2
Vue
React
Preact
Extensions
Alpine.js 2.1.2
AngularJS 1.1.1
AngularJS 1.2.1
AngularJS 1.4.8
AngularJS 2.0.0-alpha.47
Bonsai 0.4.1
Brick edge
CreateJS 2013.09.25
CreateJS 2015.05.21
D3 3.x
D3 4.13.0
D3 5.9.2
Dojo (nightly)
Dojo 1.4.8
Dojo 1.5.6
Dojo 1.6.5
Dojo 1.7.12
Dojo 1.8.14
Dojo 1.9.11
Dojo 1.10.8
Dojo 1.11.4
Dojo 1.12.2
Ember (latest)
Enyo (nightly)
Enyo 2.0.1
Enyo 2.1
Enyo 2.2.0
Enyo 2.4.0
Enyo 2.5.1
Enyo 2.7.0
ExtJS 3.1.0
ExtJS 3.4.0
ExtJS 4.1.0
ExtJS 4.1.1
ExtJS 4.2.0
ExtJS 5.0.0
ExtJS 5.1.0
ExtJS 6.2.0
FabricJS 1.5.0
FabricJS 1.7.7
FabricJS 1.7.15
FabricJS 1.7.20
Inferno 1.0.0-beta9
JSBlocks (edge)
KineticJS 4.0.5
KineticJS 4.3.1
Knockout.js 2.0.0
Knockout.js 2.1.0
Knockout.js 2.2.1
Knockout.js 2.3.0
Knockout.js 3.0.0
Knockout.js 3.4.2
Lo-Dash 2.2.1
Minified 1.0 beta1
MithrilJS 0.2.0
MithrilJS 1.1.6
Mootools (nightly)
Mootools 1.3.2
Mootools 1.3.2 (compat)
Mootools 1.4.5
Mootools 1.4.5 (compat)
Mootools 1.5.1
Mootools 1.5.2
Mootools 1.5.2 (compat)
Mootools 1.6.0
Mootools 1.6.0 (compat)
No-Library (pure JS)
OpenUI5 (latest, mobile)
Paper.js 0.22
Pixi 3.0.11
Pixi 4.0.0
Processing.js 1.2.3
Processing.js 1.3.6
Processing.js 1.4.1
Processing.js 1.4.7
Prototype 1.6.1.0
Prototype 1.7.3
RactiveJS 0.7.3
Raphael 1.4
Raphael 1.5.2
Raphael 2.1.0
React 0.3.2
React 0.4.0
React 0.8.0
React 0.9.0
React 0.14.3
RightJS 2.1.1
RightJS 2.3.1
Riot 3.7.4
Shipyard (nightly)
Shipyard 0.2
Thorax 2.0.0rc3
Thorax 2.0.0rc6
Three.js r54
Three.js 105
Underscore 1.3.3
Underscore 1.4.3
Underscore 1.4.4
Underscore 1.8.3
Vue (edge)
Vue 1.0.12
Vue 2.2.1
WebApp Install 0.1
XTK edge
YUI 2.8.0r4
YUI 3.5.0
YUI 3.6.0
YUI 3.7.3
YUI 3.8.0
YUI 3.10.1
YUI 3.14.0
YUI 3.16.0
YUI 3.17.2
Zepto 1.0rc1
jQuery (edge)
jQuery 1.5.2
jQuery 1.9.1
jQuery 2.1.3
jQuery 2.2.4
jQuery 3.2.1
jQuery 3.3.1
jQuery 3.4.1
jQuery Slim 3.2.1
jQuery Slim 3.3.1
jQuery Slim 3.4.1
jTypes 2.1.0
qooxdoo 2.0.3
qooxdoo 2.1
svg.js 2.6.5
svg.js 2.7.1
svg.js 3.0.5
jQuery Lint
jQuery UI 1.8.9
script
attribute
Language
CSS
SCSS
SASS
PostCSS (Stage 0+)
PostCSS (Stage 3+)
Tailwind CSS
Reset CSS
The default implimentation. <br /> <meter min="0" low="25" value="50" optimum="50" high="75" max="100" title="Units">Units </meter><br /> A meter with the uiMeter applied to it. <meter class="testM" min="0" low="25" value="50" optimum="50" high="75" max="100" title="Units">Testing</meter> A div with uiMeter applied to it. <div class="testM" min="0" low="25" value="50" optimum="50" high="75" max="100" title="Units"></div> <hr /> These controls are used to adjust the settings of the meters above. <ul class="sliders"> <li> <div class="slider" id="smin" title="Min" data-val="0" data-for="min"></div> <input type="checkbox" title="disable min" data-attr="min" /><label id="lsmin">min 0</label> </li><li> <div class="slider" id="slow" title="Low" data-val="25" data-for="low"></div> <input type="checkbox" title="disable low" data-attr="low" /><label id="lslow">low 25</label><br /> </li><li> <div class="slider" id="svalue" title="Value" data-val="50" data-for="value" ></div> <input type="checkbox" title="disable value" data-attr="value"/><label id="lsvalue">value 50</label><br /> </li><li> <div class="slider" id="soptimum" title="Optimum" data-val="50" data-for="optimum" ></div> <input type="checkbox" title="disable optimum" data-attr="optimum"/><label id="lsoptimum">optimum 50</label><br /> </li><li> <div class="slider" id="shigh" title="High" data-val="75" data-for="high" ></div> <input type="checkbox" title="disable high" data-attr="high"/><label for="shigh" id="lshigh">high 75</label><br /> </li><li> <div class="slider" id="smax" title="Max" data-val="100" data-for="max" ></div> <input type="checkbox" title="disable max" data-attr="max"/><label id="lsmax">max 100</label><br /> </li></ul> <span id="addProperty">Add Property</span><br/> <div id="divDialog" title="Add meter property"> <label for="inpName">Property Name: </label><br /><input type="text" id="inpName" /><br /> <label for="inpAdjust">Adjust:</label><br /> <select id="inpAdjust"> <option value="margin-left" selected="true">Default margin-left</option> <option value="width">width</option> <option value="height">height</option> <option value="margin-left">margin-right</option> </select> </div>
meter { width: 50%; } .slider {width: 50%} .testM { width: 50%;} .uiMeter { position: relative; width: 50%; height: 1em; border: 1px solid black; padding: 0 0 0 0; margin: 0 0 0 0; background-color: silver; } .uiMeter meter { display: none; } .uiMeter .meterElm { border-right: 2px solid black; bottom: 0px; display: inline; height: 1em; padding: 0 0 0 0; position: absolute; left: 0px; margin: 0 0 0 0; width: 0px; z-index: 1 } .uiMeter .value{ background-color: green; border-right: 0px solid black; top: 0px; z-index: 0 } .uiMeter .min{ } .uiMeter .low{ } .uiMeter .optimum{ } .uiMeter .high{ } .uiMeter .max{ } .sliders li { margin: 2px; padding: 3px;} #addProperty { display: none;} #divDialog {display: none} #divDialog input, #divDialog select {width: 80%;}
// this code is release under MIT licesnes. With the additional clause that it cannot be used for evil. (function($) { $.widget("ui.meter", { options: { wrapper: '<div />', attribs: [{ name: 'value', adjust: "width"}, { name: 'low'}, { name: 'high'}, { name: 'optimum'}, { name: 'min'}, { name: 'max'}], valueAttrib: 'value', attrWrapper: '<div />', adjust: "margin-left", attrName: "name" }, defattribs: ['adjust', 'css', 'class'], _create: function() { var $self = this, elm = $($self.element), uiMeter = $($self.uiMeter = $($self.options.wrapper)).addClass("uiMeter"); elm.wrap(uiMeter); }, min: 0, max: 0, _init: function(){ if (this.options.attribs === undefined) { return; } var $self = this, meter = $($self.element), uiMeter = meter.closest('.uiMeter'), elms = $self.options.attribs, l = elms.length, awrapp = $self.options.attrWrapper || '<div>'; uiMeter.children(".meterElm").addClass("meterremove"); for(var i = 0; i<l;i++) { var elm = elms[i]; if (elm[$self.options.attrName] === undefined) { continue; } var attrName = elm[$self.options.attrName], v = elm.value; if (v===undefined){ v=meter.attr(attrName);} if (v===undefined || isNaN(v)){ continue; } if (this.min>v){this.min=v;} if (this.max<v){ this.max=v;} var meterElm = uiMeter.find('.meterElem.' + attrName), adjust = elm.adjust || $self.options.adjust; if (meterElm.length === 0){ meterElm = $($self.options.attrWrapper); } meterElm.data({'value': v, 'name': attrName, 'adj': adjust}) .addClass('meterElm ' + attrName) .removeClass('meterremove') .appendTo(uiMeter); } var diff = this.max-this.min; uiMeter.children(".meterremove").remove().end() .find('.meterElm').each(function(){ var $t = $(this); var per = (($t.data('value')/diff)*100) + '%'; $t.css($t.data('adj'), per) .attr("title", $t.data('name') + ' ' + $t.data('value')); }); }, destroy: function(){ $self = this; $self.element.closest('.uiMeter').find('.meterElem').remove().end().end().unwrap(); } }); })(jQuery); // Items below this line are not used in the example yet. //**************************************************************************************************************** $("#addProperty").button().click(function() { $("#divDialog").dialog("open"); }); $("#divDialog").dialog({ autoOpen: false }); function addSlider(name, adjust) { } $("#inpName").bind("keyup change", function() { this.value = this.value.replace(" ", ""); }); var $mm = $(".testM").meter(), $m = $("meter"), $d = $("#myProtoMeter"); function doSlider(){ $('.slider').each(function() { var $t = $(this); $t.slider({ value: $t.data("val"), slide: function(event, ui) { var f = $t.data("for"); $t.data("val", ui.value); $m.attr(f, ui.value); $("#l" + $t.attr("id")).text(f + ' ' + ui.value); var adjust = (f === "value") ? 'width' : 'margin-left'; $d.find("." + f).css(adjust, ui.value + "%").attr("title", f + " " + ui.value); $(".testM").meter(); } }); }); } doSlider(); $("input:checkbox").click(function() { var $c = $(this); $("#s" + $c.data('attr')).slider("option", "disabled", this.checked); if (this.checked) { $m.removeAttr($c.data("attr")); } else { $m.attr($c.data("attr"), $("#s" + $c.data('attr')).data('val')); } });
This fiddle has previously unsaved changes.
Apply changes
Discard
Color Palette Generator
Generate a cool color palette with a few clicks