임시저장 json 버전 개발 완료
This commit is contained in:
@ -4,21 +4,19 @@ include_once('./_common.php');
|
|||||||
if (!$is_member) die('0');
|
if (!$is_member) die('0');
|
||||||
|
|
||||||
$uid = escape_trim($_REQUEST['uid']);
|
$uid = escape_trim($_REQUEST['uid']);
|
||||||
$subject = escape_trim($_REQUEST['subject']);
|
$subject = escape_trim(stripslashes($_REQUEST['subject']));
|
||||||
$content = escape_trim($_REQUEST['content']);
|
$content = escape_trim(stripslashes($_REQUEST['content']));
|
||||||
|
//$subject = escape_trim(htmlentities($_REQUEST['subject'], ENT_QUOTES));
|
||||||
|
//$content = escape_trim($_REQUEST['content']);
|
||||||
|
|
||||||
/*
|
if ($subject && $content) {
|
||||||
$uid = get_session("ss_autosave_uid");
|
$sql = " select count(*) as cnt from {$g4['autosave_table']} where mb_id = '{$member['mb_id']}' and as_subject = '$subject' and as_content = '$content' ";
|
||||||
if (!$uid) {
|
$row = sql_fetch($sql);
|
||||||
$uid = get_uniqid();
|
if (!$row['cnt']) {
|
||||||
set_session("ss_autosave_uid", $uid);
|
$sql = " insert into {$g4['autosave_table']} set mb_id = '{$member['mb_id']}', as_uid = '{$uid}', as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' on duplicate key update as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' ";
|
||||||
}
|
$result = sql_query($sql, false);
|
||||||
*/
|
|
||||||
|
|
||||||
if ($content) {
|
echo autosave_count($member['mb_id']);
|
||||||
$sql = " insert into {$g4['autosave_table']} set mb_id = '{$member['mb_id']}', as_uid = '{$uid}', as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' on duplicate key update as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' ";
|
}
|
||||||
$result = sql_query($sql, false);
|
|
||||||
|
|
||||||
echo autosave_count($member['mb_id']);
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
16
bbs/ajax.autosavelist.php
Normal file
16
bbs/ajax.autosavelist.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
include_once('./_common.php');
|
||||||
|
|
||||||
|
if (!$is_member) die('');
|
||||||
|
|
||||||
|
$sql = " select as_id, as_subject, as_datetime from {$g4['autosave_table']} where mb_id = '{$member['mb_id']}' order by as_id desc ";
|
||||||
|
$result = sql_query($sql);
|
||||||
|
$arr = array();
|
||||||
|
for ($i=0; $row=sql_fetch_array($result); $i++) {
|
||||||
|
//$subject = utf8_strcut(stripslashes($row['as_subject']), 25);
|
||||||
|
$subject = htmlspecialchars(utf8_strcut($row['as_subject'], 25), ENT_QUOTES);
|
||||||
|
$datetime = substr($row['as_datetime'],2,14);
|
||||||
|
$arr[] = "{\"id\": \"{$row['as_id']}\", \"subject\": \"{$subject}\", \"datetime\": \"{$datetime}\"}";
|
||||||
|
}
|
||||||
|
echo "{\"autosave\":[".implode(", ", $arr)."]}";
|
||||||
|
?>
|
||||||
15
bbs/ajax.autosaveload.php
Normal file
15
bbs/ajax.autosaveload.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
include_once('./_common.php');
|
||||||
|
|
||||||
|
if (!$is_member) die('');
|
||||||
|
|
||||||
|
$as_id = (int)$_REQUEST['as_id'];
|
||||||
|
|
||||||
|
$sql = " select as_subject, as_content from {$g4['autosave_table']} where mb_id = '{$member['mb_id']}' and as_id = {$as_id} ";
|
||||||
|
$row = sql_fetch($sql);
|
||||||
|
//$subject = stripslashes($row['as_subject']);
|
||||||
|
//$content = stripslashes($row['as_content']);
|
||||||
|
$subject = str_replace("\'", "\\\'", addslashes($row['as_subject']));
|
||||||
|
$content = stripslashes($row['as_content']);
|
||||||
|
echo "{\"subject\":\"{$subject}\", \"content\":\"{$content}\"}";
|
||||||
|
?>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
/* 게시판 쓰기 */
|
/* 게시판 쓰기 */
|
||||||
#autosave_wrapper {position:relative}
|
#autosave_wrapper {position:relative}
|
||||||
#autosave_pop {z-index:10;position:absolute;top:24px;right:117px;padding:8px;width:300px;height:auto !important;height:180px;max-height:180px;border:1px solid #565656;background:#fff;overflow-y:scroll}
|
#autosave_pop {display:none;z-index:10;position:absolute;top:24px;right:117px;padding:8px;width:350px;height:auto !important;height:180px;max-height:180px;border:1px solid #565656;background:#fff;overflow-y:scroll}
|
||||||
html.no-overflowscrolling #autosave_pop {height:auto;max-height:10000px !important} /* overflow 미지원 기기 대응 */
|
html.no-overflowscrolling #autosave_pop {height:auto;max-height:10000px !important} /* overflow 미지원 기기 대응 */
|
||||||
#autosave_pop strong {position:absolute;font-size:0;line-height:0;overflow:hidden}
|
#autosave_pop strong {position:absolute;font-size:0;line-height:0;overflow:hidden}
|
||||||
#autosave_pop div {text-align:right}
|
#autosave_pop div {text-align:right}
|
||||||
@ -45,6 +45,8 @@ html.no-overflowscrolling #autosave_pop {height:auto;max-height:10000px !importa
|
|||||||
#autosave_pop li:after {display:block;visibility:hidden;clear:both;content:""}
|
#autosave_pop li:after {display:block;visibility:hidden;clear:both;content:""}
|
||||||
#autosave_pop a {display:block;float:left}
|
#autosave_pop a {display:block;float:left}
|
||||||
#autosave_pop span {display:block;float:right}
|
#autosave_pop span {display:block;float:right}
|
||||||
|
.autosave_close {cursor:pointer;}
|
||||||
|
.autosave_content {display:none;}
|
||||||
|
|
||||||
/* 게시판 읽기 */
|
/* 게시판 읽기 */
|
||||||
#bo_v {margin-bottom:20px;padding-bottom:20px}
|
#bo_v {margin-bottom:20px;padding-bottom:20px}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
|||||||
<h2 id="wrapper_title"><?php echo $g4['title'] ?></h2>
|
<h2 id="wrapper_title"><?php echo $g4['title'] ?></h2>
|
||||||
|
|
||||||
<!-- 게시물 작성/수정 시작 { -->
|
<!-- 게시물 작성/수정 시작 { -->
|
||||||
<form name="fwrite" id="fwrite" class="autosave" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">
|
<form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">
|
||||||
<input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
|
<input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
|
||||||
<input type="hidden" name="w" value="<?php echo $w ?>">
|
<input type="hidden" name="w" value="<?php echo $w ?>">
|
||||||
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
|
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
|
||||||
@ -107,23 +107,18 @@ echo $option_hidden;
|
|||||||
<div id="autosave_wrapper">
|
<div id="autosave_wrapper">
|
||||||
<input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">
|
<input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">
|
||||||
<?php if ($is_member) { ?>
|
<?php if ($is_member) { ?>
|
||||||
<button type="button" class="btn_frmline">임시 저장된 글 (<span id="autosave_count"><?php echo $autosave_count; ?></span>)</button>
|
<button type="button" id="btn_autosave" class="btn_frmline">임시 저장된 글 (<span id="autosave_count"><?php echo $autosave_count; ?></span>)</button>
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<div id="autosave_pop">
|
<div id="autosave_pop">
|
||||||
<strong>임시 저장된 글 목록</strong>
|
<strong>임시 저장된 글 목록</strong>
|
||||||
<div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>
|
<div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php // for 시작 ?>
|
||||||
// for 시작
|
<!-- <li><a href="#none" class="autosave_load">저장제목</a><span>일시 <button type="button" class="autosave_del">삭제</button></span></li> -->
|
||||||
?>
|
<?php // for 끝 ?>
|
||||||
<li><a href="#none" class="autosave_load">저장제목</a><span>일시 <button type="button" class="autosave_del">삭제</button></span></li>
|
|
||||||
<?php
|
|
||||||
// for 끝
|
|
||||||
?>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>
|
<div><button type="button" class="autosave_close"><img src="<?php echo $board_skin_url; ?>/img/btn_close.gif" alt="닫기"></button></div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -238,27 +233,79 @@ function fwrite_submit(f)
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
<?php if ($is_member) { ?>
|
<?php if ($is_member) { ?>
|
||||||
|
// 글의 제목과 내용을 저장하는 변수
|
||||||
|
var save_wr_subject = "";
|
||||||
|
var save_wr_content = "";
|
||||||
function autosave() {
|
function autosave() {
|
||||||
jQuery("form.autosave").each(function() {
|
$("form#fwrite").each(function() {
|
||||||
if (typeof(CKEDITOR.instances.wr_content)!="undefined")
|
if (typeof(CKEDITOR.instances.wr_content)!="undefined")
|
||||||
this.wr_content.value = CKEDITOR.instances.wr_content.getData();
|
this.wr_content.value = CKEDITOR.instances.wr_content.getData();
|
||||||
jQuery.ajax({
|
// 변수에 저장해 놓은 값과 다를 경우에만 임시 저장함
|
||||||
url: g4_bbs_url+"/ajax.autosave.php",
|
if (save_wr_subject != this.wr_subject.value || save_wr_content != this.wr_content.value) {
|
||||||
data: {
|
$.ajax({
|
||||||
"uid" : this.uid.value,
|
url: g4_bbs_url+"/ajax.autosave.php",
|
||||||
"subject": this.wr_subject.value,
|
data: {
|
||||||
"content": this.wr_content.value
|
"uid" : this.uid.value,
|
||||||
},
|
"subject": this.wr_subject.value,
|
||||||
type: "POST",
|
"content": this.wr_content.value
|
||||||
success: function(data){
|
},
|
||||||
if (data) {
|
type: "POST",
|
||||||
$("#autosave_count").html(data);
|
success: function(data){
|
||||||
|
if (data) {
|
||||||
|
$("#autosave_count").html(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
save_wr_subject = this.wr_subject.value;
|
||||||
|
save_wr_content = this.wr_content.value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(autosave, 3 * 1000);
|
setInterval(autosave, 1 * 1000);
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
$("#btn_autosave").click(function(){
|
||||||
|
if ($("#autosave_pop").is(":hidden")) {
|
||||||
|
$.get(g4_bbs_url+"/ajax.autosavelist.php", function(data){
|
||||||
|
//<li><a href="#none" class="autosave_load">저장제목</a><span>일시 <button type="button" class="autosave_del">삭제</button></span></li>
|
||||||
|
//console.log( "JSON Data: " + data );
|
||||||
|
$("#autosave_pop ul").empty();
|
||||||
|
$.each(data.autosave, function(i, as) {
|
||||||
|
$("#autosave_pop ul").append('<li class="autosave_load"><a href="#none">'+as.subject+'</a><span>'+as.datetime+' <button type="button" class="autosave_del">삭제</button></span></li>');
|
||||||
|
$.data(document.body, "autosave_load"+i, as.id);
|
||||||
|
});
|
||||||
|
}, "json");
|
||||||
|
$("#autosave_pop").show();
|
||||||
|
} else {
|
||||||
|
$("#autosave_pop").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".autosave_close").click(function(){ $("#autosave_pop").hide(); });
|
||||||
|
|
||||||
|
$(".autosave_load").live("click", function(){
|
||||||
|
var as_id = $.data(document.body, "autosave_load"+$(this).index());
|
||||||
|
$.get(g4_bbs_url+"/ajax.autosaveload.php", {"as_id":as_id}, function(data){
|
||||||
|
//console.log( "JSON Data: " + data );
|
||||||
|
$("#wr_subject").val(data.subject.replace(/\\\'/g, "'"));
|
||||||
|
if (typeof(CKEDITOR.instances.wr_content)!="undefined") {
|
||||||
|
CKEDITOR.instances.wr_content.setData(data.content);
|
||||||
|
}
|
||||||
|
}, "json");
|
||||||
|
$("#autosave_pop").hide();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
$(document).click(function() {
|
||||||
|
$("#autosave_pop").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).focusin(function() {
|
||||||
|
$("#autosave_pop").hide();
|
||||||
|
});
|
||||||
|
*/
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user