Implemented AJAX request for inserting date/time
SVN revision: 1838
This commit is contained in:
+31
-2
@@ -112,8 +112,37 @@ function queryHeading(text)
|
||||
|
||||
function insertTime(text)
|
||||
{
|
||||
selection = getSelection(text);
|
||||
elcode1(text, '', datetime, selection);
|
||||
var xmlHttp;
|
||||
|
||||
try {
|
||||
xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
catch (e) {
|
||||
alert("Your browser does not support AJAX!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlHttp.onreadystatechange = function()
|
||||
{
|
||||
if(xmlHttp.readyState == 4)
|
||||
{
|
||||
selection = getSelection(text);
|
||||
elcode1(text, '', xmlHttp.responseText, selection);
|
||||
}
|
||||
}
|
||||
|
||||
xmlHttp.open("GET","?cmd=gettimedate",true);
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
|
||||
function elKeyInit()
|
||||
|
||||
+13
-8
@@ -9233,13 +9233,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
||||
else
|
||||
rsprintf("browser = 'Other';\n");
|
||||
|
||||
if (!getcfg(lbs->name, "Time format", format, sizeof(format)))
|
||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||
time(<ime);
|
||||
pts = localtime(<ime);
|
||||
my_strftime(str, sizeof(str), format, pts);
|
||||
rsprintf("datetime = '%s';", str);
|
||||
|
||||
rsprintf("//-->\n");
|
||||
rsprintf("</script>\n");
|
||||
|
||||
@@ -24361,7 +24354,7 @@ void server_loop(void)
|
||||
{
|
||||
int status, i, n, n_error, authorized, min, i_min, i_conn, length;
|
||||
struct sockaddr_in serv_addr, acc_addr;
|
||||
char pwd[256], str[1000], url[256], cl_pwd[256], *p;
|
||||
char pwd[256], str[1000], url[256], cl_pwd[256], format[256], *p;
|
||||
char cookie[256], boundary[256], list[1000], theme[256],
|
||||
host_list[MAX_N_LIST][NAME_LENGTH], logbook[256], logbook_enc[256], global_cmd[256];
|
||||
int lsock, len, flag, content_length, header_length;
|
||||
@@ -24370,6 +24363,8 @@ void server_loop(void)
|
||||
struct timeval timeout;
|
||||
char *net_buffer = NULL;
|
||||
int net_buffer_size;
|
||||
time_t now;
|
||||
struct tm *ts;
|
||||
|
||||
i_conn = content_length = 0;
|
||||
net_buffer_size = 100000;
|
||||
@@ -25279,6 +25274,16 @@ void server_loop(void)
|
||||
if (!logbook[0] && global_cmd[0] && stricmp(global_cmd, "GetConfig") == 0) {
|
||||
download_config();
|
||||
goto redir;
|
||||
} else if (stricmp(global_cmd, "gettimedate") == 0) {
|
||||
if (!getcfg(logbook, "Time format", format, sizeof(format)))
|
||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||
time(&now);
|
||||
ts = localtime(&now);
|
||||
my_strftime(str, sizeof(str), format, ts);
|
||||
show_http_header(NULL, FALSE, NULL);
|
||||
rsputs(str);
|
||||
rsputs(" ");
|
||||
goto redir;
|
||||
} else if (strncmp(net_buffer, "GET", 3) == 0) {
|
||||
/* extract path and commands */
|
||||
if (strchr(net_buffer, '\r'))
|
||||
|
||||
Reference in New Issue
Block a user