mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-15 16:06:41 +03:00
c2472dcffc
This adds custom CSS classes and a widget to show/hide various parts of the docs. By default, we show exported interfaces only. The user can also select "public" (all public interfaces, even those not exported), and "everything" (even private members). Issue #1259 Change-Id: Iff8f4d84658a3d19ad8f2f979ab37b256393589f
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
function onShowChange() {
|
|
var value = document.getElementById('show').value;
|
|
localStorage.setItem('show', value);
|
|
|
|
|
|
var setVisibilityByAccess = function(access, visible) {
|
|
var selector = '.access-' + access;
|
|
var list = document.querySelectorAll(selector);
|
|
// querySelectorAll returns an array-like object, not an array.
|
|
Array.prototype.forEach.call(list, function(element) {
|
|
if (visible) {
|
|
element.classList.add('show');
|
|
} else {
|
|
element.classList.remove('show');
|
|
}
|
|
});
|
|
};
|
|
|
|
if (value == 'exported') {
|
|
setVisibilityByAccess('public', false);
|
|
setVisibilityByAccess('private', false);
|
|
} else if (value == 'public') {
|
|
setVisibilityByAccess('public', true);
|
|
setVisibilityByAccess('private', false);
|
|
} else {
|
|
setVisibilityByAccess('public', true);
|
|
setVisibilityByAccess('private', true);
|
|
}
|
|
}
|
|
|
|
function initShowWidget() {
|
|
// get the previous setting from storage and populate the form.
|
|
var storedSetting = localStorage.getItem('show');
|
|
document.getElementById('show').value = storedSetting;
|
|
|
|
if (!document.getElementById('show').value) {
|
|
// fix nonsense, missing, or corrupted values.
|
|
document.getElementById('show').value = 'exported';
|
|
}
|
|
|
|
// enact the setting we loaded.
|
|
onShowChange();
|
|
}
|