提交 | 用户 | 时间
|
e7c126
|
1 |
$(function() { |
H |
2 |
|
|
3 |
// init code editor |
|
4 |
var codeEditor; |
|
5 |
function initIde(glueSource) { |
|
6 |
if (codeEditor == null) { |
|
7 |
codeEditor = CodeMirror(document.getElementById("ideWindow"), { |
|
8 |
mode : ideMode, |
|
9 |
lineNumbers : true, |
|
10 |
matchBrackets : true, |
|
11 |
value: glueSource |
|
12 |
}); |
|
13 |
} else { |
|
14 |
codeEditor.setValue(glueSource); |
|
15 |
} |
|
16 |
} |
|
17 |
|
|
18 |
initIde($("#version_now").val()); |
|
19 |
|
|
20 |
// code change |
|
21 |
$(".source_version").click(function(){ |
|
22 |
var sourceId = $(this).attr('version'); |
|
23 |
var temp = $( "#" + sourceId ).val(); |
|
24 |
|
|
25 |
//codeEditor.setValue(''); |
|
26 |
initIde(temp); |
|
27 |
}); |
|
28 |
|
|
29 |
// code source save |
|
30 |
$("#save").click(function() { |
|
31 |
$('#saveModal').modal({backdrop: false, keyboard: false}).modal('show'); |
|
32 |
}); |
|
33 |
|
|
34 |
$("#saveModal .ok").click(function() { |
|
35 |
|
|
36 |
var glueSource = codeEditor.getValue(); |
|
37 |
var glueRemark = $("#glueRemark").val(); |
|
38 |
|
|
39 |
if (!glueRemark) { |
|
40 |
layer.open({ |
|
41 |
title: I18n.system_tips, |
|
42 |
btn: [ I18n.system_ok], |
|
43 |
content: I18n.system_please_input + I18n.jobinfo_glue_remark , |
|
44 |
icon: '2' |
|
45 |
}); |
|
46 |
return; |
|
47 |
} |
|
48 |
if (glueRemark.length <4 || glueRemark.length > 100) { |
|
49 |
layer.open({ |
|
50 |
title: I18n.system_tips , |
|
51 |
btn: [ I18n.system_ok ], |
|
52 |
content: I18n.jobinfo_glue_remark_limit , |
|
53 |
icon: '2' |
|
54 |
}); |
|
55 |
return; |
|
56 |
} |
|
57 |
|
|
58 |
$.ajax({ |
|
59 |
type : 'POST', |
|
60 |
url : base_url + '/jobcode/save', |
|
61 |
data : { |
|
62 |
'id' : id, |
|
63 |
'glueSource' : glueSource, |
|
64 |
'glueRemark' : glueRemark |
|
65 |
}, |
|
66 |
dataType : "json", |
|
67 |
success : function(data){ |
|
68 |
if (data.code == 200) { |
|
69 |
layer.open({ |
|
70 |
title: I18n.system_tips, |
|
71 |
btn: [ I18n.system_ok ], |
|
72 |
content: (I18n.system_save + I18n.system_success) , |
|
73 |
icon: '1', |
|
74 |
end: function(layero, index){ |
|
75 |
//$(window).unbind('beforeunload'); |
|
76 |
window.location.reload(); |
|
77 |
} |
|
78 |
}); |
|
79 |
} else { |
|
80 |
layer.open({ |
|
81 |
title: I18n.system_tips, |
|
82 |
btn: [ I18n.system_ok ], |
|
83 |
content: (data.msg || (I18n.system_save + I18n.system_fail) ), |
|
84 |
icon: '2' |
|
85 |
}); |
|
86 |
} |
|
87 |
} |
|
88 |
}); |
|
89 |
|
|
90 |
}); |
|
91 |
|
|
92 |
// before upload |
|
93 |
/*$(window).bind('beforeunload',function(){ |
|
94 |
return 'Glue尚未保存,确定离开Glue编辑器?'; |
|
95 |
});*/ |
|
96 |
|
|
97 |
}); |