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 $('.ctf-table tbody tr').on('click', function(){ href = $(this).attr('href'); //if full writeup is available, redirect if(href) { window.location = href; } else { //else open comment popup href = $(this).attr('data-comment'); //only load if attr is found, which means a comment should be found 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 commentModal.modal({show:true}); //reset hash on hide commentModal.on('hide.bs.modal', () => history.replaceState(null, null, ' ')) }); } } } $(window).ready(loadComments); $(window).on('hashchange', loadComments);