Skip to content

Commit

Permalink
Checkbox to remove unavailable commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
BSVino committed Aug 19, 2014
1 parent a35f5b9 commit 6d08fe7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
37 changes: 30 additions & 7 deletions html/copy/docs.gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function gl_printable_name(name) {

window.last_gl_version = "";
window.api_version = "";
window.hide_deprecated = false;
window.last_hide_deprecated = false;

function set_api_version(version) {
window.api_version = version;
Expand All @@ -42,7 +44,7 @@ function set_api_version(version) {
$(".category").addClass("disabled");
$(".command").addClass("disabled");
$("." + version).removeClass("disabled");

version_directory = version.substring(0, 3);
$(".rewritelink").each(function() {
if ($(this).hasClass(version))
Expand Down Expand Up @@ -93,17 +95,26 @@ function set_api_version(version) {
}
});

if (window.last_gl_version != version.substring(0, 2))
if (window.last_gl_version != version.substring(0, 2) || window.last_hide_deprecated || window.hide_deprecated)
{
// Remove functions from GL that ES doesn't have and vice versa.
hide_commands = function() {
$(this).addClass("hidden");

var classList = $(this).attr('class').split(/\s+/);
for (var i = 0; i < classList.length; i++) {
if (classList[i].substring(0, 2) === version.substring(0, 2)) {
$(this).removeClass("hidden");
break;
if (window.hide_deprecated) {
for (var i = 0; i < classList.length; i++) {
if (classList[i] === version) {
$(this).removeClass("hidden");
break;
}
}
} else {
for (var i = 0; i < classList.length; i++) {
if (classList[i].substring(0, 2) === version.substring(0, 2)) {
$(this).removeClass("hidden");
break;
}
}
}
};
Expand All @@ -115,6 +126,7 @@ function set_api_version(version) {
$("span.bonsai_inner").trigger('click');

window.last_gl_version = version.substring(0, 2);
window.last_hide_deprecated = window.hide_deprecated;
}
}

Expand All @@ -127,6 +139,12 @@ $(function() {
}
});

if (typeof $.cookie("hide_deprecated") != 'undefined')
{
window.hide_deprecated = $.cookie("hide_deprecated");
$('#hide_deprecated').prop('checked', window.hide_deprecated);
}

if (typeof $.cookie("api_version") != 'undefined')
{
set_api_version($.cookie("api_version"));
Expand Down Expand Up @@ -167,7 +185,6 @@ $(function() {
var alias_api = version.substring(0, 2);
var alias = value;
var directory = version.substring(0, 3) + "/";
console.log(alias_api + ":" + alias + ":" + directory);
if (version == 'all')
{
alias_api = value.substring(0, 2);
Expand Down Expand Up @@ -207,4 +224,10 @@ $(function() {
$("#search_versions").val($.cookie("api_version").substring(0, 3) + "." + $.cookie("api_version").substring(3, 4)).selectmenu('refresh');
$("#search").autocomplete( "option", "source", search_versions[$("#search_versions").val()] );
}

$('#hide_deprecated').click(function() {
window.hide_deprecated = $(this).is(':checked');
$.cookie("hide_deprecated", window.hide_deprecated, {path: '/'});
set_api_version(window.api_version);
});
});
4 changes: 4 additions & 0 deletions html/copy/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ a {
margin: 20px;
}

#hide_label {
font-size: 11px;
}

#khronos {
width: 610px;
float: left;
Expand Down
3 changes: 2 additions & 1 deletion html/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<div id="everything">
<div id="toc">
<strong id="opengl_name"></strong>
<div id="versions_container"><span id="api">API:</span><select id="versions_dropdown">{$versions_options}</select></div>
<div id="versions_container"><span id="api">API:</span><select id="versions_dropdown">{$versions_options}</select><br />
<label id="hide_label" for="hide_deprecated">Hide unavailable:</label><input id="hide_deprecated" type="checkbox"></div>

<br clear="both" />
<ul id="command_categories">{$api_commands}</ul>
Expand Down

0 comments on commit 6d08fe7

Please sign in to comment.