Author |
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 06 2007 at 09:59 | IP Logged
|
|
|
Hey Guys,
I have been brewing on an idea about making a Graphical User Interface in a PSP page for entering timed events the easy way...
My idea:
1: A javascript pop-up-calendar, a datetime-picker
2: A dropdownbox with current installed Macros in PH
These 2 combined should make it possible to create a timed event the easy-way....
what I've got so far:
the javascript calendar:
It has already been adapted to have the correct date-and-time output!!!
Code:
// Title: Timestamp picker
// Description: See the demo at url
// URL: http://us.geocities.com/tspicker/
// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml
// Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
// header lines are left unchanged. Feel free to contact the author
// for feature requests and/or donations
function show_calendar(str_target, str_datetime) {
var arr_months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
var n_weekstart = 1; // day week starts from (normally 0 or 1)
var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime));
var dt_prev_month = new Date(dt_datetime);
dt_prev_month.setM onth(d t_date time.getMonth()-1);
var dt_next_month = new Date(dt_datetime);
dt_next_month.setM onth(d t_date time.getMonth()+1);
var dt_firstday = new Date(dt_datetime);
dt_firstday.setDate(1);
dt_firstday.setDat e(1-(7 +dt_fi rstday.getDay()-n_weekstart)%7);
var dt_lastday = new Date(dt_next_month);
dt_lastday.setDate(0);
// html generation (feel free to tune it for your particular application)
// print calendar header
var str_buffer = new String (
"<html>\n"+
"<head>\n"+
" <t itle>Cale ndar</tit le>\n"+
"</head>\n"+
"<body bgcolor=\"White\">\n"+
"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
"<tr><td bgcolor=\"#4682B4\">\n"+
"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
"<tr>\n <t d bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
"<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
" alt=\"previous month\"></a></td>\n"+
" <td bgcolor=\"#4682B4\" colspan=\"5\">"+
"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
" <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
+str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\"> ; ;"+
"<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
" alt=\"next month\"></a></td>\n</tr>\n"
);
var dt_current_day = new Date(dt_firstday);
// print weekdays titles
str_buffer += "<tr>\n";
for (var n=0; n<7; n++)
str_buffer += " <td bgcolor=\"#87CEFA\">"+
"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
week_days[(n_weekstart+n)%7]+"</font></td>\n";
// print calendar table
str_buffer += "</tr>\n";
while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
dt_current_day.getMonth() == dt_firstday.getMonth()) {
// print row heder
str_buffer += "<tr>\n";
for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
if (dt_current_day.getDate() == dt_datetime.getDate() &&
dt_current_day.getMonth() == dt_datetime.getMonth())
// print current date
str_buffer += " <td bgcolor=\"#FFB6C1\" align=\"right\">";
else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
// weekend days
str_buffer += " <td bgcolor=\"#DBEAF5\" align=\"right\">";
else
// print working days of current month
str_buffer += " <td bgcolor=\"white\" align=\"right\">";
if (dt_current_day.getMonth() == dt_datetime.getMonth())
// print days of current month
str_buffer += "<a href=\"javascript:window.opener."+str_target+
".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.val ue; window.close();\">"+
"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
else
// print days of other months
str_buffer += "<a href=\"javascript:window.opener."+str_target+
".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.val ue; window.close();\">"+
"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
str_buffer += dt_current_day.getDate()+"</font></a></td> \n";
dt_current_day.setDate(dt_current_day.getDate()+1);
}
// print row footer
str_buffer += "</tr>\n";
}
// print calendar footer
str_buffer +=
"<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
"Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n< /form>\n" +
"</table>\n" +
"</tr>\n</td>\n</table>\n" +
"</body>\n" +
"</html>\n";
var vWinCal = window.open("", "Calendar",
"width=200,height=250,status=no,resizable=yes,top=200,left=200");
vWinCal.opener = self;
var calc_doc = vWinCal.document;
calc_doc.write (str_buffer);
calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
if (!re_date.exec(str_datetime))
return alert("Invalid Datetime format: "+ str_datetime);
return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
return (new String (
dt_datetime.getFul lYear()+"-"+ (dt_datetime.getMonth()+1)+"-"+dt_datetime.getDate()+" "));
}
function dt2tmstr (dt_datetime) {
return (new String (
dt_datetime.getHou rs()+":"+dt_ datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}
|
|
|
the exampleform to go with it:
Code:
<html>
<head>
<title>Create TimedEvent GUI Page</title>
<script language="JavaScript" src="ts_picker.js">
//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script
</script>
</HEAD>
<body>
<form name="tstest" >
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" alt="Click Here to Pick up the timestamp"></a>
</form>
</BODY>
|
|
|
The Macrolisting in a dropdownbox (TonyNo...you should remember this since thiis is part of your code:
Code:
<form method="get" action="/macrolisting.psp">Macro: <select name="id" size=1>
<option value="">
<% ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1)) %>
</select>
<input type="submit" value="Show">
</form><p>
|
|
|
Now......
it MUST be possible to merge these codes together and make a GUI-page for creating timed-events...
After all this is done, I will publisdh this for all to use....
what about my idea? is it doable?
Peter
forgot: the Javascript calendar can be found at:
http://javascriptkit.com/script/script2/timestamp.shtml
Edited by krommetje - January 06 2007 at 10:04
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 17 2007 at 04:41 | IP Logged
|
|
|
I took a look at it again:
My plan is to get the macro-ID from TonyNo's code:
Code:
<form method="get" action="/macrolisting.psp">Macro: <select name="id" size=1>
<option value="">
<% ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1)) %>
</select>
<input type="submit" value="Show">
</form><p>
<% ph_rtne( ph_setvar_s(1, 2, ""))%>
<% ph_rtne( ph_setvar_s(1, 3, ph_getwebparm("id")))%>
<% ph_rtne(if( ph_getwebauth()=2, 0, ph_setvar_s(1,3,""))) %>
<b>Macro: </b><% upper( "[LOCAL3]") %><p>
|
|
|
this leaves me with the first variable: "[LOCAL3]"
Now I have to account for the second variable taken out of this page and this is the page that passes the date and time...:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>My Date Time Picker</title>
<script language="JavaScript" src="ts_picker.js">
//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script
</script>
<form name="tstest">
<input type="Text" name="timestamp" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" alt="Click Here to Pick up the timestamp"></a>
</form>
|
|
|
This is a javascript Variable and since I am not a javascript programmer....
How do I combine the "[LOCAL3]" and the javascript-Var
together to a formula so I can enter a Timed Event?
Any help would be more then welcome!!!
Peter
Edited by krommetje - January 17 2007 at 06:27
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 17 2007 at 07:41 | IP Logged
|
|
|
I've been meaning to look at this.
The issue is that JavaScript is client-side, which means you'll need to pass it back to PH so it knows. There are a few ways to do it.
I'll try to finish up this post tonight!
Edited by TonyNo - January 17 2007 at 07:44
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 18 2007 at 04:40 | IP Logged
|
|
|
I've gotten this far:
Code:
<html>
<head>
<title>Create TimedEvent Page</title>
<script language="JavaScript" src="ts_picker.js">
//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script
</script>
</HEAD>
<body>
<form name="tstest" action="/ph-cgi/eventmod">
<form method="get" action="/ph-cgi/eventmod">
<input type="Text" name="timestamp" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
<form method="get" action="/macrolisting.psp">Macro: <select name="id" size=1>
<option value="">
<% ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1)) %>
</select>
<input type="submit" value="show">
</form><p>
<% ph_rtne( ph_setvar_s(1, 2, ""))%>
<% ph_rtne( ph_setvar_s(1, 3, ph_getwebparm("id")))%>
<% ph_rtne(if( ph_getwebauth()=2, 0, ph_setvar_s(1,3,""))) %>
<b>Macro: </b><% upper( "[LOCAL3]") %><p>
</form>
|
|
|
However I have the impression that something is wrong because I get an error 404...
the URL passed by this form is like this:
http://192.168.1.11/ph-cgi/eventmod?timestamp=2007-1-31+10%3 A32%3A8&id=EETKAMERLAMP+UIT
At least I am on the right track!
Does this help you tonyNo and others?
Peter
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 21 2007 at 13:07 | IP Logged
|
|
|
Guys!!!
I am really stuck here! I keep on hitting this 404 error..
it seems that the time, although correctly entered, is not passed correctly to PH in this form...
Peter
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 21 2007 at 13:41 | IP Logged
|
|
|
I could not find info for ph-cgi/eventmod, so I'm deferring to Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 21 2007 at 13:59 | IP Logged
|
|
|
If I look at the URL passed to PH, then the : is actually sent as %3.... could this be the fault...
Or should I do this another way with e.g. ph_createdtimedevent(0,"[LOCAL3]",now I am lost)
to have the form pass to ph_formula(phcreate.....???
Dave???
Peter
p.s. Thanks for thinking along with me TonyNo
Edited by krommetje - January 21 2007 at 14:06
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: January 22 2007 at 18:05 | IP Logged
|
|
|
Ok,
Ive tried to catch up on this but have not had a chance to really delve deep into it. I can offer a few things at the moment though.
There is no ph-cgi/eventmod function. There is a ph-cgi/timedeventmod function, but the parameters that you're passing are incorrect.
There should be no problem with the characters being converted into escape codes...PowerHome will interpret it correctly. The 404 error is due to the fact that ph-cgi/eventmod is not a valid function.
I don't think I would try to use the ph_createtimedevent function. The ph_createtimedevent function only allows for the creation of "One Shot" events. If this is the only type of event you're creating, then this would be the best way of doing it and I would use the ph-cgi/evalformula function to evaluate the ph_createtimedevent function.
If you're creating the full gamut of timed events, then you'll either want to use the ph-cgi/timedeventmod function or possibly direct SQL commands. The ph-cgi/timedeventmod function is not typically a user function, but there is no reason you couldnt adapt it for your own use...just keep in mind that it's designed for the internal Timed Events web screen. If you want to use this function, let me know and I'll see what I can do about putting together some documentation for you.
HTH,
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: January 22 2007 at 18:22 | IP Logged
|
|
|
A followup...
Im taking a deeper look at the code and not really seeing how this work at the moment. In the last code snippet, I see 3 forms. Two of them are calling the ph-cgi/eventmod function and 1 is calling a macrolisting.psp.
The way I see for this to work would be a single form whose action would be to call ph-cgi/evalformula. You would have a hidden parameter for nexturl and formula. You would have your Javascript date/time picker and the PowerHome macro list. A button would then call a Javascript function to retrieve the selected date/time, the currently highlighted macro ID, and populate the hidden formula field with the appropriate ph_createtimedevent function and submit the form. You wouldnt need any other PSP's or forms within the page.
After reading further on what you're attempting to do, it would appear that you're only interested in the one-shot timed events so the best way to accomplish this would be with the ph_createtimedevent function.
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 23 2007 at 15:56 | IP Logged
|
|
|
Quote:
There is no ph-cgi/eventmod function. There is a ph-cgi/timedeventmod function, but the parameters that you're passing are incorrect. |
|
|
Please explain....
Quote:
The way I see for this to work would be a single form whose action would be to call ph-cgi/evalformula. You would have a hidden parameter for nexturl and formula. You would have your Javascript date/time picker and the PowerHome macro list. A button would then call a Javascript function to retrieve the selected date/time, the currently highlighted macro ID, and populate the hidden formula field with the appropriate ph_createtimedevent function and submit the form. You wouldnt need any other PSP's or forms within the page.
|
|
|
now you've got me completely in the dark... the evalformula was the 2nd way in my mind but since this is more difficult then I thought....
Is this an idea?
Code:
<form name="tstest" action="/ph-cgi/evalformula" form method="post">
<input type="Text" name="ph_createtimedevent(" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
<input type="hidden" name="" value="">
<form method="get" action="/macrolisting.psp">Macro: <select name="id" size=1>
<option value="">
<% ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1)) %>
</select>
<input type="submit" value="Show">
</form><p>
<% ph_rtne( ph_setvar_s(1, 2, ""))%>
<% ph_rtne( ph_setvar_s(1, 3, ph_getwebparm("id")))%>
<% ph_rtne(if( ph_getwebauth()=2, 0, ph_setvar_s(1,3,""))) %>
<b>Macro: </b><% upper( "[LOCAL3]") %><p>
</form>
|
|
|
But how do I get the ending ) into the formula?
Am I on the right track?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: January 25 2007 at 17:09 | IP Logged
|
|
|
Peter,
I went ahead and created the skeleton you need to accomplish this. The code is below:
Code:
<html>
<head>
<title>PowerHome Timed Event Creator</title>
<script language="JavaScript">
<!--
function te()
{
document.tecreate.formula.value = 'ph_createtimedevent(0,"' + document.macro.id.value + '",2007-01-31 15:10:00)';
document.tecreate.submit();
}
// -->
</script>
</head>
<body bgcolor="#ffffff">
<form method="post" action="/ph-cgi/evalformula" name="tecreate"><input type="hidden" name="formula"><input type="hidden" name="nexturl" value="/ph-cgi/main"></form>
<form name="macro">Macro: <select name="id" size=1>
<option value="">
<%ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1))%>
</select>
</form>
<form name="create"><input type="button" value="Create" onclick="te()"></form>
</body>
</html>
|
|
|
You can take this entire piece of code and save it as "tecreate.psp" and place it in the web directory. It's current functionality is to allow a user to select a Macro ID and then will automatically create the Timed event to fire on 2007-01-31 at 15:10:00. You can see this hardcoded into the Javascript function te(). No other PSP or other file is needed. The main form is titled "tecreate" and calls the ph-cgi/evalformula function. You can then see a dummy form named "macro" that allows the user to select the macro ID. Another dummy form named "create" will then call the te() function when the "Create" button is pressed. The Javascript function will then extract the selected macro ID from the "macro" form and will modify the "formula" parameter in the "tecreate" form and submit it.
At this point, all you really need to do is add the Javascript date/time picker. Ultimately, you want this control to most likely be in a dummy form so that when a date/time is chosen, a parameter in the form is updated (just like in the "macro" form). You would then extract this date/time info from the dummy form in the te() function (just like the ID for the macro is extracted) and replace the hard-coded date/time.
Hope this helps,
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 26 2007 at 06:50 | IP Logged
|
|
|
Your example works, thank you...
now to intergrate the DateTimePicker:
Here is what I made
Code:
<html>
<head>
<title>PowerHome Timed Event Creator</title>
<script language="JavaScript">
<!--
// Title: Timestamp picker
// Description: See the demo at url
// URL: http://us.geocities.com/tspicker/
// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml
// Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
// header lines are left unchanged. Feel free to contact the author
// for feature requests and/or donations
function show_calendar(str_target, str_datetime) {
var arr_months = ["January", "February", "March", "April", "May", "June",
"July", &n bsp; ;" Au gu st ", "September", "October", "November", "December"];
var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
var n_weekstart = 1; // day week starts from (normally 0 or 1)
var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime));
var dt_prev_month = new Date(dt_datetime);
dt_prev_month.setM onth(d t_date time.getMonth()-1);
var dt_next_month = new Date(dt_datetime);
dt_next_month.setM onth(d t_date time.getMonth()+1);
var dt_firstday = new Date(dt_datetime);
dt_firstday.setDate(1);
dt_firstday.setDat e(1-(7 +dt_fi rstday.getDay()-n_weekstart)%7);
var dt_lastday = new Date(dt_next_month);
dt_lastday.setDate(0);
// html generation (feel free to tune it for your particular application)
// print calendar header
var str_buffer = new String (
"<html>\n"+
"& &n bsp;lt ;head>\n"+
" & nbsp; <tit le>Ca le ndar</tit le>\n"+
"</head>\n"+
"<bod y bgcolor=\"White\">\n"+
"<table &nbs&n bs p; p; cl as s= \"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
"<tr><td & n bsp; ;b gc ol or =\"#4682B4\">\n"+
"<table &nbs&n bs p; p; ce ll sp acing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
"<tr>\n & n& nbsp; bsp; ; ; &nbs p;;& & nbsp;lt; ;t d bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
str_target+"', &n bs &n bs p; p; '" +& nbsp; dt2dtstr(dt_prev_month)+"'+document.cal.tim e.value);\">"+
"<img &nbs&nbs p; p; sr c= \" prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
"   ;a lt =\ "p revious month\"></a></td>\n"+
"   ; ;& nbsp; <td bgcolor=\"#4682B4\" colspan=\"5\">"+
"   ;& lt; ;f ont color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
+arr_months &n bsp; ;& nb sp;[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
"   ; ;& nbsp; <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
+str_target+"', & n bsp; ;' "+ dt 2d ts tr (d t_next_month)+"'+document.cal.time.value);\"> ; ;"+
"<img &nbs&nbs p; p; sr c= \"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
"   ; ;alt=\"next month\"></a></td>\n</tr>\n"
);
var dt_current_day = new Date(dt_firstday);
// print weekdays titles
str_buffer += "<tr>\n";
for (var n=0; n<7; n++)
str_buffer &nbs&n bs p; p; += " &nbs p; & nbsp;< ;td bgcolor=\"#87CEFA\">"+
"   ;& lt; ;f ont color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
week_days &n bsp; ;& nb sp;[(n_weekstart+n)%7]+"</font></td>\n";
// print calendar table
str_buffer += "</tr>\n";
while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
dt_current_day.get Mo nt h( ) & n bsp; ;= = dt_firstday.getMonth()) {
// &nbs p; pr in t row heder
str_buffer &nbs&n bs p; p; += "<tr>\n";
for ( var n_current_wday=0; n_current_wday<7; n_current_wday++) {
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; if (dt_current_day.getDate() == dt_datetime.getDate() &&
dt_current_day.get Mo nt h( ) & n bsp; ;= = dt_datetime.getMonth())
// &nbs p; pr in t current date
str_buffer &nbs&n bs p; p; += " &nbs p; & nbsp;< ;td bgcolor=\"#FFB6C1\" align=\"right\">";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
&n bsp; &n bsp; // weekend days
str_buffer &nbs&n bs p; p; += " &nbs p; & nbsp;< ;td bgcolor=\"#DBEAF5\" align=\"right\">";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; else
// &nbs p; pr in t working days of current month
str_buffer &nbs&n bs p; p; += " &nbs p; & nbsp;< ;td bgcolor=\"white\" align=\"right\">";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; if (dt_current_day.getMonth() == dt_datetime.getMonth())
// &nbs p; pr in t days of current month
&n bs p; &nbs p; str_buffer +=&nbs p; "<a href=\"javascript:window.opener."+str_target+
&n bsp; &n bsp; " . value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.valu e; window.close();\">"+
"   ;& lt; ;f ont color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; else
// &nbs p; pr in t days of other months
&n bs p; &nbs p; str_buffer +=&nbs p; "<a href=\"javascript:window.opener."+str_target+
&n bsp; &n bsp; " . value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.valu e; window.close();\">"+
"   ;& lt; ;f ont color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; str_buffer += dt_current_day.getDate()+"</font></a></td> \n";
&n bsp; &n bsp; &n bsp; &nb sp; &nb sp; &nb sp; &n bsp; dt_current_day.setDate(dt_current_day.getDate()+1);
}
// &nbs p; pr in t row footer
str_buffer &nbs&n bs p; p; += "</tr>\n";
}
// print calendar footer
str_buffer +=
"   ;& lt; ;f orm name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
"   ;& lt; ;f ont color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
"   ;T im e: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
"   ;\ " size=\"8\" maxlength=\"8\"></font></td></tr>\n< /form>\n" +
"   ;& lt; ;/ table>\n" +
"   ;& lt; ;/ tr>\n</td>\n</table>\n" +
"   ;& lt; ;/ body>\n" +
"   ;& lt; ;/ html>\n";
var vWinCal = window.open("", "Calendar",
"   ; ;width=200,height=250,status=no,resizabl e=yes,top=200,left=2 0 0");
vWinCal.opener = self;
var calc_doc = vWinCal.document;
calc_doc.write (str_buffer);
calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
if (!re_date.exec(str_datetime))
return &nbs p; al er t( "Invalid Datetime format: "+ str_datetime);
return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
return (new String (
dt_datetime.getFul lYear()+"-"+ (dt_datetime.getMonth()+1)+"-"+dt_datetime.getDate()+" "));
}
function dt2tmstr (dt_datetime) {
return (new String (
dt_datetime.getHou rs()+":"+dt_ datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}
function te()
{
document.tecreate.formula.value = 'ph_createtimedevent(0,"' + document.macro.id.value + '",' + document.tstest.timestamp.value +' )';
document.tecreate.submit();
}
// -->
</script>
</head>
<body bgcolor="#ffffff">
<form method="post" action="/ph-cgi/evalformula" name="tecreate"><input type="hidden" name="formula"><input type="hidden" name="nexturl" value="/ph-cgi/main"></form>
<form name="macro">Macro: <select name="id" size=1>
<option value="">
<%ph_rtne(ph_sqlselect(1,"select id from macroheader order by 1") + ph_setvar_a(1,1,1) + ph_doloop("ph_concatvar(1,2,'<option value=~~"' + ph_getdata(1,ph_getvar_n(1,1),1) + '~~">' + ph_getdata(1,ph_getvar_n(1,1),1) + '~r~n') + ph_rtne(ph_addtovar(1,1,1))","ph_getvar_n(1,1) <= ph_getsqlrows(1)")) + ph_getvar_s(1,2) + ph_rtne(ph_sqldestroy(1))%>
</select>
</form>
<form name="tstest">Time and Date:
<input type="Text" name="timestamp" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" alt="Click Here to Pick up the timestamp"></a>
</form>
<br></br>
<form name="create"><input type="button" value="Create" onclick="te()"></form>
</body>
</html>
|
|
|
the Date amnd Time are passed to PH because I can find it in the eventlog however a TimedEvent is NOT created... When I use you example the Time Event is actually created... There is still something worng in this... Can anyone find out what?
It has something to do with the altered function te() but like I said: I am not a javascript programmer...
this is an example found in the eventlog:
ph_createtimedevent%280%2C%22EETKAMERLAMP+UIT%22%2C2007-1-31
+12%3A53%3A14+%29&nexturl=%2Fph-cgi%2Fmain
second try:
ph_createtimedevent%280%2C%22EETKAMERLAMP+UIT%22%2C2007-1-31
+12%3A58%3A26+%29&nexturl=%2Fph-cgi%2Fmain
Peter
Edited by krommetje - January 26 2007 at 07:10
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 27 2007 at 09:51 | IP Logged
|
|
|
I've been banging my head on this one for a few hours this morning, and I think the problem has something to do with plus signs replacing spaces.
<later>
No, that's not it. It's the single-digit numbers that need to have leading zeros.
Edited by TonyNo - January 27 2007 at 10:11
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 27 2007 at 11:06 | IP Logged
|
|
|
Got it...
Timed Event Scheduler Code (PSP)
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 27 2007 at 20:26 | IP Logged
|
|
|
Now to kick it up a notch!
Here's a version that adds point-and-click time value tweaking.
dtpicker2.psp
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 28 2007 at 03:50 | IP Logged
|
|
|
And Again I have to go on my knees for TonyNo....
What did you do to solve the leading zero problem?
Could you post the GIFS belonging to the dtpicker.psp page?
Peter
p.s. I am going to post it in the repository!
Edited by krommetje - January 28 2007 at 03:52
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 28 2007 at 08:34 | IP Logged
|
|
|
I added a zeropad function to add zeros.
Code:
function zeropad(number) {
outstr=number.toString();
while(outstr.length<2) outstr='0'+outstr;
return outstr;
} |
|
|
For the graphics, I just rotated an arrow from the calendar...
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: January 28 2007 at 12:20 | IP Logged
|
|
|
I am not a javascript programmer but this little piece of code I understand... Thank you again for solving this...
Peter
|
Back to Top |
|
|
|
|