Post by Chris on Jun 24, 2007 13:25:26 GMT -8
Yeah, that's right. One of those "impossible" codes has been done. And with no server side usage either.
Firstly, this code is not full proof. There's a few unfixable things that you may consider bugs but were instead done to make the code work properly.
1. The code rounds up to the nearest hour for last visit time. ProBoards would not accept a search for a decimal hour value and doesn't have a minutes parameter. Therefore, some posts that you saw last visit MAY appear.
2. A "visit" is only initiated whenever the visit cookie can be set. The cookie can only be set again IF a user clears their cookies or closes their browser. Therefore, people who leave their browser open always are out of luck.
3. Guests can not use this code.
4. The button appears inside the "Mark as Read" row on the main page. Therefore, codes that remove the Mark as Read row also remove this button.
Main Footers
<script type="text/Javascript">
// View Posts Since Last Visit by Chris
// This script may not be redistributed outside of Studio Zero, ProBoards Support, SoCal, or ProVision
var imageUrl = "http://img232.imageshack.us/img232/994/buttonch6.png";
// Don't edit
var pslv = {
image: imageUrl,
lastTime: 0, // Last login time
genRand: function(){
return Math.floor(Math.random()*500)+500;
},
genLink: function(){
var sstring = "?action=search2&search=&match=1&whattosearch=1&user=";
sstring += "&maxresults="+this.genRand()+"&viewtype=1&subject=1&message=1";
// Check into search string
// Check into match type
// Add the date here
var x = (new Date()).getTime()-this.lastTime;
x = Math.ceil(((x/1000)/60)/60); // Milliseconds to seconds to minutes to hours
sstring += "&hours="+x;
// Load board data
var f = document.getElementById("forumjump").options;
for(a=6;a<f.length;a++){
if(f.value.match(/board=/i)){
sstring += "&board-"+f.value.split(/board=/i)[1]+"=1";
}
}
location.href = sstring+'&days=0';
},
addInfo: function(){
var aTD = document.getElementsByTagName("td");
for(a=0;a<aTD.length;a++){
if(aTD.colSpan == 5 && aTD.getElementsByTagName("img")[0]){
var v = aTD.firstChild;
v.appendChild(document.createTextNode(" "));
var ah = v.appendChild(document.createElement("a"));
ah.href = "javascript:void(0);"
ah.onclick = function(){ pslv.genLink(); };
ah.appendChild(new Image()).src = this.image;
ah.firstChild.alt = ah.firstChild.title = "Posts Since Last Visit";
ah.firstChild.border = 0;
break;
}
}
},
init: function(){
if(pb_username == "Guest")
return false;
if(!(location.href.match(/action=home/i) || !location.href.match(/(action|board)=/i)))
return false;
this.addInfo();
this.lastTime = this.c.get("session_visit") || this.c.get("last_visit") || 1;
this.c.set("session_visit", this.lastTime);
this.c.set("last_visit", (new Date()).getTime(), true);
},
c: {
get: function(n){
if(document.cookie.match(new RegExp("pslv_"+n+"=(.+?)(;|$)", "gi"))){
return RegExp.$1;
}
return 0;
},
set: function(n, v, e){
document.cookie = "pslv_"+n+"="+v+";"+(e?"expires="+(new Date( )).toGMTString().replace(/\d{4}/, "2050"):"");
}
}
};
pslv.init();
</script>
Enjoy people.
February 17, 2009: Bug Fix ~ Triad
Firstly, this code is not full proof. There's a few unfixable things that you may consider bugs but were instead done to make the code work properly.
1. The code rounds up to the nearest hour for last visit time. ProBoards would not accept a search for a decimal hour value and doesn't have a minutes parameter. Therefore, some posts that you saw last visit MAY appear.
2. A "visit" is only initiated whenever the visit cookie can be set. The cookie can only be set again IF a user clears their cookies or closes their browser. Therefore, people who leave their browser open always are out of luck.
3. Guests can not use this code.
4. The button appears inside the "Mark as Read" row on the main page. Therefore, codes that remove the Mark as Read row also remove this button.
Main Footers
<script type="text/Javascript">
// View Posts Since Last Visit by Chris
// This script may not be redistributed outside of Studio Zero, ProBoards Support, SoCal, or ProVision
var imageUrl = "http://img232.imageshack.us/img232/994/buttonch6.png";
// Don't edit
var pslv = {
image: imageUrl,
lastTime: 0, // Last login time
genRand: function(){
return Math.floor(Math.random()*500)+500;
},
genLink: function(){
var sstring = "?action=search2&search=&match=1&whattosearch=1&user=";
sstring += "&maxresults="+this.genRand()+"&viewtype=1&subject=1&message=1";
// Check into search string
// Check into match type
// Add the date here
var x = (new Date()).getTime()-this.lastTime;
x = Math.ceil(((x/1000)/60)/60); // Milliseconds to seconds to minutes to hours
sstring += "&hours="+x;
// Load board data
var f = document.getElementById("forumjump").options;
for(a=6;a<f.length;a++){
if(f.value.match(/board=/i)){
sstring += "&board-"+f.value.split(/board=/i)[1]+"=1";
}
}
location.href = sstring+'&days=0';
},
addInfo: function(){
var aTD = document.getElementsByTagName("td");
for(a=0;a<aTD.length;a++){
if(aTD.colSpan == 5 && aTD.getElementsByTagName("img")[0]){
var v = aTD.firstChild;
v.appendChild(document.createTextNode(" "));
var ah = v.appendChild(document.createElement("a"));
ah.href = "javascript:void(0);"
ah.onclick = function(){ pslv.genLink(); };
ah.appendChild(new Image()).src = this.image;
ah.firstChild.alt = ah.firstChild.title = "Posts Since Last Visit";
ah.firstChild.border = 0;
break;
}
}
},
init: function(){
if(pb_username == "Guest")
return false;
if(!(location.href.match(/action=home/i) || !location.href.match(/(action|board)=/i)))
return false;
this.addInfo();
this.lastTime = this.c.get("session_visit") || this.c.get("last_visit") || 1;
this.c.set("session_visit", this.lastTime);
this.c.set("last_visit", (new Date()).getTime(), true);
},
c: {
get: function(n){
if(document.cookie.match(new RegExp("pslv_"+n+"=(.+?)(;|$)", "gi"))){
return RegExp.$1;
}
return 0;
},
set: function(n, v, e){
document.cookie = "pslv_"+n+"="+v+";"+(e?"expires="+(new Date( )).toGMTString().replace(/\d{4}/, "2050"):"");
}
}
};
pslv.init();
</script>
Enjoy people.
February 17, 2009: Bug Fix ~ Triad