Loading frontend.htm 0 → 100644 +266 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <body onload="Startup()"> <h2>Please select a project</h2> <div id="projectinput"> <input id="project"> </div> <button onclick="SelectProject()">Select project</button> <p> <p> <div id="branchinput"> </div> <p> <p> <div id="fileinput"> </div> <!-- Swagger Parser --> <script src="https://apidevtools.org/swagger-parser/dist/swagger-parser.min.js"></script> <script> var project = ""; var branch = ""; var yamlfiles = []; var gitlaburl = "https://forge.etsi.org/gitlab/"; function readUriQueryParam(qparam) { var str = document.URL; var pos = str.indexOf("?"+qparam); if (pos != -1) { str = str.slice(pos + 2 + qparam.length); pos = str.indexOf("?"); if (pos != -1) { return str.slice(0, pos); } else { return str; } } else { return -1; } } function SelectedFileDemo() { var x = document.forms["yamlfile"]["url"].value; window.alert(x); } function ParseSelectedFile() { var x = document.forms["yamlfile"]["url"].value; new SwaggerParser().validate(x) .then(function(api) { window.alert("No errors discovered in " + api.info.title + " version " + api.info.version); }) .catch(function(err) { window.alert("Test failed: " + err.message); }); } function OpenGitlabEditor() { var x = document.forms["yamlfile"]["url"].value; x = x.replace("/raw/","/blob/"); window.open(x); } function ParseAllFiles() { function ParseFile(x) { var url = "https://forge.etsi.org/gitlab/degregorioj/5GC_APIs/raw/master/" + x; new SwaggerParser().validate(url) .then(function(api) { document.getElementById("parseresults").innerHTML += "<p><p>No errors discovered in " + api.info.title + " version " + api.info.version + "</p><p>"; }) .catch(function(err) { document.getElementById("parseresults").innerHTML += "<p><p>Errors discovered in " + x + ": " + err.message + "</p><p>"; }); } var yLen = yamlfiles.length; if ( yLen ) { document.getElementById("parseresults").innerHTML = "<p><p><h2>Parsing results</h2><p><p>";; for (i = 0; i < yLen; i++) { ParseFile(yamlfiles[i]); } } } function Startup() { var x = readUriQueryParam("project"); if (x == -1) { project = ""; } else { document.getElementById("projectinput").innerHTML = "<input id=\"project\" value=\"" + x + "\">"; //TestProject(x); project = x; ShowBranches(); } } function ShowBranches() { var x = readUriQueryParam("branch"); if (x == -1) { branch = "" } else { //TestBranch(x); branch = x; ShowFiles(); } var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4 && this.status == 200) { var str = this.responseText; branches = []; var pos = str.indexOf("<li class=\"branch-item js-branch-"); while (pos != -1) { str = str.slice(pos + 33); pos = str.indexOf("\">"); if (pos != -1) { branches.push(str.slice(0, pos)); } var pos = str.indexOf("<li class=\"branch-item js-branch-"); } var yLen = branches.length; if ( yLen ) { var text = "<h2>Please select a branch</h2><p><p><form action=\"\" name=\"branches\"><select name=\"branch\">"; for (i = 0; i < yLen; i++) { if (branches[i] == branch) { text += "<option value=\"" + branches[i] + "\" selected>"+ branches[i] + "</option>"; } else { text += "<option value=\"" + branches[i] + "\">"+ branches[i] + "</option>"; } } text += "</select><br><br><input type=\"button\" value=\"Select branch\" onclick=\"SelectBranch()\"><p>"; text += "</form><br>"; document.getElementById("branchinput").innerHTML = text; } else { document.getElementById("branchinput").innerHTML = "No branches found."; } } }; //xhttp.open("GET", gitlaburl + project + "/branches", true); xhttp.open("GET", "file:///D:/userdata/dems1cd2/OneDrive - Nokia/temp/example2gitlab.htm", true); xhttp.send(); } function SelectBranch() { var x = document.forms["branches"]["branch"].value; if (x == -1) { branch = "" } else { //TestBranch(x); ShowFiles(); branch = x; } } function SelectProject() { var x = document.getElementById("project").value; if (x.length > 0) { //TestProject(x); project = x; ShowBranches(); } else { window.alert("Please enter Project name in text box before pressing this button!"); } } function TestProject(x) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4) { if (this.status == 200) { project = x; ShowBranches(); } else { window.alert("Error: Could not access Gitlab Page " + gitlaburl + x); project = ""; } } }; xhttp.open("GET", gitlaburl + x, true); xhttp.send(); } function TestBranch(x) { var url = gitlaburl + project + "/" + x; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4) { if (this.status == 200) { branch = x; ShowFiles(); } else { window.alert("Error: Could not access Gitlab Page " + url); project = ""; } } }; xhttp.open("GET", url, true); xhttp.send(); } function ShowFiles() { var url = gitlaburl + project; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4 && this.status == 200) { var str = this.responseText; yamlfiles = []; var pos = str.indexOf("title=\"TS"); while (pos != -1) { str = str.slice(pos + 7); pos = str.indexOf(".yaml\""); if (pos != -1) { yamlfiles.push(str.slice(0, pos + 5)); } var pos = str.indexOf("title=\"TS"); } var yLen = yamlfiles.length; if ( yLen ) { var text = "<h2>Please select a file</h2><p><p><form name=\"yamlfile\", action=\"\" target=\"_blank\"><select name=\"url\">"; for (i = 0; i < yLen; i++) { text += "<option value=\"" + url + "/raw/" + yamlfiles[i] + "\">"+ yamlfiles[i] + "</option>"; //text += "<option value=\"https://forge.etsi.org/gitlab/degregorioj/5GC_APIs/raw/master/" + yamlfiles[i] + "\">"+ yamlfiles[i] + "</option>"; } text += "</select><br><br>"; text += "<input type=\"submit\" value=\"Open file in Swagger editor\" formaction=\"https://forge.etsi.org/swagger/editor/\"><br>"; text += "<input type=\"submit\" value=\"Open file in user interface inspector\" formaction=\"https://forge.etsi.org/swagger/ui/\"><br>"; text += "<input type=\"button\" value=\"Open File in Gitlab\" onclick=\"OpenGitlabEditor()\"><br>"; text += "<input type=\"button\" value=\"Parse Selected File\" onclick=\"ParseSelectedFile()\"><br>"; text += "<input type=\"button\" value=\"Show Selected File\" onclick=\"SelectedFileDemo()\"><br><br>"; text += "<input type=\"button\" value=\"Parse All Files\" onclick=\"ParseAllFiles()\">"; text += "</form>"; document.getElementById("fileinput").innerHTML = text; } else { document.getElementById("fileinput").innerHTML = "No yaml file found."; } } }; xhttp.open("GET", "file:///D:/userdata/dems1cd2/OneDrive - Nokia/temp/examplegitlab.htm", true); //xhttp.open("GET", url, true); xhttp.send(); } Loading
frontend.htm 0 → 100644 +266 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html> <body onload="Startup()"> <h2>Please select a project</h2> <div id="projectinput"> <input id="project"> </div> <button onclick="SelectProject()">Select project</button> <p> <p> <div id="branchinput"> </div> <p> <p> <div id="fileinput"> </div> <!-- Swagger Parser --> <script src="https://apidevtools.org/swagger-parser/dist/swagger-parser.min.js"></script> <script> var project = ""; var branch = ""; var yamlfiles = []; var gitlaburl = "https://forge.etsi.org/gitlab/"; function readUriQueryParam(qparam) { var str = document.URL; var pos = str.indexOf("?"+qparam); if (pos != -1) { str = str.slice(pos + 2 + qparam.length); pos = str.indexOf("?"); if (pos != -1) { return str.slice(0, pos); } else { return str; } } else { return -1; } } function SelectedFileDemo() { var x = document.forms["yamlfile"]["url"].value; window.alert(x); } function ParseSelectedFile() { var x = document.forms["yamlfile"]["url"].value; new SwaggerParser().validate(x) .then(function(api) { window.alert("No errors discovered in " + api.info.title + " version " + api.info.version); }) .catch(function(err) { window.alert("Test failed: " + err.message); }); } function OpenGitlabEditor() { var x = document.forms["yamlfile"]["url"].value; x = x.replace("/raw/","/blob/"); window.open(x); } function ParseAllFiles() { function ParseFile(x) { var url = "https://forge.etsi.org/gitlab/degregorioj/5GC_APIs/raw/master/" + x; new SwaggerParser().validate(url) .then(function(api) { document.getElementById("parseresults").innerHTML += "<p><p>No errors discovered in " + api.info.title + " version " + api.info.version + "</p><p>"; }) .catch(function(err) { document.getElementById("parseresults").innerHTML += "<p><p>Errors discovered in " + x + ": " + err.message + "</p><p>"; }); } var yLen = yamlfiles.length; if ( yLen ) { document.getElementById("parseresults").innerHTML = "<p><p><h2>Parsing results</h2><p><p>";; for (i = 0; i < yLen; i++) { ParseFile(yamlfiles[i]); } } } function Startup() { var x = readUriQueryParam("project"); if (x == -1) { project = ""; } else { document.getElementById("projectinput").innerHTML = "<input id=\"project\" value=\"" + x + "\">"; //TestProject(x); project = x; ShowBranches(); } } function ShowBranches() { var x = readUriQueryParam("branch"); if (x == -1) { branch = "" } else { //TestBranch(x); branch = x; ShowFiles(); } var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4 && this.status == 200) { var str = this.responseText; branches = []; var pos = str.indexOf("<li class=\"branch-item js-branch-"); while (pos != -1) { str = str.slice(pos + 33); pos = str.indexOf("\">"); if (pos != -1) { branches.push(str.slice(0, pos)); } var pos = str.indexOf("<li class=\"branch-item js-branch-"); } var yLen = branches.length; if ( yLen ) { var text = "<h2>Please select a branch</h2><p><p><form action=\"\" name=\"branches\"><select name=\"branch\">"; for (i = 0; i < yLen; i++) { if (branches[i] == branch) { text += "<option value=\"" + branches[i] + "\" selected>"+ branches[i] + "</option>"; } else { text += "<option value=\"" + branches[i] + "\">"+ branches[i] + "</option>"; } } text += "</select><br><br><input type=\"button\" value=\"Select branch\" onclick=\"SelectBranch()\"><p>"; text += "</form><br>"; document.getElementById("branchinput").innerHTML = text; } else { document.getElementById("branchinput").innerHTML = "No branches found."; } } }; //xhttp.open("GET", gitlaburl + project + "/branches", true); xhttp.open("GET", "file:///D:/userdata/dems1cd2/OneDrive - Nokia/temp/example2gitlab.htm", true); xhttp.send(); } function SelectBranch() { var x = document.forms["branches"]["branch"].value; if (x == -1) { branch = "" } else { //TestBranch(x); ShowFiles(); branch = x; } } function SelectProject() { var x = document.getElementById("project").value; if (x.length > 0) { //TestProject(x); project = x; ShowBranches(); } else { window.alert("Please enter Project name in text box before pressing this button!"); } } function TestProject(x) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4) { if (this.status == 200) { project = x; ShowBranches(); } else { window.alert("Error: Could not access Gitlab Page " + gitlaburl + x); project = ""; } } }; xhttp.open("GET", gitlaburl + x, true); xhttp.send(); } function TestBranch(x) { var url = gitlaburl + project + "/" + x; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4) { if (this.status == 200) { branch = x; ShowFiles(); } else { window.alert("Error: Could not access Gitlab Page " + url); project = ""; } } }; xhttp.open("GET", url, true); xhttp.send(); } function ShowFiles() { var url = gitlaburl + project; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { //window.alert("readyState: " + this.readyState + " status: " + this.status + " " + this.statusText); if (this.readyState == 4 && this.status == 200) { var str = this.responseText; yamlfiles = []; var pos = str.indexOf("title=\"TS"); while (pos != -1) { str = str.slice(pos + 7); pos = str.indexOf(".yaml\""); if (pos != -1) { yamlfiles.push(str.slice(0, pos + 5)); } var pos = str.indexOf("title=\"TS"); } var yLen = yamlfiles.length; if ( yLen ) { var text = "<h2>Please select a file</h2><p><p><form name=\"yamlfile\", action=\"\" target=\"_blank\"><select name=\"url\">"; for (i = 0; i < yLen; i++) { text += "<option value=\"" + url + "/raw/" + yamlfiles[i] + "\">"+ yamlfiles[i] + "</option>"; //text += "<option value=\"https://forge.etsi.org/gitlab/degregorioj/5GC_APIs/raw/master/" + yamlfiles[i] + "\">"+ yamlfiles[i] + "</option>"; } text += "</select><br><br>"; text += "<input type=\"submit\" value=\"Open file in Swagger editor\" formaction=\"https://forge.etsi.org/swagger/editor/\"><br>"; text += "<input type=\"submit\" value=\"Open file in user interface inspector\" formaction=\"https://forge.etsi.org/swagger/ui/\"><br>"; text += "<input type=\"button\" value=\"Open File in Gitlab\" onclick=\"OpenGitlabEditor()\"><br>"; text += "<input type=\"button\" value=\"Parse Selected File\" onclick=\"ParseSelectedFile()\"><br>"; text += "<input type=\"button\" value=\"Show Selected File\" onclick=\"SelectedFileDemo()\"><br><br>"; text += "<input type=\"button\" value=\"Parse All Files\" onclick=\"ParseAllFiles()\">"; text += "</form>"; document.getElementById("fileinput").innerHTML = text; } else { document.getElementById("fileinput").innerHTML = "No yaml file found."; } } }; xhttp.open("GET", "file:///D:/userdata/dems1cd2/OneDrive - Nokia/temp/examplegitlab.htm", true); //xhttp.open("GET", url, true); xhttp.send(); }