-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathcrosslink_redirect.html
More file actions
112 lines (92 loc) · 4.42 KB
/
crosslink_redirect.html
File metadata and controls
112 lines (92 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<script type="text/javascript">
var uidServiceData = '${UID_SERVICE_MAPPING}';
var uidToServiceName = JSON.parse(uidServiceData);
var defaultUrl = "root/html/index.html";
function getQueryStringParameter(name, url) {
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
name = name.replace(/[\[\]]/g, "\\$&");
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function escapeCharacters(toEscape) {
var escapedString = "";
for(var i = 0; i < toEscape.length; ++i) {
var character = toEscape.charAt(i);
if(character != character.toLowerCase()) {
escapedString += '_' + character.toLowerCase();
}
else if(character == ':') {
escapadString += "_1";
}
else {
escapedString += character;
}
}
return escapedString;
}
function transformRequestToDoxygenLink(url, typeName, operation) {
var uid = getQueryStringParameter("uid", url);
var serviceName = uidToServiceName[uid];
if(serviceName == null) {
return defaultUrl;
}
var dirtyName = "class_aws_1_1_";
dirtyName += serviceName.charAt(0).toLowerCase() + serviceName.substring(1);
if(typeName != null) {
dirtyName += "_1_1_model_1_1_";
var firstCharLowered = typeName.charAt(0).toLowerCase() + typeName.substring(1);
var operationCanonicalizedStr = firstCharLowered.replace("Input", "Request").replace("Output", "Result");
dirtyName += operationCanonicalizedStr;
}
else if(operation != null) {
dirtyName += "_1_1_";
var firstCharLowered = serviceName.charAt(0).toLowerCase() + serviceName.substring(1);
dirtyName += firstCharLowered;
dirtyName += "_client";
//once we figure out the operation link, add the #stuff here:
//dirtyName += "#operationName";
}
dirtyName += ".html";
return "aws-cpp-sdk-" + serviceName.toLowerCase() + "/html/" + escapeCharacters(dirtyName);
}
function checkResourceExists(url) {
try {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", url, false );
xmlHttp.send( null );
return xmlHttp.status == 200;
}
catch(err) {
return false;
}
}
var url = window.location.href;
var typeName = getQueryStringParameter("type", url);
var operation = getQueryStringParameter("operation", url);
var firstAttempt = transformRequestToDoxygenLink(url, typeName, operation);
//if the first one exists, load that one.
if(checkResourceExists(firstAttempt)){
window.location.href = firstAttempt;
}
//otherwise, try and swap operation and typename.
else {
var secondAttempt = transformRequestToDoxygenLink(url, operation, typeName)
//if that fails, fall back to the default page.
if(checkResourceExists(secondAttempt)){
window.location.href = secondAttempt;
}
else {
window.location.href = defaultUrl;
}
}
</script>
</head>
<body>
</body>
</html>