add HTML entity de- and encoding
This commit is contained in:
		
							parent
							
								
									e6de88ef31
								
							
						
					
					
						commit
						feb7939488
					
				
					 1 changed files with 43 additions and 8 deletions
				
			
		
							
								
								
									
										37
									
								
								dencode.js
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								dencode.js
									
										
									
									
									
								
							|  | @ -92,6 +92,41 @@ | |||
| 					}; | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "encodehtmlentities", | ||||
| 			"name": "Encode HTML entities", | ||||
| 			"convert": function (input) { | ||||
| 				return { | ||||
| 					"status": "OK", | ||||
| 					"content": input | ||||
| 						.replace(/\&/g, "&") | ||||
| 						.replace(/\</g, "<") | ||||
| 						.replace(/\>/g, ">") | ||||
| 						.replace(/\"/g, """) | ||||
| 				}; | ||||
| 			} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "decodehtmlentities", | ||||
| 			"name": "Decode HTML entities", | ||||
| 			"convert": function (input) { | ||||
| 				try { | ||||
| 					return { | ||||
| 						"status": "OK", | ||||
| 						"content": input | ||||
| 							.replace(/\"\;/g, "\"") | ||||
| 							.replace(/\>\;/g, ">") | ||||
| 							.replace(/\<\;/g, "<") | ||||
| 							.replace(/\&\;/g, "&") | ||||
| 					}; | ||||
| 				} catch (exception) { | ||||
| 					return { | ||||
| 						"status": "ERROR", | ||||
| 						"content": "Invalid HTML entity string." | ||||
| 					}; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	]; | ||||
| 
 | ||||
|  | @ -151,7 +186,7 @@ | |||
| 		} | ||||
| 		if (appendNewOutput) { | ||||
| 			if (output !== "") { | ||||
| 				$output = $(template.replace(/\{index\}/g, "" + outputIndex).replace(/\{content\}/g, output)); | ||||
| 				$output = $(template.replace(/\{index\}/g, "" + outputIndex).replace(/\{content\}/g, output.replace(/\&/g, "&"))); | ||||
| 				if (status === "ERROR") { | ||||
| 					$output.find("textarea").addClass("error"); | ||||
| 				} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue