diff options
Diffstat (limited to 'templates/tableview.html')
-rw-r--r-- | templates/tableview.html | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/templates/tableview.html b/templates/tableview.html index 996113b..d2936ce 100644 --- a/templates/tableview.html +++ b/templates/tableview.html @@ -38,7 +38,6 @@ width: 40%; } - /* Clear floats after the columns */ .row:after { content: ""; display: table; @@ -49,6 +48,7 @@ <div class="row"> <div class="column left" > + You can click on the column header to sort by that column. <h4> {{ message |safe}} </h4> <body> <table id="myTable" border="1"> @@ -63,15 +63,19 @@ {} var table = document.getElementById("myTable"); var header = table.createTHead(); - var row = header.insertRow(0); + var row = header.insertRow(0); var cell = row.insertCell(0); cell.innerHTML = "<b>Gene</b>"; + cell.onclick = function() {sortTable(0)}; var cell = row.insertCell(1); cell.innerHTML = "<b>Abstract Count</b>"; + cell.onclick = function() {sortTable(1)}; var cell = row.insertCell(2); cell.innerHTML = "<b>Keyword</b>"; + cell.onclick = function() {sortTable(2)}; var cell = row.insertCell(3); cell.innerHTML = "<b>Category</b>"; + cell.onclick = function() {sortTable(3)}; {%for p in jedges['data']%} var x=document.getElementById('myTable').insertRow(1); @@ -94,7 +98,6 @@ this_url1 = '\\sentences?edgeID='+'{{genes_session_tmp}}'+'_snt|'+source+'|'+target; this_url2 = '\\shownode?nodetype='+type+'&node='+target; {%endif%} - //genegene_url = '/startGeneGene?forTopGene='+source; genegene_url = '\\synonyms?node='+source; y.innerHTML="<a href='"+genegene_url+"'>{{p['source']}}</a>"; y= x.insertCell(1); @@ -106,6 +109,66 @@ {% endfor %} } </script> + +<script> + function sortTable(n) { + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("myTable"); + switching = true; + dir = "asc"; + while (switching) { + switching = false; + rows = table.rows; + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x =rows[i].getElementsByTagName("TD")[n] + if(x.innerHTML.toString().includes("a href=")) { + x = rows[i].getElementsByTagName("TD")[n].innerHTML.toString().split("</a>")[0].split("\">")[1]; + y = rows[i+1].getElementsByTagName("TD")[n].innerHTML.toString().split("</a>")[0].split("\">")[1]; + } + else { + x =rows[i].getElementsByTagName("TD")[n].innerHTML; + y = rows[i + 1].getElementsByTagName("TD")[n].innerHTML; + } + if (dir == "asc") { + if (!(isNaN(parseInt(x)))){ + if(parseInt(x)>parseInt(y)){ + shouldSwitch = true; + break; + } + } + else if (x.toLowerCase() > y.toLowerCase()) { + shouldSwitch= true; + break; + } + } else if (dir == "desc") { + if (!(isNaN(parseInt(x)))){ + if(parseInt(x)<parseInt(y)){ + shouldSwitch = true; + break; + } + } + else if (x.toLowerCase() < y.toLowerCase()) { + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + switchcount ++; + } else { + if (switchcount == 0 && dir == "asc") { + dir = "desc"; + switching = true; + } + } + } + } + </script> + + {%endif%} <br> <a href='/tableview0/?rnd={{rnd_url}}&genequery={{genes_url}}'>Review</a> searches that have <b>zero</b> abstract counts. |