xxl-job

jobcode.index.1.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. $(function() {
  2. // init code editor
  3. var codeEditor = CodeMirror.fromTextArea(document.getElementById("codeSource"), {
  4. mode : "text/x-java",
  5. lineNumbers : true,
  6. matchBrackets : true
  7. });
  8. codeEditor.setValue( $("#demoCode").val() );
  9. // editor height
  10. var height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight);
  11. $(".CodeMirror").attr('style', 'height:'+ height +'px');
  12. // code source save
  13. $("#save").click(function() {
  14. var codeSource = codeEditor.getValue();
  15. var codeRemark = $("#codeRemark").val();
  16. if (!codeRemark) {
  17. ComAlert.show(2, "请输入备注");
  18. return;
  19. }
  20. if (codeRemark.length < 6|| codeRemark.length > 100) {
  21. ComAlert.show(2, "备注长度应该在6至100之间");
  22. return;
  23. }
  24. ComConfirm.show("是否执行保存操作?", function(){
  25. $.ajax({
  26. type : 'POST',
  27. url : base_url + '/jobcode/save',
  28. data : {
  29. 'jobInfo.id' : id,
  30. 'jobInfo.codeSource' : codeSource,
  31. 'jobInfo.codeRemark' : codeRemark
  32. },
  33. dataType : "json",
  34. success : function(data){
  35. if (data.code == 200) {
  36. ComAlert.show(1, '保存成功', function(){
  37. //$(window).unbind('beforeunload');
  38. window.location.reload();
  39. });
  40. } else {
  41. ComAlert.alert(data.msg);
  42. }
  43. }
  44. });
  45. });
  46. });
  47. // before upload
  48. /*$(window).bind('beforeunload',function(){
  49. return 'Glue尚未保存,确定离开Glue编辑器?';
  50. });*/
  51. });