HighDots Forums  

Automating date/time input for modem/router

Javascript JavaScript language (comp.lang.javascript)


Discuss Automating date/time input for modem/router in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Franc Zabkar
 
Posts: n/a

Default Automating date/time input for modem/router - 02-01-2006 , 10:55 PM






My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).

The router's IP address is 10.1.1.1. AIUI, all relative addresses in
the PopOutPage would need to be changed to reflect this..

The date/time input code is accessed via this URL:
http://10.1.1.1/PopOutPage?id=3&ex_param1=

The source code for the above JS form is here:
http://www.users.on.net/~fzabkar/DSL...PopOutPage.htm

The above form calls these .gsv and .css files:
http://10.1.1.1/hag/js/global.gsv
http://10.1.1.1/hag/css/style.css

The respective source code is here:
http://www.users.on.net/~fzabkar/DSL-302G/global.gsv
http://www.users.on.net/~fzabkar/DSL-302G/style.css

Thanks in advance for any pointers.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.

Reply With Quote
  #2  
Old   
Franc Zabkar
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-02-2006 , 03:04 PM






On Thu, 02 Feb 2006 14:55:09 +1100, Franc Zabkar
<fzabkar (AT) iinternode (DOT) on.net> put finger to keyboard and composed:

Quote:
My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).
OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.


Reply With Quote
  #3  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-02-2006 , 03:24 PM



Franc Zabkar wrote:

Quote:
I need a small JS routine that reads the PC date/time and builds a URL
in this format:


http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit
The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".
One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");

Quote:
Thanks in advance for any assistance.
RTFM next time.


PointedEars


Reply With Quote
  #4  
Old   
Dr John Stockton
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-03-2006 , 08:20 AM



JRS: In article <qeo4u19qqm33uec44dp1fn1rnn10dc2djn (AT) 4ax (DOT) com>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in news:comp.lang.javascript,
Franc Zabkar <fzabkar (AT) iinternode (DOT) on.net> posted :
Quote:
OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...ys_year=2005&s
ysm_time_check=&sys_hour=22&sys_minute=2&sys_secon d=22&timezone_combo=42&dst=1&h
ost_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.
Did you consider reading the newsgroup FAQ before posting? See sig
below.

EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.

You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.

Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


Reply With Quote
  #5  
Old   
Franc Zabkar
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-04-2006 , 08:31 PM



On Fri, 3 Feb 2006 13:20:32 +0000, Dr John Stockton
<jrs (AT) merlyn (DOT) demon.co.uk> put finger to keyboard and composed:

Quote:
JRS: In article <qeo4u19qqm33uec44dp1fn1rnn10dc2djn (AT) 4ax (DOT) com>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in news:comp.lang.javascript,
Franc Zabkar <fzabkar (AT) iinternode (DOT) on.net> posted :

OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_che...ys_year=2005&s
ysm_time_check=&sys_hour=22&sys_minute=2&sys_secon d=22&timezone_combo=42&dst=1&h
ost_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.

Did you consider reading the newsgroup FAQ before posting? See sig
below.
Sorry, I did not. The reason is that I have absolutely *no*
prerequisite knowledge of HTML, JS, or C, and I don't foresee any
pressing need for same. In any case, I have two books on JS, but they
both assume a working knowledge of HTML.

Anyway I thought the answer would be simple enough, and indeed it was.
While it isn't pretty, here is my solution (using input from this NG):

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm

Quote:
EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.
I have no control over this because it is built into the modem's
firmware. In any case I don't consider timezone_combo as a true
variable because this setting can be saved in the modem's nonvolatile
memory. The user can preset his own choice in the abovementioned JS
script. Indeed, it would be impossible to programmatically select the
preferred timezone_combo given that some system time zones can map to
several timezone_combo options, eg:

20 CET +0100 Central European
21 FWT +0100 French Winter
22 MET +0100 Middle European
23 MEWT +0100 Middle European Winter
24 SWT +0100 Swedish Winter

Quote:
You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.
This code is purely for my own convenience. The *only* reason that I
wish to synchronise the modem's date and time is so that I can make
sense of the modem's event log. I really don't care too much about the
time zone, or whether daylight is being saved. Therefore I am quite
happy to hard-code the TZ and DST parameters. In any case these
parameters can be retained by the modem's nonvolatile memory and need
not be updated.

Perhaps this log of PPP events will illustrate the problem:

