-
-
Save dodok1/7925037 to your computer and use it in GitHub Desktop.
Improved ordering and full JQL as tooltip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript'> | |
var refreshJqlHistoryPane = function() { | |
var localHistory = localStorage.getItem('jqlHistory'); | |
if(localHistory){ | |
var history = JSON.parse(localHistory); | |
var historyEntries = history.map(function(jql){ | |
var display = jql; | |
if(display.length > 25){ | |
display = display.substr(0,22) + "..."; | |
} | |
return '<li><a href="'+ AJS.contextPath() + '/issues/?jql=' + encodeURIComponent(jql) + '" title="' + AJS.escapeHtml(jql) + '">' + display + '</a></li>'; | |
}); | |
var historyBlock = '<nav class="aui-navgroup aui-navgroup-vertical"><div id="jql-history-panel"><div class="aui-nav-heading">JQL History</div>' + | |
'<ul class="aui-nav">' + | |
historyEntries.join("") + '</ul></div></nav>'; | |
if(AJS.$('#jql-history-panel')){ | |
AJS.$('#jql-history-panel').remove(); | |
} | |
AJS.$(AJS.$('.filter-panel-section')[0]).after(historyBlock); | |
} | |
} | |
var handleJqlSearch = function(){ | |
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(){ | |
var currJql = AJS.$('#advanced-search').val(); | |
if(null != currJql && currJql !== "") | |
{ | |
var rawdata = localStorage.getItem('jqlHistory'); | |
var history; | |
if(rawdata){ | |
history = JSON.parse(rawdata); | |
var match = -1; | |
while( (match = history.indexOf(currJql)) > -1 ) history.splice(match, 1); | |
history.unshift(currJql) | |
if(history.length > 10) history.pop(); | |
} | |
else{ | |
history = new Array(); | |
history.push(currJql); | |
} | |
localStorage.setItem('jqlHistory', JSON.stringify(history)); | |
} | |
refreshJqlHistoryPane(); | |
}); | |
} | |
AJS.$(document).ready(function() { | |
if(AJS.$('#advanced-search')) { | |
handleJqlSearch(); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment