simple clock inside MM - help

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: simple clock inside MM - help

Re: simple clock inside MM - help

by NRGman » Sun Feb 12, 2012 1:50 am

Bump...

Adding a clock to MM

by NRGman » Sat Feb 04, 2012 7:50 am

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.

Re: simple clock inside MM - help

by LikeMM » Sat Nov 19, 2011 12:30 pm

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

Image

simple clock inside MM - help

by LikeMM » Tue Nov 01, 2011 5:19 pm

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>


Top