Skip to content

Commit

Permalink
feat: remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohansebas committed Nov 25, 2024
1 parent d5ca463 commit 04aa2df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 69 deletions.
1 change: 0 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
{% endif %}

<script data-cfasync="false" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script data-cfasync="false" src="/js/ismobile.js"></script>
<script data-cfasync="false" src="/js/app.js"></script>
<script data-cfasync="false" defer src="/js/menu.js"></script>
<script data-cfasync="false" src="/js/retina.js"></script>
Expand Down
76 changes: 9 additions & 67 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

$(function(){
var doc = $(document);
var lang = document.location.pathname.split('/')[1]

// top link
$('#top').click(function(e){
Expand All @@ -26,34 +25,6 @@ $(function(){
}
})

// edit page link
var latest = '';
var branchPath = 'https://github.com/expressjs/expressjs.com';
var pathName = document.location.pathname;

var currentVersion = (pathName.match(/^(?:\/[a-z]{2})?\/([0-9]x|)/) || [])[1] || '4x'; // defaults to current version
var fileName = pathName.split('/').splice(-2)[1];
var pagePath;
var editPath;

// the api doc cannot be edited individually, we'll have to link to the dir instead
if (fileName == 'api.html') {
editPath = branchPath + '/tree/gh-pages/_includes/api/en/'+ currentVersion;
}
// link to individual doc files
else {
pagePath = pathName.replace(/\.html$/, '.md');
editPath = branchPath + '/blob/gh-pages' + pagePath;
}

var editLink;

if (lang === 'en') {
if (pathName == '/') editLink = '<a href="' + branchPath + '">Fork the website on GitHub</a>.';
else editLink = '<a href="' + editPath + '">Edit this page on GitHub</a>.';
$('#fork').html(editLink);
}

// code highlight

$('code.language-js').each(function(){
Expand All @@ -68,9 +39,6 @@ $(function(){

// menu bar

var prev;
var n = 0;

var headings = $('h2, h3').map(function(i, el){
return {
top: $(el).offset().top - 200,
Expand Down Expand Up @@ -99,50 +67,25 @@ $(function(){
});

$(document).scroll(function() {

var h = closest();
if (!h) return;

currentApiPrefix = h.id.split('.')[0];
parentMenuSelector = '#'+ currentApiPrefix + '-menu';

if (window.location.pathname == '/3x/api.html') {

if (prev) {
prev.removeClass('active');
prev.parent().parent().removeClass('active');
}
var a = $('a[href="#' + h.id + '"]');
a.addClass('active');
a.parent().parent().addClass('active');
prev = a;
$(parentMenuSelector).addClass('active');

if (lastApiPrefix && (lastApiPrefix != currentApiPrefix)) {
$('#'+ lastApiPrefix + '-menu').removeClass('active');
}

else {

currentApiPrefix = h.id.split('.')[0];
parentMenuSelector = '#'+ currentApiPrefix + '-menu';

$(parentMenuSelector).addClass('active');

if (lastApiPrefix && (lastApiPrefix != currentApiPrefix)) {
$('#'+ lastApiPrefix + '-menu').removeClass('active');
}

$('#menu li a').removeClass('active');
$('#menu li a').removeClass('active');

var a = $('a[href="#' + h.id + '"]');
a.addClass('active');

lastApiPrefix = currentApiPrefix.split('.')[0];

}
var a = $('a[href="#' + h.id + '"]');
a.addClass('active');

lastApiPrefix = currentApiPrefix.split('.')[0];
})
$('#tags-side-menu li').on('click', function() {
// Remove prev 'active's
$(this).next().siblings().removeClass('active');
$(this).next().addClass('active')
})

// i18n notice
if (readCookie('i18nClose')) {
Expand All @@ -154,7 +97,6 @@ $(function(){
createCookie('i18nClose', 1);
})
}

})


Expand Down
1 change: 0 additions & 1 deletion js/ismobile.js

This file was deleted.

0 comments on commit 04aa2df

Please sign in to comment.