145 lines
3.5 KiB
PHP
145 lines
3.5 KiB
PHP
![]() |
<?php
|
||
|
$pre = $_GET['pre']??'';
|
||
|
|
||
|
if ($pre == 'search') {
|
||
|
displaySearch();
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<h2>Item information</h2>
|
||
|
|
||
|
<div id="itemData">
|
||
|
|
||
|
<div class="line">
|
||
|
<label>Item name</label>
|
||
|
<span id="iName">(loading data, please wait...)</span>
|
||
|
</div>
|
||
|
|
||
|
<div class="line">
|
||
|
<label>Survey block</label>
|
||
|
<span id="iBlock">(loading data, please wait...)</span>
|
||
|
</div>
|
||
|
|
||
|
<div class="line">
|
||
|
<label>Item name</label>
|
||
|
<span id="iLabel">(loading data, please wait...)</span>
|
||
|
</div>
|
||
|
|
||
|
<div class="line">
|
||
|
<label>Item text</label>
|
||
|
<span id="iText">(loading data, please wait...)</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<h2>Citation information (n=<span id="numHits">loading...</span>)</h2>
|
||
|
<form id="spreadsheet" action="parts/spreadsheet.php" method="post" target="_blank">
|
||
|
<input type="hidden" name="id_item" value="<?=$_GET['id']?>">
|
||
|
<input type="submit" value="Download this bibliography in a spreadheet format">
|
||
|
</form>
|
||
|
|
||
|
<ul id="resultsList">
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
function itemError() {
|
||
|
$('#itemData').html(GeneralLoadErrorText());
|
||
|
}
|
||
|
|
||
|
|
||
|
$(document).ready(function () {
|
||
|
|
||
|
// retrieve data via web
|
||
|
$.ajax ({
|
||
|
method: "POST",
|
||
|
url: API_URL,
|
||
|
data: {
|
||
|
w: 'display_item',
|
||
|
id: '<?=($_GET['id']??'')?>'
|
||
|
}
|
||
|
})
|
||
|
.done (function (msg) {
|
||
|
if (msg == '') {
|
||
|
itemError();
|
||
|
}
|
||
|
else {
|
||
|
// if everything is OK
|
||
|
if (msg['status'] == "200") {
|
||
|
$('#iBlock').html(msg['data']['block']);
|
||
|
$('#iName').html(msg['data']['name']);
|
||
|
$('#iLabel').html(msg['data']['label']);
|
||
|
$('#iText').html(msg['data']['txt']);
|
||
|
|
||
|
console.log(msg);
|
||
|
}
|
||
|
else {
|
||
|
console.log(msg);
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
.fail (function() {
|
||
|
itemError();
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
// citations
|
||
|
$.ajax ({
|
||
|
method: "POST",
|
||
|
url: API_URL,
|
||
|
data: {
|
||
|
w: 'item_citations',
|
||
|
d: <?=$_GET['id']?>
|
||
|
}
|
||
|
|
||
|
})
|
||
|
.done (function (msg) {
|
||
|
if (msg == '') {
|
||
|
console.log('No response received from API!');
|
||
|
}
|
||
|
else {
|
||
|
// if everything is OK
|
||
|
if (msg['status'] == "200") {
|
||
|
console.log('Looks OK...');
|
||
|
results = msg['data'];
|
||
|
var all_citations = '';
|
||
|
|
||
|
$('#numHits').html(msg['data'].length);
|
||
|
|
||
|
if (msg['data'].length == 0) {
|
||
|
$('#resultsList').html('No results found.');
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
msg['data'].forEach(function (item) {
|
||
|
if (item['citation']!='') {
|
||
|
all_citations += '<li>' + item['citation'] + '</li>';
|
||
|
}
|
||
|
});
|
||
|
$('#resultsList').html(all_citations);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else {
|
||
|
console.log(msg);
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
.fail (function(jqXHR, textStatus, errorThrown) {
|
||
|
console.log('Failure ' + jqXHR.stringify + textStatus + errorThrown);
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
});
|
||
|
|
||
|
</script>
|
||
|
|
||
|
<?php
|
||
|
function displaySearch() {
|
||
|
$id = $_GET['id']??'';
|
||
|
|
||
|
// include_once ('search_bar.php');
|
||
|
}
|
||
|
?>
|