diff --git a/modules/editor/tpl/js/editor_common.js b/modules/editor/tpl/js/editor_common.js index d90458cf2..8bbcceefc 100644 --- a/modules/editor/tpl/js/editor_common.js +++ b/modules/editor/tpl/js/editor_common.js @@ -31,12 +31,16 @@ function editorFocus(editor_sequence) { * 자동 저장 기능 **/ // 자동 저장 활성화 시키는 함수 (50초마다 자동저장) -function editorEnableAutoSave(fo_obj, editor_sequence) { - var title = fo_obj.title.value; +function editorEnableAutoSave(fo_obj, editor_sequence, callback) { + var title = fo_obj.title.value; var content = editorRelKeys[editor_sequence]['content'].value; + editorAutoSaveObj = {"fo_obj":fo_obj, "editor_sequence":editor_sequence, "title":title, "content":content, locked:false}; - setTimeout('_editorAutoSave()', 50000); + + clearTimeout(editorEnableAutoSave.timer); + editorEnableAutoSave.timer = setTimeout(function(){_editorAutoSave(false, callback)}, 5000); } +editorEnableAutoSave.timer = null; // ajax를 이용하여 editor.procEditorSaveDoc 호출하여 자동 저장시킴 exe는 강제 코드 function _editorAutoSave(exe, callback) { @@ -44,7 +48,10 @@ function _editorAutoSave(exe, callback) { var editor_sequence = editorAutoSaveObj.editor_sequence; // 50초마다 동기화를 시킴 강제 실행은 제외 - if(!exe) setTimeout('_editorAutoSave()', 50000); + if(!exe) { + clearTimeout(editorEnableAutoSave.timer); + editorEnableAutoSave.timer = setTimeout(function(){ _editorAutoSave(exe, callback) }, 50000); + } // 현재 자동저장중이면 중지 if(editorAutoSaveObj.locked == true) return;