JavaScript Example

Top  Previous  Next

You can use JavaScript to generate a URL that stays current as days pass.  Here is an example of JavaScript code that will let you create any number of links that stay current.  This example script provides links to graphical schedules. It uses the items shown for graphical schedules in the Direct Links topic.  It is an example only.  You will have to edit it with your server, port, username, password, as well as specifics of the schedule you want to generate.

 

In the <Head> section of web page, add this function script:

 

<script type="text/javascript">

function schedulelink(type,period,entity,timeline,primeonly,colorsource,textsource,interval,yearoffset,monthoffset,dateoffset)

{

               // Get today's date as a variable

var d=new Date();

             // Build the href from the passed parameters

var myref= '<a href=\"http://yourserveraddress:88/ScanBookings?username=VIEWUSER&password=12345';

myref = myref + '&type=' + type;

myref = myref + '&entity=' + entity;

myref = myref + '&period=' + period;

myref = myref + '&colorsource=' + colorsource;

myref = myref + '&textsource=' + textsource;

myref = myref + '&interval=' + interval;

if (timeline == 1)

 {

 myref = myref + '&timeline=1';

 }

if (primeonly == 1)

 {

 myref = myref + '&primeonly=1'

 }

         //Date entry must be constructed from today's date

         // and any offset, formatted mm/dd/yyyy or dd/mm/yy

         // as per server settings. Note: getMonth() returns 0-11 not 1-12

myref = myref + '&date='+(d.getMonth()+1+monthoffset)+ '\\'+ (d.getDate()+dateoffset) +  '\\' + (d.getFullYear()+yearoffset);

myref = myref +'\">'

return myref

}

</script>

 

In the body of the page any where you want to place a link to schedule, add this script with your own parameters and text.

 

<script type="text/javascript">

document.write(schedulelink("RESOURCE","MONTH", "OAK ROOM",0,0,"CLIENT","BOOKING",60,0,0,0)+"<strong>Oak Room This Month</strong></a>")

</script>

 

To show the same schedule for the next month as well, you would simply copy the script but with 1 in the monthoffset parameter.