forked from ucamhal/lookup-institution-list-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
179 lines (160 loc) · 9.27 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
<!doctype html>
<html>
<head>
<title>Institution list builder</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore.js"></script>
<script src="lib/ucsv.min.js"></script>
<script src="js.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
<!-- The contents of stylesheet.xml is repeated here to make it available when using file:// (e.g. ajax not available). -->
<script id="xslt-stylesheet" type="text/xsl">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:l="http://www.lookup.cam.ac.uk"
extension-element-prefixes="l"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- Index institutions by their parents to avoid O(n^2) behavior which
would be incurred by searching all institutions for children at each
institution. -->
<xsl:key name="institution-by-parent"
match="/l:result/l:entities/l:institutions/l:institution"
use="l:parentInsts/l:institution/@ref"/>
<!-- Entry point -->
<xsl:template match="/">
<ul id="institution-tree">
<!-- Start the traversal from institutions with no parents (the root(s)) -->
<xsl:apply-templates select="//l:entities/l:institutions/l:institution[not(l:parentInsts/l:institution)]"/>
</ul>
</xsl:template>
<!-- Template each institution in a <li> -->
<xsl:template match="l:institution">
<li title="{l:name}">
<label for="checkbox-{@instid}">
<input type="checkbox" id="checkbox-{@instid}" data-instid="{@instid}"/>
<xsl:value-of select="l:name"/>
</label>
<!-- Recursively template child institutions in a <ul> -->
<xsl:variable name="children" select="key('institution-by-parent', @id)"/>
<xsl:if test="$children">
<ul>
<xsl:apply-templates select="$children"/>
</ul>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>
</script>
</head>
<body class="container">
<div class="jumbotron">
<h1>Institution list builder</h1>
<p>Follow the steps to build an institution list.</p>
<p><a class="btn btn-primary btn-lg" role="button" title="it looks cool though">This button does nothing</a></p>
</div>
<div class="container">
<h2><small>Step 1</small> Input institution XML from lookup</h2>
<form role="form" id="step-1-form">
<div id="step-1-form-xml-group" class="form-group">
<p class="help">
<small title="lookup.cam does not send CORS headers">Due to technical restrictions, it's not <span class="strike">possible</span> practical to automatically fetch the institution data from lookup.cam.</small>
</p>
<h5>Instructions</h5>
<ol>
<li>Use the link below view the latest institution list from lookup.cam.ac.uk</li>
<li>When prompted, log in with the username <code>anonymous</code> and no password</li>
<li>Copy the XML (it should start with <code><?xml version</code> — if you just see text you probably need to right click and choose “view source” or similar</li>
<li>Paste it in the area below and press Submit</li>
</ol>
<p>The institution list is available at <a target="_blank" href="view-source:https://www.lookup.cam.ac.uk/api/v1/inst/all-insts?fetch=parent_insts&flatten=true">https://www.lookup.cam.ac.uk/api/v1/inst/all-insts?fetch=parent_insts&flatten=true</a></p>
<textarea
name="institution-input-xml"
class="form-control xml-input"
id="step-1-form-xml"
placeholder="<?xml version="1.0" encoding="UTF-8" standalone="yes"?> ..."
rows="10"></textarea>
<p class="help-block error-msg"></p>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
<div class="hidden" id="step-2">
<h2><small>Step 2</small> Curate full institution list</h2>
<p>Tick the entries you wish to be included. An exclusion list of the institutions you've not selected is maintained at the side of the page.</p>
<form role="form" id="step-2-form">
<div class="row">
<div class="form-group col-xs-6" id="institution-tree-group">
<!-- Rendered tree goes here -->
</div>
<div id="exclusion-list-fixed-wrapper" class="col-xs-6">
<div class="form-group">
<label for="exclusion-list">Exclusion list</label>
<textarea
class="form-control"
id="exclusion-list"
name="exclusion-list"
rows="6"
placeholder="One institution ID per line"
></textarea>
<p class="help-block">
As you uncheck institutions from the tree they'll show up in this list. This works in both directions — changes to this list will update the tree. This allows you to restore a previously used exclusion list by pasting it into this box at a later date.
</p>
<button type="button" id="exclusion-list-dl-btn" class="btn btn-sm btn-info"><span class="glyphicon glyphicon-download"></span> Download exclusion list</button>
</div>
<div class="form-group">
<label for="substitutions-input">Substitutions</label>
<textarea
class="form-control"
id="substitutions-input"
rows="6"
placeholder="One substitution per line in format 's/find/replace/'"
></textarea>
<p class="help-block">Specify substitutions to apply to the institution names.</p>
<button type="button" id="btn-substitutions-download" class="btn btn-sm btn-info"><span class="glyphicon glyphicon-download"></span> Download substitutions</button>
<script type="text/template" id="substitution-template">
<li class="list-group-item substitution">
Replace <span class="label label-danger"><%= find || " " %></span> with <span class="label label-success"><%= replace || " " %></span>
<small class="pull-right">(replaced <%= occurences %> occurence<%= occurences !== 1 ? 's' : '' %>)</small>
</li>
</script>
<ul id="substitutions-list" class="list-group"></ul>
</div>
<div class="form-group">
<label for="institution-list-csv">Institution list CSV</label>
<textarea
readonly
class="form-control"
id="institution-list-csv"
name="institution-list-csv"
rows="6"
placeholder="Selected institutions will appear here"
>This is some text</textarea>
<p class="help-block">
Selected institutions will appear here. Download this file and send it to someone with admin rights to the Open Access site.
</p>
<button type="button" id="csv-dl-btn" class="btn btn-sm btn-info"><span class="glyphicon glyphicon-download"></span> Download CSV</button>
</div>
</div>
</div>
</form>
</div>
<div id="modal-stylesheet-error" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="mySmallModalLabel">Error</h4>
</div>
<div class="modal-body">
Unable to fetch XML stylesheet.
</div>
</div>
</div>
</div>
</body>
</html>