-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
98 lines (93 loc) · 3.49 KB
/
edit.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
<?php
include "env/config.php";
include "lib/helpers.php";
$res = get_annotation_by_id($_GET["id"]);
$anno = json_decode($res, true);
?>
<html>
<?php include "layout/head.html"; ?>
<body>
<div class="container">
<?php include "layout/navbar.php"; ?>
<h2>Editing Annotation <?php echo $anno["id"] ?></h2>
<form action="<?php echo $status_link_url?>/edit_save.php" method="post">
<!-- hidden fields -->
<input type="hidden" name="id" value="<?php echo $anno['id'] ?>"/>
<div class="row anno">
<!-- Identification and Links -->
<div class="col-md-3">
<h5>Letter: <?php echo $anno["pageID"] ?></h5>
<p>ID: <?php echo $anno["id"] ?></p>
<?php if (isset($anno["pageID"])): ?>
<a href="<?php echo $boilerplate_url?><?php echo $anno["pageID"]?>.html">Annotate</a>
|
<a href="<?php echo $catherletters_url ?>/<?php echo $anno["pageID"] ?>">Cather View</a>
<?php else: ?>
No links available for nonexistent id
<?php endif; ?>
</div>
<div class="col-md-2">
<p>
Status Tag:
<select name="tags">
<?php echo generate_tag_dropdown($anno["tags"][0]) ?>
</select>
</p>
<p>
<label>
<input id="ref_toggle" type="checkbox" name="ref"
<?php
$ref = (isset($anno["anno_ref_id"])
&& $anno["anno_ref_id"] !== "") ? true : false;
if ($ref) echo "checked"
?>
> Reference another annotation
</label>
</p>
</div>
<!-- Annotation content -->
<div class="col-md-7">
<h5>
Highlight:
<span class="quote"><?php echo $anno["quote"]?></span>
</h5>
<div id="anno"<?php if ($ref) echo ' class="hide"' ?>>
<label for="anno_text">Annotation Text: </label>
<textarea id="anno_text" class="form-control" name="text" rows="8"><?php echo $anno["text"] ?></textarea>
</div>
<div id="anno_ref"<?php if (! $ref) echo ' class="hide"' ?>>
<label for="anno_ref_id"> Referenced Annotation ID:</label>
<input id="anno_ref_id" class="form-control" type="text" name="anno_ref_id"
<?php if ($ref) echo " value=\"$anno[anno_ref_id]\"" ?>
>
</div>
<div class="col-md-6">
<input class="form-control save" type="submit" value="Save"/>
</div>
</div>
</form>
<a href="<?php echo $status_link_url ?>">Back to Status View</a>
</div>
</div>
<script>
$(function () {
$("#ref_toggle").click(function() {
$("#anno").toggleClass("hide");
$("#anno_ref").toggleClass("hide");
var $ref_id = $("#anno_ref_id");
if (! $("#ref_toggle").prop("checked")) {
// Empty ref ID input, otherwise annotation text will be discarded
$ref_id.data("previous", $ref_id.val());
$ref_id.val('');
}
else {
// Restore value if saved when unchecking the toggle
if ($ref_id.data("previous") !== undefined) {
$ref_id.val($ref_id.data("previous"));
}
}
});
});
</script>
</body>
</html>