Textarea to tinymce wysiwyg in wordpress plugin

Hi guys, today i have to create a plugin to wordpress. In that i have task to make text area into a tinymce wysiwyg editable field. I learned how to do. I thought of sharing to you guys.

<?php
add_action(“admin_print_scripts”, “js_libs”);
function js_libs() {
wp_enqueue_script(‘tiny_mce’);
}
wp_tiny_mce( false , // true makes the editor “teeny”
array(
“editor_selector” => “tinymce_data”
)
);
?>

<script type=”text/javascript”>
jQuery(document).ready(function($) {
$(‘a.toggleVisual’).click(function() {
console.log(tinyMCE.execCommand(‘mceAddControl’, false, ‘tinymce_data’));
});
$(‘a.toggleHTML’).click(function() {
console.log(tinyMCE.execCommand(‘mceRemoveControl’, false, ‘tinymce_data’));
});
});
</script>

<form method=”post” action=””>
<ul>
<li>
<span id=”submit”><input class=”button” type=”submit”></span>
<p id=”toggle” align=”right”><a class=”button toggleVisual”>Visual</a><a class=”button toggleHTML”>HTML</a></p>
</li>
<li><textarea style=”width:100%;” class=”tinymce_data” id=”tinymce_data” name=”tinymce_data”></textarea></li>
</ul>
</form>