CoolFace
Modelpublic

james1075/ultimate-manga-scraper

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
list-posts.js333 linesDownload Raw Back to scripts
1"use strict"; 
2var { registerBlockType } = wp.blocks;
3var gcel = wp.element.createElement;
4
5registerBlockType( 'ultimate-manga-scraper/ums-list', {
6    title: 'Ultimate Mange Scraper List Posts',
7    icon: 'smartphone',
8    category: 'embed',
9    attributes: {
10        ruletype : {
11            default: '',
12            type:   'string',
13        },
14        ruleid : {
15            default: '',
16            type:   'string',
17        },
18        category : {
19            default: '',
20            type:   'string',
21        },
22        posts : {
23            default: '50',
24            type:   'string',
25        },
26        orderby : {
27            default: 'title',
28            type:   'string',
29        },
30        order : {
31            default: 'ASC',
32            type:   'string',
33        },
34        type : {
35            default: 'any',
36            type:   'string',
37        }
38    },
39    keywords: ['list', 'posts', 'ums'],
40    edit: (function( props ) {
41		var ruletype = props.attributes.ruletype;
42        var ruleid = props.attributes.ruleid;
43        var category = props.attributes.category;
44        var posts = props.attributes.posts;
45        var orderby = props.attributes.orderby;
46        var order = props.attributes.order;
47        var type = props.attributes.type;
48		function updateMessage( event ) {
49            props.setAttributes( { ruletype: event.target.value} );
50		}
51        function updateMessage2( event ) {
52            props.setAttributes( { ruleid: event.target.value} );
53		}
54        function updateMessage3( event ) {
55            props.setAttributes( { category: event.target.value} );
56		}
57        function updateMessage4( event ) {
58            props.setAttributes( { posts: event.target.value} );
59		}
60        function updateMessage5( event ) {
61            props.setAttributes( { orderby: event.target.value} );
62		}
63        function updateMessage6( event ) {
64            props.setAttributes( { order: event.target.value} );
65		}
66        function updateMessage7( event ) {
67            props.setAttributes( { type: event.target.value} );
68		}
69		return gcel(
70			'div', 
71			{ className: 'coderevolution_gutenberg_div' },
72            gcel(
73				'h4',
74				{ className: 'coderevolution_gutenberg_title' },
75                'Ultimate Mange Scraper List Posts ',
76                gcel(
77                    'div', 
78                    {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
79                    ,
80                    gcel(
81                        'div', 
82                        {className:'bws_hidden_help_text'},
83                        'This block is used to list posts generated by this plugin. It is a simple way to list posts.'
84                    )
85                )
86			),
87            gcel(
88				'label',
89				{ className: 'coderevolution_gutenberg_label' },
90                'Rule Type: '
91			),
92            gcel(
93                'div', 
94                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
95                ,
96                gcel(
97                    'div', 
98                    {className:'bws_hidden_help_text'},
99                    'Select the source of the posts that will be listed.'
100                )
101            ),
102			gcel(
103				'select',
104				{ value: ruletype, onChange: updateMessage, className: 'coderevolution_gutenberg_select' }, 
105                gcel(
106                    'option',
107                    { value: 0},
108                    'APKs to Posts'
109                ),
110                gcel(
111                    'option',
112                    { value: 0},
113                    'Custom Page Import'
114                ),
115                gcel(
116                    'option',
117                    { value: ''},
118                    'Any'
119                )
120            ),
121            gcel(
122				'br'
123			),
124            gcel(
125				'label',
126				{ className: 'coderevolution_gutenberg_label' },
127                'Rule ID: '
128			),
129            gcel(
130                'div', 
131                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
132                ,
133                gcel(
134                    'div', 
135                    {className:'bws_hidden_help_text'},
136                    'Select the ID of the rule you wish to list posts from. To list all posts from a specific rule, leave this field blank.'
137                )
138            ),
139			gcel(
140				'input',
141				{ type:'number',min:0,placeholder:'Rule id to list', value: ruleid, onChange: updateMessage2, className: 'coderevolution_gutenberg_input' }
142			),
143            gcel(
144				'br'
145			),
146            gcel(
147				'label',
148				{ className: 'coderevolution_gutenberg_label' },
149                'Category Slug: '
150			),
151            gcel(
152                'div', 
153                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
154                ,
155                gcel(
156                    'div', 
157                    {className:'bws_hidden_help_text'},
158                    'Select the post category slug from where you wish to list posts.'
159                )
160            ),
161			gcel(
162				'textarea',
163				{ rows:1,placeholder:'Category slug', value: category, onChange: updateMessage3, className: 'coderevolution_gutenberg_input' }
164			),
165            gcel(
166				'br'
167			),
168            gcel(
169				'label',
170				{ className: 'coderevolution_gutenberg_label' },
171                'Posts Per Page: '
172			),
173            gcel(
174                'div', 
175                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
176                ,
177                gcel(
178                    'div', 
179                    {className:'bws_hidden_help_text'},
180                    'Select the number of posts to be shown at max.'
181                )
182            ),
183			gcel(
184				'input',
185				{ type:'number',min:1,placeholder:'10', value: posts, onChange: updateMessage4, className: 'coderevolution_gutenberg_input' }
186			),
187            gcel(
188				'br'
189			),
190            gcel(
191				'label',
192				{ className: 'coderevolution_gutenberg_label' },
193                'Order By: '
194			),
195            gcel(
196                'div', 
197                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
198                ,
199                gcel(
200                    'div', 
201                    {className:'bws_hidden_help_text'},
202                    'Select how to order results.'
203                )
204            ),
205            gcel(
206				'select',
207				{ value: orderby, onChange: updateMessage5, className: 'coderevolution_gutenberg_select' }, 
208                gcel(
209                    'option',
210                    { value: 'none'},
211                    'none'
212                ), 
213                gcel(
214                    'option',
215                    { value: 'date'},
216                    'date'
217                ), 
218                gcel(
219                    'option',
220                    { value: 'ID'},
221                    'ID'
222                ), 
223                gcel(
224                    'option',
225                    { value: 'author'},
226                    'author'
227                ), 
228                gcel(
229                    'option',
230                    { value: 'title'},
231                    'title'
232                ), 
233                gcel(
234                    'option',
235                    { value: 'name'},
236                    'name'
237                ), 
238                gcel(
239                    'option',
240                    { value: 'type'},
241                    'type'
242                ), 
243                gcel(
244                    'option',
245                    { value: 'modified'},
246                    'modified'
247                ), 
248                gcel(
249                    'option',
250                    { value: 'parent'},
251                    'parent'
252                ), 
253                gcel(
254                    'option',
255                    { value: 'rand'},
256                    'rand'
257                ), 
258                gcel(
259                    'option',
260                    { value: 'comment_count'},
261                    'comment_count'
262                ), 
263                gcel(
264                    'option',
265                    { value: 'relevance'},
266                    'relevance'
267                ), 
268                gcel(
269                    'option',
270                    { value: 'menu_order'},
271                    'menu_order'
272                )
273            ),
274            gcel(
275				'br'
276			),
277            gcel(
278				'label',
279				{ className: 'coderevolution_gutenberg_label' },
280                'Sort By: '
281			),
282            gcel(
283                'div', 
284                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
285                ,
286                gcel(
287                    'div', 
288                    {className:'bws_hidden_help_text'},
289                    'Select how to sort results.'
290                )
291            ),
292            gcel(
293				'select',
294				{ value: order, onChange: updateMessage6, className: 'coderevolution_gutenberg_select' }, 
295                gcel(
296                    'option',
297                    { value: 'ASC'},
298                    'ASC'
299                ), 
300                gcel(
301                    'option',
302                    { value: 'DESC'},
303                    'DESC'
304                )
305            ),
306            gcel(
307				'br'
308			),
309            gcel(
310				'label',
311				{ className: 'coderevolution_gutenberg_label' },
312                'Post Type: '
313			),
314            gcel(
315                'div', 
316                {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'}
317                ,
318                gcel(
319                    'div', 
320                    {className:'bws_hidden_help_text'},
321                    'Select the post type to be listed. You can input a comma separated list of multiple post types (custom post types supported).'
322                )
323            ),
324			gcel(
325				'textarea',
326				{ rows:1,placeholder:'post', value: type, onChange: updateMessage7, className: 'coderevolution_gutenberg_input' }
327			)
328		);
329    }),
330    save: (function( props ) {
331       return null;
332    }),
333} );