Miva - Product Description Cleaner
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Miva Text Cleaner</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>Miva Text Cleaner</h1>
<p>Paste product descriptions in here to replace invalid feed characters with their HTML entities.</p>
</div>
</div>
<div class="container">
<form action="#" name="data">
<h2>Dirty Input</h2>
<textarea name="input" cols="30" rows="10" class="form-control"></textarea>
<h3>Clean Output</h3>
<textarea name="output" cols="30" rows="10" class="form-control" readonly></textarea>
</form>
</div>
<script>
(function(){
var form = document.forms.data,
input = form.elements.input;
output = form.elements.output;
var cleanString = function(str){
return str.replace(/–/g, '-').replace(/…/g, '...').replace(/’/g, "'").replace(/“/g, '"').replace(/”/g, '"').replace(/\®/g, '®').replace(/\©/g, '©').replace(/\™/g, '™');
};
var cleanInputToOutput = function(){
output.value = cleanString(input.value);
};
input.addEventListener('input', cleanInputToOutput);
output.addEventListener('click focus', function(){
output.select();
});
})();
</script>
</body>
</html>