Dedent this code by doing an early return instead of if.
This commit is contained in:
		
							parent
							
								
									faf0c62426
								
							
						
					
					
						commit
						00ad82e07c
					
				
					 1 changed files with 24 additions and 24 deletions
				
			
		|  | @ -396,35 +396,35 @@ function add_searchtag(box, value, inputted_list, li_class) | ||||||
|             remove_searchtag(box, existing_tag, inputted_list); |             remove_searchtag(box, existing_tag, inputted_list); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if (!already_have) |     if (already_have) | ||||||
|     { |     {return;} | ||||||
|         inputted_list.push(value); |  | ||||||
|         var new_li = document.createElement("li"); |  | ||||||
|         new_li.className = li_class; |  | ||||||
| 
 | 
 | ||||||
|         var new_span = document.createElement("span"); |     inputted_list.push(value); | ||||||
|         new_span.className = "tag_object"; |     var new_li = document.createElement("li"); | ||||||
|         new_span.innerHTML = value; |     new_li.className = li_class; | ||||||
| 
 | 
 | ||||||
|         var new_delbutton = document.createElement("button") |     var new_span = document.createElement("span"); | ||||||
|         new_delbutton.classList.add("remove_tag_button"); |     new_span.className = "tag_object"; | ||||||
|         new_delbutton.classList.add("red_button"); |     new_span.innerHTML = value; | ||||||
|         new_delbutton.onclick = function(){remove_searchtag(new_delbutton, value, inputted_list)}; |  | ||||||
| 
 | 
 | ||||||
|         new_li.appendChild(new_span); |     var new_delbutton = document.createElement("button") | ||||||
|         new_li.appendChild(new_delbutton); |     new_delbutton.classList.add("remove_tag_button"); | ||||||
|  |     new_delbutton.classList.add("red_button"); | ||||||
|  |     new_delbutton.onclick = function(){remove_searchtag(new_delbutton, value, inputted_list)}; | ||||||
| 
 | 
 | ||||||
|         box_li = box.parentElement; |     new_li.appendChild(new_span); | ||||||
|         ul = box_li.parentElement; |     new_li.appendChild(new_delbutton); | ||||||
|         ul.insertBefore(new_li, box_li); |  | ||||||
| 
 | 
 | ||||||
|         // The datalist autocomplete box can sometimes stick around after the |     box_li = box.parentElement; | ||||||
|         // tag has already been submitted and the input box moves down -- now |     ul = box_li.parentElement; | ||||||
|         // covered by the autocomplete. So we temporarily unfocus it to make |     ul.insertBefore(new_li, box_li); | ||||||
|         // that thing go away. | 
 | ||||||
|         box.blur(); |     // The datalist autocomplete box can sometimes stick around after the | ||||||
|         box.focus(); |     // tag has already been submitted and the input box moves down -- now | ||||||
|     } |     // covered by the autocomplete. So we temporarily unfocus it to make | ||||||
|  |     // that thing go away. | ||||||
|  |     box.blur(); | ||||||
|  |     box.focus(); | ||||||
| } | } | ||||||
| function remove_searchtag(li_member, value, inputted_list) | function remove_searchtag(li_member, value, inputted_list) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue