Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function()
- {
- $("#myTable").tablesorter();
- setHeightByAttr('Sum');
- }
- );
- function setAllSameHeight()
- {
- var t = document.getElementById("myTable");
- for(var i=0; i<t.rows.length; i++){
- t.rows[i].style.height = "30px";
- }
- }
- function setHeightByAttr(attr)
- {
- //find the index of the attribute and save it in a variable called index
- setTimeout(function() {
- var index = null;
- var t = document.getElementById("myTable");
- for(var i = 0; i < t.rows[0].cells.length; i++){
- if(t.rows[0].cells[i].innerText == attr+"n"){
- index = i;
- break
- }
- }
- t.rows[1].style.height = "30px";
- for(var i=2; i < t.rows.length; i++) {
- var sumi = t.rows[i].cells[index].innerHTML;
- var sumiminus1 = t.rows[i-1].cells[index].innerHTML;
- t.rows[i].style.height = 30+30*(Math.abs(sumi-sumiminus1)).toString()+"px";
- }
- }, 5);
- }
- <div class="container">
- <div class="row">
- <h5>The Ranklist is last updated at {{$update}}</h5>
- </div>
- <div class="row">
- <div class="col-xs-12">
- <table id="myTable" class="table table-condensed tablesorter">
- <thead>
- <tr>
- <th class="rank">R</th>
- <th class="hidden-xs flag" onclick= "setAllSameHeight()">Flag</th>
- <th onclick="setAllSameHeight()">Name</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('MC')">MC</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('TC')">TC</th>
- <th class="sortInitialOrder-desc" onclick="setHeightByAttr('SPE')">SPE</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('HW')">HW</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('Bs')">Bs</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('KS')">KS</th>
- <th class="hidden-xs sortInitialOrder-desc" onclick= "setHeightByAttr('Ac')">Ac</th>
- <th class="sortInitialOrder-desc" onclick="setHeightByAttr('DIL')">DIL</th>
- <th class="sortInitialOrder-desc" onclick="setHeightByAttr('Sum')">Sum</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement