File tree 3 files changed +30
-3
lines changed
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ def update(pkg_name, version):
136
136
original_div = soup .find ('section' , class_ = 'versions' ).findAll ('div' )[- 1 ]
137
137
new_div = copy .copy (original_div )
138
138
anchor = new_div .find ('a' )
139
- anchor ['onclick' ] = f"load_readme('{ version } ', scroll_to_div=true)"
139
+ new_div ['onclick' ] = f"load_readme('{ version } ', scroll_to_div=true); "
140
140
new_div ['id' ] = norm_version
141
141
new_div ['class' ] = ""
142
142
if not is_stable (version ):
Original file line number Diff line number Diff line change 79
79
_author
80
80
</ p >
81
81
< section class ="versions " id ="versions ">
82
- < div id ="_version ">
83
- < a href ="_link " onclick =" load_readme('_version', scroll_to_div=true) " >
82
+ < div id ="_version " onclick =" load_readme('_version', scroll_to_div=true) " >
83
+ < a href ="_link ">
84
84
_version
85
85
</ a >
86
86
</ div >
Original file line number Diff line number Diff line change 1
1
function load_readme ( version , scroll_to_div = false ) {
2
+ addDynamicClickDelegation ( `${ version } ` ) ;
3
+
2
4
let urlVersion = url_readme_main . replace ( 'main' , version ) ;
3
5
fetch ( urlVersion )
4
6
. then ( response => {
@@ -35,4 +37,29 @@ function redirectToIndex() {
35
37
window . location . href = "../index.html" ;
36
38
}
37
39
40
+ function addDynamicClickDelegation ( parentId ) {
41
+ const parentDiv = document . getElementById ( parentId ) ;
42
+
43
+ if ( parentDiv ) {
44
+ parentDiv . addEventListener ( 'click' , function ( event ) {
45
+ if ( event . target !== this ) {
46
+ event . stopPropagation ( ) ;
47
+ this . click ( ) ; // Trigger the parent div's onclick function
48
+ }
49
+ } ) ;
50
+ }
51
+ }
52
+
53
+ function removeHrefFromAnchors ( ) {
54
+ var versionsSection = document . getElementById ( 'versions' ) ;
55
+ if ( versionsSection ) {
56
+ var anchors = versionsSection . getElementsByTagName ( 'a' ) ;
57
+ for ( var i = 0 ; i < anchors . length ; i ++ ) {
58
+ anchors [ i ] . removeAttribute ( 'href' ) ;
59
+ }
60
+ }
61
+ }
38
62
63
+ window . onload = function ( ) {
64
+ removeHrefFromAnchors ( ) ;
65
+ } ;
You can’t perform that action at this time.
0 commit comments