Raised This Month: $ Target: $400
 0% 

Vista gadget


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 09-05-2008 , 17:21   Vista gadget
Reply With Quote #1

Well since this is a scripting forum i thought this may can go here(and it is OT)

I have vista on my new computer and have added the addon Driveinfo (download)
(add here a download to another without the memory leak but still it dosent show right :/ here)
And what it does is it shows a little icon with the harddisks info memory left etc
but if the choosen harddisk is larger than 300gb it just being a black box can someone see if they can fix?
source code
Code:
<html>
  <head>
    <title>Drive Info</title>
    <style>
      body { margin: 0; padding: 0; width: 156px; height: 56px; background-image: url(images\canvas.png); color: #ffffff; font-family: 'Segoe UI'; }
      #targets { position: absolute; top: 0; left: 0; }
      .target { position: absolute; width: 56px; height: 48px; left: 0; cursor: hand; }
    </style>
    <script type="text/javascript">
      var drives, background;

      function convertBytes(b)
      {
        var i = 0, u = Array(' MB', ' GB', ' TB');

        while (b >= 1024 && (b / 1024) >= 1)
        {
      b /= 1024;
      i++;
        }

        return (Math.round(b * 100) / 100) + u[i];
      }

      function openDrive()
      {        
        var d = window.event.srcElement.getAttribute('drive');    
        System.Shell.execute(d + ':\\');
      }

      function showDrives()
      {
   
        var y = 0;
        canvas.removeObjects();
        targets.innerHtml = '';

        for(var i = 0; i < drives.length; i++)
        {
          var d = drives[i];
          if (d)
          {
            canvas.addImageObject('images/backgrounds/background' + background + '.png', 0, y);  
         

            if (d.isReady) 
            {
              var f = Math.round(d.freeSpace / d.totalSize * 100);

              var  u = (100 - f);


              var m = canvas.addImageObject('images/meter' + (u < 90 ? 'blue': (u < 98 ? 'orange': 'red')) + '.png', 24, y + 34);   
              m.width = Math.floor((u * 128 / 100));
              m.left = 24 - Math.floor(((128 - m.width) / 2));

              canvas.addImageObject('images/drives/drive' + d.driveType + '.png', 0, y);
              canvas.addTextObject(d.volumeLabel + ' (' + d.driveLetter + ':)', 'Segoe UI', 11, 'white', 58, y + 5);
              canvas.addTextObject(convertBytes(d.freeSpace) + ' / ' + f + '%', 'Segoe UI', 10, 'white', 58, y + 17);

              var o = document.createElement('DIV');
              o.className = 'target';
              o.style.posTop = y;
              o.setAttribute('drive', d.driveLetter);
              o.ondblclick = openDrive;
              targets.appendChild(o);
            }
            else
            {            
              canvas.addImageObject('images/drives/drive' + d.driveType + '.png', 0, y);
              canvas.addImageObject('images/notready.png', 5, y + 29);
              canvas.addTextObject('(' + d.driveLetter + ':)', 'Segoe UI', 11, 'white', 60, y + 5);
            }

            y += 48;
          }
        }

        if (y < 57) y = 57;
        canvas.style.height = y;
        document.body.style.posHeight = y;

        window.setTimeout(showDrives, 5000);
      }

      function initDrives()
      {
    var d = System.Gadget.Settings.read("drives");
        if (d.length == 0) d = 'C';

        drives = new Array(d.length);
        for(var i = 0; i < drives.length; i++)
        {
          drives[i] = System.Shell.drive(d.charAt(i));
        }

        background = parseInt('0' + System.Gadget.Settings.read("background"));
        if (background == 0) background = 1;

        showDrives();
      }

      function onLoad()
      {
        System.Gadget.settingsUI = "Settings.html";
        System.Gadget.onSettingsClosed = initDrives;

        initDrives();
      }
    </script>
  </head>
  <body onload="onLoad()">
    <div id="targets"></div>
    <g:background id="canvas" src="images/canvas.png" style="position: absolute; top: 0; left: 0; z-index: -999;" opacity="0" />
  </body>
</html>
(if you dont already know it the .gadget file is like a zip file so u can open it with winrar)


thx in advanced

Last edited by micke1101; 09-06-2008 at 02:34.
micke1101 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode