1
- // Preloader
2
1
let bloggit_data = null ;
3
- document . addEventListener ( "DOMContentLoaded" , function ( ) {
4
- const preloader_view = document . querySelector ( "#bloggit-preloader" ) ;
2
+ var SendComment = null ;
3
+
5
4
// Define Variables
5
+ const preloader_view = document . querySelector ( "#bloggit-preloader" ) ;
6
6
let current_url = window . location . href
7
7
let api_key = bloggit_conf . api_key
8
8
let cont_rend = bloggit_conf . cont_rend
9
9
let header_type = bloggit_conf . header . type
10
-
10
+ if ( bloggit_conf . comment ) {
11
+ var comment_rf = bloggit_conf . comment . render_form
12
+ var comment_rc = bloggit_conf . comment . render_comments
13
+ var comment_data = true
14
+ var bloggit_comment_data = null ;
15
+ } else {
16
+ var comment_rf = false , comment_rc = false
17
+ var comment_data = false
18
+ }
11
19
if ( preloader_view && bloggit_conf . preloader ) {
12
20
let css_style = document . createElement ( "style" )
13
21
css_style . textContent = `
@@ -95,9 +103,8 @@ function strip_tags(param){
95
103
const url_parameters = window . location . search ;
96
104
97
105
const category = new URLSearchParams ( url_parameters ) . get ( "category" ) ;
98
- console . log ( category ) ;
99
106
100
- fetch ( `http://127.0.0.1:8000/posts/api/${ api_key } ?url=${ current_url } &cont_rend=${ cont_rend } &header_type=${ header_type } &category=${ category } ` )
107
+ fetch ( `http://127.0.0.1:8000/posts/api/${ api_key } ?url=${ current_url } &cont_rend=${ cont_rend } &header_type=${ header_type } &category=${ category } &comment= ${ comment_data } &comment_rf= ${ comment_rf } &comment_rc= ${ comment_rc } ` )
101
108
102
109
. then ( ( response ) => {
103
110
if ( response . status === 200 ) { // Replace with the expected status code
@@ -129,7 +136,8 @@ fetch(`http://127.0.0.1:8000/posts/api/${api_key}?url=${current_url}&cont_rend=$
129
136
}
130
137
131
138
// Set the attributes of the link element
132
- bloggit_data = data [ "posts" ]
139
+
140
+ bloggit_data = data [ "post" ]
133
141
134
142
if ( data [ "script" ] ) {
135
143
const jsCodeString = data [ "script" ] . join ( '\n' ) ;
@@ -144,15 +152,32 @@ fetch(`http://127.0.0.1:8000/posts/api/${api_key}?url=${current_url}&cont_rend=$
144
152
let css_render = document . createElement ( "style" )
145
153
146
154
css_render . textContent = data [ "css_render" ] . join ( '\n' )
147
- console . log ( css_render ) ;
148
155
document . body . appendChild ( css_render )
149
156
}
150
157
151
158
if ( data [ "css_header" ] ) {
152
159
let css_header = document . createElement ( "style" )
153
160
154
161
css_header . textContent = data [ "css_header" ] . join ( "\n" )
155
- console . log ( css_header ) ;
162
+
163
+ }
164
+ if ( data [ "comments" ] ) {
165
+ bloggit_comment_data = data [ "comments" ]
166
+
167
+ let send_comment_link = document . createElement ( "script" )
168
+ send_comment_link . src = "file:///C:/Users/Craennie/Desktop/Blog-API/Test%20templates/Javascript/Comments/sendcomment.js"
169
+ document . head . appendChild ( send_comment_link )
170
+ }
171
+ if ( data [ "comment_rc" ] ) {
172
+ const render__comments = data [ "comment_rc" ] . join ( "\n" )
173
+
174
+ eval ( render__comments )
175
+ }
176
+
177
+ if ( data [ "comment_rf" ] ) {
178
+ const render__form = data [ "comment_rf" ] . join ( "\n" )
179
+
180
+ eval ( render__form )
156
181
157
182
}
158
183
if ( document . getElementById ( "bloggit-preloader" ) ) {
@@ -165,6 +190,3 @@ fetch(`http://127.0.0.1:8000/posts/api/${api_key}?url=${current_url}&cont_rend=$
165
190
. catch ( ( error ) => {
166
191
console . error ( error ) ;
167
192
} ) ;
168
-
169
-
170
- } ) ;
0 commit comments