aboutsummaryrefslogtreecommitdiff
path: root/templates/tableview.html
blob: d2936cee739de69d765cb6a16f3d037a33459281 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{% extends "layout.html" %}
{% block content %}

<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.6.0/cytoscape.min.js" integrity="sha256-uZV2wRlscgr52q3Wb3Oew0rKCPsM3g4aBTv46sF4qzg=" crossorigin="anonymous"></script>
<head>
    {%if num_gene==1%}
        <h2> <b>GENE: {{gene_name}}</b> </h2>
        {%if nodata_temp==1%}
            <b>No result was found.</b>
        {%endif%}
    {%else%}
    <h2> <b>GENES: {{gene_name}}</b> </h2>
        {%if nodata_temp==1%}
            <b>No result was found.</b>
        {%endif%}
    {%endif%}
</head>
{%if nodata_temp!=1%}
<style>
    * {
      box-sizing: border-box;
    }
    
    .column {
      float: left;
      padding: 10px;
    }
    
    .left {
      width: 60%;
    }
    
    .middle {
      width: 50%;
    }

    .right {
      width: 40%;
    }
    
    .row:after {
      content: "";
      display: table;
      clear: both;
    }
    tr:nth-child(even) {background-color: #f2f2f2;}
</style>

<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"> 
            </table>
        </body>
    </div>
    <div class="column right">
        {{ message3 |safe}} 
    </div>
</div>
    <script>{
        {}   
        var table = document.getElementById("myTable");
        var header = table.createTHead();
        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);
            source = '{{p['source']}}';
            target = '{{p['target']}}';
            var y= x.insertCell(0);        
            {%for p1 in jnodes['data']%}
                {%if p['target'] == p1['id']%}
                    color='{{p1['nodecolor']}}'
                    type='{{p1['nodetype']}}'
                {%endif%}
            {%endfor%}
            {%if 'GWAS' in  p['target']%}
                color="#AEB6BF"
                type='GWAS'
                key_gwas = target.replace("_GWAS","")
                    this_url1 = '\\sentences?edgeID=gwas_addiction.tab|'+source+'|'+target;
                    this_url2 = 'https://www.ebi.ac.uk/gwas/search?query='+key_gwas;
                {%else%}
                    this_url1 = '\\sentences?edgeID='+'{{genes_session_tmp}}'+'_snt|'+source+'|'+target;
                    this_url2 = '\\shownode?nodetype='+type+'&node='+target;
            {%endif%}
            genegene_url = '\\synonyms?node='+source;
            y.innerHTML="<a href='"+genegene_url+"'>{{p['source']}}</a>";
            y= x.insertCell(1);
            y.innerHTML="<center> <a href='"+this_url1+"'> {{p['sentCnt']}}</a> </center>"; 
            y= x.insertCell(2);
            y.innerHTML="<a href='"+this_url2+"'>{{p['target']}}</a>";
            y= x.insertCell(3);
            y.innerHTML=type; 
        {% 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.

{%endblock%}