Generated contact page
This commit is contained in:
+72
-17
@@ -1,6 +1,7 @@
|
||||
(function () {
|
||||
var currentArtId = null;
|
||||
var currentImageIdx = null;
|
||||
var currentDocId = null;
|
||||
|
||||
var mainContent = document.getElementById('main-content');
|
||||
var infoOverlay = document.getElementById('info-overlay');
|
||||
@@ -12,6 +13,7 @@
|
||||
var fullscreenImage = document.getElementById('fullscreen-image');
|
||||
var navHome = document.getElementById('nav-home');
|
||||
var navDocs = document.getElementById('nav-docs');
|
||||
var navContact = document.getElementById('nav-contact');
|
||||
var homeLink = document.getElementById('home-link');
|
||||
|
||||
function getArtIndex(id) {
|
||||
@@ -28,6 +30,13 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function getDocBySlug(slug) {
|
||||
for (var i = 0; i < DATA.docFiles.length; i++) {
|
||||
if (DATA.docFiles[i].id === slug) return DATA.docFiles[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatParagraphs(text) {
|
||||
var parts = text.split('\n\n');
|
||||
var result = '';
|
||||
@@ -47,6 +56,11 @@
|
||||
if (currentImageIdx !== null) {
|
||||
params.set('img', currentImageIdx);
|
||||
}
|
||||
} else if (currentDocId) {
|
||||
params.set('view', 'docs');
|
||||
params.set('doc', currentDocId);
|
||||
} else if (mainContent.querySelector('#contact-view')) {
|
||||
params.set('view', 'contact');
|
||||
}
|
||||
var qs = params.toString();
|
||||
var url = qs ? '?' + qs : window.location.pathname;
|
||||
@@ -57,7 +71,8 @@
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
return {
|
||||
view: params.get('view'),
|
||||
img: params.get('img') !== null ? parseInt(params.get('img'), 10) : null
|
||||
img: params.get('img') !== null ? parseInt(params.get('img'), 10) : null,
|
||||
doc: params.get('doc')
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,21 +128,32 @@
|
||||
nextArt.style.display = idx < DATA.arts.length - 1 ? 'block' : 'none';
|
||||
}
|
||||
|
||||
function renderDocsView() {
|
||||
function renderDocsView(docId) {
|
||||
currentDocId = docId || null;
|
||||
|
||||
var html = '<div id="docs-view">' +
|
||||
'<div class="docs-tree">' +
|
||||
'<div class="folder-label">docs/</div><ul>';
|
||||
|
||||
for (var i = 0; i < DATA.docFiles.length; i++) {
|
||||
var doc = DATA.docFiles[i];
|
||||
html += '<li data-file="' + doc.filename.replace(/"/g, '"') + '">' +
|
||||
var activeClass = (doc.id === docId) ? ' active' : '';
|
||||
html += '<li data-doc-id="' + doc.id + '" class="' + activeClass + '">' +
|
||||
doc.filename + '<span class="type-badge">' + (doc.type || '?') + '</span></li>';
|
||||
}
|
||||
|
||||
html += '</ul></div>' +
|
||||
'<div class="docs-content">' +
|
||||
'<pre id="docs-content-pre">Select a file to view</pre>' +
|
||||
'</div></div>';
|
||||
'<pre id="docs-content-pre">';
|
||||
|
||||
if (docId) {
|
||||
var found = getDocBySlug(docId);
|
||||
html += found ? found.raw.replace(/</g, '<').replace(/>/g, '>') : 'File not found';
|
||||
} else {
|
||||
html += 'Select a file to view';
|
||||
}
|
||||
|
||||
html += '</pre></div></div>';
|
||||
|
||||
mainContent.innerHTML = html;
|
||||
|
||||
@@ -139,20 +165,31 @@
|
||||
active[j].classList.remove('active');
|
||||
}
|
||||
this.classList.add('active');
|
||||
var filename = this.dataset.file;
|
||||
for (var k = 0; k < DATA.docFiles.length; k++) {
|
||||
if (DATA.docFiles[k].filename === filename) {
|
||||
document.getElementById('docs-content-pre').textContent = DATA.docFiles[k].raw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var slug = this.dataset.docId;
|
||||
currentDocId = slug;
|
||||
updateUrl();
|
||||
var found = getDocBySlug(slug);
|
||||
document.getElementById('docs-content-pre').textContent = found ? found.raw : 'File not found';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function renderContactView() {
|
||||
var html = '<div id="contact-view">' +
|
||||
'<div class="section-header" style="border-bottom:1px solid #222;padding-bottom:0.5rem;margin-bottom:2rem;color:#666;font-size:0.85rem;">CONTACT</div>' +
|
||||
'<div class="contact-list">' +
|
||||
'<div class="contact-item"><span class="contact-label">email</span><a href="mailto:jonmcc.0723@gmail.com">jonmcc.0723@gmail.com</a></div>' +
|
||||
'<div class="contact-item"><span class="contact-label">linkedIn</span><a href="https://www.linkedin.com/in/jonmcc/" target="_blank" rel="noopener">Jonathan McCaffrey | LinkedIn</a></div>' +
|
||||
'<div class="contact-item"><span class="contact-label">git</span><a href="https://git.jonathanmccaffrey.ca/JonathanMcCaffrey" target="_blank" rel="noopener">Jonathan McCaffrey - Gitea: Git with a cup of tea</a></div>' +
|
||||
'<div class="contact-item"><span class="contact-label">website</span><a href="https://jonathanmccaffrey.ca/" target="_blank" rel="noopener">Ottawa .NET Developer | Jonathan McCaffrey</a></div>' +
|
||||
'</div></div>';
|
||||
mainContent.innerHTML = html;
|
||||
}
|
||||
|
||||
function openInfoOverlay(artId, imgIdx) {
|
||||
currentArtId = artId;
|
||||
currentImageIdx = (imgIdx !== undefined && imgIdx !== null) ? imgIdx : null;
|
||||
currentDocId = null;
|
||||
renderInfoOverlay(artId);
|
||||
infoOverlay.classList.remove('hidden');
|
||||
|
||||
@@ -201,15 +238,25 @@
|
||||
closeInfoOverlay();
|
||||
currentArtId = null;
|
||||
currentImageIdx = null;
|
||||
currentDocId = null;
|
||||
renderMainPage();
|
||||
updateUrl();
|
||||
}
|
||||
|
||||
function goDocs() {
|
||||
function goDocs(docId) {
|
||||
closeInfoOverlay();
|
||||
renderDocsView();
|
||||
currentArtId = null;
|
||||
currentImageIdx = null;
|
||||
renderDocsView(docId || null);
|
||||
updateUrl();
|
||||
}
|
||||
|
||||
function goContact() {
|
||||
closeInfoOverlay();
|
||||
currentArtId = null;
|
||||
currentImageIdx = null;
|
||||
currentDocId = null;
|
||||
renderContactView();
|
||||
updateUrl();
|
||||
}
|
||||
|
||||
@@ -234,9 +281,15 @@
|
||||
goDocs();
|
||||
});
|
||||
|
||||
navContact.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
goContact();
|
||||
});
|
||||
|
||||
homeLink.addEventListener('click', function (e) {
|
||||
if (!infoOverlay.classList.contains('hidden') ||
|
||||
mainContent.querySelector('#docs-view')) {
|
||||
mainContent.querySelector('#docs-view') ||
|
||||
mainContent.querySelector('#contact-view')) {
|
||||
e.preventDefault();
|
||||
goHome();
|
||||
}
|
||||
@@ -261,8 +314,10 @@
|
||||
function init() {
|
||||
var params = parseUrl();
|
||||
|
||||
if (params.view === 'docs') {
|
||||
renderDocsView();
|
||||
if (params.view === 'contact') {
|
||||
renderContactView();
|
||||
} else if (params.view === 'docs') {
|
||||
renderDocsView(params.doc || null);
|
||||
} else if (params.view && getArtById(params.view)) {
|
||||
renderMainPage();
|
||||
openInfoOverlay(params.view, params.img);
|
||||
|
||||
Reference in New Issue
Block a user