home *** CD-ROM | disk | FTP | other *** search
/ Freelog 117 / FreelogNo117-OctobreNovembre2013.iso / Theme / 8GadgetPack / 8GadgetPackSetup.msi / Gadgets.7z / Gadgets / Volume_Control.gadget / gadget.js < prev    next >
Text File  |  2012-01-28  |  3KB  |  126 lines

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. //                                                                                 //
  3. //  Volume Control Gadget 1.2 by Orbmu2k ┬⌐ 2007                                   //
  4. //                                                                                 //
  5. //  Copyright ┬⌐ 2007 Orbmu2k.  All rights reserved.                                //
  6. //                                                                                 //
  7. //  http://blog.orbmu2k.de                                                         //
  8. //                                                                                 //
  9. //  Email: sidebargadget@orbmu2k.de                                                //
  10. //                                                                                 //
  11. /////////////////////////////////////////////////////////////////////////////////////
  12.  
  13. System.Gadget.settingsUI = "settings.html";
  14. System.Gadget.onSettingsClosed = onSettingsClosed;
  15.  
  16. var sound;
  17. var t;
  18. var vol;
  19. var mute;
  20. var imgSpeaker;
  21. var imgCross;
  22. var updating = false;
  23.  
  24. function init()
  25. {
  26.     sound = GetLibrary();
  27.     loadSettings();
  28.     initObjects();
  29.     t = setInterval("refreshdisplay()",75);
  30. }
  31.  
  32. function loadSettings()
  33. {
  34.     var b = System.Gadget.Settings.readString("background");
  35.     if ( b != "") background.src = b;    
  36. }
  37.  
  38. function onSettingsClosed()
  39. {
  40.     loadSettings();
  41. }
  42.  
  43. function terminate()
  44. {
  45.     UnregisterLibrary(); 
  46. }
  47.  
  48. function initObjects()
  49. {
  50.     imgSpeaker = background.addImageObject("kmix.png", 4, 6);
  51.     imgSpeaker.width = 24;
  52.     imgSpeaker.height = 24;
  53.  
  54.     imgCross = background.addImageObject("cross.png", 18, 22)
  55.     imgCross.width = 12;
  56.     imgCross.height = 12;
  57. }
  58.  
  59. function changeVolume()
  60. {
  61.     var v = sound.MasterVolume;
  62.  
  63.     if (event.wheelDelta >= 20)
  64.         v += 3;
  65.     else 
  66.         v -= 3;
  67.     
  68.     if (v >= 100) v = 100;
  69.     if (v <= 0) v = 0;
  70.  
  71.     sound.MasterVolume = v;
  72. }
  73.  
  74. function muteVolume()
  75. {
  76.     if (event.button == 4)
  77.     {                
  78.         sound.MasterMute = !sound.MasterMute;
  79.     }
  80.     onMouseMove();
  81. }
  82.  
  83. function onMouseMove()
  84. {
  85.     if (event.button == 1)
  86.     {
  87.         var v = event.x-12;
  88.         if (v >= 100) v = 100;
  89.         if (v <= 0) v = 0;
  90.         sound.MasterVolume = v;
  91.     }
  92. }
  93.  
  94. function runMixer()
  95. {
  96.     System.Shell.execute("sndvol.exe");
  97. }
  98.  
  99. function refreshdisplay()
  100. {
  101.     try
  102.     {
  103.         if (!System.Gadget.visible || updating) return;
  104.         updating = true;
  105.         
  106.         vol = sound.MasterVolume;
  107.         mute = sound.MasterMute;
  108.         
  109.         imgCross.opacity = mute ? 100 : 0;
  110.         if (mute)
  111.             txtVolume.innerText = "Volume: Mute";
  112.         else
  113.             txtVolume.innerText = "Volume: " + vol + "%";
  114.         
  115.         divvol.style.width = (Math.round((vol / 8)) * 8);
  116.         divpeakleft.style.width = (Math.round((sound.LeftPeak / 4)) * 4);
  117.         divpeakright.style.width = (Math.round((sound.RightPeak / 4)) * 4);
  118.         
  119.         updating = false;
  120.     }
  121.     catch(err) 
  122.     {
  123.     }
  124. }
  125.  
  126.