A metronome using the FRDM K64F board

Committer:
ram54288
Date:
Sun May 14 18:40:18 2017 +0000
Revision:
0:a7a43371b306
Initial commit

Who changed what in which revision?

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