Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

http-clock-html.c

Committer:
andrewboyson
Date:
2018-12-29
Revision:
14:c3c43c8faf0e
Child:
15:2cea2bbd5046

File content as of revision 14:c3c43c8faf0e:

#include <time.h>

#include      "http.h"
#include      "page.h"
#include       "nav.h"
#include "http-base.h"
#include     "clock.h"
#include       "rtc.h"
#include  "clkstate.h"
#include      "scan.h"

void HttpClockHtml()
{
    HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL);
    PageAddHeader(NavSite, "Clock", "settings.css", "clock.js");
    NavAdd(CLOCK_PAGE);
    PageAddH1(NavSite, "Clock");
    
    PageAddH2("Sync status");
    if (!  RtcIsSet()) HttpAddText("<div>RTC   is not set!</div>\r\n");
    if (!ClockIsSet()) HttpAddText("<div>Clock is not set!</div>\r\n");
    PageAddAjaxToggle(10.0, "PPS is stable", "ajax-pps-stable", "");
    PageAddAjaxToggle(10.0, "Rate synchronised", "ajax-rate-locked", "");
    PageAddAjaxToggle(10.0, "Time synchronised", "ajax-time-locked", "");

    PageAddH2("Server local time");
    HttpAddText("<div id='date-pc'></div>\r\n");

    PageAddH2("Server UTC time");
    HttpAddText("<div id='date-utc'></div>\r\n");
    
    PageAddH2("Server - PC");
    HttpAddText("<div id='date-diff'></div>\r\n");    
    PageAddH2("Ajax");
    HttpAddText("<code id='ajax-headers'></code>\r\n");
    HttpAddText("<code id='ajax-response'></code>\r\n");
    
    PageAddH2("Leap seconds");
    PageAddAjaxToggle(10.0, "Next leap enable"   , "ajax-leap-enable"  , "chg-clock-leap-enable"  );
    PageAddAjaxToggle(10.0, "Next leap backward" , "ajax-leap-backward", "chg-clock-leap-backward");
    PageAddAjaxHex   ( 6.0, "Next Year"   , 5.2  , "ajax-leap-year"    , "set-clock-leap-year"    );
    PageAddAjaxHex   ( 6.0, "Next Month"  , 5.2  , "ajax-leap-month"   , "set-clock-leap-month"   );
    PageAddAjaxHex   ( 6.0, "Count"       , 5.2  , "ajax-leap-count"   , "set-clock-leap-count"   );

    HttpAddText("<button type='button' onclick='DisplayLeap()'>Display Leap</button>\r\n");
    
    PageAddH2("Time");
    struct tm tm;
    ClockTmUtc(&tm);
    HttpAddText("<div>\r\n");
    PageAddTm(&tm);
    HttpAddText("</div>\r\n");
    ClockTmLocal(&tm);
    HttpAddText("<div>\r\n");
    PageAddTm(&tm);
    HttpAddText("</div>\r\n");
    PageAddLabelledInt("Freq ppb", 17, ClockPpb);
        
    PageAddH2("Scan times");
    PageAddLabelledInt("Program cycles avg", 17, ScanAverage);
    PageAddLabelledInt("Program cycles max", 17, ScanMaximum);
    PageAddLabelledInt("Program cycles min", 17, ScanMinimum);

    PageAddEnd();
}