<div class="ebsco-titles-container" style="background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; margin-top: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 20px;">
<div>
<h3 style="margin: 0; color: #0f172a; font-size: 1.25em;">Subscribed Full-Text Titles (44,435 Titles)</h3>
<p style="margin: 4px 0 0; color: #64748b; font-size: 0.9em;">Individual journal titles, proceedings, and publications available full-text via EBSCOhost at BUET.</p>
</div>
<!-- File download links hidden from public view; visible to authenticated staff only -->
<div id="ebsco-staff-downloads" class="ebsco-file-downloads" style="display: none; gap: 10px; flex-wrap: wrap;">
<a href="/sites/default/files/ebsco_titles/ebsco_titles_44435.csv" class="action-btn" download style="background: #0284c7; color: #fff; padding: 8px 16px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 0.9em; display: inline-flex; align-items: center; gap: 6px;">📥 Download CSV (8.9 MB)</a>
<a href="/sites/default/files/ebsco_titles/ebsco_titles_44435.json" class="action-btn" download style="background: #475569; color: #fff; padding: 8px 16px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 0.9em; display: inline-flex; align-items: center; gap: 6px;">📄 Download JSON (13.7 MB)</a>
</div>
<div id="ebsco-public-download-notice" style="display: block; font-size: 0.85em; color: #64748b; background: #e2e8f0; padding: 6px 12px; border-radius: 6px;">
🔒 Title export files (CSV/JSON) restricted to authorized BUET staff.
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px;">
<input type="text" id="ebsco-q-input" placeholder="Search by Title, ISSN, Publisher, or ID..." style="padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95em; width: 100%; box-sizing: border-box;">
<select id="ebsco-db-select" style="padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95em; width: 100%; background: #fff;">
<option value="">All 9 Subscribed Databases (44,435 Titles)</option>
<option value="Business Source Complete">Business Source Complete (36,129 Titles)</option>
<option value="Academic Search Premier">Academic Search Premier (6,073 Titles)</option>
<option value="MasterFILE Premier">MasterFILE Premier (4,459 Titles)</option>
<option value="Vente et Gestion">Vente et Gestion (545 Titles)</option>
<option value="Health Source: Nursing/Academic Edition">Health Source: Nursing/Academic (291 Titles)</option>
<option value="Health Source: Consumer Edition">Health Source: Consumer Edition (145 Titles)</option>
<option value="Regional Business News">Regional Business News (120 Titles)</option>
<option value="Newspaper Source">Newspaper Source (17 Titles)</option>
<option value="AHFS Consumer Medication Information">AHFS Consumer Medication Information (14 Titles)</option>
</select>
</div>
<div id="ebsco-status-text" style="margin-bottom: 12px; font-weight: 600; color: #334155; font-size: 0.9em;">Loading title list...</div>
<div style="overflow-x: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;">
<table style="width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9em;" id="ebsco-table">
<thead>
<tr style="background: #f1f5f9; color: #334155; border-bottom: 2px solid #cbd5e1;">
<th style="padding: 10px 12px;">ISSN</th>
<th style="padding: 10px 12px;">Publication Title</th>
<th style="padding: 10px 12px;">Publisher</th>
<th style="padding: 10px 12px;">Full-Text Coverage</th>
<th style="padding: 10px 12px;">Database</th>
<th style="padding: 10px 12px;">Access</th>
</tr>
</thead>
<tbody id="ebsco-tbody">
</tbody>
</table>
</div>
<div id="ebsco-pagination" style="display: flex; justify-content: space-between; align-items: center; margin-top: 16px;">
</div>
</div>
<script>
(function() {
var currentPage = 1;
var timer = null;
// Check authenticated status to show file download buttons
function checkStaffAuth() {
var isAuth = document.body.classList.contains('user-logged-in') || (window.drupalSettings && window.drupalSettings.user && window.drupalSettings.user.uid > 0);
var downloadsEl = document.getElementById('ebsco-staff-downloads');
var noticeEl = document.getElementById('ebsco-public-download-notice');
if (isAuth && downloadsEl && noticeEl) {
downloadsEl.style.display = 'flex';
noticeEl.style.display = 'none';
}
}
function loadEbscoTitles(page) {
currentPage = page || 1;
var q = document.getElementById('ebsco-q-input').value.trim();
var db = document.getElementById('ebsco-db-select').value.trim();
var statusEl = document.getElementById('ebsco-status-text');
var tbody = document.getElementById('ebsco-tbody');
var pagEl = document.getElementById('ebsco-pagination');
statusEl.innerHTML = 'Searching...';
var url = '/api/elibrary/ebsco/titles?page=' + currentPage + '&limit=15' +
(q ? '&q=' + encodeURIComponent(q) : '') +
(db ? '&db=' + encodeURIComponent(db) : '');
fetch(url)
.then(function(res) { return res.json(); })
.then(function(data) {
if (!data.ok) {
statusEl.innerHTML = '<span style="color:#e11d48;">' + (data.message || 'Error loading titles.') + '</span>';
return;
}
statusEl.innerHTML = 'Showing <strong>' + data.items.length.toLocaleString() + '</strong> of <strong>' + data.total_matching.toLocaleString() + '</strong> matching titles (Total Subscribed: <strong>' + data.total_unique.toLocaleString() + '</strong>)';
var html = '';
if (data.items.length === 0) {
html = '<tr><td colspan="6" style="padding:20px; text-align:center; color:#64748b;">No matching titles found.</td></tr>';
} else {
data.items.forEach(function(item) {
html += '<tr style="border-bottom:1px solid #f1f5f9;">' +
'<td style="padding:8px 12px; font-family:monospace; color:#475569;">' + (item.issn || '-') + '</td>' +
'<td style="padding:8px 12px;"><strong>' + escapeHtml(item.title) + '</strong></td>' +
'<td style="padding:8px 12px; color:#475569;">' + escapeHtml(item.publisher || '-') + '</td>' +
'<td style="padding:8px 12px; color:#0369a1; font-weight:500;">' + escapeHtml(item.ft_dates || 'Full Text Available') + '</td>' +
'<td style="padding:8px 12px;"><span style="background:#e0f2fe; color:#0369a1; padding:2px 8px; border-radius:12px; font-size:0.85em; font-weight:600;">' + escapeHtml(item.databases.join(', ')) + '</span></td>' +
'<td style="padding:8px 12px;"><a href="' + escapeHtml(item.url || 'https://search.ebscohost.com') + '" target="_blank" rel="noopener" style="background:#0284c7; color:#fff; padding:4px 10px; border-radius:4px; text-decoration:none; font-size:0.85em; font-weight:600;">Open ↗</a></td>' +
'</tr>';
});
}
tbody.innerHTML = html;
// Render Pagination
var pagHtml = '<div>Page ' + data.page + ' of ' + data.pages + '</div><div style="display:flex; gap:8px;">';
if (data.page > 1) {
pagHtml += '<button id="ebsco-prev-btn" style="padding:6px 12px; background:#e2e8f0; border:none; border-radius:4px; cursor:pointer; font-weight:600;">← Previous</button>';
}
if (data.page < data.pages) {
pagHtml += '<button id="ebsco-next-btn" style="padding:6px 12px; background:#0284c7; color:#fff; border:none; border-radius:4px; cursor:pointer; font-weight:600;">Next →</button>';
}
pagHtml += '</div>';
pagEl.innerHTML = pagHtml;
var prevBtn = document.getElementById('ebsco-prev-btn');
if (prevBtn) {
prevBtn.onclick = function() { loadEbscoTitles(currentPage - 1); };
}
var nextBtn = document.getElementById('ebsco-next-btn');
if (nextBtn) {
nextBtn.onclick = function() { loadEbscoTitles(currentPage + 1); };
}
checkStaffAuth();
})
.catch(function(err) {
statusEl.innerHTML = '<span style="color:#e11d48;">Failed to load titles from server.</span>';
});
}
function escapeHtml(str) {
if (!str) return '';
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
document.addEventListener('DOMContentLoaded', function() {
checkStaffAuth();
var qInput = document.getElementById('ebsco-q-input');
var dbSelect = document.getElementById('ebsco-db-select');
if (qInput && dbSelect) {
qInput.addEventListener('input', function() {
clearTimeout(timer);
timer = setTimeout(function() { loadEbscoTitles(1); }, 300);
});
dbSelect.addEventListener('change', function() {
loadEbscoTitles(1);
});
loadEbscoTitles(1);
}
});
if (document.readyState === 'complete' || document.readyState === 'interactive') {
setTimeout(function() {
checkStaffAuth();
var qInput = document.getElementById('ebsco-q-input');
var dbSelect = document.getElementById('ebsco-db-select');
if (qInput && dbSelect && !qInput.dataset.bound) {
qInput.dataset.bound = 'true';
qInput.addEventListener('input', function() {
clearTimeout(timer);
timer = setTimeout(function() { loadEbscoTitles(1); }, 300);
});
dbSelect.addEventListener('change', function() {
loadEbscoTitles(1);
});
loadEbscoTitles(1);
}
}, 100);
}
})();
</script>