diff --git a/main.css b/main.css index 97394d6..21abd56 100644 --- a/main.css +++ b/main.css @@ -1,401 +1,401 @@ html, body { font-family: 'Varela Round', monospace; background: url('canvas.png'), #121212; background-size: cover; /*animation: delaybg 1s;*/ } /* @keyframes delaybg { 0%, 99% { background: #121212; height: 100%; overflow: hidden;} 100% { background: url('canvas5.5.png'), #121212; height: auto; overflow: auto; } } #cover { animation: fadein ease 1.5s; animation-iteration-count: 1; animation-fill-mode: forwards; } @keyframes fadein { from { opacity: 0; } to { : 1; } } */ /*needed for background image since theres a margin-right: -15px for some reason*/ .row { margin: auto !important; } .nav-link { color: #dd7; } .nav-link:hover { color: #aa4; } #cover { top: -10%; mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 94%, rgba(0, 0, 0, 0)); -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 94%, rgba(0, 0, 0, 0)); background: #121212; /*to be overriden*/ background-size: cover; background-position: center; box-shadow: 100px; height: 110vh !important; } .tooltip { left: 0px; } .tooltip-inner { background-color: #121212; font-family: 'Varela Round', monospace; } .arrow::before { border-bottom-color:#121212 !important; border-top-color:#121212 !important; } .col { padding-left: 0.25em; padding-right: 0.25em; } #cover #mainline { margin-top: -2.5em; } #mainline { font-weight: bold; font-size: 1.25em; } #links { padding-top: 2.5vh; } #links img { max-width: 50px; width:100%; } .skills .card, #mainskill{ background-color: rgba(40, 40, 40, 0.7); box-shadow: 4px 4px 15px rgba(30, 30, 30, 0.8); border-radius: 8px; } .skills .card-body, #mainskill .card-body { font-size: 0.8rem; } #mainskill { min-width:25%; max-width:50%; } footer { background-color: rgba(10, 10, 10, 0.6); } .nav-link.inline { /*reset for footer*/ display: inline; padding: 0; } footer, .smaller { font-size: 0.75em; } .project { font-weight: bold; } .info-segment .large-content span { margin-left: 2em; } .splitview { margin-right: 0px !important; margin-left: 0px !important; } .info-segment .headings { color: #dd7; padding: .5rem 1rem; } .modal-content { background: rgba(30, 30, 30, 0.8); } /* * timeline styling */ /*assumes timeline-content has 2 columns, 1 .timeline and 1 content column thats it*/ /*anchor also needs to be flex or else the anchor node gets misaligned*/ .timeline-content, .timeline-anchor { display: flex; } .timeline { display: inline-block; max-width: 1em; height: auto; background: rgba(80, 80, 80, 0.5); margin: 3em; border-radius: 1em; /*patch for terminating the timeline at the nodes; assume p-5 divider exists at topmost and bottommost, and 2em of margin on both sides of the last element*/ margin-top: 15em; margin-bottom: 15em; } /*all elements in the non timeline column that specifies it is an anchor*/ .timeline-anchor::before { /*set up .fa for this pseudo element*/ font-size: 2em; font-family: var(--fa-style-family-classic); font-weight: 900; /*node style on timeline*/ content: "\f192"; color: rgba(200, 200, 200, 0.8); /*apparently flexbox centers content in pseudo elements*/ display:flex; flex-direction:row; align-items: center; /*move the pseudoelement onto the timeline*/ position: relative; left: -1.375em; /*.timeline margin (3em) + .col margin on timeline (0.25em) - half of this width (0.5em), scaled by 2em*/ margin-left: -1em; /*remove the size of this element in parent*/ width: 1em; } /*special types with ctf-info still in it*/ .timeline-organized::before { content: "\f005" !important; left: -1.475em !important; /*seems like certain fonts have a different width than the normal node*/ } /*big special types*/ .timeline-year::before { content: "\f79f" !important; left: -1.475em; } .timeline-year > * { font-size: 2.5em !important; padding: 1.5em !important; padding-left: 0.5em !important; } /*smaller special types*/ .timeline-join > *, .timeline-announce > *, .timeline-hiatus > * { font-size: 1.5em; padding: 0.5em !important; } .timeline-join::before { content: "\f2f6" !important; } .timeline-announce::before { content: "\f0a1" !important; } .timeline-hiatus::before { content: "\f186" !important; - left: -1.275em !important; + left: -1.275em; } /* * collapsable table styling */ .ctf-info { position: relative; width: 100%; background: rgba(30, 30, 30, 0.4); border-radius: 1em; margin-top: 2em !important; margin-bottom: 2em !important; } .ctf-info > .btn-group { /*header*/ width: 100%; height: 100%; background: rgba(60, 60, 60, 0.4); border-radius: 1em; } .ctf-info .ctf-table { width: 100%; /*if we set height here the collapse animation dies, and padding makes the animation choppy*/ } .ctf-info .table-responsive { padding: 0.7em; padding-bottom: 0em; } .ctf-info .table { background: none; width: 100%; } .ctf-table th, .ctf-table td, .ctf-table .table-dark tbody+tbody { border-top: none; } .ctf-title { font-size: 2em; display: inline-block; padding-top: 1.3em; padding-left: 1.3em; } .ctf-metadata { position: absolute; top: 0; padding: 0.7em; } .ctf-details { position: absolute; display: flex; justify-content: center; align-items: center; right: 0; height: 100%; padding-right: 3em; font-size: 1.5em; } .ctf-details > *:not(sup) { padding: 0.2em; } /*android webview still uses webkit prefix for transform even though not for keyframes*/ .ctf-info.show .btn::after { -webkit-transform: rotate(-180deg); transform:rotate(-180deg); } /*both ways should have a transition*/ .ctf-info .btn::after { transition: transform 500ms ease; scale: 1.5; } /*for modelling a less obvious separator*/ .big-sep { display: inline-block; vertical-align: middle; } .big-sep::before { content: '/'; font-size: 180%; color: rgba(80, 80, 80, 0.5); text-align: center; } .emojione { width: 1em; height: 1em; } .text-first { color: #FFD700; text-shadow: 0 0 0.4em #FFD700; } .text-second { color: #C0C0C0; text-shadow: 0 0 0.4em #FFF; } .text-third { color: #CD7F32; text-shadow: 0 0 0.4em #CD7F32; } @media (max-width: 767px) { /*fixes stretching in safari*/ .splitview img { width: 100% !important; height: 100% !important; } .skills { width: 100%; font-size: 0.75rem; } .skills .card-body { display: none; } .headings { font-size: 1.25rem; } .large-content { font-size: 0.75em; width: 100%; } .ctf-metadata { font-size: 0.5em; padding-left: 0; } .ctf-info { font-size: 0.3em; } .ctf-info .headings { font-size: inherit; } /*disable scaling for ctf info*/ .ctf-info .headings, .ctf-info .nav-link { padding: 0; } .ctf-title { font-size: 1em; padding-left: 0; max-width: 60%; overflow: auto; } .timeline { max-width: 0.25em; margin: 0.55em; margin-top: 7em; } .timeline-content .pr-5 { padding-right: 1em !important; } .timeline-content:not(.timeline) .timeline-anchor::before { font-size: 3em; left: -0.625em; } .timeline-organized::before { left: -0.675em !important; } .timeline-content .divider.timeline-anchor { font-size: 0.5em; } .timeline-content .divider.timeline-anchor::before { font-size: 2em; } /*fix safari link not wrapping*/ a { overflow-wrap: break-word; } .splitview { width: 100%; text-align: center !important; padding: 2rem !important;} .p-5-flex { padding: 2rem !important; } /*patch back padding since p-5 is too much*/ } @media (min-width: 768px) and (max-width: 1200px) { .ctf-metadata { font-size: 0.5em; padding-left: 0; } .ctf-info { font-size: 0.5em; } .ctf-info .headings { font-size: inherit; } /*disable scaling for ctf info*/ .ctf-info .headings, .ctf-info .nav-link { padding: 0; } .ctf-title { font-size: 1em; padding-left: 0; max-width: 60%; overflow: auto; } .ctf-info .timeline-anchor::before { font-size: 2em; } .timeline { max-width: 0.25em; margin-right: 1.35em; margin-top: 12.5em; margin-bottom: 12.5em } .timeline-content .divider.timeline-anchor { font-size: 0.5em; } } @media (min-width: 768px) { .headings { font-size: 1.5rem; } .large-content { font-size: 0.75em; width: 75%; } .skills { width: 90%; } .splitview { width: 50%; } .info-subsegment { display: flex; } .p-5-flex { padding: 5rem !important; } .info-segment { padding-left: 2%; padding-right: 2%; } } @media (min-width: 992px) { .headings { font-size: 1.75rem; } .large-content { font-size: 1em; } } @media (min-width: 1200px) { .headings { font-size: 2rem; } .large-content { font-size: 1.25em; } .info-segment { padding-left: 5%; padding-right: 5%; } .skills { width: 70%; } } \ No newline at end of file diff --git a/main.js b/main.js index 7e00a9d..9df38dc 100644 --- a/main.js +++ b/main.js @@ -1,48 +1,62 @@ AOS.init(); //initialize tooltips $('[data-toggle="tooltip"]').tooltip({ offset: '0, 20%' }); $('#discord').bind('click touchend', function() { if (navigator.clipboard.writeText("despawningbone#4078")) { $(this).tooltip('hide'); $('#discord').attr('data-original-title', "(copied!)"); setTimeout(() => $('#discord').attr('data-original-title', "despawningbone#4078"), 400); $(this).tooltip('show'); } }); //relative data-target patch for accordions, and also to add .show back into the button $('body').on('click', '[data-toggle=collapse]', function (e) { var $parent = $(this).parents('.ctf-info'); $parent.find('.ctf-table').collapse('toggle'); $parent.toggleClass('show') }); //ctf diary comment popup dynamically load content -//TODO allow use of url#data-comment to load modal -$('.ctf-table tbody tr').on('click',function(){ +$('.ctf-table tbody tr').on('click', function(){ href = $(this).attr('href'); //if full writeup is available, redirect if(href) { - window.location=href; + window.location = href; } else { //else open comment popup href = $(this).attr('data-comment'); - - //set comment title to chall name - $('#commentTitle').text('Comments - ' + this.firstElementChild.textContent) //only load if attr is found, which means a comment should be found - if(href) { - console.log('ctf/' + href + '.html') - $('.ctf-comment').load('ctf/' + href + '.html', function(res, status, xhr){ + if(href) + window.location.hash = href; //pass to loadComments on hashchange + } +}); + +//dynamically load comments from url +loadComments = function() { + if(window.location.hash) { + challName = window.location.hash.substring(1); + //since we dont know which chall this is we have to search to make the title + chall = $('.ctf-table tbody tr[data-comment="' + challName + '"]'); + //dont run if no valid chall found - non data-comment hashes are not comment links + if(chall.length > 0) { + $('#commentTitle').text('Comments - ' + chall[0].firstElementChild.textContent) + $('.ctf-comment').load('ctf/' + challName + '.html', function(res, status, xhr){ + commentModal = $('#comment'); if(status !== "error") //only show if we can load it, otherwise treat as no comment - $('#comment').modal({show:true}); - }); + commentModal.modal({show:true}); + //reset hash on hide + commentModal.on('hide.bs.modal', () => history.replaceState(null, null, ' ')) + }); } } -}); \ No newline at end of file +} + +$(window).ready(loadComments); +$(window).on('hashchange', loadComments); \ No newline at end of file