File tree Expand file tree Collapse file tree 3 files changed +59
-9
lines changed Expand file tree Collapse file tree 3 files changed +59
-9
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2018 The OpenGenus Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ var obj = { } ;
6
+
7
+ function readDirectory ( dirEntry ) {
8
+ var dirReader = dirEntry . createReader ( ) ;
9
+ dirReader . readEntries ( function ( entries ) {
10
+ for ( var i = 0 ; i < entries . length ; i ++ ) {
11
+ var entry = entries [ i ] ;
12
+ if ( entry . isDirectory ) {
13
+ readDirectory ( entry ) ;
14
+ }
15
+ else if ( entry . isFile ) {
16
+ var filename = entry . name ;
17
+ var filepath = entry . fullPath . split ( "/" ) . slice ( 2 , - 1 ) . join ( "/" ) ;
18
+ if ( ! obj [ filepath ] ) {
19
+ obj [ filepath ] = [ ] ;
20
+ }
21
+ obj [ filepath ] . push ( filename ) ;
22
+ }
23
+ }
24
+ localStorage [ "metadata" ] = JSON . stringify ( obj ) ;
25
+ } ) ;
26
+ }
27
+
28
+ function populate ( ) {
29
+ chrome . runtime . getPackageDirectoryEntry ( function ( storageRootEntry ) {
30
+ if ( storageRootEntry . isDirectory ) {
31
+ var dirReader = storageRootEntry . createReader ( ) ;
32
+
33
+ var readEntries = function ( ) {
34
+ dirReader . readEntries ( function ( entries ) {
35
+ for ( var i = 0 ; i < entries . length ; i ++ ) {
36
+ var entry = entries [ i ] ;
37
+ if ( entry . name === "code" ) {
38
+ readDirectory ( entry ) ;
39
+ break ;
40
+ }
41
+ }
42
+
43
+ if ( ! entries . length )
44
+ readEntries ( ) ;
45
+ } ) ;
46
+ } ;
47
+
48
+ readEntries ( ) ;
49
+ }
50
+ } ) ;
51
+ }
52
+
53
+ if ( ! localStorage [ "metadata" ] ) {
54
+ populate ( ) ;
55
+ }
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1
1
< html >
2
2
< head >
3
-
3
+ < script src =" js/metadata.js " > </ script >
4
4
< script src ="js/jquery.js "> </ script >
5
5
< script src ="js/popper.min.js "> </ script >
6
6
< script src ="js/bootstrap.min.js "> </ script >
You can’t perform that action at this time.
0 commit comments