{"version":3,"file":"js/09-noversion.js","sources":["js/09-noversion.js"],"sourcesContent":["var nextRequest = true;\n$('.doc .paragraph').append('<div class=\"loader\"></div>');\nvar contentText = addContentText();\n$(\".doc .paragraph p\").addClass(\"noversion-paragraph\");\n$(\".doc .paragraph p\").text(contentText);\n\n$(window).on(\"load\", function() {\n $.ready.then(function() {\n var params = new URLSearchParams(window.location.search);\n var ref = params.get(\"ref\");\n if (!ref.includes(\"noversion.html\")) {\n var folder = \"ROOT\";\n var dir = \"\";\n\n //accomodations for draft and staging sites\n /*var useNext =\n window.location.href.includes(\"mybluemix.net\") ||\n window.location.href.includes(\"localhost\");*/\n\n //get info about doc that was attempted to be reached\n var attempted = ref;\n var doc = attempted.substring(attempted.lastIndexOf(\"/\") + 1);\n\n var preceed1 = attempted.substring(0, attempted.lastIndexOf(\"/\"));\n preceed1 = preceed1.substring(preceed1.lastIndexOf(\"/\") + 1);\n if(preceed1 === \"api\" || preceed1 === \"spi\"){\n preceed1 = \"javadoc/\" + preceed1;\n }\n if (preceed1 === \"reference\") {\n folder = \"reference\";\n } else {\n if (\n preceed1 === \"feature\" ||\n preceed1 === \"javadoc\" ||\n preceed1 === \"config\" ||\n preceed1 === \"command\" ||\n preceed1 === \"javadoc/api\" ||\n preceed1 === \"javadoc/spi\"\n ) {\n folder = \"reference\";\n dir = \"/\" + preceed1;\n }\n }\n\n //get all current versions of docs\n var versions = [];\n $(\".components .versions .version\")\n .find(\"a\")\n .map(function() {\n versions.push($(this).text());\n });\n\n versions.sort(orderVersions);\n\n var matches = [];\n //make api calls for content of each version to see if doc exists\n //add case for reference docs\n //consider adding logic to order versions from newest to oldest\n versions.forEach(function(v, ind) {\n var ver = v;\n var matchingVersion = doesFileExist(window.location.origin+\"/docs/\"+ver+\"/\"+(folder === \"reference\" ? \"reference/\" : \"\") +(dir !== \"\" ? preceed1 + \"/\" : \"\")+doc,ver)\n if(matchingVersion) {\n matches.push(matchingVersion);\n }\n });\n\n $(\".loader\").remove();\n $(\".doc .paragraph p\").removeClass(\"noversion-paragraph\");\n $(\".doc .paragraph p\").remove();\n $(\".doc .paragraph\").text(contentText);\n\n if ($(\".doc .paragraph ul\").length) {\n $(\".doc .paragraph ul\").empty();\n $(\".doc .paragraph ul\").remove();\n }\n $(\".doc .paragraph\").append(\"<ul></ul>\");\n\n matches.sort(orderVersions);\n matches.forEach(function(m) {\n $(\".doc .paragraph ul\").append(\n \"<li><a href=\" +\n window.location.origin +\n \"/docs/\" +\n m +\n \"/\" +\n (folder === \"reference\" ? \"reference/\" : \"\") +\n (dir !== \"\" ? preceed1 + \"/\" : \"\") +\n doc +\n \">v\" +\n m +\n \"</a></li>\"\n );\n });\n\n //change around selectors to get accurate selection, test\n $(\".components .versions .version a\").on(\"click\", function(e) {\n e.preventDefault();\n var selected = $(e.target)\n .text()\n .trim();\n if (matches.includes(selected)) {\n window.location.href =\n window.location.origin +\n \"/docs/\" +\n selected +\n \"/\" +\n (folder === \"reference\" ? \"reference/\" : \"\") +\n (dir !== \"\" ? preceed1 + \"/\" : \"\") +\n doc;\n } else {\n window.location.href = \"/docs/\" + selected + \"/overview.html\";\n }\n return;\n });\n\n }\n });\n});\n\nfunction orderVersions(a, b) {\n var arrA = a.split(\".\");\n var arrB = b.split(\".\");\n for (var i = 0; i < arrA.length; i++) {\n if (parseInt(arrA[i]) > parseInt(arrB[i])) {\n return -1;\n } else if (parseInt(arrA[i]) < parseInt(arrB[i])) {\n return 1;\n }\n }\n return 0;\n}\n\nfunction doesFileExist(urlToFile,version) {\n if(nextRequest){ // if requested doc file not found, stop sending request for older versions\n var xhr = new XMLHttpRequest();\n xhr.open('HEAD', urlToFile, false);\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n xhr.send();\n // return attempted doc file available in which versions\n // with the intro of latest symbolic version, sees the requested doc file exists in latest version\n if (((xhr.status >=200)&&(xhr.status < 300)&&(xhr.responseURL === urlToFile)) || \n ((xhr.status >=200)&&(xhr.status < 300)&&(xhr.responseURL.indexOf(\"latest\") > -1))) { // Successful responses\n nextRequest = true;\n return version;\n } else {\n nextRequest = false;\n } \n }\n}\n\nfunction addContentText() {\n var version = $(\".context .version\").text();\n var displayText = \"The requested document does not exist in the \" +\n version +\n \" version of the documentation, but it is available in the following versions.\"\n return displayText;\n}"],"names":["nextRequest","contentText","$","append","addContentText","orderVersions","a","b","arrA","split","arrB","i","length","parseInt","doesFileExist","urlToFile","version","xhr","XMLHttpRequest","open","setRequestHeader","send","status","responseURL","indexOf","text","addClass","window","on","ready","then","folder","dir","doc","preceed1","versions","matches","ref","URLSearchParams","location","search","get","includes","attempted","substring","lastIndexOf","find","map","push","this","sort","forEach","v","ind","matchingVersion","origin","remove","removeClass","empty","m","e","preventDefault","selected","target","trim","href"],"mappings":"AAAA,IAAIA,YAAc,CAAA,EAEdC,aADJC,EAAE,iBAAiB,EAAEC,OAAO,4BAA4B,EACtCC,eAAe,GAqHjC,SAASC,cAAcC,EAAGC,GAGxB,IAFA,IAAIC,EAAOF,EAAEG,MAAM,GAAG,EAClBC,EAAOH,EAAEE,MAAM,GAAG,EACbE,EAAI,EAAGA,EAAIH,EAAKI,OAAQD,CAAC,GAAI,CACpC,GAAIE,SAASL,EAAKG,EAAE,EAAIE,SAASH,EAAKC,EAAE,EACtC,MAAO,CAAC,EACH,GAAIE,SAASL,EAAKG,EAAE,EAAIE,SAASH,EAAKC,EAAE,EAC7C,OAAO,CAEX,CACA,OAAO,CACT,CAEA,SAASG,cAAcC,EAAUC,GAC/B,GAAGhB,YAAY,CACb,IAAIiB,EAAM,IAAIC,eAMd,GALAD,EAAIE,KAAK,OAAQJ,EAAW,CAAA,CAAK,EACjCE,EAAIG,iBAAiB,mBAAoB,gBAAgB,EACzDH,EAAII,KAAK,EAGU,KAAbJ,EAAIK,QAAgBL,EAAIK,OAAS,KAAOL,EAAIM,cAAgBR,GAChD,KAAbE,EAAIK,QAAgBL,EAAIK,OAAS,KAA2C,CAAC,EAArCL,EAAIM,YAAYC,QAAQ,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