-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
251 lines (210 loc) · 8.61 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
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
ini_set('display_errors', 'off');
// text wrapped in <h4> tags above book information
$_HEADER_TEXT = "Patron: Please do not remove this strap";
$_STRAP_BODY = "
<p><strong>OVERDUE FINE OF $2.00 PER DAY</strong> </p>
<p>Requests for renewal should be made on, or before due date. <p>
<p>To request a renewal, please contact the ILL office by email at <srong>illd@muhlenberg.edu</strong> or by phone at <strong>484-664-3510</strong>.
</br>Please include your name, the ILL/Barcode number, and book title.</p>
<p><b>Please Do Not Shelve</b></p>
<h4>Return to Lending Services Desk</h4>
<h4>Patron: Please do not remove this strap</h4>
<h5>Interlibrary loan books are subject to recall by the lending library at any time.</h5>
";
if(!empty($_GET)) {
$lender = $_GET['lender'];
$patron = urldecode($_GET['patron']);
$barcode = $_GET['barcode'];
$dueDate = urldecode($_GET['dueDate']);
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Begin yr ILL strap template here -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
#barcode {
font-weight: normal;
font-style: normal;
line-height: normal;
font-size: 10px;
}
#container {
margin-top: 25%;
}
#otherthing {
width:250px;
left:20px;
}
</style>
<body>
<?php if (!empty($_GET)) { ?>
<div id="container" class="span4">
<div id="otherthing">
<?php if ( isset($_HEADER_TEXT) ) { ?>
<h4><?php echo $_HEADER_TEXT; ?></h4>
<?php } ?>
<p>Lender Symbol: <strong><?php echo $lender; ?></strong></p>
<p>Patron: <strong><?php echo $patron; ?></strong></p>
<p>Barcode/ILL#</p>
<p id="barcode">(<?php echo $barcode; ?>)</p>
<p>Due Date: <h3 class="dueDate" contenteditable="true"><?php echo $dueDate; ?></h3></p>
<?php if ( isset($_STRAP_BODY) ) { echo $_STRAP_BODY; } ?>
</div>
</div>
<?php } else { ?>
<div class="container-fluid">
<form class="form form-horizontal" action="." method="get">
<legend>Build an Interlibrary Loan strap</legend>
<div class="control-group">
<label class="control-label" for="lender">Lender Symbol</label>
<div class="controls">
<input type="text" id="lender" name="lender" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="patron">Patron Name</label>
<div class="controls">
<input type="text" id="patron" name="patron" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="barcode">Barcode #</label>
<div class="controls">
<input type="text" id="barcode" name="barcode" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="dueDate">Due Date</label>
<div class="controls">
<input type="date" id="dueDate" name="dueDate" required />
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-default">Generate your strap!</button>
</div>
</div>
</form>
<hr>
<div class="accordion" id="accordion">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="accordion" href="#collapseOne">
Build the bookmarklet
</a>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<fieldset class="form-inline">
<input id="path" type="text" placeholder="Path to strappy.php file" value="http://<?php echo $_SERVER['SERVER_NAME'] .$_SERVER['PHP_SELF']; ?>" class="input-xlarge">
<input id="title" type="text" placeholder="Title for bookmarklet (default: 'Strappy')" class="input-xlarge"/>
<button id="bkmklt-btn" class="btn btn-success">Generate Bookmarklet</button>
</fieldset>
<div class="container-fluid">
<div id="bookmarklet"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php if ( empty($_GET) ) { ?>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script>
function removeChildren(el) {
if ( !(el instanceof HTMLElement) ) {
el = document.querySelector(el);
}
var counter = 0;
if ( el.hasChildNodes() ) {
for ( var i = 0; i < el.childNodes.length; i++ ) {
if ( el.removeChild(el.childNodes[i]) ) { counter++ }
}
}
}
function buildLink() {
var strappy_path = document.getElementById('path').value || ''
, strappy_path = !/^http:\/\//.test(strappy_path) ? 'http://' + strappy_path : strappy_path
, bookmarklet = document.getElementById('bookmarklet')
, bkmrk = '!function(){var a=document.getElementsByClassName("yui-field-originalDueDate"),b=document.getElementsByClassName("lendingInformationExtra"),c=document.getElementsByClassName("patronExtra"),d=document.getElementsByClassName("accordionRequestDetailsRequestId"),e="' + strappy_path + '";return!a|!a.length|!b|!b.length|!c|!c.length|!d|!d.length?!1:(a=a[a.length-1].innerHTML,b=b[b.length-1].innerHTML.replace("(Supplier: ","").replace(")",""),c=c[c.length-1].innerHTML.replace("(","").replace(")",""),d=d[d.length-1].innerHTML,void window.open(e+"?barcode="+d+"&lender="+b+"&patron="+encodeURI(c)+"&dueDate="+encodeURI(a),"_blank"))}();'
, a, arrow, i, clear
;
removeChildren(bookmarklet);
bookmarklet.className = '';
a = document.createElement('a');
a.href = 'javascript:' + bkmrk;
a.innerText = document.getElementById('title').value || 'strappy';
a.id = 'bookmark';
a.className = 'label label-info';
a.style.fontWeight = '400';
a.style.padding = '5px';
arrow = document.createElement('span');
i = document.createElement('i');
i.className = 'icon-arrow-left';
i.style.marginLeft = '10px';
arrow.appendChild(i);
arrow.innerHTML += ' drag this button into your bookmarks bar'
clear = document.createElement('a');
clear.addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('path').value = '';
bookmarklet.removeChild(a);
bookmarklet.removeChild(arrow);
bookmarklet.removeChild(clear);
bookmarklet.className = '';
});
clear.href = '#';
clear.innerText = 'click to clear';
clear.style.display = 'block';
bookmarklet.className = 'well';
bookmarklet.appendChild(a);
bookmarklet.appendChild(arrow);
bookmarklet.appendChild(clear);
}
document.getElementById('bkmklt-btn').addEventListener('click', buildLink);
</script>
<?php } else { ?>
<script type="text/javascript" src="connectcode-javascript-code39.js"></script>
<script >
var barcode = document.getElementById('barcode')
, dueDate = document.querySelector('.dueDate')
;
if ( barcode ) {
barcode.innerHTML = DrawHTMLBarcode_Code39(
barcode.innerHTML, // data
0, // checkDigit
'yes', // humanReadable
'in', // units
0, // minBarWidth
3, // width
.35, // height
3, // barWidthRatio
'bottom', // textLocation
'center', // textAlignment
'', // textStyle
'black', // foreColor
'white' // backColor
);
var spans = document.querySelectorAll('#barcode div span');
/*
* because we can, let's escape the asterisks that appear b/c of code39.js
*/
spans[(spans.length - 1)].textContent = spans[(spans.length - 1)].textContent.replace(/\*/g, '')
/*
* if no due date is provided from worldcat, let's draw the user's attention to it
* and have them fill it in
*/
if ( dueDate.innerHTML === "" ) {
alert("Hey I need a due date!");
dueDate.focus();
}
}
</script>
<?php } ?>
</body>
</html>