simple clock inside MM - help

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

LikeMM
Posts: 142
Joined: Sat Feb 02, 2008 5:29 pm

simple clock inside MM - help

Post by LikeMM »

I took the java code from this page and tried to create a simple clock panel inside MM.

http://www.elated.com/res/File/articles ... clock.html

The panel comes up but I don't see the clock. Can anybody make it work, please? (I made a clock using only vbscript and label caption method. That works but when the second changes, the clock text flickers quite often; whereas the java clock inside a webpage is smooth.)

I tried changing various things unsuccessfully. The clock.html file displays the clock in IE8 by itself.

Two files, both go into scripts/auto folder.

1. clock.vbs

Code: Select all

'A simple real time Clock inside Monkey

Sub OnStartup
  'create panel
  Dim ui: Set ui = SDB.UI
  Dim pan : Set pan = ui.NewDockablePersistentPanel("Clock")
  If pan.IsNew Then
    pan.DockedTo = 4
    pan.Common.Width = 250
    pan.Common.Height = 50
  End If
  pan.showCaption = True
  pan.Common.Visible = True

  'create a web browser component
  Dim web : Set web = ui.NewActiveX(pan,"Shell.Explorer")
  web.Common.ClientWidth = pan.Common.ClientWidth
  web.Common.ClientHeight = pan.Common.ClientHeight
  web.Common.Anchors = 15
  web.Common.ControlName = "ClockWeb"

  'apply skin
  Dim path : path = Left(Script.ScriptPath,InStrRev(Script.ScriptPath,"\"))
  path = path&"clock.html"
  Call web.Interf.Navigate(path)
End Sub
2. clock.html

Code: Select all

<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -->
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Clock</title>
     <style type="text/css">
      #clock { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: blue; background-color: white; text-align: left;}
    </style>
    <script type="text/javascript">
      function init ( )
      {
        timeDisplay = document.createTextNode ( "" );
        document.getElementById("clock").appendChild ( timeDisplay );
      }

      function updateClock ( )
      {
        var currentTime = new Date ( );
        var myDays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"]

        var currentHours = currentTime.getHours ( );
        var currentMinutes = currentTime.getMinutes ( );
        var currentSeconds = currentTime.getSeconds ( );
        var month = currentTime.getMonth() + 1;
        var day = currentTime.getDate();
        var year = currentTime.getFullYear();
        var thisDaynum=currentTime.getDay();
        var thisDay=myDays[thisDaynum];

        // Pad the minutes and seconds with leading zeros, if required
        currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
        currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

        // Choose either "AM" or "PM" as appropriate
        var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

        // Convert the hours component to 12-hour format if needed
        currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

        // Convert an hours component of "0" to "12"
        currentHours = ( currentHours == 0 ) ? 12 : currentHours;

        // Compose the string for display
        var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
        currentTimeString = month + "/" + day + "/" + year + " " + thisDay + " " + currentTimeString;
        
        // Update the time display
        document.getElementById("clock").firstChild.nodeValue = currentTimeString;
      }
    </script>
  </head>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
  <div style="clear: both;"> </div>
  <div style="width: 250px; text-align: left;">
    <span id="clock">&nbsp;</span>
  </div>
</body>
</html>

LikeMM
Posts: 142
Joined: Sat Feb 02, 2008 5:29 pm

Re: simple clock inside MM - help

Post by LikeMM »

I overloaded MonkeyRok to handle this too :) Made no changes to the code, simply added it to skin.html :o

Image
NRGman
Posts: 37
Joined: Wed Jan 12, 2011 9:12 am
Location: Perth, Australia

Adding a clock to MM

Post by NRGman »

Hi, I'm trying to add a clock to MM because I'd like to be able to auto hide my task bar...

this is what i got to when searching, any ideas on how to get it working?

http://www.mediamonkey.com/forum/viewto ... ilit=clock

Thanks for your time.
Last edited by Lowlander on Sat Feb 04, 2012 11:08 am, edited 1 time in total.
Reason: Merged with existing topic
My Setup:
"HFPC" Dell Optiplex 320 (2GB RAM, 3.0 Dual Core 1.5TB HDD) Win7 Ultimate SP1 x86
Musiland Monitor 02 US USB DAC
Nad C356BEE Integrated Amplifier
Custom 2-way loudspeakers
NRGman
Posts: 37
Joined: Wed Jan 12, 2011 9:12 am
Location: Perth, Australia

Re: simple clock inside MM - help

Post by NRGman »

Bump...
My Setup:
"HFPC" Dell Optiplex 320 (2GB RAM, 3.0 Dual Core 1.5TB HDD) Win7 Ultimate SP1 x86
Musiland Monitor 02 US USB DAC
Nad C356BEE Integrated Amplifier
Custom 2-way loudspeakers
Post Reply