Skip to content

Instantly share code, notes, and snippets.

@MeoMix
Created July 26, 2012 03:11
Show Gist options
  • Save MeoMix/3180025 to your computer and use it in GitHub Desktop.
Save MeoMix/3180025 to your computer and use it in GitHub Desktop.
var updateSoundIcon = function(volume){
//Repaint the amount of white filled in the bar showing the distance the grabber has been dragged.
var backgroundImage = '-webkit-gradient(linear,left top, right top, from(#ccc), color-stop('+ volume/100 +',#ccc), color-stop('+ volume/100+',rgba(0,0,0,0)), to(rgba(0,0,0,0)))';
volumeSlider.css('background-image', backgroundImage);
var active = '#fff';
var inactive = '#555';
//Paint the various bars indicating the sound level.
var fillColor = volume >= 25 ? active : inactive;
$('#MuteButtonBar1').css('fill', fillColor);
fillColor = volume >= 50 ? active : inactive;
$('#MuteButtonBar2').css('fill', fillColor);
fillColor = volume >= 75 ? active : inactive;
$('#MuteButtonBar3').css('fill', fillColor);
//NOTE: Volume is a string here. Careful of type coercion.
fillColor = volume == 100 ? active : inactive;
$('#MuteButtonBar4').css('fill', fillColor);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment