ESS_Bibliography_frontend/parts/topic-item-module.php

154 lines
5.3 KiB
PHP
Raw Normal View History

2023-01-24 19:02:00 +01:00
<div class="browseFields full">
<div class="line nomargin"><label>ESS topics used:</label>
<?=($de==1?'Display entries that use <input type="radio" name="topic_logic" value="0" id="topic_logic_0" checked="checked"><label class="nolabel" for="topic_logic_0"><strong>any</strong></label>&nbsp;
/<input type="radio" name="topic_logic" value="1" id="topic_logic_1"><label class="nolabel" for="topic_logic_1"><strong>all</strong> of selected below</label></div>
<div class="line"><label>&nbsp;</label><i>(none selected means any)</i></div>':'')?>
<div class="nolabel w800 ml200 mb50" id="cnt_ess_topic">
Loading data, please wait...
</div>
<div class="line"><label>ESS items used:</label>
<?=($de==1?'Display entries that use <input type="radio" name="item_logic" value="0" id="item_logic_0" checked="checked"><label class="nolabel" for="item_logic_0"><strong>any</strong></label>&nbsp;
/<input type="radio" name="topic_item" value="1" id="item_logic_1"><label class="nolabel" for="item_logic_1"><strong>all</strong> of selected below</label></div>
<div class="line"><label>&nbsp;</label><i>(none selected means any)</i></div>':'')?>
<div class="nolabel w800 ml200 mb50" id="cnt_ess_item">
Loading data, please wait...
</div>
<div class="line"><label>ESS modules used:</label>
<?=($de==1?'Display entries that use <input type="radio" name="module_logic" value="0" id="module_logic_0" checked="checked"><label class="nolabel" for="module_logic_0"><strong>any</strong></label>&nbsp;
/<input type="radio" name="module_logic" value="1" id="module_logic_1"><label class="nolabel" for="module_logic_1"><strong>all</strong> of selected below</label></div>
<div class="line"><label>&nbsp;</label><i>(none selected means any)</i></div>':'')?>
<div class="columns2 w800 ml200 mb50" id="cnt_ess_module">
Loading data, please wait...
</div>
</div>
<script>
function getTopicData() {
if(typeof toLoad !== 'undefined'){
}
else {
toLoad = 0;
}
// topics.
$.ajax ({
method: "POST",
url: API_URL,
data: {
w: 'list_topics'
}
})
.done (function (msg) {
if (msg == '') {
console.log('No response received from API!');
}
else {
$('#cnt_ess_topic').html('');
// if everything is OK
if (msg['status'] == "200") {
msg['data'].forEach(function (item) {
$('#cnt_ess_topic').html( $('#cnt_ess_topic').html() +
'<input type="checkbox" name="topic" value="' + item['id'] + '" id="_ess_topic_' + item['id'] +'"><label for="_ess_topic_' + item['id'] + '">' + item['name'] + '</label><br>');
});
console.log(msg);
toLoad++;
getItemsData();
}
else {
console.log(msg);
}
}
})
.fail (function() {
console.log('No response received from API!');
});
// topics done
}
function getItemsData() {
// items
$.ajax ({
method: "POST",
url: API_URL,
data: {
w: 'list_items'
}
})
.done (function (msg) {
if (msg == '') {
console.log('No response received from API!');
}
else {
$('#cnt_ess_item').html('');
// if everything is OK
if (msg['status'] == "200") {
msg['data'].forEach(function (item) {
$('#cnt_ess_item').html( $('#cnt_ess_item').html() +
'<input type="checkbox" name="item" value="' + item['id'] + '" id="_ess_item_' + item['id'] +'"><label for="_ess_item_' + item['id'] + '">' + item['name'] + '</label><br>');
});
console.log(msg);
toLoad++;
getModulesData();
}
else {
console.log(msg);
}
}
})
.fail (function() {
console.log('No response received from API!');
});
// items done
}
function getModulesData() {
// modules
$.ajax ({
method: "POST",
url: API_URL,
data: {
w: 'list_modules'
}
})
.done (function (msg) {
if (msg == '') {
console.log('No response received from API!');
}
else {
$('#cnt_ess_module').html('');
// if everything is OK
if (msg['status'] == "200") {
msg['data'].forEach(function (item) {
$('#cnt_ess_module').html( $('#cnt_ess_module').html() +
'<input type="checkbox" name="module" value="' + item['id'] + '" id="_ess_module_' + item['id'] +'"><label for="_ess_module_' + item['id'] + '">' + item['name'] + '</label><br>');
});
console.log(msg);
toLoad++;
}
else {
console.log(msg);
}
}
})
.fail (function() {
console.log('No response received from API!');
});
}
</script>