github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v1/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().reverse() 26 .forEach(function(major) { 27 majors[major].sort((a,b) => b-a); 28 for (const minor of majors[major]) { 29 const v = major + minor; 30 selectElement.append(new Option(v, v, v === version, v === version)); 31 } 32 }); 33 34 function selectSchema(selectObject) { 35 var value = selectObject.value; 36 if (value != "") { 37 location.href = `/docs/references/yaml/?version=${value}` 38 } 39 } 40 41 function getCurrentSchemaVersion() { 42 const versionParam = "?version="; 43 const index = window.location.href.indexOf(versionParam); 44 if (index === -1) { 45 return ""; 46 } else { 47 return window.location.href.substr(index + versionParam.length); 48 } 49 }