<%@ page import="com.atlassian.jira.web.SessionKeys,
                 com.atlassian.jira.user.UserHistory,
                 java.util.Iterator,
                 com.opensymphony.util.TextUtils,
                 com.atlassian.core.util.StringUtils"%>
<%@ taglib uri="webwork" prefix="webwork" %>

<%-- if you change something here - make sure you also change it in issuepicker.jsp --%>
<html>
<head><title><webwork:text name="'popups.recenthistory.title'"/></title></head>
<hr>
<script language="JavaScript" type="text/javascript">
<!--
// Provide hover and click effect to entire table rows.
// Usage:
// <table class="grid">
//   <tr href="somelink.jsp" onmouseover="rowHover(this)">
//   ...

function rowHover(row)
{
    row.oldClassName = row.className;
    row.className = 'rowHover';
    row.onmouseout = function()
    {
        this.className = this.oldClassName;
    }
}

function openLinkToIssue(issueKey)
{
   if(window.opener != null)
   {
       window.opener.location='<%= request.getContextPath()%>/browse/' + issueKey;
       window.close();
       return false;
   }
   else
   {
       return true;
   }
}
	//-->
</script>
<body>

<%
    UserHistory history = null;
    if (session.getAttribute(SessionKeys.USER_ISSUE_HISTORY) == null)
    {
%>

<p><webwork:text name="'popups.recenthistory.noissues'"/></p>
<%
    }
    else
    {
%>
<table width="100%">
<%
        history = (UserHistory) session.getAttribute(SessionKeys.USER_ISSUE_HISTORY);
        for (Iterator iterator = history.getIssues().iterator(); iterator.hasNext();)
        {
            UserHistory.IssueSummary issueSummary = (UserHistory.IssueSummary) iterator.next();
            String summary = TextUtils.htmlEncode(issueSummary.getSummary());
            String shortSummary = StringUtils.crop(summary, 80, " ...");
%>
    <tr onmouseover="rowHover(this)" onClick="javascript:openLinkToIssue('<%= issueSummary.getIssueKey() %>');" >
    <td width="1%" nowrap><a href="<%= request.getContextPath()%>/browse/<%= issueSummary.getIssueKey() %>" title="<%= shortSummary %>" onClick="javascript:openLinkToIssue('<%= issueSummary.getIssueKey() %>');"><%= issueSummary.getIssueKey() %></a> &nbsp;</td>
    <td><a href="<%= request.getContextPath()%>/browse/<%= issueSummary.getIssueKey() %>" title="<%= shortSummary %>" onClick="javascript:openLinkToIssue('<%= issueSummary.getIssueKey() %>');" style="text-decoration: none; "><%= shortSummary %> </td></tr>
<%
        }
    }
%>
</table>

</body>
</html>