1 line
8.6 KiB
JavaScript
1 line
8.6 KiB
JavaScript
|
|
$(document).ready(function(){function l(a){if(f)f=!1;else{if($("#myJS_form").data("changed"))if(confirm("------------------------------------\n\u63d0\u793a\uff1a\u672a\u4fdd\u5b58\u7684\u5185\u5bb9\u5c06\u4f1a\u4e22\u5931\uff01\n------------------------------------\n\n\u786e\u8ba4\u79bb\u5f00\u5417\uff1f"))$("#myJS_form").data("changed",!1),k=a;else{f=!0;$("#myJS_listbox").jqxListBox("selectIndex",k);return}else k=a;-1===a?($("#myJS_ok").text("\u65b0\u589e"),$("#myJS_name").val(""),$("#myJS_description").val(""),c.setValue("",-1),$("#myJS_form").data("changed",!1)):($("#myJS_ok").text("\u4fee\u6539"),a=e.records[a],$("#myJS_name").val(a.js_name),$("#myJS_description").val(a.js_description),m(a.js_name))}}function m(a){$("#myJS_form").data("changed",!1);c.setReadOnly(!0);$.ajax({url:urlbase+"?my_js_cmd\x3dget\x26name\x3d"+a,dataType:"json",timeout:interval,success:function(a){c.setValue(a,-1);$("#myJS_form").data("changed",!1);c.setReadOnly(!1)},complete:function(a,b){"timeout"==b?alert("\u8f7d\u5165\u8d85\u65f6\uff01"):"parsererror"==b&&(window.location.href="login.php")}})}function h(){$("#myJS_form").data("changed",!1);e.dataBind()}var d=$("#nav-section").height()-$("#dash-logo").outerHeight(!0);$("#myJS_splitter").jqxSplitter({width:"100%",height:0<d?d:0,panels:[{size:"400px"}]});var k=-1,f=!1,g="",e=new $.jqx.dataAdapter({datatype:"json",datafields:[{name:"js_uri"},{name:"js_name"},{name:"js_description"},{name:"js_name_abbr"},{name:"js_description_abbr"}],id:"js_name",url:urlbase+"?my_js_cmd\x3dlist"},{loadComplete:function(){""!==g&&($("#myJS_listbox").jqxListBox("selectItem",g),g="")}});$("#myJS_listbox").jqxListBox({selectedIndex:-1,source:e,displayMember:"js_name",valueMember:"js_name",itemHeight:60,width:"100%",height:0<d-29?d-29:0,renderer:function(a,c,b){a=e.records[a];return'\x3ctable class\x3d"listbox_item_table"\x3e\x3ctr\x3e\x3ctd class\x3d"listbox_item_img" rowspan\x3d"2"\x3e\x3cimg height\x3d"50" width\x3d"50" src\x3d"static/images/js_icon.png"/\x3e\x3c/td\x3e\x3ctd class\x3d"listbox_item_name"\x3e'+a.js_name_abbr+'.js\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd class\x3d"listbox_item_description"\x3e'+a.js_description_abbr+"\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e"}});$("#myJS_listbox").on("select",function(a){l(a.args.index)});$("#myJS_add_button").jqxButton({width:65,height:20});$("#myJS_del_button").jqxButton({width:65,height:20});$("#myJS_clear_button").jqxButton({width:65,height:20});$("#myJS_add_button").click(function(a){$("#myJS_listbox").jqxListBox("selectIndex",-1)});$("#myJS_del_button").click(function(a){a=$("#myJS_listbox").jqxListBox("getSelectedIndex");0<=a&&confirm("\u60a8\u786e\u8ba4\u6267\u884c\u5220\u9664\u64cd\u4f5c\u4e48\uff1f")&&$.ajax({url:urlbase+"?my_js_cmd\x3ddel\x26name\x3d"+e.records[a].js_name,dataType:"json",timeout:interval,success:function(a){a?($("#myJS_listbox").jqxListBox("selectIndex",-1),h()):($("#failedWindow").jqxWindow("open"),$("#failedWindow").addClass("animated"))},complete:function(a,b){"timeout"==b?($("#failedWindow").jqxWindow("open"),$("#failedWindow").addClass("animated")):"parsererror"==b&&(window.location.href="login.php")}})});$("#myJS_clear_button").click(function(a){confirm("\u60a8\u786e\u8ba4\u6e05\u7a7a\u6240\u6709JS\u6a21\u677f\u4e48\uff1f")&&$.ajax({url:urlbase+"?my_js_cmd\x3dclear",dataType:"json",timeout:interval,success:function(a){a?($("#myJS_listbox").jqxListBox("selectIndex",-1),h()):($("#failedWindow").jqxWindow("open"),$("#failedWindow").addClass("animated"))},complete:function(a,b){"timeout"==b?($("#failedWindow").jqxWindow("open"),$("#failedWindow").addClass("animated")):"parsererror"==b&&(window.location.href="login.php")}})});$("#myJS_form").change(function(){$("#myJS_form").data("changed",!0)});$("#myJS_name").jqxInput({width:"80%",height:"20px",placeHolder:"\u8bf7\u8f93\u5165js\u6a21\u677f\u540d..."});$("#myJS_description").jqxTextArea({width:"100%",height:50,placeHolder:"\u8bf7\u8f93\u5165js\u6a21\u677f\u63cf\u8ff0..."});$("#myJS_content").height(0<d-207?d-207:0);var c=ace.edit("myJS_content");c.setTheme("ace/theme/chrome");c.session.setMod
|