#!/bin/csh -f
#Edited for globec.whoi.edu.  Add new variables jgofsroot and tmpdir
#	and use to make more portable.  rcg 7/23/1998
set jgofsroot="/data5/globec"
set tmpdir="/jgofsopt"

echo "Content-type: text/html"
echo ""

setenv HD $jgofsroot

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

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

# Move the final space introducted by htmlesc.  Moved the sed to 
#	a script to strip the space as per CH fix.  7/23/1998

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`)

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

cat << XXSTUFFXX
<html>
<title>Simple XY Plotting via Matlab</title>
<head>
<h1>Simple XY Plot via Matlab</h1>
</head>
<body>
<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>
XXSTUFFXX
# original: Note - if this page is incomplete, try clicking <a href="/jg/cleanplot$PATH_INFO?$QUERY_STRING">here</a>.


echo "<form action="\""/jg/matplot$OBJ?$QS"\"" method="\""POST"\"">"

cat << XXSTUFFXX
Plot type (gif or postscript): <select name="matfile" size="1">
<option selected>xy-gif.m
<option>xy-ps.m
</select><p>
XXSTUFFXX

echo "Select an X variable ($CUROPT[1]): <select name="\""xvar"\"" size="\""4"\"">"
$HD/htmlbin/bin/nawkscr $CUROPT[1] < variables
echo "</select><p>"

echo "Select a reverse or log X axis ($CUROPT[2]):  <select name="\""xopt"\"">"
$HD/htmlbin/bin/nawkscr $CUROPT[2] << XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX
echo "</select><p>"

echo "Select a Y variable ($CUROPT[3]): <select name="\""yvar"\"" size="\""4"\"">"
$HD/htmlbin/bin/nawkscr $CUROPT[3] < variables
echo "</select><p>"

echo "Select a reverse or log Y axis ($CUROPT[4]):  <select name="\""yopt"\"">"
$HD/htmlbin/bin/nawkscr $CUROPT[4]  << XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX
echo "</select><p>"

echo "Select a symbol for plotting the values ($CUROPT[5]): <select name="\""sym"\"">"
$HD/htmlbin/bin/nawkscr $CUROPT[5] << XXSTUFFXX
line
+
o
x
+(connected)
o(connected)
x(connected)
XXSTUFFXX
echo "</select><p>"

echo "Title: <input type="\""text"\"" size="\""50"\"" name="\""title"\"" value="\""$FULLOBJ"\""><p>"

cat << XXSTUFFXX
<hr noshade>
<input type="submit" value="Make the Plot"> if the selected options are satisfactory.
XXSTUFFXX
echo "</form>"

