jobcode.index.1.js 1.4 KB

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