| -22,25 +25,29 |
|
| IE와 FF에서 자바스크립트를 처리하는 방식이 다른지, 구현에 문제가 좀 있었다. 다른 브라우저를 지원하기 위해서 별도의 수정이 필요할 지 모른다. 아래에 자세히 설명. (<index(호환성문제)>) |
|
| [http://mdiwebma.com/ WebMa]에서 탭을 닫을 때는 동작을 안 한다. 주의. |
| [http://mdiwebma.com/ WebMa]에서 탭을 닫을 때는 동작을 안 한다. 웹마 쓰는 사람들 주의<footnote(주인장은 정말 자주 당하는 경우이다. 탭을 십수개 띄운 상태에서 정리한다고 쓱쓱 지우다가 편집 중인 창까지 닫아버린다 -_-;)>. |
|
| === # wikiscript.js 수정 === |
| 다음 함수를 추가해 준다. chk_close()는 페이지가 unload 될 때에 (닫히거나 뒤로 가거나 등) 불리게 된다. closeok 변수가 false일 때는 경고창을 띄우게 된다. |
|
| {{{#!vim javascript |
| // 작성 취소 시 확인 |
| var closeok = false; |
| var previous_text = "", current_text = "", conflict = false, closeok = false; |
| function chk_close(e, str) { |
| if (!e) e = event; |
| if (!closeok) { |
| e.returnValue = str; |
| current_text = document.form_edit.text.value; |
|
| if (conflict || (previous_text != current_text)) { |
| e.returnValue = str; |
| } |
| } |
| } |
| }}} |
|
| === # wiki.pl 수정 === |
|
| 페이지 편집 모드(action=edit)일 때 body에다가 "on before unload" 이벤트를 잡아내어 chk_close()함수를 부르도록 한다. |
| 페이지 편집 모드(action=edit)거나 충돌이 발생했을 때 body에다가 "on before unload" 이벤트를 잡아내어 chk_close()함수를 부르도록 한다. |
|
| {{{#!vim perl |
| sub GetHtmlHeader { |
| -51,7 +58,10 |
| ############### |
|
| ### 작성 취소시 확인 - 이 단락 추가 |
| if ((lc(&GetParam("action","")) eq "edit") && (&UserCanEdit($id,1))) { |
| if ( |
| (&GetParam("oldtime", "") ne "") || |
| ((lc(&GetParam("action","")) eq "edit") && (&UserCanEdit($id,1))) |
| ) { |
| my $close_string = T('If you leave current page, the contents you are writing will not be stored.'); |
| $bodyExtra .= qq( onbeforeunload="chk_close(event, '$close_string')" ); |
| } |
| -63,16 +73,26 |
| } |
| }}} |
|
| 편집 폼에다가 submit시에는 경고창을 띄우지 않도록 closeok 변수를 true로 세팅하게 한다. |
| 편집 폼에다가 submit시에는 경고창을 띄우지 않도록 closeok 변수를 true로 세팅하게 한다. 또한 편집 모드에 들어간 직후에 텍스트 에리어에 있는 내용을 미리 저장해둔다. |
|
| {{{#!vim perl |
| sub DoEdit { |
| ... |
| ### 편집모드에 들어갔을때 포커스가 편집창에 있도록 한다 |
| # print &GetFormStart(); |
| # print &GetFormStart("form_edit"); 이 줄을 다시 아래와 같이 바꾼다 |
| print $q->startform(-method=>"POST", -action=>"$ScriptName", -enctype=>"application/x-www-form-urlencoded" ,-name=>"form_edit", -onSubmit=>"closeok=true; return true;") ; |
| # print &GetFormStart("form_edit"); # 이 줄을 다시 아래와 같이 바꾼다 |
| print $q->startform(-method=>"POST", -action=>"$ScriptName", -enctype=>"application/x-www-form-urlencoded", |
| -name=>"form_edit", -onSubmit=>"closeok=true; return true;"); |
| ### |
| ... |
| print "\n<script language=\"JavaScript\" type=\"text/javascript\">\n" |
| . "<!--\n" |
| . "previous_text = document.form_edit.text.value;\n" # 이 줄과 |
| . (($isConflict)?"conflict = true;\n":"") # 이 줄 추가 |
| . "document.form_edit.text.focus();\n" |
| . "//-->\n" |
| . "</script>\n"; |
| ... |
| } |
| }}} |
|