From 04aa2dfc307fea7bfffc309df0d19ffa89b59ac6 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Sun, 24 Nov 2024 19:34:18 -0500 Subject: [PATCH] feat: remove unused functions --- _includes/head.html | 1 - js/app.js | 76 ++++++--------------------------------------- js/ismobile.js | 1 - 3 files changed, 9 insertions(+), 69 deletions(-) delete mode 100644 js/ismobile.js diff --git a/_includes/head.html b/_includes/head.html index 99a3c4d029..6081d3e02a 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -42,7 +42,6 @@ {% endif %} - diff --git a/js/app.js b/js/app.js index 17b086e694..a911964f9b 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,6 @@ $(function(){ var doc = $(document); - var lang = document.location.pathname.split('/')[1] // top link $('#top').click(function(e){ @@ -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 = 'Fork the website on GitHub.'; - else editLink = 'Edit this page on GitHub.'; - $('#fork').html(editLink); - } - // code highlight $('code.language-js').each(function(){ @@ -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, @@ -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')) { @@ -154,7 +97,6 @@ $(function(){ createCookie('i18nClose', 1); }) } - }) diff --git a/js/ismobile.js b/js/ismobile.js deleted file mode 100644 index 3591097497..0000000000 --- a/js/ismobile.js +++ /dev/null @@ -1 +0,0 @@ -!function(a){var b=/iPhone/i,c=/iPod/i,d=/iPad/i,e=/(?=.*\bAndroid\b)(?=.*\bMobile\b)/i,f=/Android/i,g=/(?=.*\bAndroid\b)(?=.*\bSD4930UR\b)/i,h=/(?=.*\bAndroid\b)(?=.*\b(?:KFOT|KFTT|KFJWI|KFJWA|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|KFARWI|KFASWI|KFSAWI|KFSAWA)\b)/i,i=/Windows Phone/i,j=/(?=.*\bWindows\b)(?=.*\bARM\b)/i,k=/BlackBerry/i,l=/BB10/i,m=/Opera Mini/i,n=/(CriOS|Chrome)(?=.*\bMobile\b)/i,o=/(?=.*\bFirefox\b)(?=.*\bMobile\b)/i,p=new RegExp("(?:Nexus 7|BNTV250|Kindle Fire|Silk|GT-P1000)","i"),q=function(a,b){return a.test(b)},r=function(a){var r=a||navigator.userAgent,s=r.split("[FBAN");if("undefined"!=typeof s[1]&&(r=s[0]),s=r.split("Twitter"),"undefined"!=typeof s[1]&&(r=s[0]),this.apple={phone:q(b,r),ipod:q(c,r),tablet:!q(b,r)&&q(d,r),device:q(b,r)||q(c,r)||q(d,r)},this.amazon={phone:q(g,r),tablet:!q(g,r)&&q(h,r),device:q(g,r)||q(h,r)},this.android={phone:q(g,r)||q(e,r),tablet:!q(g,r)&&!q(e,r)&&(q(h,r)||q(f,r)),device:q(g,r)||q(h,r)||q(e,r)||q(f,r)},this.windows={phone:q(i,r),tablet:q(j,r),device:q(i,r)||q(j,r)},this.other={blackberry:q(k,r),blackberry10:q(l,r),opera:q(m,r),firefox:q(o,r),chrome:q(n,r),device:q(k,r)||q(l,r)||q(m,r)||q(o,r)||q(n,r)},this.seven_inch=q(p,r),this.any=this.apple.device||this.android.device||this.windows.device||this.other.device||this.seven_inch,this.phone=this.apple.phone||this.android.phone||this.windows.phone,this.tablet=this.apple.tablet||this.android.tablet||this.windows.tablet,"undefined"==typeof window)return this},s=function(){var a=new r;return a.Class=r,a};"undefined"!=typeof module&&module.exports&&"undefined"==typeof window?module.exports=r:"undefined"!=typeof module&&module.exports&&"undefined"!=typeof window?module.exports=s():"function"==typeof define&&define.amd?define("isMobile",[],a.isMobile=s()):a.isMobile=s()}(this); \ No newline at end of file