-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
239 lines (227 loc) · 6.63 KB
/
index.html
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>NeuroLinks - Explore Resources in the Neuroimaging Community!</title>
<link rel=icon href="lynx.png">
<link href="./lib/bootstrap-3.3.7-dist/css/bootstrap.css" type="text/css" rel="stylesheet"/>
<link href="./lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css" type="text/css" rel="stylesheet"/>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://unpkg.com/vue"></script>
<script type='text/javascript' src="./lib/rdfstore_min.js">
</script>
<script type="text/x-template" id="grid-template">
<div>
<table class="table table-hover">
<thead>
<tr>
<th v-for="key in columns">
{{ key }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="entry in data">
<td v-for="key in columns" v-html="entry[key]">
{{ entry[key] }}
</td>
</tr>
</tbody>
</table>
</div>
</script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="https://brainhack101.github.io/neurolinks">NeuroLinks</a>
</div>
</div>
</nav>
<div class="container theme-showcase" style="padding-top:5em" role="main">
<div class="row jumbotron">
<h1 style="display:inline"><img height="80px" ="20px" style="padding-bottom:10pt" src="./lynx.png">Neuro<span style="color:rgb(57,126,161)">Links</span></h1><br/><h3 style="display:inline">Easily find and share resources for computational neuroscience</h3>
</div>
<div class="row">
<div id="gridC">
<div class="col-md-2"><h3>Resource:</h3>
<div class="form-group">
<select v-model="selected" class="form-control">
<option disabled value="">Please select one</option>
<option v-for="option in options" v-bind:value="option.value">
{{option.text}}
</option>
</select>
</div>
<p>Add your resource by opening an issue <a href="https://github.com/brainhack101/neurolinks">here!</a></p>
</div>
<div class="col-md-10" style="height:1em">
<demo-grid
:data="gridData"
:columns="gridColumns">
</demo-grid>
</div>
</div>
<script>
Vue.component('demo-grid', {
template: '#grid-template',
props: {
data: Array,
columns: Array
},
data: function () {
var sortOrders = {}
this.columns.forEach(function (key) {
sortOrders[key] = 1
})
return {
sortKey: '',
sortOrders: sortOrders
}
}
})
var gridC = new Vue({
el: '#gridC',
data: {
selected:'none',
options:[
{text:'Course', value:'jsons/course.json'},
{text:'Data', value:'jsons/data.json'},
{text:'Community', value:'jsons/community.json'},
{text:'Organization', value:'jsons/organization.json'},
{text:'Tool', value:'jsons/tool.json'}
],
gridColumns: [],
gridData: [],
},
computed: {
showDefault:{
get: function(){
},
set: function () {
console.log("gridC.selected", gridC.selected)
parse_data(gridC)
}
}
},
watch: {
'selected': function() {
console.log("gridC.selected", gridC.selected)
parse_data(gridC)
}
}
})
// Loads all data into obj dictionary
var objs = {}
load_json = function(gc) {
var counter = 0;
gridC.options.forEach(function(opt){
opt = opt.value
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var json_string = xmlhttp.responseText;
objs[opt] = JSON.parse( json_string );
console.log(objs[opt])
counter++;
if (counter == gridC.options.length){
// Set "selected" to be the course table
gridC.selected = 'jsons/course.json'
}
}
}
xmlhttp.open("GET", opt, true);
xmlhttp.send();
});
};
// Load data on page load
load_json(gridC)
// Creates current table
parse_data = function(gc) {
data = objs[gc.selected]
var onts = data.ontologies;
var terms = data.terms;
var items = data.entities;
// Reorganize columns based on priority
terms.sort(function(a, b){
return a.priority > b.priority;
});
// Sets column names
gc.gridColumns = []
terms.forEach( function(term){
if (! ('hide' in term && term.hide == true)) {
if (term.pretty == "Boutiques") {
gc.gridColumns.push("Platforms")
} else {
gc.gridColumns.push(term.pretty)
}
}
});
// Puts data into table
var stacks = []
items.forEach( function(itm){
var stack = {}
gc.gridColumns.forEach( function(term){
if (term !== "Platforms") { var ind = terms.find(function(a) {return a.pretty === term}).label }
switch(term){
case "URL":
stack[term] = shorten(itm[ind], 30 - (gc.gridColumns.length-5)*3, true)
break;
case "Description":
stack[term] = shorten(itm[ind], 100, false)
break;
case "Platforms":
stack[term] = ""
if (itm["boutiquesdescriptor"]) {
stack[term] += platforms(itm["boutiquesdescriptor"], "https://raw.githubusercontent.com/boutiques/boutiques.github.io/master/images/logo.png")
}
if (itm["dockercontainer"]) {
stack[term] += platforms(itm["dockercontainer"], "https://secure.gravatar.com/avatar/26da7b36ff8bb5db4211400358dc7c4e.jpg?s=512&r=g&d=mm")
}
if (itm["singularitycontainer"]) {
stack[term] += platforms(itm["singularitycontainer"], "http://singularity.lbl.gov/images/logo/logo.svg")
}
break;
default:
stack[term] = itm[ind]
}
});
stacks.push(stack);
});
// Reorganize columns based on name
stacks.sort(function(a, b){
var loc = gc.gridColumns[0]
return a[loc].toUpperCase() > b[loc].toUpperCase();
});
console.log(stacks);
gc.gridData = stacks
};
// Shortens long URLs
shorten = function(patter, len, link) {
if (patter.length > len) {
if (link) {
return (patter.slice(0,len-3)+'...').link(patter)
} else {
return patter.slice(0,len-3)+'...'
}
} else {
if (link) {
return patter.link(patter)
} else {
return patter
}
}
};
// Puts a picture that links to a thing
platforms = function(url, logo) {
return ("<img height='25px' src='" + logo + "' />").link(url)
};
</script>
</div>
<script src="./lib/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</body>
</html>