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