1
+ /* eslint-disable */
1
2
var data = null ;
2
3
var filter = "" ;
3
4
var converter = new showdown . Converter ( ) ;
@@ -8,7 +9,9 @@ var sepVersion = "@";
8
9
var template =
9
10
'<p class="cmd-title">@@main-cmd@@</p><p class="cmd-description">@@cmd-description@@</p><p> </p><p>Options:</p>@@options@@<p> </p>' ;
10
11
var optionTemplate =
11
- '<p>@@option@@</p><p class="cmd-description">@@description@@</p><div class="line-space"></div>' ;
12
+ '<p>@@option@@</p><p class="cmd-description">@@description@@</p>@@inherit@@<div class="line-space"></div>' ;
13
+ var inheritTemplate =
14
+ '<p class="cmd-inherit">inherit @@inherit@@ from spk config.yaml</p>' ;
12
15
var relTemplate =
13
16
'<li><a class="preserve-view button is-small has-border-none has-inner-focus has-flex-justify-content-start is-full-width has-text-wrap is-text-left">@@value@@</a></li>' ;
14
17
@@ -19,18 +22,18 @@ function sanitize(str) {
19
22
function getExistingVersions ( ) {
20
23
$ . ajax ( {
21
24
url : "releases.txt" ,
22
- success : function ( result ) {
23
- result . split ( "\n" ) . forEach ( function ( r ) {
25
+ success : function ( result ) {
26
+ result . split ( "\n" ) . forEach ( function ( r ) {
24
27
var rTrim = r . trim ( ) ;
25
28
if ( rTrim && releases . indexOf ( rTrim ) === - 1 ) {
26
29
releases . push ( rTrim ) ;
27
30
}
28
31
} ) ;
29
- releases . sort ( function ( a , b ) {
32
+ releases . sort ( function ( a , b ) {
30
33
return a > b ? - 1 : 1 ;
31
34
} ) ;
32
35
} ,
33
- async : false
36
+ async : false ,
34
37
} ) ;
35
38
}
36
39
@@ -56,8 +59,8 @@ function populateVersionList() {
56
59
return a + relTemplate . replace ( "@@value@@" , c ) ;
57
60
} , "" )
58
61
) ;
59
- oSelect . find ( "li" ) . each ( function ( i , elm ) {
60
- $ ( elm ) . on ( "click" , function ( evt ) {
62
+ oSelect . find ( "li" ) . each ( function ( i , elm ) {
63
+ $ ( elm ) . on ( "click" , function ( evt ) {
61
64
evt . stopPropagation ( ) ;
62
65
oSelect . css ( "display" , "none" ) ;
63
66
var ver = $ ( this ) . text ( ) ;
@@ -91,15 +94,27 @@ function showDetails(key) {
91
94
) ;
92
95
content = content . replace ( "@@cmd-description@@" , cmd . description ) ;
93
96
94
- var options = ( cmd . options || [ ] ) . reduce ( function ( a , c ) {
95
- a + = optionTemplate
97
+ var options = ( cmd . options || [ ] ) . reduce ( function ( a , c ) {
98
+ var o = optionTemplate
96
99
. replace ( "@@option@@" , sanitize ( c . arg ) )
97
100
. replace ( "@@description@@" , sanitize ( c . description ) ) ;
101
+
102
+ if ( c . inherit ) {
103
+ o = o . replace (
104
+ "@@inherit@@" ,
105
+ inheritTemplate . replace ( "@@inherit@@" , c . inherit )
106
+ ) ;
107
+ } else {
108
+ o = o . replace ( "@@inherit@@" , "" ) ;
109
+ }
110
+
111
+ a += o ;
98
112
return a ;
99
113
} , "" ) ;
100
114
options += optionTemplate
101
115
. replace ( "@@option@@" , "-h, --help" )
102
- . replace ( "@@description@@" , "output usage information" ) ;
116
+ . replace ( "@@description@@" , "output usage information" )
117
+ . replace ( "@@inherit@@" , "" ) ;
103
118
104
119
content = content . replace ( "@@options@@" , options ) ;
105
120
@@ -121,11 +136,11 @@ function showDetails(key) {
121
136
function populateListing ( ) {
122
137
var cmdKeys = Object . keys ( data ) ;
123
138
if ( filter ) {
124
- cmdKeys = cmdKeys . filter ( function ( k ) {
139
+ cmdKeys = cmdKeys . filter ( function ( k ) {
125
140
return k . indexOf ( filter ) !== - 1 ;
126
141
} ) ;
127
142
}
128
- var listing = cmdKeys . reduce ( function ( a , c ) {
143
+ var listing = cmdKeys . reduce ( function ( a , c ) {
129
144
a +=
130
145
"<li><a href=\"javascript:showDetails('" +
131
146
c +
@@ -159,32 +174,29 @@ function populateListing() {
159
174
}
160
175
}
161
176
162
- var subheaderItems = function ( ) {
163
- $ ( "#item_share" ) . click ( function ( evt ) {
177
+ var subheaderItems = function ( ) {
178
+ $ ( "#item_share" ) . click ( function ( evt ) {
164
179
evt . stopPropagation ( ) ;
165
180
$ ( "#sharing-menu" ) . css ( "display" , "block" ) ;
166
181
} ) ;
167
- $ ( "body" ) . click ( function ( ) {
182
+ $ ( "body" ) . click ( function ( ) {
168
183
$ ( "#sharing-menu" ) . css ( "display" , "none" ) ;
169
184
} ) ;
170
- $ ( "#item_contribute" ) . click ( function ( evt ) {
185
+ $ ( "#item_contribute" ) . click ( function ( evt ) {
171
186
var win = window . open ( "https://github.com/CatalystCode/spk" , "_blank" ) ;
172
187
win . focus ( ) ;
173
188
} ) ;
174
189
} ;
175
190
176
191
function loadCommands ( ) {
177
192
var url = version === "master" ? "./data.json" : "./data" + version + ".json" ;
178
- $ . getJSON ( url , function ( json ) {
193
+ $ . getJSON ( url , function ( json ) {
179
194
data = json ;
180
195
subheaderItems ( ) ;
181
196
populateListing ( ) ;
182
197
183
- $ ( "#commandfilter" ) . on ( "input" , function ( ) {
184
- filter = $ ( this )
185
- . val ( )
186
- . trim ( )
187
- . toLowerCase ( ) ;
198
+ $ ( "#commandfilter" ) . on ( "input" , function ( ) {
199
+ filter = $ ( this ) . val ( ) . trim ( ) . toLowerCase ( ) ;
188
200
populateListing ( ) ;
189
201
} ) ;
190
202
} ) ;
@@ -206,15 +218,15 @@ function showReleaseSelector(bShow) {
206
218
}
207
219
}
208
220
209
- $ ( function ( ) {
210
- $ ( "#btnSelectRelease" ) . on ( "click" , function ( evt ) {
221
+ $ ( function ( ) {
222
+ $ ( "#btnSelectRelease" ) . on ( "click" , function ( evt ) {
211
223
evt . stopPropagation ( ) ;
212
224
showReleaseSelector ( ) ;
213
225
} ) ;
214
- $ ( document . body ) . on ( "click" , function ( ) {
226
+ $ ( document . body ) . on ( "click" , function ( ) {
215
227
showReleaseSelector ( false ) ;
216
228
} ) ;
217
- $ ( document ) . keyup ( function ( evt ) {
229
+ $ ( document ) . keyup ( function ( evt ) {
218
230
if ( evt . keyCode === 27 ) {
219
231
showReleaseSelector ( false ) ;
220
232
}
0 commit comments