| 1 |
window.onload = function() { |
| 2 |
|
| 3 |
var expanded = []; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
var should_sync = true; |
| 10 |
|
| 11 |
$(document).ready(function() { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
$('.api-detail') |
| 17 |
.on('hide.bs.collapse', function(e) { |
| 18 |
processButton(this, 'detail'); |
| 19 |
var index = expanded.indexOf(this.id); |
| 20 |
if (index > -1) { |
| 21 |
expanded.splice(index, 1); |
| 22 |
} |
| 23 |
sync_expanded(); |
| 24 |
}) |
| 25 |
.on('show.bs.collapse', function(e) { |
| 26 |
processButton(this, 'close'); |
| 27 |
expanded.push(this.id); |
| 28 |
sync_expanded(); |
| 29 |
}); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
var expandAllActive = true; |
| 35 |
$('#expand-all').click(function () { |
| 36 |
should_sync = false; |
| 37 |
if (expandAllActive) { |
| 38 |
expandAllActive = false; |
| 39 |
$('.api-detail').collapse('show'); |
| 40 |
$('#expand-all').attr('data-toggle', ''); |
| 41 |
$(this).text('Hide All'); |
| 42 |
} else { |
| 43 |
expandAllActive = true; |
| 44 |
$('.api-detail').collapse('hide'); |
| 45 |
$('#expand-all').attr('data-toggle', 'collapse'); |
| 46 |
$(this).text('Show All'); |
| 47 |
} |
| 48 |
should_sync = true; |
| 49 |
sync_expanded(); |
| 50 |
}); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
if (window.location.search.substring(1).indexOf("expanded") > -1) { |
| 55 |
should_sync = false; |
| 56 |
var parts = window.location.search.substring(1).split('&'); |
| 57 |
for (var i = 0; i < parts.length; i++) { |
| 58 |
var keyval = parts[i].split('='); |
| 59 |
if (keyval[0] == "expanded" && keyval[1]) { |
| 60 |
var expanded_ids = keyval[1].split(','); |
| 61 |
for (var j = 0; j < expanded_ids.length; j++) { |
| 62 |
$('#' + expanded_ids[j]).collapse('show'); |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
should_sync = true; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
$(document.body).scrollTop($(window.location.hash).offset().top); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
$('.mv_selector').on('click', function(e) { |
| 77 |
var version = e.currentTarget.innerHTML; |
| 78 |
|
| 79 |
$(this).addClass('active').siblings().removeClass('active'); |
| 80 |
if (version == "All") { |
| 81 |
reset_microversion(); |
| 82 |
} else { |
| 83 |
set_microversion(version); |
| 84 |
} |
| 85 |
}); |
| 86 |
}); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
function processButton(button, text) { |
| 91 |
$('#' + $(button).attr('id') + '-btn').text(text) |
| 92 |
.toggleClass('btn-info') |
| 93 |
.toggleClass('btn-default'); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
function sync_expanded() { |
| 101 |
if (should_sync) { |
| 102 |
var url = UpdateQueryString('expanded', expanded.join(',')); |
| 103 |
history.pushState('', 'new expand', url); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
function UpdateQueryString(key, value, url) { |
| 112 |
if (!url) url = window.location.href; |
| 113 |
var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"), |
| 114 |
hash; |
| 115 |
|
| 116 |
if (re.test(url)) { |
| 117 |
if (typeof value !== 'undefined' && value !== null) |
| 118 |
return url.replace(re, '$1' + key + "=" + value + '$2$3'); |
| 119 |
else { |
| 120 |
hash = url.split('#'); |
| 121 |
url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, ''); |
| 122 |
if (typeof hash[1] !== 'undefined' && hash[1] !== null) |
| 123 |
url += '#' + hash[1]; |
| 124 |
return url; |
| 125 |
} |
| 126 |
} |
| 127 |
else { |
| 128 |
if (typeof value !== 'undefined' && value !== null) { |
| 129 |
var separator = url.indexOf('?') !== -1 ? '&' : '?'; |
| 130 |
hash = url.split('#'); |
| 131 |
url = hash[0] + separator + key + '=' + value; |
| 132 |
if (typeof hash[1] !== 'undefined' && hash[1] !== null) |
| 133 |
url += '#' + hash[1]; |
| 134 |
return url; |
| 135 |
} |
| 136 |
else |
| 137 |
return url; |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
function set_microversion(number) { |
| 144 |
var major = number.split(".")[0]; |
| 145 |
var micro = number.split(".")[1]; |
| 146 |
for (var i = os_min_mv; i <= os_max_mv; i++) { |
| 147 |
var max_class = ".rp_max_ver_" + major + "_" + i; |
| 148 |
var min_class = ".rp_min_ver_" + major + "_" + i; |
| 149 |
if (i < micro) { |
| 150 |
$(max_class).hide(400); |
| 151 |
$(min_class).show(400); |
| 152 |
} else if (i >= micro) { |
| 153 |
$(min_class).hide(400); |
| 154 |
$(max_class).show(400); |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
function reset_microversion() { |
| 160 |
$('[class^=rp_min_ver]').show(400); |
| 161 |
$('[class^=rp_max_ver]').show(400); |
| 162 |
} |
| 163 |
|
| 164 |
}; |