Log in to remove this sponsored message
Figured I would pop this in here so as not to turn RQFS into web coding.
quote Redemption
This is a cool idea, but for performance reasons Neoseeker is designed to stop checking if you have PMs once your browser loses focus on the Neoseeker window.
We'd have to get rid of that performance feature in order to do this, which wouldn't be a problem except that you might have 10 or 20 Neoseeker tabs open at home, another 5-6 at work, and another few tabs open on your laptop. That would mean that one user could potentially be doing 30-40 PM checks every few seconds to make this feature work.
I thought it would be possible to utilize cookies to store a
lastPMCheckTime so that the tabs won't check too often. Wrote up some javascript to support that idea. The timings 1-2 minutes can be adjusted.
//function to get random number
function randomXToY(minVal,maxVal,floatVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
//function to get unixtimestamp
function getUnixTimestamp() {
var ts = Math.round(new Date().getTime() / 1000);
return ts;
}
function doPMCheck() {
/*GET THE TIME THE LAST AJAX CHECK OCCURED*/
var lastChecked = $.cookie("lastPMCheckTime");
/*GET THE TIME NOW AND SET A THRESHOLD BOTTOM BOUNDARY FOR TWO MINUTES*/
var timeNow = getUnixTimestamp();
var threshHold = timeNow - 120;
/*IF THE LAST CHECK OCCURED MORE THAN 2 MINUTES AGO, CHECK FOR PMS*/
if(lastChecked < threshHold) {
/*UPDATE THE COOKIE TIME*/
$.cookie("lastPMCheckTime", timeNow);
/*THIS IS WHERE YOU PERFORM THE AJAX CHECK*/
}
/*TRY TO UPDATE AGAIN IN 60-120 SECONDS*/
var newCheckTime = randomXToY(60,120) * 1000;
setTimeout("doPMCheck()", newCheckTime);
}
$(document).ready(function() {
/*SINCE THE PAGE JUST LOADED DON'T CHECK FOR NEW PMS YET, DO IT IN 1-2 MINUTES*/
var firstCheckTime = randomXToY(60,120);
setTimeout("doPMCheck()", firstCheckTime);
});
I tested on my local computer and it seemed to work fine. Anybody have any 2 cents to add?
Mod Edit: Mar 12, 12 2:27pm by Redemption