-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
238 lines (228 loc) · 5.64 KB
/
index.php
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
<?php
$re = $_GET['region'] ?? '';
$sy = $_GET['sy'] ?? '';
$ey = $_GET['ey'] ?? '';
$pe = $_GET['id'] ?? '';
$gr = $_GET['gid'] ?? '';
$faves = $_GET['faves'] ?? '';
if (!empty($re)){
$datastring[] = 'region='.$re;
$querystring[] = 'region='.$re;
}
if (!empty($sy)){
$datastring[] = 'sy='.$sy;
$querystring[] = 'sy='.$sy;
}
if (!empty($ey)){
$datastring[] = 'ey='.$ey;
$querystring[] = 'ey='.$ey;
}
if (!empty($pe)){
$datastring[] = 'id='.$pe;
$querystring[] = 'pid='.$pe;
}
if (!empty($gr)){
$datastring[] = 'gid='.$gr;
$querystring[] = 'gid='.$gr;
}
if (!empty($faves)){
$datastring[] = 'faves='.$faves;
$querystring[] = 'faves='.$faves;
}
include '../core/inc.php';
include 'db/cognizdb.php';
include 'db/cognizqueries.php';
include 'regions.php';
if($re != ''){
$area = $regions[$re];
}
else {
$area = 'All regions';
}
if($sy){
if($sy > 0){
$sd = $sy;
}
if($ey > 0){
$sd .= '-'.$ey.'';
}
else {$sd .= ' to present';}
}
$json = 'https://www.coreymwamba.co.uk/resources/rhizome/rhizome-json.php?'.join('&',$datastring);
$count = json_decode(file_get_contents($json),true);
$peo = $count['count']['people'];
$gro = $count['count']['groups'];
$qu = join('&',$querystring);
if($qu){
$qjson = file_get_contents('https://www.coreymwamba.co.uk/resources/rhizome/query?'.$qu);
$dq = json_decode($qjson,true);
$graph = $dq[0]["@graph"][0];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<base href="http://www.coreymwamba.co.uk/resources/" />
<title>THE RHIZOME</title>
<meta name="description" content="a necessarily unfinished network graph showing jazz/improv groups and musicians in Britain and Ireland" />
<link href="https://www.coreymwamba.co.uk/resources/style.css" rel="stylesheet" />
<style>
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
.node:hover {
cursor: pointer;
}
svg#rhizome {
overflow: auto;
width: 800px; height: 600px
}
aside {
font-size: 80%;
background-color: rgba(250,250,250,0.8);
z-index: 400;
padding-left: 0.3em;
}
#metadata ul{
list-style: none;
}
option {width: 12em}
input[type=number] {width: 6em}
label {display: block; margin: 0.3em}
section {border-top: 1px solid #bbb; border-bottom: 1px solid #bbb; padding: 0.3em 0; margin: 1em 0;}
@media (max-width: 800px){
svg#rhizome {width: 450px; height: 300px}
main {min-height: 10vh}
}
</style>
</head>
<body>
<main>
<svg id="rhizome"<?php if (isset($datastring)){echo ' data-query="'.join('&',$datastring).'"';}?>></svg>
<script src="rhizome/d3.min.js"></script>
<script src="rhizome/rhizome-2.js"></script>
</main>
<aside id="metadata">
<h1>THE RHIZOME</h1>
<?php
if(!$_GET){
?>
<p> <?php echo $peo;?> people; <?php echo $gro;?> groups. <strong>Desktop/laptop recommended</strong>.</p>
<?php
}
else {
include 'vis.php';
}
?>
<section>
<ul>
<li><a href="rhizome">RESET AND RELOAD</a></li>
<li><a href="rhizome/group-maker.php">Feed the RHIZOME with groups and people</a></li>
<li><a href="rhizome/picknmix.php">Pick and mix</a></li>
<li><a href="rhizome/search.php">Finder (text-based)</a></li>
<li><a href="rhizome/query">Query endpoint</a></li>
</ul>
</section>
<?php
if(!$_GET){
?>
<label for="finder">Focus the rhizome by entering a name</label>
<input type="text" id="finder" />
<input type="button" onclick="unsetFinder();" value="reset focus" />
<div id="sr"></div>
<?php
}
else {
echo '<div id="sr"></div>'."\n";
}
?>
<section>
<form method="GET">
<label>British/Irish region
<select name="region">
<option value=""></option>
<?php
foreach($regions as $key => $value){
echo '<option value="'.$key.'">'.$value.'</option>'."\n";
}
?>
</select>
</label>
<label>Year started <input type="number" min="1900" max="2018" name="sy" /></label>
<label>Year dissolved <input type="number" min="1900" max="2018" name="ey" /></label>
<input type="submit" value="FILTER" />
</form>
</section>
<p>by Corey Mwamba and Tom Ward</p>
<p>Inspired by a <a href="https://medium.com/@ktcita/the-new-uk-jazz-family-tree-b25db4b47cbe" target="_blank">beautiful, static version by Kimberley Crofts</a>. </p>
</aside>
<?php
include '../menu.html';
?>
<script>
<?php
if(!isset($datastring)){
?>
var holder = document.getElementById("finder");
holder.addEventListener("keyup",findNames,false);
function unsetFinder(){
var holder = document.getElementById("finder");
var nameInput = document.getElementById("sr");
nameInput.innerHTML = "";
holder.value = "";
allNodesOpacity(1);
}
function findNames() {
var holder = document.getElementById("finder");
var nameInput = document.getElementById("sr");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState==4 && this.status==200){
nameInput.innerHTML = this.responseText;
}
}
xhr.open("GET","https://www.coreymwamba.co.uk/resources/rhizome/groupsearch.php?b="+holder.value);
xhr.send();
}
function displayGroup(id){
var nameInput = document.getElementById("sr");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState==4 && this.status==200){
nameInput.innerHTML = this.responseText;
}
}
xhr.open("GET","https://www.coreymwamba.co.uk/resources/rhizome/groupsearch.php?j="+encodeURIComponent(id));
xhr.send();
}
<?php
}
?>
function displayMus(id){
var nameInput = document.getElementById("sr");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState==4 && this.status==200){
nameInput.innerHTML = this.responseText;
}
}
xhr.open("GET","https://www.coreymwamba.co.uk/resources/rhizome/groupsearch.php?k="+encodeURIComponent(id));
xhr.send();
}
</script>
<?php
if ($qjson){
echo '<script type="application/ld+json">'."\n";
echo $qjson."\n";
echo '</script>'."\n";
}
?>
</body>
</html>