Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


code to show server time in title bar

 
Post new topic   Reply to topic    Cacti Forum Index -> Addons for Cacti
Author Message
Mikf



Joined: 13 Aug 2004
Posts: 36
Location: Paris, France

PostPosted: Thu Oct 28, 2004 3:30 pm    Post subject: code to show server time in title bar Reply with quote

Hello,
i have written a little script (php+javascript) to show the time of the cacti server in the window title bar or status bar
i use it in include/top_graph_header.php at the end of the <head> section :

Code:
<script language="javascript">
        var localtime = new Date();
        var serverTime= new Date();
        <?php $date = getdate(); ?>
        serverTime.setYear(<?php print($date['year']);?>);
        serverTime.setMonth(<?php print($date['mon']);?>);
        serverTime.setDate(<?php print($date['mday']);?>);
        serverTime.setHours(<?php print($date['hours'] . "," . $date['minutes'] . "," . $date['seconds']);?>);
        var difftime = localtime - serverTime;
        this.setInterval("sample(difftime)",1000);
        function sample()
        {
                var d = new Date();
                serverd = new Date();
                serverd.setTime(d.getTime() - difftime);
                if(document.all || document.getElementById){
                      document.title = "Cacti - Server Time : " + serverd.toLocaleTimeString();
                }else{
                     self.status = "Cacti - Server Time : " + serverd.toLocaleTimeString();
                }

        }
</script>



titlebar.jpg
 Description:
 Filesize:  6 KB
 Viewed:  2952 Time(s)

titlebar.jpg


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Addons for Cacti All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group