11"use strict" ;
22
3- class ActionButton
4- {
5- constructor ( action , label , clear = false )
6- {
7- this . action = action ;
8- this . label = label ;
9- this . clear = clear ;
10- }
3+ class ActionButton {
4+ constructor ( action , label , clear = false ) {
5+ this . action = action ;
6+ this . label = label ;
7+ this . clear = clear ;
8+ }
119
12- isValidUrl ( urlString )
13- {
14- const urlPattern = new RegExp ( "^(https?:\\/\\/)?" + // validate protocol
15- "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // validate domain name
16- "((\\d{1,3}\\.){3}\\d{1,3}))" + // validate OR ip (v4) address
17- "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // validate port and path
18- "(\\?[;&a-z\\d%_.~+=-]*)?" + // validate query string
19- "(\\#[-a-z\\d_]*)?$" , "i" ) ; // validate fragment locator
20- return ! ! urlPattern . test ( urlString ) ;
21- }
10+ isValidUrl ( urlString ) {
11+ const urlPattern = new RegExp (
12+ "^(https?:\\/\\/)?" + // validate protocol
13+ "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // validate domain name
14+ "((\\d{1,3}\\.){3}\\d{1,3}))" + // validate OR ip (v4) address
15+ "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // validate port and path
16+ "(\\?[;&a-z\\d%_.~+=-]*)?" + // validate query string
17+ "(\\#[-a-z\\d_]*)?$" ,
18+ "i" ,
19+ ) ; // validate fragment locator
20+ return ! ! urlPattern . test ( urlString ) ;
21+ }
2222}
2323
24- class ActionButtonView extends ActionButton
25- {
26- constructor ( label , url , clear = false )
27- {
28- super ( "view" , label , clear ) ;
29-
30- this . url = url ;
31- }
24+ class ActionButtonView extends ActionButton {
25+ constructor ( label , url , clear = false ) {
26+ super ( "view" , label , clear ) ;
3227
28+ this . url = url ;
29+ }
3330}
3431
35- class ActionButtonHTTP extends ActionButton
36- {
37- constructor ( label , url , clear = false )
38- {
39- super ( "http" , label , clear ) ;
40-
41- this . url = url ;
42- this . method = "POST" ;
43- this . headers = { } ;
44- this . body = "" ;
45- }
32+ class ActionButtonHTTP extends ActionButton {
33+ constructor ( label , url , clear = false ) {
34+ super ( "http" , label , clear ) ;
4635
47- getData ( )
48- {
49- return {
50- action : this . action ,
51- label : this . label ,
52- url : this . url ,
53- method : this . method ,
54- headers : this . headers ,
55- body : this . body ,
56- clear : this . clear
57- } ;
58- }
36+ this . url = url ;
37+ this . method = "POST" ;
38+ this . headers = { } ;
39+ this . body = "" ;
40+ }
5941
60- setMethod ( method )
61- {
62- this . method = method ;
63- }
42+ getData ( ) {
43+ return {
44+ action : this . action ,
45+ label : this . label ,
46+ url : this . url ,
47+ method : this . method ,
48+ headers : this . headers ,
49+ body : this . body ,
50+ clear : this . clear ,
51+ } ;
52+ }
6453
65- setHeaders ( headers )
66- {
67- this . headers = headers ;
68- }
69-
70- setBody ( body )
71- {
72- this . body = body ;
73- }
74- }
54+ setMethod ( method ) {
55+ this . method = method ;
56+ }
7557
76- class ActionButtonAB extends ActionButton
77- {
58+ setHeaders ( headers ) {
59+ this . headers = headers ;
60+ }
7861
62+ setBody ( body ) {
63+ this . body = body ;
64+ }
7965}
8066
67+ class ActionButtonAB extends ActionButton { }
8168
82- module . exports = { ActionButton, ActionButtonView, ActionButtonHTTP, ActionButtonAB } ;
69+ module . exports = {
70+ ActionButton,
71+ ActionButtonView,
72+ ActionButtonHTTP,
73+ ActionButtonAB,
74+ } ;
0 commit comments