| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
let dynsection = { |
| 27 |
|
| 28 |
|
| 29 |
updateStripes : function() { |
| 30 |
$('table.directory tr'). |
| 31 |
removeClass('even').filter(':visible:even').addClass('even'); |
| 32 |
$('table.directory tr'). |
| 33 |
removeClass('odd').filter(':visible:odd').addClass('odd'); |
| 34 |
}, |
| 35 |
|
| 36 |
toggleVisibility : function(linkObj) { |
| 37 |
const base = $(linkObj).attr('id'); |
| 38 |
const summary = $('#'+base+'-summary'); |
| 39 |
const content = $('#'+base+'-content'); |
| 40 |
const trigger = $('#'+base+'-trigger'); |
| 41 |
const src=$(trigger).attr('src'); |
| 42 |
if (content.is(':visible')===true) { |
| 43 |
content.hide(); |
| 44 |
summary.show(); |
| 45 |
$(linkObj).addClass('closed').removeClass('opened'); |
| 46 |
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); |
| 47 |
} else { |
| 48 |
content.show(); |
| 49 |
summary.hide(); |
| 50 |
$(linkObj).removeClass('closed').addClass('opened'); |
| 51 |
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); |
| 52 |
} |
| 53 |
return false; |
| 54 |
}, |
| 55 |
|
| 56 |
toggleLevel : function(level) { |
| 57 |
$('table.directory tr').each(function() { |
| 58 |
const l = this.id.split('_').length-1; |
| 59 |
const i = $('#img'+this.id.substring(3)); |
| 60 |
const a = $('#arr'+this.id.substring(3)); |
| 61 |
if (l<level+1) { |
| 62 |
i.removeClass('iconfopen iconfclosed').addClass('iconfopen'); |
| 63 |
a.html('▼'); |
| 64 |
$(this).show(); |
| 65 |
} else if (l==level+1) { |
| 66 |
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed'); |
| 67 |
a.html('►'); |
| 68 |
$(this).show(); |
| 69 |
} else { |
| 70 |
$(this).hide(); |
| 71 |
} |
| 72 |
}); |
| 73 |
this.updateStripes(); |
| 74 |
}, |
| 75 |
|
| 76 |
toggleFolder : function(id) { |
| 77 |
|
| 78 |
const currentRow = $('#row_'+id); |
| 79 |
|
| 80 |
|
| 81 |
const rows = currentRow.nextAll("tr"); |
| 82 |
|
| 83 |
const re = new RegExp('^row_'+id+'\\d+_$', "i"); |
| 84 |
|
| 85 |
|
| 86 |
const childRows = rows.filter(function() { return this.id.match(re); }); |
| 87 |
|
| 88 |
|
| 89 |
if (childRows.filter(':first').is(':visible')===true) { |
| 90 |
|
| 91 |
const currentRowSpans = currentRow.find("span"); |
| 92 |
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
| 93 |
currentRowSpans.filter(".arrow").html('►'); |
| 94 |
rows.filter("[id^=row_"+id+"]").hide(); |
| 95 |
} else { |
| 96 |
|
| 97 |
const currentRowSpans = currentRow.find("span"); |
| 98 |
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen"); |
| 99 |
currentRowSpans.filter(".arrow").html('▼'); |
| 100 |
|
| 101 |
const childRowsSpans = childRows.find("span"); |
| 102 |
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
| 103 |
childRowsSpans.filter(".arrow").html('►'); |
| 104 |
childRows.show(); |
| 105 |
} |
| 106 |
this.updateStripes(); |
| 107 |
}, |
| 108 |
|
| 109 |
toggleInherit : function(id) { |
| 110 |
const rows = $('tr.inherit.'+id); |
| 111 |
const img = $('tr.inherit_header.'+id+' img'); |
| 112 |
const src = $(img).attr('src'); |
| 113 |
if (rows.filter(':first').is(':visible')===true) { |
| 114 |
rows.css('display','none'); |
| 115 |
$(img).attr('src',src.substring(0,src.length-8)+'closed.png'); |
| 116 |
} else { |
| 117 |
rows.css('display','table-row'); |
| 118 |
$(img).attr('src',src.substring(0,src.length-10)+'open.png'); |
| 119 |
} |
| 120 |
}, |
| 121 |
}; |
| 122 |
|
| 123 |
let codefold = { |
| 124 |
opened : true, |
| 125 |
|
| 126 |
|
| 127 |
plusImg: [ "var(--fold-plus-image)", "var(--fold-plus-image-relpath)" ], |
| 128 |
minusImg: [ "var(--fold-minus-image)", "var(--fold-minus-image-relpath)" ], |
| 129 |
|
| 130 |
|
| 131 |
toggle_all : function(relPath) { |
| 132 |
if (this.opened) { |
| 133 |
$('#fold_all').css('background-image',this.plusImg[relPath]); |
| 134 |
$('div[id^=foldopen]').hide(); |
| 135 |
$('div[id^=foldclosed]').show(); |
| 136 |
} else { |
| 137 |
$('#fold_all').css('background-image',this.minusImg[relPath]); |
| 138 |
$('div[id^=foldopen]').show(); |
| 139 |
$('div[id^=foldclosed]').hide(); |
| 140 |
} |
| 141 |
this.opened=!this.opened; |
| 142 |
}, |
| 143 |
|
| 144 |
|
| 145 |
toggle : function(id) { |
| 146 |
$('#foldopen'+id).toggle(); |
| 147 |
$('#foldclosed'+id).toggle(); |
| 148 |
}, |
| 149 |
|
| 150 |
init : function(relPath) { |
| 151 |
$('span[class=lineno]').css({ |
| 152 |
'padding-right':'4px', |
| 153 |
'margin-right':'2px', |
| 154 |
'display':'inline-block', |
| 155 |
'width':'54px', |
| 156 |
'background':'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%' |
| 157 |
}); |
| 158 |
|
| 159 |
$('span[class=lineno]:first').append('<span class="fold" id="fold_all" '+ |
| 160 |
'onclick="javascript:codefold.toggle_all('+relPath+');" '+ |
| 161 |
'style="background-image:'+this.minusImg[relPath]+';"></span>'); |
| 162 |
|
| 163 |
$('span[class=lineno]').not(':eq(0)').append('<span class="fold"></span>'); |
| 164 |
|
| 165 |
$('div[class=foldopen]').each(function() { |
| 166 |
|
| 167 |
const id = $(this).attr('id').replace('foldopen',''); |
| 168 |
|
| 169 |
const start = $(this).attr('data-start'); |
| 170 |
const end = $(this).attr('data-end'); |
| 171 |
|
| 172 |
$(this).find('span[class=fold]:first').replaceWith('<span class="fold" '+ |
| 173 |
'onclick="javascript:codefold.toggle(\''+id+'\');" '+ |
| 174 |
'style="background-image:'+codefold.minusImg[relPath]+';"></span>'); |
| 175 |
|
| 176 |
$(this).after('<div id="foldclosed'+id+'" class="foldclosed" style="display:none;"></div>'); |
| 177 |
|
| 178 |
const line = $(this).children().first().clone(); |
| 179 |
|
| 180 |
$(line).removeClass('glow'); |
| 181 |
if (start) { |
| 182 |
|
| 183 |
$(line).html($(line).html().replace(new RegExp('\\s*'+start+'\\s*$','g'),'')); |
| 184 |
} |
| 185 |
|
| 186 |
$(line).find('span[class=fold]').css('background-image',codefold.plusImg[relPath]); |
| 187 |
|
| 188 |
$(line).append(' '+start+'<a href="javascript:codefold.toggle(\''+id+'\')">…</a>'+end); |
| 189 |
|
| 190 |
$('#foldclosed'+id).html(line); |
| 191 |
}); |
| 192 |
}, |
| 193 |
}; |
| 194 |
|