jobcode.index.1.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. $("#save").click(function() {
  10. var codeSource = codeEditor.getValue();
  11. var codeRemark = $("#codeRemark").val();
  12. if (!codeRemark) {
  13. ComAlert.show(1, "请输入备注");
  14. return;
  15. }
  16. if (codeRemark.length < 6|| codeRemark.length > 100) {
  17. ComAlert.show(1, "备注长度应该在6至100之间");
  18. return;
  19. }
  20. ComConfirm.show("是否执行保存操作?", function(){
  21. $.ajax({
  22. type : 'POST',
  23. url : base_url + '/jobcode/save',
  24. data : {
  25. 'jobInfo.id' : id,
  26. 'jobInfo.codeSource' : codeSource,
  27. 'jobInfo.codeRemark' : codeRemark
  28. },
  29. dataType : "json",
  30. success : function(data){
  31. if (data.code == 200) {
  32. ComAlert.show(1, '提交成功', function(){
  33. //$(window).unbind('beforeunload');
  34. window.location.reload();
  35. });
  36. } else {
  37. ComAlert.alert(data.msg);
  38. }
  39. }
  40. });
  41. });
  42. });
  43. // before upload
  44. /*$(window).bind('beforeunload',function(){
  45. return 'Glue尚未保存,确定离开Glue编辑器?';
  46. });*/
  47. });