<script language="JavaScript">
<!--
var sepchar = "@"; // unique separator character
var BMtotal = 6; // max number of bookmarks permitted
var ShowCount = 0;
var expDays = 30; // 쿠키 지속 기간
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function ListBookmarks() {
var NumBookmarks = GetCookie('PT_NumBookmarks');
var i;
var Bookmark;
function AddBookmark(BMtitle, BMaddress) {
var NumBookmarks = GetCookie('PT_NumBookmarks');
var i;
var ToDoItem;
var Bookmark;
var OldestBookmark = 0;
var CountBookmarks = 0;
if (NumBookmarks == null) {
NumBookmarks = 0;
}
for (i=1; i <= NumBookmarks ; i++) {
Bookmark = GetCookie('PT_Bookmark'+i);
if (Bookmark != null) {
CountBookmarks++;
if (OldestBookmark == 0) {
OldestBookmark = i;
}
}
if (Bookmark == BMtitle+sepchar+BMaddress) {
alert(''+BMtitle+'이/가 북마크 되었습니다.'); // 북마크 되었다는 메세지
history.go(0); // 페이지 새로고침 - 북마크시 페이지 새로고침해야 나옴..
return; }
}
if (CountBookmarks > BMtotal) {
DeleteBookmark(OldestBookmark);
}
NumBookmarks++;
SetCookie('PT_Bookmark'+NumBookmarks, BMtitle+sepchar+BMaddress, exp);
SetCookie('PT_NumBookmarks',NumBookmarks, exp);
alert(''+BMtitle+'이/가 북마크 되었습니다.'); // 북마크 되었다는 메세지
history.go(0); // 페이지 새로고침 - 북마크시 페이지 새로고침해야 나옴..
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function addurl() { // 폼의 값을 받는부분..
AddBookmark(''+document.cookie_bookmark.addurl_title.value+'','http://'+document.cookie_bookmark.addurl_url.value+'');
}
//-->
</script>
<!--
폼 구성 부분
아래 북마크 소스 출려하는 자스의 경우 꼭
<table>을 붙여줘야함..
//-->
<form name="cookie_bookmark" method="post">
<table border="0" width="300" cellspacing="0" cellpadding="2" style="border:1 solid #000000;">
<tr>
<th colspan="3" width="300">쿠키 북마크</th>
<tr>
<tr>
<th width="100">북마크 타이틀</th>
<td colspan="2" align="center" width="200"><input type="text" name="addurl_title" tabindex="1" style="width:100%;"></td>
</tr>
<tr>
<th width="100">북마크 경로</th>
<th width="45"><input type="text" value="http://" style="width:45px;" tabindex="4"readonly></th>
<td align="center" width="155"><input type="text" name="addurl_url" tabindex="2" style="width:100%;"></td>
</tr>
<tr>
<td colspan="3" align="center" width="300"><input type="button" value="click" onclick="addurl();" tabindex="3" style="width:50%;"></td>
</tr>
<tr>
<td colspan="3" width="300"><Br>