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.setMode("ace/mode/javascript");c.session.setUseWrapMode(!0);c.renderer.setScrollMargin(10,10);c.setOptions({autoScrollEditorIntoView:!0});c.on("change",function(){$("#myJS_form").data("changed",!0)});c.$blockScrolling=Infinity;c.setFontSize(16);$("#myJS_content_toolBar").jqxToolBar({width:"100%",height:35,minimizeWidth:100,tools:"button | button | combobox button | button | button",initTools:function(a,n,b,d){"button"==a&&b.attr("type","button");switch(n){case 0:b.val("\u683c\u5f0f\u5316");b.click(function(){var a=c.getValue();""!==a&&(a=js_beautify(a),c.setValue(a,-1))});break;case 1:b.val("\u538b\u7f29");b.click(function(){var a=c.getValue();""!==a&&(a=jsmin(a,3),c.setValue(a.trim(),-1))});break;case 2:b.attr("id","insert_jsTemplate_button");break;case 3:b.val("\u63d2\u5165\u6a21\u677f");b.click(function(){var a=$("#insert_jsTemplate_button").jqxComboBox("getSelectedIndex");0<=a&&$.ajax({url:urlbase+"?js_template_cmd\x3dget\x26name\x3d"+jsTemplate_dataAdapter.records[a].js_name,dataType:"json",timeout:interval,success:function(a){c.insert(a)},complete:function(a,b){"timeout"==b?alert("\u8f7d\u5165\u8d85\u65f6\uff01"):"parsererror"==b&&(window.location.href="login.php")}})});break;case 4:b.val("\u751f\u6210payload");b.click(function(){var a=$("#myJS_listbox").jqxListBox("getSelectedIndex");if(0<=a){var a=e.records[a],b=window.location.href.lastIndexOf("/"),a=window.location.href.substr(0,b+1)+a.js_uri;$("#Ww_B_0_textarea").val('\x3cscript src\x3d"'+a+'"\x3e\x3c/script\x3e');$("#xssorWindow").jqxWindow("open");$("#xssorWindow").addClass("animated")}else alert("\u8bf7\u5148\u4fdd\u5b58\uff01")});break;case 5:b.val("\u590d\u5236js\u5730\u5740"),(new ZeroClipboard(b)).on("copy",function(a){var b=$("#myJS_listbox").jqxListBox("getSelectedIndex");if(0<=b){a=a.clipboardData;var b=e.records[b],c=window.location.href.lastIndexOf("/"),b=window.location.href.substr(0,c+1)+b.js_uri;a.setData("text/plain",b)}else alert("\u8bf7\u5148\u4fdd\u5b58\uff01")})}}});$("#insert_jsTemplate_button").jqxComboBox({source:jsTemplate_dataAdapter,selectedIndex:0,displayMember:"js_name",valueMember:"js_name",width:200,autoDropDownHeight:!1,placeHolder:"\u9009\u62e9js\u6a21\u677f",renderer:function(a,c,b){a=jsTemplate_dataAdapter.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_ok").jqxButton({width:65,height:25});$("#myJS_cancel").jqxButton({width:65,height:25});$("#myJS_ok").click(function(a){var d=$("#myJS_name").val();a=$("#myJS_description").val();var b=c.getValue(),f=$("#myJS_listbox").jqxListBox("getSelectedIndex");-1===f?(a={name:d,desc:a,content:b},$.ajax({type:"POST",data:a,url:urlbase+"?my_js_cmd\x3dadd",dataType:"json",timeout:interval,success:function(a){a?(g=d,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")}})):(a={old_name:e.records[f].js_name,name:d,desc:a,content:b},$.ajax({type:"POST",data:a,url:urlbase+"?my_js_cmd\x3dmodify",dataType:"json",timeout:interval,success:function(a){a?(g=d,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_cancel").click(function(a){$("#myJS_form").data("changed",!1);a=$("#myJS_listbox").jqxListBox("getSelectedIndex");l(a)});$("#xssorWindow").jqxWindow({height:290,width:610,resizable:!1,isModal:!0,modalOpacity:.3,autoOpen:!1,title:"XSS'OR js\u7f16\u7801\u5de5\u5177"});$("#Ww_B_0_textarea").jqxTextArea({height:220,width:270});$("#rwb_b2").jqxButton();$("#rwb_b2_j").jqxButton();$("#rwb_b1").jqxButton();$("#rwb_b1_j").jqxButton();$("#rwb_b3").jqxButton();$("#rwb_b3j").jqxButton();$("#rwb_b4").jqxButton();$("#rwb_b4j").jqxButton();$("#rwb_b5").jqxButton();$("#rwb_b5j").jqxButton();$("#rwb_b6").jqxButton();$("#rwb_b6j").jqxButton();$("#rwb_b7").jqxButton();$("#rwb_b7j").jqxButton();$("#rwb_b8").jqxButton();$(window).resize(function(){var a=$("#nav-section").height()-$("#dash-logo").outerHeight(!0);$("#myJS_splitter").jqxSplitter({height:0<a?a:0});$("#myJS_listbox").jqxListBox({height:0<a-29?a-29:0});$("#myJS_content").height(0<a-207?a-207:0)})}); |