@@ -7,16 +7,15 @@ import {
77 useDefaultToken
88} from './editor' ;
99import { setupJwtCounter } from './counter.js' ;
10+ import { setupSmoothScrolling } from './smooth-scrolling.js' ;
11+ import { setupHighlighting } from './highlighting.js' ;
1012import { getParameterByName , smoothScrollTo } from './utils.js' ;
1113import {
1214 publicKeyTextArea ,
1315 codeElements ,
1416 debuggerSection ,
15- menuScrollableLinks
1617} from './dom-elements.js' ;
1718
18- import hljs from 'highlight.js' ;
19-
2019/* For initialization, look at the end of this file */
2120
2221function parseLocationQuery ( ) {
@@ -38,7 +37,9 @@ function parseLocationQuery() {
3837 scroll = true ;
3938 }
4039
41- debuggerSection . scrollIntoView ( true ) ;
40+ if ( scroll ) {
41+ debuggerSection . scrollIntoView ( true ) ;
42+ }
4243}
4344
4445function loadToken ( ) {
@@ -55,39 +56,6 @@ function loadToken() {
5556 }
5657}
5758
58- function setupHighlighting ( ) {
59- // TODO: consider replacing this with CodeMirror, which we already use.
60-
61- hljs . configure ( {
62- classPrefix : ''
63- } ) ;
64-
65- Array . prototype . forEach . call ( codeElements , element => {
66- if ( ! element . classList . contains ( 'hljs' ) ) {
67- element . classList . add ( 'hljs' ) ;
68- hljs . highlightBlock ( element ) ;
69- }
70- } ) ;
71- }
72-
73- function setupSmoothScrolling ( ) {
74- Array . prototype . forEach . call ( menuScrollableLinks , scrollable => {
75- scrollable . addEventListener ( 'click' , event => {
76- event . preventDefault ( ) ;
77-
78- const start = scrollable . href . indexOf ( '#' ) ;
79- if ( start === - 1 ) {
80- console . error ( '<a> element with .scrollto set and bad link: ' ,
81- scrollable . href ) ;
82- return ;
83- }
84-
85- const id = scrollable . href . substr ( start + 1 ) ;
86- smoothScrollTo ( document . getElementById ( id ) ) ;
87- } ) ;
88- } ) ;
89- }
90-
9159// Initialization
9260setupNavbar ( ) ;
9361setupExtensionButton ( ) ;
0 commit comments