Это после <head>: Code <script type="text/javascript" src="/bookmarks.js"></script> Вот это сохранить в файл bookmarks.js: Code // ** bookmark functions
var sepchar = "@"; var BMtotal = 10; var ShowCount = 0; var expDays = 30;
var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function GetTotalBookmarks() { var NumBookmarks = GetCookie('PT_NumBookmarks'); var i; var Bookmark; var count = 0; if (NumBookmarks == null) { NumBookmarks = 0; } for (i=1; i <= NumBookmarks ; i++) { Bookmark = GetCookie('PT_Bookmark'+i); if (Bookmark != null) { count++; } } if (count == 0) { return 0; } else { return 1; } }
function ListBookmarks() { var NumBookmarks = GetCookie('PT_NumBookmarks'); var i; var Bookmark;
if (NumBookmarks == null) { NumBookmarks = 0; } ShowCount = 0; SwapColour = 0; for (i=1; i <= NumBookmarks ; i++) { Bookmark = GetCookie('PT_Bookmark'+i); if (Bookmark != null) { PrintBookmark(Bookmark, i); } } }
function DeleteBookmark(Count) { DeleteCookie('PT_Bookmark'+Count); window.location = window.location; }
function PrintBookmark (Bookmark, Count) {
var color = ""; var pairs = Bookmark.split(sepchar); pairs[0]= unescape(pairs[0]); pairs[1]= unescape(pairs[1]); pairs[2]= unescape(pairs[2]); var BMtitle = pairs[0]; var BMaddress = pairs[1]; var BMtitleFull = pairs[2];
ShowCount++; document.write("<tr><td width=90%><a class=m href='"+BMaddress+"' title='"+BMtitleFull+"'>"+BMtitle+"</a></td>"); document.write("<td><a href='javascript:DeleteBookmark(" + Count + ")' title='Удалить'><font color=red><b>X</b></font></a></td>"); document.write("</tr>"); }
function AddBookmark(BMtitle, BMaddress) {
var NumBookmarks = GetCookie('PT_NumBookmarks'); var i; var ToDoItem; var Bookmark; var OldestBookmark = 0; var CountBookmarks = 0; var new_title; var BMtitleFull; BMtitleFull = BMtitle; new_title = BMtitle.substring(0,19)+'..'; BMtitle = new_title;
if (NumBookmarks == null) { NumBookmarks = 0;} // check if already exists, and count bookmarks 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+sepchar+BMtitleFull) { alert("Ссылка уже существует: "+BMtitleFull); return; } }
// check if limit reached if (CountBookmarks > BMtotal) { DeleteBookmark(OldestBookmark); }
// now add it NumBookmarks++; SetCookie('PT_Bookmark'+NumBookmarks, BMtitle+sepchar+BMaddress+sepchar+BMtitleFull, exp); SetCookie('PT_NumBookmarks',NumBookmarks, exp); alert("Добавлена новая ссылка: "+BMtitleFull); }
// cookie functions
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;
document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } Это в профиль в нужное место где будет стоять список друзей: Code <!-- --> <SCRIPT LANGUAGE="JavaScript"> var total = GetTotalBookmarks(); if (total == 0) { document.write("<style type='text/css'>.embed_mini_other {display: none;}</style>"); } </SCRIPT> <div class="embed_mini_other"> <table class="Fmenu1" border="0" width="30%" cellpadding="0" cellspacing="0"> <tr><td class="Ftbmenu1" align="center">Друзья:</td></tr> <tr><td class="Ftbmenu2"> <table border="0" width="100%"> <SCRIPT LANGUAGE="JavaScript"> ListBookmarks(); </SCRIPT> </table> </td></tr> <tr><td class="Ftbmenu3"></td></tr> </table>
</div> <!--/--> Кнопка добавления в друзья: Code <input type="button" href="javascript://" onClick="javascript:AddBookmark(document.title, window.location)" value="Добавить в друзья" title="В друзья"> И +в репу
|