feat: add browsable peptide directory with category filtering, REST API, and extended meta fields (v4.3.0)
Adds [peptide_directory] shortcode with card grid, category taxonomy (8 terms), search, pagination, detail modal, and /v1/compounds REST endpoint. Includes 9 new meta fields (half-life, stability, solubility, etc.), admin data tools for migration/re-enrichment, integration hooks for cross-plugin extensibility, dark mode support, and full uninstall cleanup. Refactors AI generator into PSA_OpenRouter + PSA_KB_Builder classes. Adds PHPUnit tests for PostType and Directory classes. Fixes QA findings: dead JS selector, renderError loading state, numeric meta validation, prepared SQL in uninstall. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
621
assets/css/psa-directory.css
Executable file
621
assets/css/psa-directory.css
Executable file
@@ -0,0 +1,621 @@
|
||||
/* ==========================================================================
|
||||
Peptide Directory — Card Grid, Filters, and Detail Modal
|
||||
Namespace: .psa-dir-* (BEM)
|
||||
========================================================================== */
|
||||
|
||||
/* --- CSS Custom Properties for category badge colors (reusable by other plugins) --- */
|
||||
:root {
|
||||
--psa-cat-tissue-repair-bg: #d4edda;
|
||||
--psa-cat-tissue-repair-fg: #155724;
|
||||
--psa-cat-lipid-metabolism-bg: #d1ecf1;
|
||||
--psa-cat-lipid-metabolism-fg: #0c5460;
|
||||
--psa-cat-aging-research-bg: #e2d5f1;
|
||||
--psa-cat-aging-research-fg: #432874;
|
||||
--psa-cat-dermatological-bg: #fce4d6;
|
||||
--psa-cat-dermatological-fg: #7c4a1a;
|
||||
--psa-cat-metabolic-bg: #fff3cd;
|
||||
--psa-cat-metabolic-fg: #856404;
|
||||
--psa-cat-growth-hormone-bg: #cce5ff;
|
||||
--psa-cat-growth-hormone-fg: #004085;
|
||||
--psa-cat-immunology-bg: #f5c6cb;
|
||||
--psa-cat-immunology-fg: #721c24;
|
||||
--psa-cat-endocrine-bg: #c3e6cb;
|
||||
--psa-cat-endocrine-fg: #1b5e20;
|
||||
}
|
||||
|
||||
/* --- Wrapper --- */
|
||||
.psa-dir-wrap {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem 1rem;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
}
|
||||
|
||||
/* --- Header --- */
|
||||
.psa-dir-header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.psa-dir-title {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-subtitle {
|
||||
font-size: 1.05rem;
|
||||
color: #64748b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* --- Search --- */
|
||||
.psa-dir-search-wrap {
|
||||
max-width: 480px;
|
||||
margin: 0 auto 1.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-search {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
font-size: 15px;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.psa-dir-search:focus {
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
|
||||
}
|
||||
|
||||
/* --- Tabs --- */
|
||||
.psa-dir-tabs {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-tab {
|
||||
padding: 8px 20px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.psa-dir-tab:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.psa-dir-tab--active {
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
/* --- Category Filters --- */
|
||||
.psa-dir-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.psa-dir-filter {
|
||||
padding: 6px 16px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.psa-dir-filter:hover {
|
||||
border-color: #2563eb;
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.psa-dir-filter--active {
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
/* --- Grid --- */
|
||||
.psa-dir-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
/* --- Card --- */
|
||||
.psa-dir-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.psa-dir-card:hover {
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
|
||||
}
|
||||
|
||||
.psa-dir-card__header {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.psa-dir-card__title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-card__badge {
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
padding: 2px 10px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.psa-dir-card__meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-bottom: 1rem;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.psa-dir-card__meta-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.psa-dir-card__meta-label {
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.psa-dir-card__meta-value {
|
||||
color: #1e293b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.psa-dir-card__btn {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.psa-dir-card__btn:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
/* --- Category Badge Colors --- */
|
||||
.psa-dir-badge--tissue-repair { background: var(--psa-cat-tissue-repair-bg); color: var(--psa-cat-tissue-repair-fg); }
|
||||
.psa-dir-badge--lipid-metabolism { background: var(--psa-cat-lipid-metabolism-bg); color: var(--psa-cat-lipid-metabolism-fg); }
|
||||
.psa-dir-badge--aging-research { background: var(--psa-cat-aging-research-bg); color: var(--psa-cat-aging-research-fg); }
|
||||
.psa-dir-badge--dermatological { background: var(--psa-cat-dermatological-bg); color: var(--psa-cat-dermatological-fg); }
|
||||
.psa-dir-badge--metabolic { background: var(--psa-cat-metabolic-bg); color: var(--psa-cat-metabolic-fg); }
|
||||
.psa-dir-badge--growth-hormone { background: var(--psa-cat-growth-hormone-bg); color: var(--psa-cat-growth-hormone-fg); }
|
||||
.psa-dir-badge--immunology { background: var(--psa-cat-immunology-bg); color: var(--psa-cat-immunology-fg); }
|
||||
.psa-dir-badge--endocrine { background: var(--psa-cat-endocrine-bg); color: var(--psa-cat-endocrine-fg); }
|
||||
|
||||
/* --- Empty State --- */
|
||||
.psa-dir-empty,
|
||||
.psa-dir-coming-soon {
|
||||
text-align: center;
|
||||
padding: 3rem 1rem;
|
||||
color: #64748b;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* --- Loader --- */
|
||||
.psa-dir-loader {
|
||||
text-align: center;
|
||||
padding: 3rem 1rem;
|
||||
}
|
||||
|
||||
.psa-dir-loader p {
|
||||
color: #64748b;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
/* --- Load More --- */
|
||||
.psa-dir-load-more-wrap {
|
||||
text-align: center;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.psa-dir-load-more {
|
||||
padding: 12px 32px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
background: #fff;
|
||||
color: #2563eb;
|
||||
border: 2px solid #2563eb;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.psa-dir-load-more:hover {
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.psa-dir-load-more:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* --- Error --- */
|
||||
.psa-dir-error {
|
||||
text-align: center;
|
||||
color: #991b1b;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Detail Modal
|
||||
========================================================================== */
|
||||
|
||||
.psa-dir-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 99999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.psa-dir-modal__backdrop {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.psa-dir-modal__content {
|
||||
position: relative;
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
max-width: 700px;
|
||||
width: 90%;
|
||||
max-height: 85vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.psa-dir-modal__close {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 16px;
|
||||
font-size: 28px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: #94a3b8;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.psa-dir-modal__close:hover {
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.psa-dir-modal__title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin: 0 0 0.5rem;
|
||||
padding-right: 2rem;
|
||||
}
|
||||
|
||||
.psa-dir-modal__badges {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.psa-dir-modal__desc {
|
||||
font-size: 15px;
|
||||
line-height: 1.65;
|
||||
color: #475569;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
/* --- Sequence --- */
|
||||
.psa-dir-modal__sequence-wrap {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
background: #f1f5f9;
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.psa-dir-modal__sequence {
|
||||
font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
|
||||
font-size: 13px;
|
||||
word-break: break-all;
|
||||
flex: 1;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.psa-dir-modal__copy {
|
||||
padding: 4px 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.psa-dir-modal__copy:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
/* --- Data Grid --- */
|
||||
.psa-dir-modal__data-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 12px;
|
||||
margin-bottom: 1.5rem;
|
||||
padding: 1rem;
|
||||
background: #f8fafc;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.psa-dir-modal__data-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.psa-dir-modal__data-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.psa-dir-modal__data-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
/* --- Modal Sections --- */
|
||||
.psa-dir-modal__section {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-modal__section h4 {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin: 0 0 0.5rem;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 2px solid #2563eb;
|
||||
}
|
||||
|
||||
.psa-dir-modal__section p {
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: #475569;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
/* --- PubChem Link --- */
|
||||
.psa-dir-modal__pubchem {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
color: #2563eb;
|
||||
text-decoration: none;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.psa-dir-modal__pubchem:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* --- Full Page Link --- */
|
||||
.psa-dir-modal__full-link {
|
||||
display: inline-block;
|
||||
padding: 10px 24px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
background: #f1f5f9;
|
||||
color: #2563eb;
|
||||
text-decoration: none;
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.psa-dir-modal__full-link:hover {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Responsive
|
||||
========================================================================== */
|
||||
|
||||
/* Tablet: 2 columns */
|
||||
@media (max-width: 900px) {
|
||||
.psa-dir-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile: 1 column */
|
||||
@media (max-width: 600px) {
|
||||
.psa-dir-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.psa-dir-title {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.psa-dir-modal__content {
|
||||
width: 95%;
|
||||
padding: 1.25rem;
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
.psa-dir-modal__data-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.psa-dir-filters {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.psa-dir-filter {
|
||||
font-size: 12px;
|
||||
padding: 5px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Dark Mode Support
|
||||
Uses the theme's data-theme="dark" attribute and CSS custom properties.
|
||||
========================================================================== */
|
||||
|
||||
[data-theme="dark"] .psa-dir-wrap {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-title {
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-subtitle {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-search {
|
||||
background: #1e293b;
|
||||
border-color: #334155;
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-tab {
|
||||
background: #1e293b;
|
||||
border-color: #334155;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-tab--active {
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-filter {
|
||||
background: #1e293b;
|
||||
border-color: #334155;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-filter--active {
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-card {
|
||||
background: #1e293b;
|
||||
border-color: #334155;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-card__title {
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-card__meta-label {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-card__meta-value {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__content {
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__title {
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__desc {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__data-grid {
|
||||
background: #1e293b;
|
||||
border-color: #334155;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__data-label {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__data-value {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__sequence-wrap {
|
||||
background: #1e293b;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__sequence {
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__close {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .psa-dir-modal__close:hover {
|
||||
color: #f1f5f9;
|
||||
}
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
function showError(msg) {
|
||||
hideAll();
|
||||
$error.html('<strong>Error:</strong> ' + esc(msg)).show();
|
||||
$error.html('<strong>' + esc(psaAjax.i18n.error) + '</strong> ' + esc(msg)).show();
|
||||
$error.attr('role', 'alert');
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@
|
||||
|
||||
function sourceBadge(source) {
|
||||
var map = {
|
||||
'pubchem': { label: 'Verified', cls: 'psa-badge-verified' },
|
||||
'manual': { label: 'Curated', cls: 'psa-badge-manual' }
|
||||
'pubchem': { label: psaAjax.i18n.verified, cls: 'psa-badge-verified' },
|
||||
'manual': { label: psaAjax.i18n.curated, cls: 'psa-badge-manual' }
|
||||
};
|
||||
var b = map[source];
|
||||
if (!b) return '';
|
||||
return '<span class="psa-result-badge ' + b.cls + '">' + b.label + '</span>';
|
||||
return '<span class="psa-result-badge ' + b.cls + '">' + esc(b.label) + '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,8 +72,7 @@
|
||||
function renderResults(data) {
|
||||
hideAll();
|
||||
|
||||
var html = '<p class="psa-result-count">' + data.total + ' peptide' +
|
||||
(data.total !== 1 ? 's' : '') + ' found</p>';
|
||||
var html = '<p class="psa-result-count">' + data.total + ' ' + esc(psaAjax.i18n.peptidesFound) + '</p>';
|
||||
|
||||
data.results.forEach(function (item) {
|
||||
html += '<a href="' + esc(item.url) + '" class="psa-result-item">';
|
||||
@@ -100,7 +99,7 @@
|
||||
function showPending(name) {
|
||||
hideAll();
|
||||
$pending.find('.psa-pending-inner p').html(
|
||||
'<strong>' + esc(name) + '</strong> is currently being added to our database. Please check back again later.'
|
||||
'<strong>' + esc(name) + '</strong> ' + esc(psaAjax.i18n.pendingMsg)
|
||||
);
|
||||
$pending.show();
|
||||
}
|
||||
@@ -111,7 +110,7 @@
|
||||
function showInvalid(name, reason) {
|
||||
hideAll();
|
||||
$invalid.find('.psa-invalid-text').html(
|
||||
'<strong>' + esc(name) + '</strong> does not appear to be a recognized peptide. Please check the spelling or try a different search term.'
|
||||
'<strong>' + esc(name) + '</strong> ' + esc(psaAjax.i18n.invalidMsg)
|
||||
);
|
||||
$invalid.show();
|
||||
}
|
||||
@@ -144,7 +143,7 @@
|
||||
success: function (response) {
|
||||
$results.attr('aria-busy', 'false');
|
||||
if (!response.success) {
|
||||
showError(response.data || 'Search failed.');
|
||||
showError(response.data || psaAjax.i18n.searchFailed);
|
||||
return;
|
||||
}
|
||||
var d = response.data;
|
||||
@@ -159,24 +158,24 @@
|
||||
showInvalid(query, d.message);
|
||||
break;
|
||||
case 'rate_limited':
|
||||
showError(d.message || 'Too many requests. Please try again later.');
|
||||
showError(d.message || psaAjax.i18n.rateLimited);
|
||||
break;
|
||||
default:
|
||||
showError('Unexpected response.');
|
||||
showError(psaAjax.i18n.unexpected);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
error: function (jqXHR, textStatus) {
|
||||
$results.attr('aria-busy', 'false');
|
||||
var errorMsg = 'Could not connect to the server. Please try again.';
|
||||
var errorMsg = psaAjax.i18n.networkError;
|
||||
if (textStatus === 'timeout') {
|
||||
errorMsg = 'Request timed out. The server took too long to respond. Please try again.';
|
||||
errorMsg = psaAjax.i18n.timeout;
|
||||
} else if (textStatus === 'error') {
|
||||
if (jqXHR.status === 0) {
|
||||
errorMsg = 'Network error. Please check your connection and try again.';
|
||||
errorMsg = psaAjax.i18n.connectionError;
|
||||
} else if (jqXHR.status === 500) {
|
||||
errorMsg = 'Server error. Please try again later.';
|
||||
errorMsg = psaAjax.i18n.serverError;
|
||||
} else if (jqXHR.status === 503) {
|
||||
errorMsg = 'Server is temporarily unavailable. Please try again later.';
|
||||
errorMsg = psaAjax.i18n.unavailable;
|
||||
}
|
||||
}
|
||||
showError(errorMsg);
|
||||
|
||||
501
assets/js/psa-directory.js
Executable file
501
assets/js/psa-directory.js
Executable file
@@ -0,0 +1,501 @@
|
||||
/**
|
||||
* Peptide Directory — Frontend JavaScript
|
||||
*
|
||||
* Renders the browsable directory grid with category filters, search,
|
||||
* pagination, and detail modal. Uses vanilla JS (no build step required).
|
||||
*
|
||||
* Data source: REST API at /wp-json/peptide-search-ai/v1/compounds
|
||||
* Config: psaDirectory global (localized from class-psa-directory.php)
|
||||
*
|
||||
* @see includes/class-psa-directory.php — shortcode + REST endpoint
|
||||
* @see assets/css/psa-directory.css — all .psa-dir-* styles
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var config = window.psaDirectory;
|
||||
if (!config) return;
|
||||
|
||||
var root = document.getElementById('psa-directory-root');
|
||||
if (!root) return;
|
||||
|
||||
var state = {
|
||||
compounds: [],
|
||||
page: 1,
|
||||
totalPages: 0,
|
||||
total: 0,
|
||||
category: '',
|
||||
search: '',
|
||||
loading: false,
|
||||
activeTab: 'single',
|
||||
modalData: null
|
||||
};
|
||||
|
||||
var i18n = config.i18n;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Utility
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
var d = document.createElement('div');
|
||||
d.appendChild(document.createTextNode(str));
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
function debounce(fn, delay) {
|
||||
var timer;
|
||||
return function () {
|
||||
var args = arguments, ctx = this;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function () { fn.apply(ctx, args); }, delay);
|
||||
};
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function fetchCompounds(append) {
|
||||
if (state.loading) return;
|
||||
state.loading = true;
|
||||
updateLoadMoreBtn();
|
||||
|
||||
var url = config.restUrl +
|
||||
'?page=' + state.page +
|
||||
'&per_page=' + config.perPage;
|
||||
|
||||
if (state.search) url += '&search=' + encodeURIComponent(state.search);
|
||||
if (state.category) url += '&category=' + encodeURIComponent(state.category);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.setRequestHeader('X-WP-Nonce', config.nonce);
|
||||
xhr.onload = function () {
|
||||
state.loading = false;
|
||||
if (xhr.status === 200) {
|
||||
var data = JSON.parse(xhr.responseText);
|
||||
if (append) {
|
||||
state.compounds = state.compounds.concat(data.compounds);
|
||||
} else {
|
||||
state.compounds = data.compounds;
|
||||
}
|
||||
state.total = data.total;
|
||||
state.totalPages = data.total_pages;
|
||||
renderGrid();
|
||||
} else {
|
||||
renderError();
|
||||
}
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
state.loading = false;
|
||||
renderError();
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function fetchCompoundDetail(id, callback) {
|
||||
var url = config.restUrl + '?search=&per_page=1&page=1&fields=full';
|
||||
/* Find by iterating existing data first to avoid extra API call. */
|
||||
var existing = null;
|
||||
for (var i = 0; i < state.compounds.length; i++) {
|
||||
if (state.compounds[i].id === id) {
|
||||
existing = state.compounds[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (existing && existing.sequence !== undefined) {
|
||||
callback(existing);
|
||||
return;
|
||||
}
|
||||
/* Fallback: fetch from API (shouldn't normally be needed for full fields). */
|
||||
callback(existing);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Render — Shell
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function renderShell() {
|
||||
root.innerHTML =
|
||||
'<div class="psa-dir-header">' +
|
||||
'<h2 class="psa-dir-title">' + esc(i18n.title) + '</h2>' +
|
||||
'<p class="psa-dir-subtitle">' + esc(i18n.subtitle) + '</p>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-search-wrap">' +
|
||||
'<input type="text" class="psa-dir-search" placeholder="' + esc(i18n.searchPlaceholder) + '" aria-label="' + esc(i18n.searchPlaceholder) + '" />' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-tabs" role="tablist">' +
|
||||
'<button class="psa-dir-tab psa-dir-tab--active" data-tab="single" role="tab" aria-selected="true">' + esc(i18n.singleReagents) + '</button>' +
|
||||
'<button class="psa-dir-tab" data-tab="protocols" role="tab" aria-selected="false">' + esc(i18n.protocolModels) + '</button>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-filters" role="group" aria-label="Category filter"></div>' +
|
||||
'<div class="psa-dir-content">' +
|
||||
'<div class="psa-dir-grid" role="list"></div>' +
|
||||
'<div class="psa-dir-coming-soon" style="display:none;">' +
|
||||
'<p>' + esc(i18n.comingSoon) + '</p>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-empty" style="display:none;">' +
|
||||
'<p>' + esc(i18n.noResults) + '</p>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-loader" style="display:none;">' +
|
||||
'<div class="psa-spinner"></div>' +
|
||||
'<p>' + esc(i18n.loading) + '</p>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-load-more-wrap" style="display:none;">' +
|
||||
'<button class="psa-dir-load-more">' + esc(i18n.loadMore) + '</button>' +
|
||||
'</div>' +
|
||||
'<div class="psa-dir-modal" role="dialog" aria-modal="true" aria-label="Peptide details" style="display:none;">' +
|
||||
'<div class="psa-dir-modal__backdrop"></div>' +
|
||||
'<div class="psa-dir-modal__content" tabindex="-1"></div>' +
|
||||
'</div>';
|
||||
|
||||
renderFilters();
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Render — Filters
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function renderFilters() {
|
||||
var wrap = root.querySelector('.psa-dir-filters');
|
||||
var html = '<button class="psa-dir-filter psa-dir-filter--active" data-category="">' + esc(i18n.showAll) + '</button>';
|
||||
config.categories.forEach(function (cat) {
|
||||
html += '<button class="psa-dir-filter" data-category="' + esc(cat.slug) + '">' + esc(cat.name) + '</button>';
|
||||
});
|
||||
wrap.innerHTML = html;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Render — Grid
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function renderGrid() {
|
||||
var grid = root.querySelector('.psa-dir-grid');
|
||||
var empty = root.querySelector('.psa-dir-empty');
|
||||
var loader = root.querySelector('.psa-dir-loader');
|
||||
var coming = root.querySelector('.psa-dir-coming-soon');
|
||||
|
||||
loader.style.display = 'none';
|
||||
coming.style.display = 'none';
|
||||
|
||||
if (state.activeTab === 'protocols') {
|
||||
grid.style.display = 'none';
|
||||
empty.style.display = 'none';
|
||||
coming.style.display = 'block';
|
||||
updateLoadMoreBtn();
|
||||
return;
|
||||
}
|
||||
|
||||
grid.style.display = '';
|
||||
|
||||
if (state.compounds.length === 0 && !state.loading) {
|
||||
empty.style.display = 'block';
|
||||
grid.innerHTML = '';
|
||||
updateLoadMoreBtn();
|
||||
return;
|
||||
}
|
||||
|
||||
empty.style.display = 'none';
|
||||
|
||||
var html = '';
|
||||
state.compounds.forEach(function (c) {
|
||||
var catBadge = '';
|
||||
if (c.categories && c.categories.length > 0) {
|
||||
catBadge = '<span class="psa-dir-card__badge psa-dir-badge--' + esc(c.categories[0].slug) + '">' + esc(c.categories[0].name) + '</span>';
|
||||
}
|
||||
|
||||
var metaHtml = '';
|
||||
if (c.half_life) {
|
||||
metaHtml += '<div class="psa-dir-card__meta-item"><span class="psa-dir-card__meta-label">' + esc(i18n.halfLife) + '</span><span class="psa-dir-card__meta-value">' + esc(c.half_life) + '</span></div>';
|
||||
}
|
||||
if (c.stability) {
|
||||
metaHtml += '<div class="psa-dir-card__meta-item"><span class="psa-dir-card__meta-label">' + esc(i18n.stability) + '</span><span class="psa-dir-card__meta-value">' + esc(c.stability) + '</span></div>';
|
||||
}
|
||||
|
||||
var extrasHtml = c.extras ? c.extras : '';
|
||||
|
||||
html += '<div class="psa-dir-card" role="listitem" data-id="' + c.id + '">' +
|
||||
'<div class="psa-dir-card__header">' +
|
||||
'<h3 class="psa-dir-card__title">' + esc(c.name) + '</h3>' +
|
||||
catBadge +
|
||||
'</div>' +
|
||||
(metaHtml ? '<div class="psa-dir-card__meta">' + metaHtml + '</div>' : '') +
|
||||
extrasHtml +
|
||||
'<button class="psa-dir-card__btn" data-id="' + c.id + '">' + esc(i18n.viewDetails) + '</button>' +
|
||||
'</div>';
|
||||
});
|
||||
|
||||
grid.innerHTML = html;
|
||||
updateLoadMoreBtn();
|
||||
}
|
||||
|
||||
function updateLoadMoreBtn() {
|
||||
var wrap = root.querySelector('.psa-dir-load-more-wrap');
|
||||
var btn = root.querySelector('.psa-dir-load-more');
|
||||
|
||||
if (state.activeTab === 'protocols' || state.page >= state.totalPages || state.compounds.length === 0) {
|
||||
wrap.style.display = 'none';
|
||||
} else {
|
||||
wrap.style.display = 'block';
|
||||
btn.textContent = state.loading ? i18n.loading : i18n.loadMore;
|
||||
btn.disabled = state.loading;
|
||||
}
|
||||
}
|
||||
|
||||
function renderError() {
|
||||
state.loading = false;
|
||||
var grid = root.querySelector('.psa-dir-grid');
|
||||
grid.innerHTML = '<p class="psa-dir-error">Failed to load directory. Please try again.</p>';
|
||||
root.querySelector('.psa-dir-loader').style.display = 'none';
|
||||
updateLoadMoreBtn();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Render — Modal
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function openModal(compound) {
|
||||
state.modalData = compound;
|
||||
var modal = root.querySelector('.psa-dir-modal');
|
||||
var content = root.querySelector('.psa-dir-modal__content');
|
||||
|
||||
var catBadges = '';
|
||||
if (compound.categories) {
|
||||
compound.categories.forEach(function (cat) {
|
||||
catBadges += '<span class="psa-dir-card__badge psa-dir-badge--' + esc(cat.slug) + '">' + esc(cat.name) + '</span> ';
|
||||
});
|
||||
}
|
||||
|
||||
var dataGrid = '';
|
||||
var fields = [
|
||||
{ label: i18n.solubility, value: compound.solubility },
|
||||
{ label: i18n.vialSize, value: compound.vial_size_mg ? compound.vial_size_mg + ' mg' : '' },
|
||||
{ label: i18n.storageLyo, value: compound.storage_lyophilized },
|
||||
{ label: i18n.storageRecon, value: compound.storage_reconstituted },
|
||||
{ label: i18n.halfLife, value: compound.half_life },
|
||||
{ label: i18n.stability, value: compound.stability },
|
||||
{ label: i18n.molecularWeight, value: compound.molecular_weight },
|
||||
{ label: i18n.formula, value: compound.molecular_formula }
|
||||
];
|
||||
fields.forEach(function (f) {
|
||||
if (f.value) {
|
||||
dataGrid += '<div class="psa-dir-modal__data-item">' +
|
||||
'<span class="psa-dir-modal__data-label">' + esc(f.label) + '</span>' +
|
||||
'<span class="psa-dir-modal__data-value">' + esc(f.value) + '</span>' +
|
||||
'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
var researchHtml = '';
|
||||
if (compound.typical_dose_mcg || compound.cycle_parameters) {
|
||||
researchHtml = '<div class="psa-dir-modal__section">' +
|
||||
'<h4>' + esc(i18n.researchParams) + '</h4>';
|
||||
if (compound.typical_dose_mcg) {
|
||||
researchHtml += '<p><strong>' + esc(i18n.typicalDose) + ':</strong> ' + esc(compound.typical_dose_mcg) + '</p>';
|
||||
}
|
||||
if (compound.cycle_parameters) {
|
||||
researchHtml += '<p><strong>' + esc(i18n.cycleParams) + ':</strong> ' + esc(compound.cycle_parameters) + '</p>';
|
||||
}
|
||||
researchHtml += '</div>';
|
||||
}
|
||||
|
||||
var pubchemHtml = '';
|
||||
if (compound.pubchem_cid) {
|
||||
pubchemHtml = '<a class="psa-dir-modal__pubchem" href="https://pubchem.ncbi.nlm.nih.gov/compound/' + parseInt(compound.pubchem_cid, 10) + '" target="_blank" rel="noopener">' + esc(i18n.pubchemLink) + '</a>';
|
||||
}
|
||||
|
||||
var sequenceHtml = '';
|
||||
if (compound.sequence) {
|
||||
sequenceHtml = '<div class="psa-dir-modal__section">' +
|
||||
'<h4>' + esc(i18n.sequence) + '</h4>' +
|
||||
'<div class="psa-dir-modal__sequence-wrap">' +
|
||||
'<code class="psa-dir-modal__sequence">' + esc(compound.sequence) + '</code>' +
|
||||
'<button class="psa-dir-modal__copy" data-seq="' + esc(compound.sequence) + '">' + esc(i18n.copySequence) + '</button>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
var mechanismHtml = '';
|
||||
if (compound.mechanism) {
|
||||
mechanismHtml = '<div class="psa-dir-modal__section">' +
|
||||
'<h4>Mechanism of Action</h4>' +
|
||||
'<p>' + esc(compound.mechanism).replace(/\n\n/g, '</p><p>').replace(/\n/g, '<br>') + '</p>' + // Safe: esc() HTML-encodes all user content before structural tags are inserted.
|
||||
|
||||
'</div>';
|
||||
}
|
||||
|
||||
content.innerHTML =
|
||||
'<button class="psa-dir-modal__close" aria-label="' + esc(i18n.close) + '">×</button>' +
|
||||
'<h2 class="psa-dir-modal__title">' + esc(compound.name) + '</h2>' +
|
||||
'<div class="psa-dir-modal__badges">' + catBadges + '</div>' +
|
||||
(compound.description ? '<p class="psa-dir-modal__desc">' + esc(compound.description) + '</p>' : '') +
|
||||
sequenceHtml +
|
||||
(dataGrid ? '<div class="psa-dir-modal__data-grid">' + dataGrid + '</div>' : '') +
|
||||
researchHtml +
|
||||
mechanismHtml +
|
||||
pubchemHtml +
|
||||
'<a class="psa-dir-modal__full-link" href="' + esc(compound.url) + '">' + esc(i18n.viewFullPage) + '</a>';
|
||||
|
||||
modal.style.display = 'flex';
|
||||
content.focus();
|
||||
|
||||
// Update URL hash for direct linking.
|
||||
if (compound.slug) {
|
||||
history.replaceState(null, '', '#' + compound.slug);
|
||||
}
|
||||
|
||||
// Fire integration hook for Peptide Community.
|
||||
document.dispatchEvent(new CustomEvent('psa_after_peptide_detail', {
|
||||
detail: { postId: compound.id }
|
||||
}));
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
var modal = root.querySelector('.psa-dir-modal');
|
||||
modal.style.display = 'none';
|
||||
state.modalData = null;
|
||||
history.replaceState(null, '', window.location.pathname + window.location.search);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Events
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function bindEvents() {
|
||||
// Search input.
|
||||
var searchInput = root.querySelector('.psa-dir-search');
|
||||
var debouncedSearch = debounce(function () {
|
||||
state.search = searchInput.value.trim();
|
||||
state.page = 1;
|
||||
showLoader();
|
||||
fetchCompounds(false);
|
||||
}, 400);
|
||||
searchInput.addEventListener('input', debouncedSearch);
|
||||
|
||||
// Category filter buttons.
|
||||
root.querySelector('.psa-dir-filters').addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('.psa-dir-filter');
|
||||
if (!btn) return;
|
||||
|
||||
root.querySelectorAll('.psa-dir-filter').forEach(function (b) {
|
||||
b.classList.remove('psa-dir-filter--active');
|
||||
});
|
||||
btn.classList.add('psa-dir-filter--active');
|
||||
|
||||
state.category = btn.getAttribute('data-category');
|
||||
state.page = 1;
|
||||
showLoader();
|
||||
fetchCompounds(false);
|
||||
});
|
||||
|
||||
// Tab buttons.
|
||||
root.querySelector('.psa-dir-tabs').addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('.psa-dir-tab');
|
||||
if (!btn) return;
|
||||
|
||||
root.querySelectorAll('.psa-dir-tab').forEach(function (b) {
|
||||
b.classList.remove('psa-dir-tab--active');
|
||||
b.setAttribute('aria-selected', 'false');
|
||||
});
|
||||
btn.classList.add('psa-dir-tab--active');
|
||||
btn.setAttribute('aria-selected', 'true');
|
||||
|
||||
state.activeTab = btn.getAttribute('data-tab');
|
||||
renderGrid();
|
||||
});
|
||||
|
||||
// Load More button.
|
||||
root.querySelector('.psa-dir-load-more').addEventListener('click', function () {
|
||||
state.page++;
|
||||
fetchCompounds(true);
|
||||
});
|
||||
|
||||
// Card "View Research Details" button — delegate on grid.
|
||||
root.querySelector('.psa-dir-grid').addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('.psa-dir-card__btn');
|
||||
if (!btn) return;
|
||||
var id = parseInt(btn.getAttribute('data-id'), 10);
|
||||
fetchCompoundDetail(id, function (compound) {
|
||||
if (compound) openModal(compound);
|
||||
});
|
||||
});
|
||||
|
||||
// Modal close: X button, backdrop click, Escape key.
|
||||
root.querySelector('.psa-dir-modal').addEventListener('click', function (e) {
|
||||
if (e.target.classList.contains('psa-dir-modal__backdrop') || e.target.classList.contains('psa-dir-modal__close')) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape' && state.modalData) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
// Copy sequence button.
|
||||
root.addEventListener('click', function (e) {
|
||||
var copyBtn = e.target.closest('.psa-dir-modal__copy');
|
||||
if (!copyBtn) return;
|
||||
var seq = copyBtn.getAttribute('data-seq');
|
||||
navigator.clipboard.writeText(seq).then(function () {
|
||||
copyBtn.textContent = i18n.copied;
|
||||
setTimeout(function () { copyBtn.textContent = i18n.copySequence; }, 2000);
|
||||
});
|
||||
});
|
||||
|
||||
// Check URL hash on load for direct modal linking.
|
||||
checkUrlHash();
|
||||
}
|
||||
|
||||
function showLoader() {
|
||||
var grid = root.querySelector('.psa-dir-grid');
|
||||
var loader = root.querySelector('.psa-dir-loader');
|
||||
var empty = root.querySelector('.psa-dir-empty');
|
||||
grid.innerHTML = '';
|
||||
empty.style.display = 'none';
|
||||
loader.style.display = 'block';
|
||||
}
|
||||
|
||||
/**
|
||||
* If URL has a hash like #bpc-157, find the matching compound and open modal.
|
||||
*/
|
||||
function checkUrlHash() {
|
||||
var hash = window.location.hash.replace('#', '');
|
||||
if (!hash) return;
|
||||
/* Wait for initial load, then look for matching slug. */
|
||||
var checkInterval = setInterval(function () {
|
||||
if (state.loading) return;
|
||||
clearInterval(checkInterval);
|
||||
for (var i = 0; i < state.compounds.length; i++) {
|
||||
if (state.compounds[i].slug === hash) {
|
||||
openModal(state.compounds[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
/* Safety: stop checking after 5 seconds. */
|
||||
setTimeout(function () { clearInterval(checkInterval); }, 5000);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Init
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
renderShell();
|
||||
showLoader();
|
||||
fetchCompounds(false);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user