diff --git a/index.html b/index.html index 4ce9b69..1ae3537 100644 --- a/index.html +++ b/index.html @@ -217,6 +217,17 @@

ONDC NTS Services Developer Guide

>SandBox-UI --> +
@@ -344,16 +355,17 @@
- +
@@ -490,6 +502,8 @@
Tags
+ + diff --git a/ui/sandboxui.js b/ui/sandboxui.js new file mode 100644 index 0000000..8f96214 --- /dev/null +++ b/ui/sandboxui.js @@ -0,0 +1,24 @@ +function loadSandbox(data){ + console.log(data,"Data") + const dropdown = data.dropdown + const sandboxDropdown = document.getElementById("sandbox-dropdown"); + sandboxDropdown.innerHTML = ""; + dropdown.forEach((dropdown) => { + var option = document.createElement("option"); + option.text = dropdown["environment-name"]; + option.setAttribute("link",dropdown.link) + sandboxDropdown.add(option); + updateSandbox() + }); +} + +function updateSandbox(){ + const dropdown = document.getElementById("sandbox-dropdown"); + const iframe = document.getElementById("sandbox-iframe") + const iframe_link = dropdown.options[dropdown.selectedIndex].getAttribute("link") + iframe.setAttribute("src",iframe_link) +} + +function selectSandbox(){ + +} \ No newline at end of file diff --git a/ui/tabs.js b/ui/tabs.js index 13f49a1..3ce66e7 100644 --- a/ui/tabs.js +++ b/ui/tabs.js @@ -3,7 +3,7 @@ function onFirstLoad(build_spec) { let data = build_spec; - const xProperties = ["x-enum", "x-tags", "x-examples", "x-flows", "x-attributes", "x-errorcodes", "x-tlc"]; + const xProperties = ["x-enum", "x-tags", "x-examples", "x-flows", "x-attributes", "x-errorcodes", "x-tlc","x-sandboxui"]; xProperties.forEach((xProperty) => { if (data[xProperty]) { switch (xProperty) { @@ -28,15 +28,32 @@ function onFirstLoad(build_spec) { case "x-tlc": loadTlc(data[xProperty]); break; + case "x-sandboxui": + if(shouldDisplay(data[xProperty].dropdown,"sandbox-nav")) loadSandbox(data[xProperty]) + break; default: break; } } else { + if(xProperty == "x-sandboxui"){ // remove sandbox when changing branch + shouldDisplay([],"sandbox-nav") + } console.log(`${xProperty} is not present in the build_spec.`); } }); } + function shouldDisplay (data,id){ + if(isNaN(data?.length) || data?.length <1){ + const element = document.getElementById(id) + if(element) element.classList.add("d-none") + return false + }else{ + const element = document.getElementById(id) + if(element) element.classList.remove("d-none") + return true + } + } // window.onload = function(){ // onFirstLoad(build_spec)