@@ -16,15 +16,15 @@ jQuery(document).ready(function($) {
16
16
} ) ;
17
17
} ) ;
18
18
window . tryGetFromCache = function ( val ) {
19
- let ch = val . substr ( 0 , 1 ) . toLowerCase ( ) ;
19
+ val = val . toLowerCase ( ) ;
20
+ let ch = val . substring ( 0 , 1 ) ;
20
21
if ( ch . match ( / ^ [ a - z ] $ / ) ) {
21
- val = val . toLowerCase ( ) ;
22
22
console . log ( 'keydown triggered, val is: ' + val ) ;
23
- if ( ! window . dreamCache [ ch ] ) {
23
+ if ( ! window . dreamCache [ ch ] ) { // is cache miss ?
24
24
window . dreamCache [ ch ] = true ; // set up placeholder
25
25
let url = window . urlPrefix + ch + '.json' ;
26
26
console . log ( 'cache miss, downloading ' + url ) ;
27
- $ . get ( url , function ( res ) {
27
+ $ . get ( url , function ( res ) { // get /dict/ json
28
28
console . log ( 'downloaded ' + url ) ;
29
29
window . dreamCache [ ch ] = res ; // save to cache
30
30
if ( val . length > 1 )
@@ -39,7 +39,7 @@ window.tryGetFromCache = function(val) {
39
39
}
40
40
window . hashChange = function ( e ) {
41
41
if ( location . hash && location . hash . length > 1 ) {
42
- let val = decodeURI ( location . hash . substr ( 1 ) ) ;
42
+ let val = decodeURI ( location . hash . substring ( 1 ) ) ;
43
43
$ ( '#symbol' ) . val ( val ) ;
44
44
window . tryGetFromCache ( val ) ;
45
45
}
@@ -48,7 +48,7 @@ $(window).bind('hashchange', window.hashChange);
48
48
window . hashChange ( ) ;
49
49
window . updateAutoCompleteWithVal = function ( ) {
50
50
if ( window . cachedVal ) {
51
- let ch = window . cachedVal . substr ( 0 , 1 ) ;
51
+ let ch = window . cachedVal . substring ( 0 , 1 ) ;
52
52
if ( window . dreamCache [ ch ]
53
53
&& window . dreamCache [ ch ] !== true ) {
54
54
window . updateAutoComplete ( window . cachedVal ) ;
@@ -57,7 +57,7 @@ window.updateAutoCompleteWithVal = function() {
57
57
}
58
58
}
59
59
window . updateAutoComplete = function ( val ) {
60
- let ch = val . substr ( 0 , 1 ) , output = '' ,
60
+ let ch = val . substring ( 0 , 1 ) , output = '' ,
61
61
items = window . dreamCache [ ch ] ;
62
62
if ( items === true ) {
63
63
console . log ( 'Scheduled search' ) ;
0 commit comments