#!/bin/csh -f
echo "Content-type: text/html"
echo ""

setenv HD /data/globec

if ( ! -e /jgofsopt/$REMOTE_HOST ) then
        mkdir /jgofsopt/$REMOTE_HOST
	cp $HD/htmlsrc/setup/* /jgofsopt/$REMOTE_HOST
        endif
cd /jgofsopt/$REMOTE_HOST

set tmp=$PATH_INFO
setenv OBJ $tmp:r
setenv FULLOBJ $OBJ
setenv UQOBJ $OBJ
setenv QS ""
unsetenv PATH_INFO

#
# 10/28/97 clh added a sed to remove final space introduced by htmlesc
#     note:  better idea when time available is to determine why htmlesc
#     wants to introduce the space.  Is it useful somewhere?  Can we 
#     change THAT use to add the space?  Seems better than having it 
#     added 'blindly'.
# 10/30/97 clh moved the sed to a script to strip the space.
#
if ( "$QUERY_STRING" != "" ) then
  setenv QS "`$HD/htmlbin/chop < $HD/htmlbin/bin/htmlesc '$QUERY_STRING'`"
  setenv FULLOBJ "$OBJ($QS)"
  setenv UQOBJ "$OBJ($QUERY_STRING)"
endif

set CUROPT=(`cat plotopt`)

cat <<XXstuffXX
<html><head><title>Simple XY Plotting</title></head>
<body>
<h1>Simple XY Plot</h1>
<b>Current object is:  $FULLOBJ</b></br>
<hr noshade>
<p>
<font size="3">
<a href="/jg/cleanplot$OBJ.plotopt?$QUERY_STRING">Select this link, if the form looks incomplete</a>.
</font>
<form action="/jg/plotxy$OBJ?$QS" method="POST">
XXstuffXX

$HD/bin/listvar "$UQOBJ" > variables

cat <<XXstuffXX
Select an X variable ($CUROPT[1]): <select name="xvar" size="4">
XXstuffXX

$HD/htmlbin/bin/nawkscr $CUROPT[1] < variables

cat <<XXstuffXX
</select><br>
Select a reverse or log X axis ($CUROPT[2]):  <select name="xopt">
XXstuffXX

$HD/htmlbin/bin/nawkscr $CUROPT[2] << XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX

cat <<XXstuffXX
</select>
<br>
Select a Y variable ($CUROPT[3]): <select name="yvar" size="4">
XXstuffXX

$HD/htmlbin/bin/nawkscr $CUROPT[3] < variables

cat <<XXstuffXX
</select><br>
Select a reverse or log Y axis ($CUROPT[4]):  <select name="yopt">
XXstuffXX

$HD/htmlbin/bin/nawkscr $CUROPT[4]  <<XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX

cat <<XXstuffXX
</select><br>
Select a symbol for plotting the values ($CUROPT[5]): <select name="sym">
XXstuffXX

$HD/htmlbin/bin/nawkscr $CUROPT[5] <<XXSTUFFXX
line
+
o
x
+(connected)
o(connected)
x(connected)
XXSTUFFXX

cat <<XXstuffXX
</select><p>
<hr noshade>
<input type="submit" value="Make the Plot"> if the selected options are satisfactory.
</form>
</body>
</html>
XXstuffXX
