-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualisation-picker.php
76 lines (55 loc) · 1.5 KB
/
visualisation-picker.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
<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php');
$db = new Hn_TS_Database();
$timestreams = $db->hn_ts_getTimestreams();
?>
<form name="timestreampicker" id="timestreamForm" action="#">
<table class="form-table">
<tr>
<th>Select a Timestream</th>
<td>
<select id="timestream" name="timestream">
<option value=""> - Select - </option>
<?php
foreach($timestreams as $timestream)
{
echo "<option value=\"$timestream->timestream_id\">$timestream->name</option>";
}
?>
</select>
</td>
</tr>
<tr>
<th>Select a Visualisation</th>
<td>
<select id="viz" name="viz">
<option value=""> - Select - </option>
<?php
$visDir = "../visualisations/";
$visDirs = glob($visDir . "*", GLOB_ONLYDIR);
foreach($visDirs as $viz)
{
$vizName = basename($viz);
echo "<option value=\"$vizName\">$vizName</option>";
}
?>
</select>
</td>
</tr>
</table>
</form>
<p class="submit">
<input type="button" class="button-primary" value="Insert Visualisation" onclick="insert()" />
</p>
<script type="text/javascript">
function insert()
{
tsSelect = document.getElementById("timestreamForm").elements["timestream"];
tsId = tsSelect.options[tsSelect.selectedIndex].value;
vizSelect = timestreamForm.elements["viz"];
vizName = vizSelect.options[vizSelect.selectedIndex].value;
shortcode = "[timestream viz=\"" + vizName + "\" tsid=" + tsId + "]";
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
tb_remove();
}
</script>