mirror of
https://github.com/ADElectronics/RTL00_WEB_WS2812.git
synced 2025-01-15 05:05:18 +00:00
1 line
No EOL
1.6 KiB
JavaScript
1 line
No EOL
1.6 KiB
JavaScript
!function(){"use strict";var e=self.HTMLInputElement&&"valueLow"in HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");self.multirange=function(n){function i(){o.style.setProperty("--low",100*((n.valueLow-a)/(r-a))+1+"%"),o.style.setProperty("--high",100*((n.valueHigh-a)/(r-a))-1+"%")}if(!e&&!n.classList.contains("multirange")){var u=n.getAttribute("value"),l=null===u?[]:u.split(","),a=+(n.min||0),r=+(n.max||100),o=n.cloneNode();n.classList.add("multirange","original"),o.classList.add("multirange","ghost"),n.value=l[0]||a+(r-a)/2,o.value=l[1]||a+(r-a)/2,n.parentNode.insertBefore(o,n.nextSibling),Object.defineProperty(n,"originalValue",t.get?t:{get:function(){return this.value},set:function(e){this.value=e}}),Object.defineProperties(n,{valueLow:{get:function(){return Math.min(this.originalValue,o.value)},set:function(e){this.originalValue=e},enumerable:!0},valueHigh:{get:function(){return Math.max(this.originalValue,o.value)},set:function(e){o.value=e},enumerable:!0}}),t.get&&Object.defineProperty(n,"value",{get:function(){return this.valueLow+","+this.valueHigh},set:function(e){var t=e.split(",");this.valueLow=t[0],this.valueHigh=t[1],i()},enumerable:!0}),"function"==typeof n.oninput&&(o.oninput=n.oninput.bind(n)),n.addEventListener("input",i),o.addEventListener("input",i),i()}},multirange.init=function(){[].slice.call(document.querySelectorAll("input[type=range][multiple]:not(.multirange)")).forEach(multirange)},"loading"==document.readyState?document.addEventListener("DOMContentLoaded",multirange.init):multirange.init()}(); |