cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

dynsections.js (2983B)


      1function toggleVisibility(linkObj)
      2{
      3 var base = $(linkObj).attr('id');
      4 var summary = $('#'+base+'-summary');
      5 var content = $('#'+base+'-content');
      6 var trigger = $('#'+base+'-trigger');
      7 var src=$(trigger).attr('src');
      8 if (content.is(':visible')===true) {
      9   content.hide();
     10   summary.show();
     11   $(linkObj).addClass('closed').removeClass('opened');
     12   $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
     13 } else {
     14   content.show();
     15   summary.hide();
     16   $(linkObj).removeClass('closed').addClass('opened');
     17   $(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
     18 } 
     19 return false;
     20}
     21
     22function updateStripes()
     23{
     24  $('table.directory tr').
     25       removeClass('even').filter(':visible:even').addClass('even');
     26}
     27function toggleLevel(level)
     28{
     29  $('table.directory tr').each(function(){ 
     30    var l = this.id.split('_').length-1;
     31    var i = $('#img'+this.id.substring(3));
     32    var a = $('#arr'+this.id.substring(3));
     33    if (l<level+1) {
     34      i.attr('src','ftv2folderopen.png');
     35      a.attr('src','ftv2mnode.png');
     36      $(this).show();
     37    } else if (l==level+1) {
     38      i.attr('src','ftv2folderclosed.png');
     39      a.attr('src','ftv2pnode.png');
     40      $(this).show();
     41    } else {
     42      $(this).hide();
     43    }
     44  });
     45  updateStripes();
     46}
     47
     48function toggleFolder(id)
     49{
     50  //The clicked row
     51  var currentRow = $('#row_'+id);
     52  var currentRowImages = currentRow.find("img");
     53
     54  //All rows after the clicked row
     55  var rows = currentRow.nextAll("tr");
     56
     57  //Only match elements AFTER this one (can't hide elements before)
     58  var childRows = rows.filter(function() {
     59    var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
     60    return this.id.match(re);
     61  });
     62
     63  //First row is visible we are HIDING
     64  if (childRows.filter(':first').is(':visible')===true) {
     65    currentRowImages.filter("[id^=arr]").attr('src', 'ftv2pnode.png');
     66    currentRowImages.filter("[id^=img]").attr('src', 'ftv2folderclosed.png');
     67    rows.filter("[id^=row_"+id+"]").hide();
     68  } else { //We are SHOWING
     69    //All sub images
     70    var childImages = childRows.find("img");
     71    var childImg = childImages.filter("[id^=img]");
     72    var childArr = childImages.filter("[id^=arr]");
     73
     74    currentRow.find("[id^=arr]").attr('src', 'ftv2mnode.png'); //open row
     75    currentRow.find("[id^=img]").attr('src', 'ftv2folderopen.png'); //open row
     76    childImg.attr('src','ftv2folderclosed.png'); //children closed
     77    childArr.attr('src','ftv2pnode.png'); //children closed
     78    childRows.show(); //show all children
     79  }
     80  updateStripes();
     81}
     82
     83
     84function toggleInherit(id)
     85{
     86  var rows = $('tr.inherit.'+id);
     87  var img = $('tr.inherit_header.'+id+' img');
     88  var src = $(img).attr('src');
     89  if (rows.filter(':first').is(':visible')===true) {
     90    rows.css('display','none');
     91    $(img).attr('src',src.substring(0,src.length-8)+'closed.png');
     92  } else {
     93    rows.css('display','table-row'); // using show() causes jump in firefox
     94    $(img).attr('src',src.substring(0,src.length-10)+'open.png');
     95  }
     96}
     97