<%@ page import="com.atlassian.jira.web.SessionKeys,
                 com.atlassian.jira.user.UserHistory,
                 java.util.Iterator,
                 com.atlassian.core.util.StringUtils,
                 com.atlassian.jira.config.properties.APKeys,
                 com.atlassian.jira.config.properties.ApplicationProperties,
                 com.atlassian.jira.ManagerFactory,
                 com.opensymphony.util.TextUtils"%>
<script language="javascript">
    function rowHover(row)
    {
        row.oldClassName = row.className;
        row.className = 'rowHover';
        row.onmouseout = function()
        {
            this.className = this.oldClassName;
        }
    }

    function showHistory(event)
    {
        var popupHtml = '<table border=0 cellpadding=0 cellspacing=0 width=100% bgcolor=ffffff>';
        popupHtml += '<tr><td width="1%"><img src="<%= request.getContextPath() %>/images/icons/favicon.png" border="0"></td><td bgcolor="<%= topBgColour %>" class="navitem" valign="middle">&nbsp;&nbsp;History</td></tr>';
        popupHtml += '<tr><td colspan="2" bgcolor="<%= menuBgColour %>"><img src="<%= request.getContextPath() %>/images/border/spacer.gif" height=5 width=1></td></tr>';
        popupHtml += '</table>';

        popupHtml += '<table width="100%">';
        <% UserHistory hist = (UserHistory) session.getAttribute(SessionKeys.USER_ISSUE_HISTORY);
            if (session.getAttribute(SessionKeys.USER_ISSUE_HISTORY) == null) { %>
            popupHtml += '<tr><td>No issues in your history.</td></tr>';
        <% } else {%>
            <% hist = (UserHistory) session.getAttribute(SessionKeys.USER_ISSUE_HISTORY);
                for (Iterator iterator = hist.getIssues().iterator(); iterator.hasNext();)
                {
                    UserHistory.IssueSummary issueSummary = (UserHistory.IssueSummary) iterator.next();
                    String summary = TextUtils.htmlEncode(issueSummary.getSummary());
                    String shortSummary = StringUtils.crop(summary, 30, " ... !!!");

                    shortSummary = org.apache.commons.lang.StringUtils.replace(shortSummary,"'", "&#39;");

            %>
            popupHtml += '<tr onmouseover="rowHover(this)" onClick="javascript:window.location.href=\'<%= request.getContextPath()%>/browse/<%= issueSummary.getIssueKey()%>\';"><td width="1%" nowrap><a href=\'<%= request.getContextPath()%>/browse/<%= issueSummary.getIssueKey()%>\'><%=issueSummary.getIssueKey()%></a></td>';
            popupHtml += '<td><%= shortSummary %></td></tr>';
        <% } }%>
            popupHtml += '</table>';
        showHelpTip(event, popupHtml, true);
        return false;
    }
</script>