new comments javascript edition

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<script type="text/javascript">
newMessages()
function newMessages() {
blogs = document.getElementById("lastBlogs").getElementsByTagName("A")
for (i=0; i<blogs.length; i++){
today = new Date()
if(blogs[i].id.split("-")[1] > cookieValue(blogs[i].id.split("-")[0])/1000) {
content = document.getElementById(blogs[i].id).innerHTML
document.getElementById(blogs[i].id).innerHTML = "<b>" + content + "</b>"
}
blogs[i].onclick = cookieClick;
}
}
function cookieClick() {
name = this.id.split("-")[0]
now = new Date()
expire = new Date()
expire.setDate(expire.getDate() + 3)
document.cookie = name + "=" + now.getTime() + ";path=/;expires=" + expire.toGMTString()
}
function cookieValue(name) {
cookies = document.cookie.split("; ")
for (z=0; z<cookies.length; z++) {
if (cookies[z].split("=")[0] == name){
return cookies[z].split("=")[1]
}
}
return 0
}
</script>