Rewritten HTML encoding tool for Blogger

Today I have written HTML tool for blogger. It was earlier in PHP and now it is in JavaScript. HTML encoding application written in PHP was converting converting &, ", ', for posting codes online. I intended to do that in JavaScript. It can be simple as just searching each characters and replacing with html entities. But in my case I want to provide the facility of mixed encoded text converted correctly. PHP based application was doing it correctly except it replace "" from escape characters. If the text was having "n" then it was becoming "n". It was not the case of writing the encoding application in JavaScript. I have just written it for fun. Mistakenly I have written the new JavaScript application which translate extra characters as well into html entities. Instead of behaving like htmlspecialchars(), it behave like htmlentities(). But this cannot be a problem. Instead it should be useful. I have left the old application link on the page, so if you were using the old application and like to continue with that then you can continue. As old application, it takes care of already encoded character and do not reconvert that again. So, if you had few characters as '&' then this will not become '&'.

Check the new online JavaScript encoding application.

Here is JavaScript code used there:

<script type="text/javascript">
	function giveMsg(msg1) {
		document.getElementById("msgDiv").innerHTML =  msg1 ;
		document.getElementById("msgDiv").className = 'msg';
		window.setTimeout('giveMsg("")', 5000);
	function convertIt() {
		var txtArea		= document.getElementById('data');
		var txtAreaVal	= txtArea.value;
		var noquote = document.getElementById('noquotes');
		var noquoteVal = noquote.checked;
		// do not convert single and double quotes
		if (noquoteVal) {
			var tmpVal = html_entity_decode (txtAreaVal);
			txtArea.value = htmlentities(tmpVal, "ENT_NOQUOTES");
			// restore single quote. Due to a bug in php.js org htmlentities function, this is required!
			$trans = {''' : "'" };
			txtArea.value = strtr(txtArea.value, $trans);
		else { // convert single and double quotes as well
			var tmpVal = html_entity_decode(txtAreaVal);
			txtArea.value = htmlentities(tmpVal, "ENT_QUOTES");
		giveMsg('Characters converted.');

This is not the only JavaScript I am using. For getting other then above JavaScript code, please use this URL: htmlspecialchars.js. I have taken these functions from, which I have mentioned earlier.

Here is the HTML code in action:

<!doctype html>
	<title> Webmaster tool: Encode code before posting on blog </title>
	<meta http-equiv=Content-Type content="text/html; charset=utf-8" />
	<meta name="keywords" content="encode, code, html, adsense, blogspot, wordpress" />
	<meta name="description" content="Code/script encoding before posting online (blog/Website). Blogspot Adsense code need to be encoded before posting inside HTML" />
		body {font-size:85%;margin-left:10px;}
		.big {font-size:16px;}
		h1 {margin:0px;}
		.footer {font-size:0.8em}
		.msg {font-weight:bold;color:red}
<div id="msgDiv"></div>
<form method=post action="" onsubmit="return checkForm(this);">
<textarea id="data" name="data" rows="20" cols="120" wrap="soft"><?php echo htmlspecialchars(stripslashes($_POST['data'])); ?></textarea>
<div style="width:800px;position:relative">
Do not convert <b class="big">"</b> and <b class="big">'</b> characters.
<input type="checkbox" id="noquotes" name="noquotes" checked="checked">
<div style="float:right"><input type="button" onclick="convertIt();" name="convert" value="Convert" > </div>
It will take care of already converted characters.

If I have missed any code and if you find any broken line then you can visit the online HTML encoding tool and check that yourself! As it is all in client side language.
Here is the post I have written when I made online encoding tool based on PHP.

Comments are open for an year period. Please, write here on Facebook page.