<%@ page import="zall.ZalleryTranscoder" %>
<%@ page import="zall.bean.*" %>
<%@ page import="java.util.Queue" %>
<%@ page import="java.io.IOException" %>
<%
if( session.getAttribute("user") == null ){
	response.sendRedirect("login");
	return;
}
%>
<%!
	public void transcodingHTML(JspWriter out, boolean transcoding, Video video) throws IOException{
		out.println("<DIV class='comment-author vcard'>");
		out.println("	<SPAN class='fn n'>");
		out.println("		"+(transcoding ? "Transcoding" : "Queued")+": <span style='font-weight: normal;'>"+video.getTitle()+"</span>");
		out.println("		<div class='"+(transcoding ? "progressbarGreen" : "progressbarYellow")+"'>");
		out.println("			<b class='progress' style='width: "+video.getTranscodingProgress()+"%'>"+video.getTranscodingProgress()+"%</b>");
		out.println("		</div>");
		out.println("	</SPAN>");
		out.println("</DIV>");
		out.println("<DIV class='comment-meta'>");
		out.println("	Time remaining: 10 min ");
		out.println("</DIV> ");
	}
%>
<jsp:include page="header.jsp" flush="false" />    

    <div id="main">    
        <div id="container">
            <div id="content">
                <DIV id="comments" style="margin-top: 0px">   
                   <DIV id="comments-list" class="comments">
                   		<H3>Transcoding Queue</H3>			
                        <UL id="UploadQueue">
                        	<%
                        	if( ZalleryTranscoder.getProcessingVideo() != null ){
                        		out.println("<LI>");
                        		transcodingHTML(out, true, ZalleryTranscoder.getProcessingVideo());
                        		out.println("</LI>");
                        	}
                        	Queue<Video> transQueue = ZalleryTranscoder.getQueue();
                        	for( Video video : transQueue ){ %>
                            <LI>
	                        	<% transcodingHTML(out, false, video); %>
                            </LI>
                            <%} %>
                        </UL>  
                        <DIV id="comments-nav-below" class="comment-navigation"> 
                             <DIV class="paginated-comments-links"></DIV> 
                        </DIV>                        
                    </DIV><!-- #comments-list .comments -->                    
                </div><!-- .comments -->            
            </div><!-- #content -->
        </div><!-- #container -->
    </div><!-- #main -->
    
<jsp:include page="footer.jsp" flush="true" />
