Skip to content

Commit 0dbbb1f

Browse files
committed
Fix libary filter js
1 parent 81147e0 commit 0dbbb1f

File tree

9 files changed

+70
-67
lines changed

9 files changed

+70
-67
lines changed

src/website/dom-elements.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const navbarElement = document.querySelector('nav.navbar');
55
export const menuTriggerElement = document.querySelector('.menu-trigger');
66
export const menuLinks = document.querySelectorAll('.navbar .menu a');
77
export const menuScrollableLinks =
8-
navbarElement.querySelectorAll('a.scrollto');
8+
navbarElement.querySelectorAll('a.scrollto');
99

1010
export const sectionElements = document.getElementsByTagName('section');
1111

@@ -14,14 +14,12 @@ export const ebookSection = document.querySelector('.jtw-ebook-banner');
1414

1515
export const extensionButton = document.getElementById('extension-button');
1616
export const extensionButtonText = extensionButton ?
17-
extensionButton.querySelector('.button-text') :
18-
undefined;
17+
extensionButton.querySelector('.button-text') :
18+
undefined;
1919

2020
export const debuggerSection = document.getElementById('debugger-io');
2121

2222
export const shareJwtButton = document.querySelector('.website-share button');
2323
export const shareJwtTextElement = shareJwtButton.querySelector('span');
2424

25-
export const starsElements = document.getElementsByClassName('stars');
26-
export const librariesElement = document.querySelector('.libraries-sv');
27-
export const librariesSelect = document.getElementById('libraries-select');
25+
export const starsElements = document.getElementsByClassName('stars');

src/website/index.js

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,53 @@
11
import { setupNavbar } from "./navbar.js";
2-
import { setupExtensionButton } from "./extension.js";
3-
import { setupLibraries } from "./libraries.js";
42
import { setupTokenEditor, setTokenEditorValue } from "../editor";
53
import { setupJwtCounter } from "./counter.js";
64
import { setupSmoothScrolling } from "./smooth-scrolling.js";
75
import { setupHighlighting } from "./highlighting.js";
8-
import { isChrome, isFirefox, isPartiallyInViewport, once } from "./utils.js";
96
import { setupShareJwtButton } from "../share-button.js";
107
import {
11-
publicKeyTextArea,
12-
debuggerSection,
13-
extensionSection,
14-
ebookSection,
15-
shareJwtButton,
16-
shareJwtTextElement,
17-
librariesElement
8+
publicKeyTextArea,
9+
debuggerSection,
10+
shareJwtButton,
11+
shareJwtTextElement,
1812
} from "./dom-elements.js";
1913

2014
import queryString from "querystring";
2115

2216
/* For initialization, look at the end of this file */
2317

2418
function parseLocationQuery() {
25-
const locSearch = queryString.parse(document.location.search.substr(1));
26-
const locHash = queryString.parse(document.location.hash.substr(1));
27-
28-
const keys = [
29-
"id_token",
30-
"access_token",
31-
"value",
32-
"token",
33-
"debugger-io?token"
34-
];
35-
for (const key of keys) {
36-
const token = locSearch[key] || locHash[key];
37-
38-
if (token) {
39-
if (locSearch.publicKey || locHash.publicKey) {
40-
publicKeyTextArea.value = locSearch.publicKey || locHash.publicKey;
41-
}
42-
43-
setTokenEditorValue(token);
44-
45-
debuggerSection.scrollIntoView(true);
46-
47-
break;
19+
const locSearch = queryString.parse(document.location.search.substr(1));
20+
const locHash = queryString.parse(document.location.hash.substr(1));
21+
22+
const keys = [
23+
"id_token",
24+
"access_token",
25+
"value",
26+
"token",
27+
"debugger-io?token"
28+
];
29+
for (const key of keys) {
30+
const token = locSearch[key] || locHash[key];
31+
32+
if (token) {
33+
if (locSearch.publicKey || locHash.publicKey) {
34+
publicKeyTextArea.value = locSearch.publicKey || locHash.publicKey;
35+
}
36+
37+
setTokenEditorValue(token);
38+
39+
debuggerSection.scrollIntoView(true);
40+
41+
break;
42+
}
4843
}
49-
}
5044
}
5145

5246
// Initialization
5347
setupNavbar();
54-
// setupExtensionButton();
5548
setupSmoothScrolling();
56-
setupLibraries();
5749
setupTokenEditor();
5850
parseLocationQuery();
5951
setupHighlighting();
6052
setupJwtCounter();
61-
setupShareJwtButton(shareJwtButton, shareJwtTextElement);
53+
setupShareJwtButton(shareJwtButton, shareJwtTextElement);

src/website/libraries/dom-elements.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const librariesElement = document.querySelector('.libraries-sv');
2+
export const librariesSelect = document.getElementById('libraries-select');

src/website/libraries/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { setupLibraries } from "./libraries.js";
2+
import { setupHighlighting } from "../highlighting.js";
3+
import { setupJwtCounter } from "../counter.js";
4+
5+
// Initialization
6+
setupLibraries();
7+
setupHighlighting();
8+
setupJwtCounter();

src/website/libraries.js renamed to src/website/libraries/libraries.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { httpGet } from "../utils.js";
21
import { librariesElement, librariesSelect } from "./dom-elements.js";
32

43
import Isotope from "isotope-layout";

views/website/libraries.pug

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ block content
5454
each lang in languages
5555
each lib in lang.libs
5656
include libraries/template.pug
57+
58+
include counter.pug
59+
60+
script(src='/js/libraries.js')

views/website/navigation.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ nav.navbar.closed
99
img(src='/img/logo.svg' alt='JWT logo').logo
1010

1111
nav.menu
12-
a(href='/').scrollto Debugger
13-
a(href='/libraries').scrollto Libraries
12+
a(href='/') Debugger
13+
a(href='/libraries') Libraries
1414
a(href='/introduction') Introduction
1515
a(href='https://community.auth0.com/c/identity/jwt', target='_blank') Ask
1616

webpack.website-dev.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const merge = require('webpack-merge');
44
const common = require('./webpack.common.js');
55

66
module.exports = merge(common, {
7-
mode: 'development',
8-
entry: {
9-
index: './src/website/index.js',
10-
introduction: './src/website/introduction/index.js'
11-
},
12-
output: {
13-
filename: '[name].js',
14-
path: __dirname + '/dist/website/js'
15-
},
16-
plugins: [
17-
]
18-
});
7+
mode: 'development',
8+
entry: {
9+
index: './src/website/index.js',
10+
introduction: './src/website/introduction/index.js',
11+
libraries: './src/website/libraries/index.js'
12+
},
13+
output: {
14+
filename: '[name].js',
15+
path: __dirname + '/dist/website/js'
16+
},
17+
plugins: []
18+
});

webpack.website-prod.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
55
const devConfig = require('./webpack.website-dev.js');
66

77
module.exports = merge(devConfig, {
8-
mode: 'production',
9-
devtool: false,
10-
plugins: [
11-
new UglifyJsPlugin(),
12-
new webpack.DefinePlugin({
13-
PRODUCTION: true
14-
})
15-
]
16-
});
8+
mode: 'production',
9+
devtool: false,
10+
plugins: [
11+
new UglifyJsPlugin(),
12+
new webpack.DefinePlugin({
13+
PRODUCTION: true
14+
})
15+
]
16+
});

0 commit comments

Comments
 (0)