client script(js)

how to convert following yii js code to yii2 version someone please help…

i have changed small thing but it couldn’t work in my page.

<?php

$this->registerJs(‘formscript’, <<<JAVASCRIPT

var oTable;

$(document).ready(function(){

oTable = $(’#entry_dt’).dataTable({

    &quot;sScrollX&quot;: &quot;100%&quot;,


  //  &quot;sScrollXInner&quot;: &quot;800%&quot;,


    &quot;bScrollCollapse&quot;: true, 


	&quot;sScrollY&quot;: &quot;200px&quot;,


    


 });


  oTable.fnSetColumnVis( 1, false );


  oTable.fnSetColumnVis( 0, false );


 /* Add a click handler for the delete row */


&#036;('#entry_dt tr').live('click', function(i) {


    var rowindex = oTable.fnGetPosition(&#036;(this).closest('tr')[0]);


     fnGetSelected( oTable ,rowindex);


});

});

function fnShowHide( iCol )

{

/* Get the DataTables object again - this is not a recreation, just a get of the object */


var oTable = &#036;('#entry_dt').dataTable();


 


var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;


oTable.fnSetColumnVis( iCol, bVis ? false : true );


if(bVis){ &#036;(&quot;#toggle_column_&quot;+iCol).removeClass(&quot;selected&quot;); 	}


else {  &#036;(&quot;#toggle_column_&quot;+iCol).addClass(&quot;selected&quot;); 	}

}

/* Get the rows which are currently selected */

function fnGetSelected( oTableLocal,rindex )

{

var aReturn = new Array();


var aTrs = oTableLocal.fnGetNodes();


//alert(rindex);


aData=oTableLocal.fnGetData(rindex);


//alert(aData[1]);


var f_id     = aData[0].replace(/&lt;&#092;/?[^&gt;]+(&gt;|&#036;)/g, &quot;&quot;);


var e_id     = aData[1].replace(/&lt;&#092;/?[^&gt;]+(&gt;|&#036;)/g, &quot;&quot;);








&#036;.ajax({


		type: &quot;POST&quot;,


		async: true,


		url: entries_view_url,


		data: {


			id:  f_id,


			eid: e_id,      


		},


		cache: false,


		global: true,


		dataType: &quot;html&quot;,


		error: function (h, f, g) {


			


		},


		success: function (e) {


			&#036;(&quot;#entry_detail&quot;).empty();


			&#036;(&quot;#entry_detail&quot;).append(e);


		}


	})

}

function deleteEntry(f_id,e_id) {

jConfirm(“This action cannot be undone.<br/><strong>All data collected by the form will be deleted as well.</strong><br/><br/>If you are sure with this, you can continue deleting this field.<br /><br />”, ‘Are you sure you want to delete this field?"’, function® {

if®{

&#036;.ajax({


		type: &quot;POST&quot;,


		async: true,


		url: entries_delete_url,


		data: {


			id:  f_id,


			eid: e_id,      


		},


		cache: false,


		global: true,


		dataType: &quot;json&quot;,


		error: function (h, f, g) {


			


		},


		success: function (e) {


			if(e.status == &quot;ok&quot;){


				 document.location.reload(true);


			}


			else {


					jAlert(&quot;Please try again within few minutes.&lt;br/&gt;unable to reach the server&#33;&quot;);


					return false;           


			}


		}


	})

}

})

}

function emailEntry(f_id,e_id){

$("#fid").val(f_id);

$("#eid").val(e_id);

$( "#dialog-form" ).dialog( "open" );

}

