-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
145 lines (115 loc) · 5.62 KB
/
index.php
File metadata and controls
145 lines (115 loc) · 5.62 KB
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
<!DOCTYPE html>
<!--
METADATEN-PROX: OCLC ISBN Webservice
Kathrin Heim, BibInfo16 Abschlussaufgabe 1
-->
<html>
<head>
<meta charset="UTF-8">
<title>Metadata Proxy</title>
<link rel="stylesheet" type="text/css" href="layout.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="validateISBN.js"></script>
<script>
/**
* On page load, the entered ISBN is checked with validateISBN.js and jquery.validate.min.js (plugin)
* @returns error message if invalid ISBN
*/
$(document).ready(function() {
$.validator.addMethod("isbn", function(value, element) {
return isValidISBN(value);
}, " Please enter a valid ISBN-13 Number. ");
//check if isbn is correct
$("#myForm").validate({
debug: true,
rules: {
isbnInput: {
required: true,
isbn: true
}
}
});
/**
* Ajax call on submit in ISBN form:
* requestHandler.php is called with ISBN input.
* On sucess, JSON response is parsed and record displayed (or error alert, if invalid/unknown ISBN).
* On complete, current date is displayed in footer.
* @param {type} submit event
* @returns JSON response, displayed as HTML
*/
$('#myForm').submit(function(event){
$.ajax({
url: "requestHandler.php",
method: "POST",
data: {
"isbn":$('#isbnInput').val()
},
complete: function(response) {
var d = new Date();
var realTime = d.toLocaleDateString('de-DE');
$('.realtime').html('• '+realTime);
},
success: function(response) {
var data = JSON.parse(response);
if (data.stat !== 'ok') {
alert("Data not found: "+data.stat);
$('.output').css('visibility', 'hidden');
} else {
$('.output').css('visibility', 'visible');
}
$('.mediatype').html("<img src='icons/"+data.list[0].form[0]+".png'>");
$('.isbn').html(data.list[0].isbn);
$('.title').html(data.list[0].title);
$('.author').html(data.list[0].author);
$('.year').html(data.list[0].year);
$('.publisher').html(data.list[0].publisher);
$('.city').html(data.list[0].city);
$('.url').html("<img src='icons/logo.png' alt='WorldCat' height='64'></br><a href="+
data.list[0].url+" target='_blank'>View record on WorldCat</a>");
},
error: function(response) {
alert("ERROR: ");
$('.output').html(response);
}
});
});
});
</script>
</head>
<body>
<div class="logo">
<h1 class="pagetitle">ISBN Metadata-Proxy</h1>
</div>
<form id='myForm'>
<label for="isbnInput"></label>
<input id="isbnInput" name="isbn" type="text" class="isbn">
<input id= "submitbutton" type="submit" name="submitbutton" value="search ISBN in Worldcat">
</form>
<div class="output">
<h1 class="record">Record: </h1>
<div class="mediatype"></div>
ISBN: <div class="isbn"></div>
Title: <div class="title"></div>
Author: <div class="author"></div>
Year: <div class="year"></div>
Publisher: <div class="publisher"></div>
City: <div class="city"></div>
<div class="url"></div>
</div>
<div class="legend">
<h2>Mediatypes:</h2>
<img src='icons/AA.png' height="40px"> Audio (AA)
<img src='icons/BA.png' height="40px"> Book (BA, BB, BC)
<img src='icons/DA.png' height="40px"> Digital (DA)
<img src='icons/FA.png' height="40px"> Video (FA, VA)
</div>
</br>
<footer>
<address>
© MetadataProxy by Kathrin Heim • BibInfo16 <span class="realtime"></span>
</address>
<a href="https://icons8.com" target="blank">Icon pack by Icons8</a>
</footer>
</body>
</html>