github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v2/static/javascripts/schemas.js (about) 1 const schema_list = [...document.getElementById("schema_list").getElementsByTagName("li")].map(l => l.textContent); 2 const selectElement = document.getElementById("schema_links") 3 const majors = {}; 4 const version = getCurrentSchemaVersion() 5 for (let s of schema_list) { 6 let i = 2; 7 for (; i < s.length; i++) { 8 if (!s[i].match(/^[a-z]+$/)) { 9 break; 10 } 11 } 12 let minor = parseInt(s.substr(i)); 13 let major = s.substr(0, i); 14 15 if (isNaN(minor)) { 16 minor = ""; 17 } 18 if (!(major in majors)) { 19 majors[major] = []; 20 } 21 majors[major].push(minor); 22 } 23 24 Object.keys(majors) 25 .sort((a, b) => { 26 // v3 was released after v3alpha and doc site should show schema in reverse chronological order 27 // so we put v3 first. 28 if (a === "v3" && b === "v3alpha") { 29 return -1 30 } 31 if (a === "v3alpha" && b === "v3") { 32 return 1 33 } 34 return a > b ? -1 : 1 35 }) 36 .forEach(function(major) { 37 majors[major].sort((a,b) => b-a); 38 for (const minor of majors[major]) { 39 const v = major + minor; 40 selectElement.append(new Option(v, v, v === version, v === version)); 41 } 42 }); 43 44 function selectSchema(selectObject) { 45 var value = selectObject.value; 46 if (value != "") { 47 location.href = `/docs/references/yaml/?version=${value}` 48 } 49 } 50 51 function getCurrentSchemaVersion() { 52 const versionParam = "?version="; 53 const index = window.location.href.indexOf(versionParam); 54 if (index === -1) { 55 return ""; 56 } else { 57 return window.location.href.substr(index + versionParam.length); 58 } 59 }