<span style="display:none;" id="mainpage-for_user" data-user="{{ for_user }}"></span>

<div style="margin-bottom: 3px;" class="stream">
{% if ui__show_user_jobs %}
	<small class="mainpage-jobs__switch" data-user="" style="display: none;" id="mainpage-jobs__switch__user">show&nbsp;my&nbsp;tests&nbsp;only</small>
	<small class="mainpage-jobs__switch visible" data-user="{{ request.user.id }}" id="mainpage-jobs__switch__all">show&nbsp;all&nbsp;tests</small>
{% else %}
	<small class="mainpage-jobs__switch visible" data-user="" id="mainpage-jobs__switch__user">show&nbsp;my&nbsp;tests&nbsp;only</small>
	<small class="mainpage-jobs__switch" data-user="{{ request.user.id }}" style="display: none;" id="mainpage-jobs__switch__all">show&nbsp;all&nbsp;tests</small>
{% endif %}
</div>
<div class="mainpage-jobs" data-filter="{{ show_all_jobs }}">
     <div class="mainpage-jobs__panel-online">
     </div>
     <div class="mainpage-jobs__panel-offline">
     	<span class="mainpage-jobs__krutilka" ><span class="krutilka fa fa-circle-o-notch fa-spin"></span> Loading...</span>
     </div>
</div>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/html" id="onlineJobTemplate">
    <div class="alert alert-warning mainpage-jobs__online">
		<div class="row"  style="position: relative;">
  			<div  class="col-sm-2">
				<a href="/<%= job.job_number %>"><div id="job_<%= job.job_number %>_preview" style="border: 1px none #c5c8d0; width:125px; height:91px; float: left;"></div></a>
  			</div>
			<div  class="col-sm-2">
				<h5 class="media-heading" style="font-weight: bold;">
					<a href="/<%= job.job_number %>"><%= job.job_number %></a>
					&nbsp;
					<% if (owner) { %>
						<span class="fa fa-stop text-danger stop_button" title="Stop" id="stop_button__<%= job.job_number %>" style="cursor: pointer;font-size: 22px;"></span>
					<% } %>
                    <span style="font-size: 12pt; font-weight: bold; white-space: nowrap; line-height: 1;" title="<%= job.cool_id %>"><%= job.cooler_id %></span>
					<br>
				</h5>
			</div>
  			<div class="col-sm-6">
				<% if (job.job_name) { %>
	    			<strong><%- job.job_name %></strong>
					<br>
				<% } %>
				<% if (job.job_dsc) { %>
	    			<span><%- job.job_dsc %></span>
					<br>
				<% } %>
			</div>
			<div class="col-sm-2">
				<div class="media-right" style="float:right;">
					<div class="dropdown">
						<img class="img-circle" id="user-avatar" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="border-radius: 50%; cursor: pointer;" src="<%= job.user_avatar_link %>" width="49" height="49"></img>
						<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="user-avatar" style="padding-left: 10px; padding-right: 10px;">
		    				<li><a href="/?user=<%= job.user_id %>" aria-hidden="true">Show user's tests</a></li>
							<% if (job.user_profile_link) { %>
		    					<li><a target="_blank" href="<%= job.user_profile_link %>">Profile</a></li>
							<% } %>
						</ul>
					</div>
				</div>
				<% if (owner) { %>
					<div style="float:right;">
						<% if (job.flag) { %>
							<i class="fa fa-star stream__action stream__action_active" aria-hidden="true" data-action="star" data-job="<%= job.job_number %>" title="Favorite"></i>
						<% } else { %>
							<i class="fa fa-star stream__action" aria-hidden="true" data-action="star" data-job="<%= job.job_number %>" title="Favorite"></i>
						<% } %>
						<i class="fa fa-pencil stream__action" data-action="edit" data-job="<%= job.job_number %>" title="Edit" aria-hidden="true"></i>
						</div>
				<% } %>
			</div>
		</div>
	</div>
