AC-1235 Speed up JS for inventory script view in browsable API.

This commit is contained in:
Chris Church
2014-05-01 19:33:46 -04:00
parent 92eb56e1d3
commit 78b5378b57

View File

@@ -207,45 +207,27 @@ html body .dropdown-submenu:hover>a {
$(function() { $(function() {
// Make links from relative URLs to resources. // Make links from relative URLs to resources.
$('span.str').each(function() { $('span.str').each(function() {
// Remove REST API links within data.
if ($(this).parent('a').size()) {
$(this).unwrap();
}
var s = $(this).html(); var s = $(this).html();
if (s.match(/^\"\/.+\/\"$/) || s.match(/^\"\/.+\/\?.*\"$/)) { if (s.match(/^\"\/.+\/\"$/) || s.match(/^\"\/.+\/\?.*\"$/)) {
$(this).html('"<a href=' + s + '>' + s.replace(/\"/g, '') + '</a>"'); $(this).html('"<a href=' + s + '>' + s.replace(/\"/g, '') + '</a>"');
} }
}); });
// Make links for all inventory script hosts. // Make links for all inventory script hosts.
$('.request-info .pln:contains("script")').each(function() { $('.request-info .pln').filter(function() {
$('.response-info span.str:contains("hosts")').each(function() { return $(this).text() === 'script';
if ($(this).text() != '"hosts"') { }).each(function() {
return; $('.response-info span.str').filter(function() {
} return $(this).text() === '"hosts"';
var hosts_state = 0; }).each(function() {
$(this).find('~ span').each(function() { $(this).nextUntil('span.pun:contains("]")').filter('span.str').each(function() {
if (hosts_state == 0) { if ($(this).text().match(/^\".+\"$/)) {
if ($(this).is('span.pun') && $(this).text() == '[') { var s = $(this).text().replace(/\"/g, '');
hosts_state = 1; $(this).html('"<a href="' + '?host=' + s + '">' + s + '</a>"');
} }
} else if ($(this).text() !== '"') {
else if (hosts_state == 1) { var s = $(this).text();
if ($(this).is('span.pun') && ($(this).text() == ']' || $(this).text() == '],')) { $(this).html('<a href="' + '?host=' + s + '">' + s + '</a>');
hosts_state = 2; }
}
else if ($(this).is('span.str')) {
if ($(this).text() == '"') {
}
else if ($(this).text().match(/^\".+\"$/)) {
var s = $(this).text().replace(/\"/g, '');
$(this).html('"<a href="' + '?host=' + s + '">' + s + '</a>"');
}
else {
var s = $(this).text();
$(this).html('<a href="' + '?host=' + s + '">' + s + '</a>');
}
}
}
}); });
}); });
}); });