File tree Expand file tree Collapse file tree 3 files changed +52
-19
lines changed
Expand file tree Collapse file tree 3 files changed +52
-19
lines changed Original file line number Diff line number Diff line change 1313 </div>
1414
1515 <div class="version-dropdown" id="versionDropdown">
16- <script>
17- // include dropdown script
18- var imported = document.createElement('script');
19- imported.src = '{{_rel}}web/version.js';
20- document.head.appendChild(imported);
21-
22- // include dropdown css
23- var head = document.getElementsByTagName('head')[0];
24- var link = document.createElement('link');
25- //link.id = cssId;
26- link.rel = 'stylesheet';
27- link.type = 'text/css';
28- link.href = '{{_rel}}web/version.css';
29- link.media = 'all';
30- head.appendChild(link);
31- </script>
3216 </div>
3317
3418 <div class="collapse navbar-collapse" id="navbar">
Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
2+
3+ function createSharedTags ( )
4+ {
5+ // get web root path
6+ var scripts = document . getElementsByTagName ( "script" ) ;
7+ var scriptPath = scripts [ scripts . length - 1 ] . src ;
8+ var versionIndex = scriptPath . lastIndexOf ( 'version/' ) ;
9+ var rootDir = scriptPath ;
10+ if ( versionIndex > 0 )
11+ {
12+ rootDir = scriptPath . substring ( 0 , versionIndex ) ;
13+ }
14+ else
15+ {
16+ rootDir = scriptPath . substring ( 0 , scriptPath . lastIndexOf ( 'styles/' ) ) ;
17+ }
18+
19+ // include dropdown script
20+ var imported = document . createElement ( 'script' ) ;
21+ imported . src = rootDir + 'web/version.js' ;
22+ imported . id = 'dropdownScript' ;
23+ document . head . appendChild ( imported ) ;
24+
25+ // include dropdown css
26+ var head = document . getElementsByTagName ( 'head' ) [ 0 ] ;
27+ var link = document . createElement ( 'link' ) ;
28+ link . rel = 'stylesheet' ;
29+ link . type = 'text/css' ;
30+ link . href = rootDir + 'web/version.css' ;
31+ link . media = 'all' ;
32+ head . appendChild ( link ) ;
33+ }
34+
35+ createSharedTags ( ) ;
Original file line number Diff line number Diff line change @@ -16,14 +16,28 @@ function createDropdown()
1616 innerDiv . className = "version-dropdown-content" ;
1717 versionDropDiv . appendChild ( btn ) ;
1818 versionDropDiv . appendChild ( innerDiv ) ;
19-
19+
20+ // get web root path
21+ var script = document . getElementById ( 'dropdownScript' ) ;
22+ var scriptPath = script . src ;
23+ var versionIndex = scriptPath . lastIndexOf ( 'version/' ) ;
24+ var rootDir = scriptPath ;
25+ if ( versionIndex > 0 )
26+ {
27+ rootDir = scriptPath . substring ( 0 , versionIndex ) ;
28+ }
29+ else
30+ {
31+ rootDir = scriptPath . substring ( 0 , scriptPath . lastIndexOf ( 'web/' ) ) ;
32+ }
33+
2034 // create default
21- createEntry ( innerDiv , defaultTitle , "../ README.html") ;
35+ createEntry ( innerDiv , defaultTitle , rootDir + " README.html") ;
2236
2337 // create version entries
2438 for ( i = 0 ; i < versionArray . length ; i ++ )
2539 {
26- createEntry ( innerDiv , versionArray [ i ] , "../ version/"+ versionArray [ i ] + "/README.html" ) ;
40+ createEntry ( innerDiv , versionArray [ i ] , rootDir + " version/"+ versionArray [ i ] + "/README.html" ) ;
2741 }
2842}
2943
You can’t perform that action at this time.
0 commit comments