Archive

Posts Tagged ‘javascript snippet’

A Simple Javascript Snippet

June 19th, 2009 Comments off

Ok, so I am not well versed with javascript and do everything with php. But this one calls for a bit of js manipulation.

For someone who knows JS this should be a five minute job.

So, we are using openx for ad management. The problem is that placing the openx javacode all over the page is simply too annoying.

so we had created a single php function called disp_ads where it would be fed the ad_zone and another variable and then it would display the ad.

this is one it looks like:

function ad_disp_raw ($ad_zone, $ad_n) {
?>
<script type=’text/javascript’><!–//<![CDATA[
var m3_u = (location.protocol=='https:'?'/cp/adserver/www/delivery/ajs.php':'/cp/adserver/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=<?=$ad_zone; ?>");
document.write ('&cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer) document.write ("&referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'></scr"+"ipt>");
//]]>–></script><noscript><a href=’/cp/adserver/www/delivery/ck.php?n=<?=$ad_n; ?>&cb=INSERT_RANDOM_NUMBER_HERE’ target=’_blank’><img src=’/cp/adserver/www/delivery/avw.php?zoneid=<?=$ad_zone; ?>&cb=INSERT_RANDOM_NUMBER_HERE&n=<?=$ad_n; ?>’ border=’0′ alt=” /></a></noscript>
<?
}

// function ad_disp is a generic add display module from phpads
function ad_disp ($ad_zone, $ad_n) {
?>
<fieldset class=ads>
<legend>ADVERTISEMENT</legend>
<? ad_disp_raw ($ad_zone, $ad_n); ?>
</fieldset><?

}

———
So as you can see, sometimes we call the ad_disp function which displays a little fieldset around the ad or we can call the ad_disp_raw function directly if we don’t want the fieldset around the ad.

—-> the job:
we need the same methodology done but ALL is java. So, no php function but a java function PLUS the call.

So, really all one needs to do is write two js functions where one calls the other (see above php functions) and their call syntax – where all we do is call the function with the two variables.

right now the function calls look like this:

<? ad_disp{12, 1233s32); ?>
so we want a call that is as simple as this!

—> this needs to be done rightaway. so if you can’t do this in less than an hour don’t bid please.

Need Javascript Snippet

May 16th, 2009 Comments off

I need a small and simple javascript snippet that displays fake membership data for my website.

The script should display a TOTAL REGISTERED MEMBES and MEMBERS CURRENTLY LOGGED IN number.

These numbers that display should be defineable as follows:

TOTAL REGISTERED MEMBERS – has a starting value and a daily growth range so that the number apppears to increases over time in a natural fashion. Probably needs to write to a text file for reference.

MEMBERS CURRENTLY LOGGED IN – is a percentage of the total registered number below. It is further definable by the hours in 24 hour day. So for example: If I set the percentage as 10% of TOTAL REGISTERED MEMBERS then I can define what percent of that 10% will display for each hour of the day. This will allow me to make the numbers appear to be more natural if I set the early morning hours to a lower percentage.

Bear