JQuery is the correct writing format:
Introduction: <script src= "/libs/jquery/jquery.js" type= "Text/javascript" ></script>
HTML notation:
Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<script src= "Modules-js/qiyi.js" ></script>
<script>
$ (function () {
Qiyiplugin.init ($ ("#zong_qiyi"));
});
</script>
<div id= "Zong_qiyi" >
Xxxxxxxxxxxxxx
</div>
jquery notation:
var qiyiplugin =
{
Init:function (parentnode) {
var self = this;
Self.parentnode = parentnode;
Refreshing local content
Self.parentnode
. On (' Refresh ', function (event) {
Self.qiyilist ();
});
},
Show
Qiyilist:function () {
var self = this;
Show internal strength Information
Self.getqiyilist (function (result) {
Console.log (result);
if (result.qiyilist) {
SELF.QIYIHTML1 ()//re-overwrite HTML to prevent repeated display of content
Self.displayqiyilist (result.qiyilist)//Show page content
}else{
Alert ("Do not get the odd art data, please check the interface");
}
});
},
Show Odd Art content
Displayqiyilist:function (qiyilist) {
var self = this;
var top = "#zong_qiyi";
$ (top). Find (' #qiyi_control_panel '). each (function () {
if ($ (this). Data (' data ')] $ (this). Remove ();
});
var line0 = $ (top). Find ("#qiyi_control_panel");
$.each (Qiyilist,function (index,item2) {
var line1 = $ (LINE0). Clone ();
$ (line1). Data (' data ', item2);//attached property data and information
$ (line1). attr (' id ', index+1);
$ (line1). Find ("#name"). HTML (item2.name);
$ (line1). Find ("#level"). HTML (item2.level);
$ (line1). Find ("#maxLevel"). HTML (item2.maxlevel);
$ (line1). Find ("#exp"). HTML (item2.exp+ "/" +item2.needexp);
$ (line1). Find ("#desc1"). HTML (ITEM2.DESC1);
$ (LINE0). before (line1);
$ (line1). Show ();
$ (line1). Find ("#upgrade")
. On (' click ', Function (event) {
var table = $ (this). Parents (' Table:first ');
var info = $ (table). Data (' data ');
Self.clicktoupgradeqiyi (info, function (result) {
if (!result.success) {
alert (RESULT.FAIL.DESC1);
}else{
alert (RESULT.SUCCESS.DESC1);
Growingplugin.playertopdata ()//Change Attrs property
Self.parentNode.trigger (' refresh ');
}
});
});
});
},
Assign HTML value-
Qiyihtml1:function () {
var string = "<table id= ' qiyi_control_panel ' class= ' table table-bordered table-hover ' style= '; width:500; ' > ";
string + = "<tr><td> Name: </TD><TD id=name>haoren_ internal strength </td></tr>";
string + = "<tr><td> Current Rating: </td><td id=level></td></tr>";
String = = "<tr><td> Max rating: </td><td id=maxlevel></td></tr>";
string + + "<tr><td>exp:</td><td id=exp></td></tr>";
string + = "<tr><td> Description: </td><td id=desc1></td></tr>";
string + + <tr><td><button id= ' upgrade ' class= ' btn btn-link ' > Upgrade </button></td></tr > ";
String = = "</table>";
$ ("#zong_qiyi"). HTML (string);
},
Qi Yi Upgrade
Clicktoupgradeqiyi:function (Info,callback) {
var query = "Operation=upgradeqiyi";
Query + + "&qiyiname=" + info.name;
Toolsplugin.play (Query,callback);
},
Get a list of odd arts
Getqiyilist:function (callback) {
var query = "Operation=getqiyilist";
Toolsplugin.play (Query,callback);
},
};