Skip to content

Commit

Permalink
chore: Remove unused files and code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmservera committed May 24, 2024
1 parent 4db8c2b commit 6c40936
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 1,206 deletions.
1 change: 1 addition & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_site
File renamed without changes.
133 changes: 1 addition & 132 deletions web/_layouts/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,135 +12,4 @@
<!-- _layouts/page.html -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function hierarchyMenu(steps, changeIndex){
var hierarchy = [$('<ul>')];
var currentLevel = 2;

var headings = $('.page-content h2, .page-content h3');
headings.each(function(i, heading) {
var level = parseInt(heading.tagName.slice(1));
var id = $(heading).attr('id');
var text = $(heading).text();
var link = $('<a>').attr('href', `#${id}`).text(text);

//TODO: manage hashchange at main level
$(window).on('hashchange', function(e){
if(location.hash==`#${id}`){
var step;
if(level==2){
step=$($(heading).parents('.section')[0]).find('.step:first')[0];
}
else{
step=$(heading).parents('.step')[0];
}
let current=steps.index(step);
changeIndex(current);
}
});

var item = $('<li>').append(link);

if (level > currentLevel) {
var newLevel = $('<ul>');
var button = $('<button>').attr('type','button').addClass('collapser').text('+').click(function() {
newLevel.toggle();
button.text(newLevel.is(':visible') ? '-' : '+');
});
hierarchy[hierarchy.length - 1].children().last().append(button);
hierarchy[hierarchy.length - 1].children().last().append(newLevel);
hierarchy.push(newLevel);
} else if (level < currentLevel) {
hierarchy.pop();
}

hierarchy[hierarchy.length - 1].append(item);
currentLevel = level;
});

$('#sidebar-index').append(hierarchy[0]);
$('#sidebar-toggle').click(function() {
$('#sidebar-index').toggleClass('collapsed');
$('#sidebar-index').hasClass('collapsed') ? $(this).text('<') : $(this).text('>');
});
}

function codeCopy(){
$('pre code').each(function() {
var button = $('<button>').attr('type', 'button').attr('title','Copy').addClass('copy-button').text('📋');
$(this).parent().prepend(button);
});

$('.copy-button').click(function() {
let btn = $(this);
var code = $(this).siblings('code').text();
var position = $(this).offset();

navigator.clipboard.writeText(code).then(function() {
btn.text('✅');
setTimeout(()=>btn.text('📋'),1800);
}, function() {
// failure
alert('Failed to copy text');
});
});
}

function tutorial(){
let steps = $('.step');
let currentIndex = 0;

// Show the first section
steps[currentIndex].classList.add('active');
$(steps[currentIndex]).parents('.section')[0].classList.add('active');

let changeIndex= (index)=>{
$(steps[currentIndex]).parents('.section')[0].classList.remove('active');
steps[currentIndex].classList.remove('active');
currentIndex=index;
steps[currentIndex].classList.add('active');
$(steps[currentIndex]).parents('.section')[0].classList.add('active');
if(currentIndex>0){
$('button.prev').removeAttr('disabled');
}
else{
$('button.prev').attr('disabled','disabled');
}
if(currentIndex<steps.length-1){
$('button.next').removeAttr('disabled');
}
else{
$('button.next').attr('disabled','disabled');
}
};

let movePrev=() => {
if (currentIndex > 0) {
changeIndex(currentIndex-1);
}
};
let moveNext= () => {
if (currentIndex < steps.length - 1) {
changeIndex(currentIndex+1);
}
}

$('button.prev').each((i,btn)=>btn.addEventListener('click',movePrev,false));
$('button.next').each((i,btn)=>btn.addEventListener('click',moveNext,false));

changeIndex(0);

hierarchyMenu(steps,changeIndex);
}

$(document).ready(function() {
codeCopy();
tutorial();
//TODO: Fix the issue with the hashchange event
if(location.hash){
let oldLoc=location.href;
window.location=location+"&";
window.location=oldLoc;
}
});
</script>
<script src="{{ "assets/js/custom.js" | relative_url }}"></script>
87 changes: 0 additions & 87 deletions web/_site/404.html

This file was deleted.

27 changes: 0 additions & 27 deletions web/_site/assets/css/custom.css

This file was deleted.

Loading

0 comments on commit 6c40936

Please sign in to comment.