Skip to content

Commit

Permalink
Look up aliases in a dictionary to make sure the user gets directed t…
Browse files Browse the repository at this point in the history
…o the correct page. Plus some other small fixes.
  • Loading branch information
BSVino committed Aug 17, 2014
1 parent f7ead31 commit 8a62119
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
17 changes: 16 additions & 1 deletion compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,23 @@ def create_directory(dir):
print "Done."

search_versions_commands = "var search_versions = {"
search_function_aliases = {}
for version in opengl.version_commands:
if version[0:2] == "gl" and float(version[2:]) < 2.1:
continue

if version[0:2] == "es" and float(version[2:]) < 2.0:
continue

search_versions_commands += "'" + version + "': ["
search_versions_commands += "'" + version + "':["

if not version[:2] in search_function_aliases:
search_function_aliases[version[:2]] = {}

for command in opengl.version_commands[version]:
search_versions_commands += "'" + command + "',"
if command != opengl.version_commands[version][command]:
search_function_aliases[version[:2]][command] = opengl.version_commands[version][command]

for command in opengl.version_commands_flat[version]:
if not command in opengl.version_commands[version]:
Expand Down Expand Up @@ -117,6 +123,15 @@ def create_directory(dir):

search_versions_commands += "]};"

search_versions_commands += "var function_aliases = {"
for version in search_function_aliases:
search_versions_commands += "'" + version + "':{"
for alias in search_function_aliases[version]:
search_versions_commands += "'" + alias + "':'" + search_function_aliases[version][alias] + "',"
search_versions_commands += "},"

search_versions_commands += "};"

search = search.replace("{$search_versions_commands}", search_versions_commands)

search_fp = open(output_dir + "/docs.gl.search.js", "w")
Expand Down
19 changes: 15 additions & 4 deletions html/copy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@

if (search_versions[version].indexOf(value) < 0)
return;

var alias_api = window.search_api.substring(0, 2);
var alias = value;
var directory = version.substring(0, 3) + "/";
if (window.search_api == 'all')
{
alias_api = value.substring(0, 2);
alias = value.substring(4);
directory = value.substring(0, 4);
}

var command_page = alias;
if (alias in function_aliases[alias_api])
command_page = function_aliases[alias_api][alias]

if (version == 'all')
window.location.href = window.base_directory + value;
else
window.location.href = window.base_directory + version.substring(0, 3) + "/" + value;
window.location.href = window.base_directory + directory + command_page;
}

$( "#es_api" ).buttonset();
Expand Down
21 changes: 18 additions & 3 deletions html/docs.gl.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ $(function() {
if (search_versions[version].indexOf(value) < 0)
return;

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')
window.location.href = window.base_directory + value;
else
window.location.href = window.base_directory + version.substring(0, 3) + "/" + value;
{
alias_api = value.substring(0, 2);
alias = value.substring(4);
directory = value.substring(0, 4);
}

var command_page = alias;
if (alias in function_aliases[alias_api])
command_page = function_aliases[alias_api][alias]

window.location.href = window.base_directory + directory + command_page;
}

$( "#search_button" ).button().click(function(event) {
Expand All @@ -36,5 +48,8 @@ $(function() {
});

if (typeof $.cookie("api_version") != 'undefined')
{
$("#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()] );
}
});

0 comments on commit 8a62119

Please sign in to comment.