Half day bookings different key to choose

Re: Half day bookings different key to choose

Postby boldfish » Wed Apr 09, 2008 1:02 am

yep, that's working now.

AFAICT

can I get the code and images?
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: Half day bookings different key to choose

Postby chris » Wed Apr 09, 2008 2:48 am

I'm glad to hear it :) , rather a messy solution but if it works....

add this to the calendar php page (ie the page that loads the calendar):
Code: Select all
document.onkeydown = capturekeyDown;
document.onkeyup = capturekeyUp;

also add a hidden form field somewhere on the page:
Code: Select all
<input type="hidden" id="current_key">


Then, in "update_cal.js" you need to make a few changes.
add these 2 functions to catch and reset the keystrokes:
Code: Select all
function capturekeyDown(e) {
   if (document.all) {
      var evnt = window.event;
      keycode = evnt.keyCode;
   }else{
      keycode = e.keyCode;
   }
   document.getElementById('current_key').value=keycode;
}
function capturekeyUp(e){
   //   remove value
   document.getElementById('current_key').value='';
}


replace the ajax_mod_state function with this:
Code: Select all
function ajax_mod_state(id_item,the_date,the_num,e){   
   //catch key press
   keycode=document.getElementById('current_key').value;
   special_state="";
   if(keycode=="16")      special_state= "pm";   // SHIFT KEY
   else if(keycode=="17")   special_state= "pm";   //   ctrl
      else if(keycode=="18")   special_state= "am";   //   alt
   else if(keycode=="80")   special_state= "prv"   //   o
   //else the_key= "ko";

   //    start class
   ajax       =   new sack();
   
   //    define image span to update
   state_elm=document.getElementById("state_"+the_date);
   // set state loading while ajax is executed
   state_elm.innerHTML = image_loading;
   
   //   define number for grahic to show (needed in completion function)
   elm_num   =   the_num;
   
   //    call ajax file to update state
   var the_url=update_url+"?id_item="+id_item+"&the_date="+the_date+"&special_state="+special_state;
   //alert(the_url);
   ajax.requestFile = the_url;
   ajax.onCompletion =reset_state;
   ajax.runAJAX();
   
}

Add to reset_state() function:
Code: Select all
||  ajax.response=="prv"


I think that is the lot, you will see that we are now not using the what_key() function so that can go ;)

I have uploaded the fireworks file (zipped) with the new images here: http://www.cbolson.com/code/availabilit ... umbers.zip

Looking at the the time, this will be one for you to do tomorrow I fancy ;)

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Half day bookings different key to choose

Postby boldfish » Wed Apr 09, 2008 9:51 am

you missed out adding:
Code: Select all
elseif($booked_days[$this_date]=="prv")   $day_image='cal_prv_'.$day_counter.'.png';


to function draw_cal in the "check if day is available" section
other than that it seems to work fine.


Many thanks...

(now to update the live site and sort out showing +12 months)

;)
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron