3
3
create : function ( codefundId ) {
4
4
return function ( hook , vm ) {
5
5
hook . ready ( function ( ) {
6
- var style = document . createElement ( 'style' )
7
- var css = '#codefund_ad span.cf-wrapper { background-color: rgba(0,0,0,0) } #codefund_ad a.cf-text { color: #444; font-weight: 400; font-size: 10px }'
8
-
9
- style . type = 'text/css'
10
- if ( style . styleSheet ) {
11
- style . styleSheet . cssText = css
12
- } else {
13
- style . appendChild ( document . createTextNode ( css ) )
14
- }
15
- document . head . appendChild ( style )
16
-
17
- var script = document . createElement ( 'script' )
18
- script . src = "https://codefund.io/scripts/" + codefundId + "/embed.js"
19
- document . body . appendChild ( script )
6
+ window . DocsifyCodefund . injectCodeFundContainer ( ) ;
7
+ window . DocsifyCodefund . injectCodeFundScript ( codefundId ) ;
20
8
} )
9
+ }
10
+ } ,
21
11
22
- hook . doneEach ( function ( ) {
23
- // create a codefun container
24
- let nav = document . getElementsByClassName ( 'sidebar-nav' )
25
- let codefunContainer = document . createElement ( 'div' )
26
- codefunContainer . id = 'codefund_ad'
27
- nav [ 0 ] . insertBefore ( codefunContainer , nav [ 0 ] . firstChild )
12
+ injectCodeFundContainer ( ) {
13
+ let nav = document . getElementsByClassName ( 'sidebar-nav' )
14
+ let codefundContainer = document . createElement ( 'div' )
15
+ codefundContainer . id = 'codefund'
16
+ nav [ 0 ] . insertBefore ( codefundContainer , nav [ 0 ] . firstChild )
28
17
29
- if ( document . getElementsByClassName ( 'cf-wrapper' ) . length === 0 ) {
30
- window . _codefund && window . _codefund . serve ( ) ;
31
- }
32
- } )
18
+ if ( document . getElementsByClassName ( 'cf-wrapper' ) . length === 0 ) {
19
+ window . _codefund && window . _codefund . serve ( ) ;
33
20
}
21
+ } ,
22
+
23
+ injectCodeFundScript ( codefundId ) {
24
+ var script = document . createElement ( 'script' )
25
+ script . src = "https://codefund.app/properties/" + codefundId + "/funder.js?template=docsify"
26
+ script . async = "async"
27
+ document . body . appendChild ( script )
34
28
}
35
29
}
36
- } ) ( window )
30
+ } ) ( window )
0 commit comments