xxl-job

jobcode.index.1.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. $(function() {
  2. // init code editor
  3. /*var codeEditor = CodeMirror.fromTextArea(document.getElementById("glueSource"), {
  4. mode : "text/x-java",
  5. lineNumbers : true,
  6. matchBrackets : true
  7. });*/
  8. var codeEditor;
  9. function initIde(glueSource) {
  10. if (codeEditor == null) {
  11. codeEditor = CodeMirror(document.getElementById("ideWindow"), {
  12. mode : ideMode,
  13. lineNumbers : true,
  14. matchBrackets : true,
  15. value: glueSource
  16. });
  17. } else {
  18. codeEditor.setValue(glueSource);
  19. }
  20. }
  21. initIde($("#version_now").val());
  22. // code change
  23. $(".source_version").click(function(){
  24. var sourceId = $(this).attr('version');
  25. var temp = $( "#" + sourceId ).val();
  26. //codeEditor.setValue('');
  27. initIde(temp);
  28. });
  29. // code source save
  30. $("#save").click(function() {
  31. $('#saveModal').modal({backdrop: false, keyboard: false}).modal('show');
  32. });
  33. $("#saveModal .ok").click(function() {
  34. var glueSource = codeEditor.getValue();
  35. var glueRemark = $("#glueRemark").val();
  36. if (!glueRemark) {
  37. layer.open({
  38. title: '系统提示',
  39. content: '请输入备注',
  40. icon: '2'
  41. });
  42. return;
  43. }
  44. if (glueRemark.length <4 || glueRemark.length > 100) {
  45. layer.open({
  46. title: '系统提示',
  47. content: '备注长度应该在4至100之间',
  48. icon: '2'
  49. });
  50. return;
  51. }
  52. $.ajax({
  53. type : 'POST',
  54. url : base_url + '/jobcode/save',
  55. data : {
  56. 'id' : id,
  57. 'glueSource' : glueSource,
  58. 'glueRemark' : glueRemark
  59. },
  60. dataType : "json",
  61. success : function(data){
  62. if (data.code == 200) {
  63. layer.open({
  64. title: '系统提示',
  65. content: '保存成功',
  66. icon: '1',
  67. end: function(layero, index){
  68. //$(window).unbind('beforeunload');
  69. window.location.reload();
  70. }
  71. });
  72. } else {
  73. layer.open({
  74. title: '系统提示',
  75. content: (data.msg || "保存失败"),
  76. icon: '2'
  77. });
  78. }
  79. }
  80. });
  81. });
  82. // before upload
  83. /*$(window).bind('beforeunload',function(){
  84. return 'Glue尚未保存,确定离开Glue编辑器?';
  85. });*/
  86. });