summaryrefslogtreecommitdiffstats
path: root/lib/libadmin/template.c
blob: 71e576cb3b6c421a3e6efc03a4deeb97ddeb0aba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
/* 
 * template.c:  The actual HTML templates in a static variable 
 *            
 * All blame to Mike McCool
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libadmin/libadmin.h"

NSAPI_PUBLIC char *helpJavaScriptForTopic( char *topic )
{
    char *tmp;
    char line[BIG_LINE];
    char *server="admserv";
    char *type;
    int	 typeLen;

    /* Get the server type, without the instance name into type */
    tmp = strchr( server, '-' );
    typeLen = tmp - server;

    type = (char *)MALLOC( typeLen + 1 );
    type[typeLen] = '\0';
    while ( typeLen-- ) {
      type[typeLen] = server[typeLen];
    }
    util_snprintf( line, BIG_LINE,
		   "if ( top.helpwin ) {"
		   "  top.helpwin.focus();"
		   "  top.helpwin.infotopic.location='%s/%s/admin/tutor?!%s';"
		   "} else {"
		   "  window.open('%s/%s/admin/tutor?%s', '"
		   INFO_IDX_NAME"_%s', "
		   HELP_WIN_OPTIONS");}",
		   getenv("SERVER_URL"), server, topic,
		   getenv("SERVER_URL"), server, topic,
		   type );
		   
    return(STRDUP(line));
}

NSAPI_PUBLIC char *helpJavaScript()
{
    char *tmp, *sn;

    tmp=STRDUP(getenv("SCRIPT_NAME"));
    if(strlen(tmp) > (unsigned)BIG_LINE)
        tmp[BIG_LINE-2]='\0';
    sn=strrchr(tmp, '/');
    if( sn )
        *sn++='\0';
    return helpJavaScriptForTopic( sn );
}