
pro trace_movie_qkl_queue, directory, tstart, tstop, $
			   html=html, insert_index=insert_index
;+
;   Name: trace_recent_movie_summary  
;
;   Purpose: return info/html summary re: recent only movie directories
;-

dirs=file_list('$path_http','last_movies_????????_????')
if dirs(0) eq '' then begin
    box_message,'No recent movie queue online..., returning'
    return
endif

dirs=[concat_dir('$path_http','last_movies'),reverse(dirs) ] ; reverse cronological
ndirs=n_elements(dirs)

genx=file_list(dirs,'*genx')

if total(file_exist(genx)) ne ndirs then begin
   box_mesage,'Cannot find all movie catalogs..., returning'
   return
endif 

d1='<!** START QUEUE**>'
d2='<!** STOP QUEUE**>'

directory=dirs
tstart=strarr(ndirs)
tstop=strarr(ndirs)
for i=0,n_elements(dirs)-1 do begin
  restgen,file=genx(i),t0,t1
  tstart(i)=anytim(t0,/vms)
  tstop(i)=anytim(t1,/vms)
endfor  

rdirs=strtrim(strextract(dirs+' ','/TRACE',' ',/inc),2)

html='<a href="'+rdirs+'">'+rdirs+'</a>'
htab=transpose([[html],[tstart],[tstop]])

httab=strtab2html(htab,/left, border=1,cellpad=2)
html=[d1, '<p>Recent queue of TRACE movies now online',httab, d2]

if keyword_set(insert_index) then begin
   box_message,'Updating index.htmls...
   index=file_list(dirs,'index.html')
   for i=0,n_elements(index)-1 do begin
      curdata=rd_tfile(index(i))
      ss=where(strpos(curdata,d1) ne -1, sscnt)
      case sscnt of
	 0:    newdata=strarrinsert(curdata, html,'SolarSoft', status=status,/first)
	 else: newdata=strarrinsert(curdata, html, d1, d2,     status=status,/first)
      endcase
      if not status then begin
	  box_message,'Could not update index html'
       endif else begin
          box_message,'Updating: ' + index(i)
          file_append,index(i), newdata, /new
       endelse
   endfor         
endif

return
end
  
  