var frm_address = $( "#frm_address" ),

        to_address = &#036;( &quot;#to_address&quot; ),


        subject = &#036;( &quot;#subject&quot; ),


        allFields = &#036;( [] ).add( frm_address ).add( to_address ).add( subject ),


        tips = &#036;( &quot;.validateTips&quot; );


    function updateTips( t ) {


        tips


            .text( t )


            .addClass( &quot;ui-state-highlight&quot; );


        setTimeout(function() {


            tips.removeClass( &quot;ui-state-highlight&quot;, 1500 );


        }, 500 );


    }





    function checkLength( o, n, min, max ) {


        if ( o.val().length &gt; max || o.val().length &lt; min ) {


            o.addClass( &quot;ui-state-error&quot; );


            updateTips( &quot;Length of &quot; + n + &quot; must be between &quot; +


                min + &quot; and &quot; + max + &quot;.&quot; );


            return false;


        } else {


            return true;


        }


    }


    function isValidEmailAddress(emailAddress) {


		var pattern = new RegExp(/^([&#092;w-&#092;.]+)@((&#092;[[0-9]{1,3}&#092;.[0-9]{1,3}&#092;.[0-9]{1,3}&#092;.)|(([&#092;w-]+&#092;.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(&#092;]?)&#036;/);


		bool = pattern.test(emailAddress.val());


		if(&#33;bool) return false;


		else      return true;


	}


    function checkRegexp( o, regexp, n ) {


        if ( &#33;( regexp.test( o.val() ) ) ) {


            o.addClass( &quot;ui-state-error&quot; );


            updateTips( n );


            return false;


        } else {


            return true;


        }


    }





    &#036;( &quot;#dialog-form&quot; ).dialog({


        autoOpen: false,


        height: 300,


        width: 350,


        modal: true,


        buttons: {


            &quot;sendMail&quot;: function() {


                var bValid = true;


                allFields.removeClass( &quot;ui-state-error&quot; );





                bValid = bValid &amp;&amp; checkLength( frm_address, &quot;From Address&quot;, 2, 80 );


                bValid = bValid &amp;&amp; checkLength( to_address, &quot;To Address&quot;, 2, 80 );


                bValid = bValid &amp;&amp; checkLength( subject, &quot;Subject&quot;, 2, 30 );


				bValid = bValid &amp;&amp; isValidEmailAddress(frm_address);


				bValid = bValid &amp;&amp; isValidEmailAddress(to_address);


                bValid = bValid &amp;&amp; checkRegexp( subject, /^([0-9a-zA-Z])+&#036;/, &quot;Password field only allow : a-z 0-9&quot; );


				                   


                if ( bValid ) {


			


                   	&#036;.ajax({


							type: &quot;POST&quot;,


							async: true,


							url: email_url,


							data: {


								 from_address: &#036;(&quot;#frm_address&quot;).val(),


								 to_address: &#036;(&quot;#to_address&quot;).val(),


								 subject: &#036;(&quot;#subject&quot;).val(),


								 id: &#036;(&quot;#fid&quot;).val(),


								 eid: &#036;(&quot;#eid&quot;).val()


							},


							cache: false,


							global: true,


							dataType: &quot;json&quot;,


							error: function (h, f, g) {


							},


							success: function (e) {


							}


							})


                   &#036;( this ).dialog( &quot;close&quot; );


                }


            },


            Cancel: function() {


                &#036;( this ).dialog( &quot;close&quot; );


            }


        },


        close: function() {


            allFields.val( &quot;&quot; ).removeClass( &quot;ui-state-error&quot; );


        }


    });

function showColumnTitle(){

if(&#036;(&quot;#showColumn&quot;).is(&quot;:visible&quot;)){


  &#036;(&quot;#showColumn&quot;).hide();


}


else {


  &#036;(&quot;#showColumn&quot;).show();


}

}

function columnTitle() {

&#036;(&quot;#showColumn&quot;).hide();

}

function showEntryView(f_id,e_id){

$.ajax({

		type: &quot;POST&quot;,


		async: true,


		url: entries_view_url,


		data: {


			id:  f_id,


			eid: e_id,      


		},


		cache: false,


		global: true,


		dataType: &quot;html&quot;,


		error: function (h, f, g) {


			


		},


		success: function (e) {


			&#036;(&quot;#entry_detail&quot;).empty();


			&#036;(&quot;#entry_detail&quot;).append(e);


		}


	})

}

JAVASCRIPT

, View::POS_END);

?>