http://www.users.on.net/~fzabkar/DSL-302G/Alarms.htm

Notice that when the modem first powers up and connects to the DSLAM,
the date and time are those which are retrieved from the modem's
nonvolatile memory:

================================================== ====================
Sat Sep 03 20:09:11 2005 : STATUS ALARM : ATM Interface Up : Interface
- atm-0
Sat Sep 03 20:09:11 2005 : STATUS ALARM : DSL Interface Up
Sat Sep 03 20:09:01 2005 : STATUS ALARM : System Up
================================================== ====================

I believe that "Sat Sep 03" was the date when I last saved the modem's
configuration settings, ie PPP, Bridging, LAN, WAN, Admin.

After synchronising the date/time, the log looks like this:

================================================== ====================
Sat Feb 04 19:02:42 2006 : STATUS ALARM : PPP Interface Up : Interface
- ppp-0
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got secondary
DNS address: 192.231.203.3
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got primary
DNS address: 192.231.203.132
================================================== ====================

Quote:
Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!
Again, this is a function of the modem's firmware. It is of no real
interest to me as I don't work past midnight and I switch off the
modem when I'm done. I may experiment with this parameter, though,
just out of curiosity. When I find out how it works I'll add an
appropriate comment to the TimeSync routine.

Thanks for your input.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.


Reply With Quote
  #6  
Old   
Franc Zabkar
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-04-2006 , 08:31 PM



On Thu, 02 Feb 2006 21:24:41 +0100, Thomas 'PointedEars' Lahn
<PointedEars (AT) web (DOT) de> put finger to keyboard and composed:

Quote:
Franc Zabkar wrote:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:


http://10.1.1.1/Action?sysm_date_che...dSubmit=Submit
The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");

Thanks in advance for any assistance.

RTFM next time.
Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult a
dictionary.

Anyway, after a considerable struggle, I came up with this:

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm

Quote:
PointedEars
- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.


Reply With Quote
  #7  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-05-2006 , 10:17 AM



Franc Zabkar wrote:

Quote:
[...] Thomas 'PointedEars' Lahn [...] wrote:

[Full quote]
Read the FAQ and the FAQ Notes before you post here again.

Quote:
RTFM next time.

Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.
The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.


PointedEars


Reply With Quote
  #8  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-05-2006 , 11:48 AM



Franc Zabkar wrote:

Quote:
[...] Anyway, after a considerable struggle, I came up with this:
Considerable struggle? Your code is essentially mine, without even
mentioning it!

Hopefully you aware that you will probably set the wrong time half
of the year.


PointedEars


Reply With Quote
  #9  
Old   
Franc Zabkar
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-05-2006 , 10:08 PM



On Sun, 05 Feb 2006 17:48:44 +0100, Thomas 'PointedEars' Lahn
<PointedEars (AT) web (DOT) de> put finger to keyboard and composed:

Quote:
Franc Zabkar wrote:

[...] Anyway, after a considerable struggle, I came up with this:

Considerable struggle?
My difficulty was not so much in creating a variable, although I would
have done it in a much less elegant way (by using a long concatenation
statement). The main problem was in breaking down several pages of
completely unfamiliar code into a basic requirement, and then finding
a way to direct my browser to a variable URL. Neither of my JS texts
addressed the latter, most important need.

Quote:
Your code is essentially mine, without even mentioning it!
I had considered acknowledging your var statement by way of a comment
within the body of the code, but wasn't sure whether this would be
deemed too trivial. No disrespect intended.

Quote:
http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm

Hopefully you aware that you will probably set the wrong time half
of the year.
Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight. Perhaps it would be
safer to specify "&dst=0", though, just in case the modem firmware
hard codes some other transition date.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.


Reply With Quote
  #10  
Old   
Franc Zabkar
 
Posts: n/a

Default Re: Automating date/time input for modem/router - 02-05-2006 , 10:08 PM



On Sun, 05 Feb 2006 16:17:03 +0100, Thomas 'PointedEars' Lahn
<PointedEars (AT) web (DOT) de> put finger to keyboard and composed:

Quote:
Franc Zabkar wrote:

[...] Thomas 'PointedEars' Lahn [...] wrote:

[Full quote]

Read the FAQ and the FAQ Notes before you post here again.

RTFM next time.

Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.

The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.
OK, your criticisms are acknowledged and accepted. I'm at page 70 of
chapter 6 of "Javascript by Example" and still reading ...

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.


Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.