|
| 1 | +function switchMainTab(evt, tabName) { |
| 2 | + // Declare all variables |
| 3 | + var i, tabcontent, tablinks; |
| 4 | + |
| 5 | + // Get all elements with class="tabcontent" and hide them |
| 6 | + tabcontent = document.getElementsByClassName("maintab tabcontent"); |
| 7 | + for (i = 0; i < tabcontent.length; i++) { |
| 8 | + tabcontent[i].className = tabcontent[i].className.replace(" active", ""); |
| 9 | + } |
| 10 | + |
| 11 | + // Get all elements with class="tablinks" and remove the class "active" |
| 12 | + tablinks = document.getElementsByClassName("maintab tablinks"); |
| 13 | + for (i = 0; i < tablinks.length; i++) { |
| 14 | + tablinks[i].className = tablinks[i].className.replace(" active", ""); |
| 15 | + } |
| 16 | + |
| 17 | + // Show the current tab, and add an "active" class to the button that opened the tab |
| 18 | + document.getElementById(tabName).className += " active"; |
| 19 | + evt.currentTarget.className += " active"; |
| 20 | +} |
| 21 | + |
| 22 | +function switchSubTab(evt, filePath) { |
| 23 | + // Declare all variables |
| 24 | + var i, tabcontent, tablinks; |
| 25 | + |
| 26 | + // Get all elements with class="tabcontent" and hide them |
| 27 | + tabcontent = document.getElementsByClassName("subtab tabcontent"); |
| 28 | + for (i = 0; i < tabcontent.length; i++) { |
| 29 | + tabcontent[i].className = tabcontent[i].className.replace(" active", ""); |
| 30 | + } |
| 31 | + |
| 32 | + // Get all elements with class="tablinks" and remove the class "active" |
| 33 | + tablinks = document.getElementsByClassName("subtab tablinks"); |
| 34 | + for (i = 0; i < tablinks.length; i++) { |
| 35 | + tablinks[i].className = tablinks[i].className.replace(" active", ""); |
| 36 | + } |
| 37 | + |
| 38 | + // Get all elements with class matching the tabname class and show them |
| 39 | + tabcontent = document.querySelectorAll(`[data-id="${filePath}"]`); |
| 40 | + for (i = 0; i < tabcontent.length; i++) { |
| 41 | + tabcontent[i].className += " active"; |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +function switchDiff(evt, filePath) { |
| 46 | + // Declare all variables |
| 47 | + var i, tabcontent, tablinks; |
| 48 | + |
| 49 | + // Get all elements with class="tabcontent" and hide them |
| 50 | + tabcontent = document.getElementsByClassName("difftab tabcontent"); |
| 51 | + for (i = 0; i < tabcontent.length; i++) { |
| 52 | + tabcontent[i].className = tabcontent[i].className.replace(" active", ""); |
| 53 | + } |
| 54 | + |
| 55 | + // Get all elements with class="tablinks" and remove the class "active" |
| 56 | + tablinks = document.getElementsByClassName("difftab tablinks"); |
| 57 | + for (i = 0; i < tablinks.length; i++) { |
| 58 | + tablinks[i].className = tablinks[i].className.replace(" active", ""); |
| 59 | + } |
| 60 | + |
| 61 | + // Get all elements with class matching the tabname class and show them |
| 62 | + tabcontent = document.querySelectorAll(`[data-id="${filePath}"]`); |
| 63 | + for (i = 0; i < tabcontent.length; i++) { |
| 64 | + tabcontent[i].className += " active"; |
| 65 | + } |
| 66 | +} |
0 commit comments