</script>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/html" id="offlineJobTemplate">
<div class="offline" id="stream_offl_job_<%= job.job_number %>" data-job="<%= job.job_number %>">
    <div class="alert alert-default mainpage-jobs__offline">
		<div class="row"  style="position: relative;">
  		<div  class="col-sm-2">
			<div class="media-left">
				<a href="/<%= job.job_number %>"><div id="job_<%= job.job_number %>_preview" style="border: 1px none #c5c8d0; width:125px; height:91px; float: left;"></div></a>
  			</div>
		</div>
		<div class="col-sm-2">
			<h5 class="media-heading" style="font-weight: bold; margin-bottom: 0;">
				<a href="/<%= job.job_number %>"><%= job.job_number %></a>
			</h5>
            <span style="font-size: 12pt; font-weight: bold; white-space: nowrap; line-height: 1;" title="<%= job.cool_id %>"><%= job.cooler_id %></span>
			<br>
			<span class="<%= statusIcons[job.quit_status_text_short] %>" title="<%= job.quit_status_text %>"></span>
            <div style="padding:5px 0;">
				<% if (job.net) { %>
					<b class="tag tag-danger b-overload-offlinepage__indicator">net</b>
				<% } else { %>
					<b class="tag tag-success b-overload-offlinepage__indicator">net</b>
				<% } %>
				&nbsp;
				<% if (job.http_2) { %><b class="tag tag-success b-overload-offlinepage__indicator" title="http">2xx</b><% } %>
				<% if (job.http_3) { %><b class="tag tag-info b-overload-offlinepage__indicator" title="http">3xx</b><% } %>
				<% if (job.http_4) { %><b class="tag tag-warning b-overload-offlinepage__indicator" title="http">4xx</b><% } %>
				<% if (job.http_5) { %><b class="tag tag-danger b-overload-offlinepage__indicator" title="http">5xx</b><% } %>
			</div>
		</div>
		<div class="col-sm-6">
			<dl>
				<dd style="font-weight: bold; white-space: normal;">
				<% if (owner) { %>
					<span class="b-overload-offline-meta__title <% if (owner) { %>b-editable<% } %>" id="name" data-action="edit-name" data-job="<%= job.job_number %>"><% if (job.job_name) { %><%- job.job_name %><% } else { %><span style="color: gray;">Test name</span><% } %></span>
					<span class="fa fa-pencil text-warning" id="name_pencil__<%= job.job_number %>" style="display: none;"></span>
					<div class="b_editname_block" id="b_editname_block__<%= job.job_number %>" style="display: none;">
						<table width="100%">
							<tr>
								<td width="100%">
									<input type="text" id="b_editname_block__firename__<%= job.job_number %>" data-job="<%= job.job_number %>" class="form-control b_textinput b_textinput__10">
								</td>
								<td>
								<div id="b_editname_block__okey__<%= job.job_number %>" data-job="<%= job.job_number %>" class="b_name_edit_block b_editname_block__okey">
									<span class="fa fa-check text-success b-editable" style="font-size: 12px;"></span>
								</div></td>
								<td>
								<div id="b_editname_block__cancel__<%= job.job_number %>" data-job="<%= job.job_number %>" class="b_name_edit_block b_editname_block__cancel">
									<span class="fa fa-ban text-danger b-editable" style="font-size: 12px;"></span>
								</div></td>
								<td>
								<div id="b_editname_block__ajax__<%= job.job_number %>" class="b_name_edit_block" style="display:none;">
									<span class="krutilka fa fa-circle-o-notch fa-spin"></span>
								</div></td>
							</tr>
						</table>
					</div>
				<% } else { %>
					<span class="b-overload-offline-meta__title"><% if (job.job_name) { %><%- job.job_name %><% } else { %><span style="color: gray;">Test name</span><% } %></span>
				<% } %>
				</dd>
				<dd style="white-space: normal; max-height: 108px; overflow: auto;">
					<span class="b-overload-offline-meta__description <% if (owner) { %>b-editable<% } %>" id="dsc" data-action="edit-dsc" data-job="<%= job.job_number %>" style="font-size: 80%; white-space: pre-line"><% if (job.job_dsc) { %><%- job.job_dsc %><% } else { %><span style="color: gray;">Description</span><% } %></span>
					<% if (owner) { %>
					<span class="fa fa-pencil text-warning" id="dsc_pencil__<%= job.job_number %>" style="display: none;"></span>
					<div class="b_editcomment_block" id="b_editcomment_block__<%= job.job_number %>" style="display: none;">
						<table width="100%">
							<tr>
								<td width="100%">
									<textarea id="b_editcomment_block__firecomment__<%= job.job_number %>" class="form-control b_textinput b_textinput__10 b_textinput__"></textarea></td>
								<td>
								<div id="b_editcomment_block__okey__<%= job.job_number %>" data-job="<%= job.job_number %>" class="b_name_edit_block2 b_editcomment_block__okey">
									<span class="fa fa-check text-success b-editable" style="font-size: 12px;"></span>
								</div>
								<div id="b_editcomment_block__cancel__<%= job.job_number %>" data-job="<%= job.job_number %>" class="b_name_edit_block2 b_editcomment_block__cancel">
									<span class="fa fa-ban text-danger b-editable" style="font-size: 12px;"></span>
								</div>
								<div id="b_editcomment_block__ajax__<%= job.job_number %>" class="b_name_edit_block2" style="display:none;">
									<span class="krutilka fa fa-circle-o-notch fa-spin"></span>
								</div></td>
							</tr>
						</table>
					</div>
					<% } %>
				</dd>
			</dl>
		</div>
		<div class="col-sm-2">
			<div class="media-right" style="float: right; margin-bottom: 10px;">
				<div class="dropdown">
					<img class="img-circle" id="user-avatar" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="border-radius: 50%; cursor: pointer;" src="<%= job.user_avatar_link %>" width="49" height="49"></img>
					<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="user-avatar" style="padding-left: 10px; padding-right: 10px;">
		    			<li><a href="/?user=<%= job.user_id %>" aria-hidden="true">Show user's tests</a></li>
						<% if (job.user_profile_link) { %>
		    				<li><a target="_blank" href="<%= job.user_profile_link %>">Profile</a></li>
						<% } %>
					</ul>
				</div>
			</div>
			<% if (owner) { %>
				<div style="float:right;">
					<% if (job.flag) { %>
						<i class="fa fa-star stream__action text-warning" aria-hidden="true" data-action="star" data-job="<%= job.job_number %>" title="Favorite"></i>
					<% } else { %>
						<i class="fa fa-star stream__action text-muted" aria-hidden="true" data-action="star" data-job="<%= job.job_number %>" title="Favorite"></i>
					<% } %>
					<i class="fa fa-pencil stream__action text-warning" data-action="edit" data-job="<%= job.job_number %>" title="Edit" aria-hidden="true"></i>
					<i class="fa fa-trash stream__action text-danger" data-action="remove" data-job="<%= job.job_number %>" title="Remove" aria-hidden="true"></i>
				</div>
			<% } %>
		</div>
		</div>
	</div>
</div>
</script>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/html" id="jobCommentsTemplate">
	<div>
		<%= comment.text %>
		<button class="btn btn-primary" id="replyTo__<%= comment.id %>" data-target="#reply__<%= comment.id %>">Reply</button>
		<% if (owner) { %>
			<button class="btn btn-secondary" id="editComment__<%= comment.id %>">Edit</button>
		<% } %>
		<div id="reply__<%= comment.id %>" class="collapse">
			<input type="text" class="form-control" value=""/>
		</div>
	</div>
</script>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type='text/javascript' src='/media/js/mainpage/stream.js?version=37'></script>
