@@ -27,8 +27,6 @@ const FILE_DIALOG_CLASS = 'jp-codeSnippet-fileDialog';
2727 */
2828const CODE_SNIPPET_DIALOG_INPUT = 'jp-codeSnippet-dialog-input' ;
2929const CODE_SNIPPET_INPUTTAG_PLUS_ICON = 'jp-codeSnippet-inputTag-plusIcon' ;
30- const CODE_SNIPPET_INPUTNAME_VALIDITY = 'jp-codeSnippet-inputName-validity' ;
31- const CODE_SNIPPET_INPUTDESC_VALIDITY = 'jp-codeSnippet-inputDesc-validity' ;
3230const CODE_SNIPPET_INPUTTAG_LIST = 'jp-codeSnippet-inputTagList' ;
3331const CODE_SNIPPET_INPUT_TAG = 'jp-codeSnippet-inputTag' ;
3432const CODE_SNIPPET_INPUT_TAG_CHECK = 'jp-codeSnippet-inputTag-check' ;
@@ -229,23 +227,12 @@ export function validateForm(
229227 let status = true ;
230228 let message = '' ;
231229 const name = input . value [ 0 ] ;
232- const description = input . value [ 1 ] ;
233230 const language = input . value [ 2 ] ;
234231
235232 if ( name === '' ) {
236233 message += 'Name must be filled out\n' ;
237234 status = false ;
238235 }
239- if ( name . match ( / [ ^ a - z A - Z 0 - 9 _ ] + / ) ) {
240- //allow lowercase, uppercase, alphanumeric, and underscore
241- message += 'Wrong format of the name\n' ;
242- status = false ;
243- }
244- if ( description . match ( / [ ^ a - z A - Z 0 - 9 _ , . ? ! ] + / ) ) {
245- //alphanumeric but can include space or punctuation
246- message += 'Wrong format of the description\n' ;
247- status = false ;
248- }
249236 if ( language === '' ) {
250237 message += 'Language must be filled out\n' ;
251238 status = false ;
@@ -254,6 +241,7 @@ export function validateForm(
254241 message += 'Language must be one of the options' ;
255242 status = false ;
256243 }
244+ // TODO: change it to a better UI
257245 if ( status === false ) {
258246 alert ( message ) ;
259247 }
@@ -315,29 +303,20 @@ class Private {
315303 static createInputNode ( tags : string [ ] ) : HTMLElement {
316304 Private . allTags = tags ;
317305 const body = document . createElement ( 'form' ) ;
318- const nameValidity = document . createElement ( 'p' ) ;
319- nameValidity . textContent =
320- 'Name of the code snippet MUST be alphanumeric, or composed of underscore(_)' ;
321- nameValidity . className = CODE_SNIPPET_INPUTNAME_VALIDITY ;
322-
323- const descriptionValidity = document . createElement ( 'p' ) ;
324- descriptionValidity . textContent =
325- 'Description of the code snippet MUST be alphanumeric but can include space or punctuation' ;
326- descriptionValidity . className = CODE_SNIPPET_INPUTDESC_VALIDITY ;
327306
328307 const nameTitle = document . createElement ( 'label' ) ;
329308 nameTitle . textContent = 'Snippet Name (required)' ;
330309 const name = document . createElement ( 'input' ) ;
331310 name . className = CODE_SNIPPET_DIALOG_INPUT ;
332311 name . required = true ;
333- name . pattern = '[a-zA-Z0-9_]+ ' ;
312+ name . placeholder = 'Ex. starter code ' ;
334313 name . onblur = Private . handleOnBlur ;
335314
336315 const descriptionTitle = document . createElement ( 'label' ) ;
337316 descriptionTitle . textContent = 'Description (optional)' ;
338317 const description = document . createElement ( 'input' ) ;
339318 description . className = CODE_SNIPPET_DIALOG_INPUT ;
340- description . pattern = '[a-zA-Z0-9_ ,.?!]+ ' ;
319+ description . placeholder = 'Description ' ;
341320 description . onblur = Private . handleOnBlur ;
342321
343322 const languageTitle = document . createElement ( 'label' ) ;
@@ -391,10 +370,8 @@ class Private {
391370
392371 body . appendChild ( nameTitle ) ;
393372 body . appendChild ( name ) ;
394- body . appendChild ( nameValidity ) ;
395373 body . appendChild ( descriptionTitle ) ;
396374 body . appendChild ( description ) ;
397- body . appendChild ( descriptionValidity ) ;
398375 body . appendChild ( languageTitle ) ;
399376 body . appendChild ( languageInput ) ;
400377 body . appendChild ( languageOption ) ;
0 commit comments