Half day bookings different key to choose

Half day bookings different key to choose

Postby boldfish » Fri Apr 04, 2008 10:11 am

I'm on a Mac, Mac's use the ctrl key as a right click, so trying to ctrl click a date doesn't work - how can I change the keys to something else? maybe left and right arrows for example?

other than that, great script! it should save me several hours if I can get it integrated into the site design and working nicely (date images a bit large, colours not quite right - can I have the fireworks file?).

If it all goes well, I shall be sending a sensibly sized donation.

thanks.
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: Half day bookings different key to choose

Postby chris » Fri Apr 04, 2008 11:47 am

Hi and welcome to the forum :)

You are right, I have probably choosen the wrong keys for cross system combatibility :(

I don't actually have a mac so I can't quickly give you an answer, I will look into it this morning (my time)

In the meantime here is the fireworks file:
http://www.cbolson.com/code/availabilit ... umbers.zip
The number backgrounds are defined in the library so it should be easy to resize and change the colors.

Should get back to you soon as regards the key codes...

Chris

PS. any donations would be very gratefully received, maybe I should put them towards a getting a mac ;) I would certainly like one!
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 chris » Fri Apr 04, 2008 12:33 pm

I have been reading up on this mac keytroke problem and it looks like I might no be able to find a "simple" solution as it seems that each operating system AND browser treats keystrokes in different ways :(

Do you know if there are the same "problems" with the "shift" key on a mac?

Could you take a look at this page: http://www.cbolson.com/code/availabilit ... ersion2.0/ and test the "pm" modifier with the "shift" key held down rather than the "ctrl" (though I have left that active for pc users)

If this works, then great :)
you will just need to open the "js/update_cal.js" file and replace the what_key(e) function with this:
Code: Select all
function what_key(e) {
   if(document.all)e = event; // IE need this
   if(e.shiftKey)      return "pm";
   else if(e.ctrlKey)   return "pm";
      else if(e.altKey)   return "am";
   else return "ko";
}


Let me know how it goes, otherwise I will continue to search for a solution.

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 » Fri Apr 04, 2008 12:38 pm

Shift key works fine as an alternative.

Thanks!

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

Re: Half day bookings different key to choose

Postby chris » Fri Apr 04, 2008 1:18 pm

Excellent news :D - I will leave this in for the next version release (you will have noticed on that demo url that I posted that I have been working on the possibility to change the calendar months shown in 3 month blocks - something that I think would be interesting for a lot of people.

Le me know how the integration works so that I can check it out in my pc and add an url to my list if you want.

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 » Fri Apr 04, 2008 1:33 pm

Yes, three month blocks looks interesting.

I am planning to adapt the search on the site to allow searches within a date window, i.e. find me properties that are free within these dates.

I'll let you know how that goes!

I found a couple of validation issues, one of which I fixed:
in functions.inc.php

<span id="state_'.$this_date.'">
<img src="'.DIR_IMAGES.''.$day_image.'" alt="'.$lang["day_".$week_day.""].' '. $date_format.'" border="0" width="20px" height="20px">
</span>

should be:

<span id="state_'.$this_date.'">
<img src="'.DIR_IMAGES.''.$day_image.'" alt="'.$lang["day_".$week_day.""].' '. $date_format.'" border="0" width="20" height="20">
</span>

i.e. px not allowed in html

and added alt="" to the four images used for the key.

for the demo page added a <ul> and fixed some typos:

<ul>
<li>Click on dates to make available or booked</li>
<li>Morning bookings - click on the date whilst holding the \"ctrl\" key down.</li>
<li>Afternoon bookings - click on the date whilst holding the \"alt\" key down.</li>
<li>Select language for display (optional)</li>
<li>Start day (Sunday or Monday) can be defined (not dynamic)</li>
</ul>

and I've dropped out of PHP rather than use echo for the page display (makes it easier to integrate)

there's a rogue <tr>, or absence of one, that's throwing up errors in the validator, just trying to track that down.

Thanks again for your help.
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: Half day bookings different key to choose

Postby chris » Fri Apr 04, 2008 2:16 pm

Thanks for pointing all that stuff out :)

I have removed the "px" (silly mistake) and added the alts to my version (not the zip yet).
I have also mangaged to remove the rouge trs - there where actually 2 of them - one after each calender was drawn (within the function) and then another after all the calendars where put together.
Again I have revmoved them in my latest demo version and it now passes the html validity test: http://validator.w3.org/check?uri=http% ... 0#line-838
:)

I am not sure exactly what you have done as regards "dropping" the php from displaying the code as you are still going to have to include bits of php to show the data. That would mean that you are opening and closing php tags within the html which is generally not a good idea as it requires more work by the server (if I understand it right) anyway, I might have misunderstood what you are referring to.

Funnily enough I have also been looking at doing searches between specific dates this morning, it will interesting to see what you come up with :)

Chris
PS. by the way, I used
Code: Select all
if(substr($the_cal,-4)=="<tr>") $the_cal=substr($the_cal,0,-4);   #remove last <tr>
to remove the <tr>s but I realise that there are proably better ways ;)
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 » Fri Apr 04, 2008 2:32 pm

I am not sure exactly what you have done as regards "dropping" the php from displaying the code as you are still going to have to include bits of php to show the data. That would mean that you are opening and closing php tags within the html which is generally not a good idea as it requires more work by the server (if I understand it right) anyway, I might have misunderstood what you are referring to.


exactly that - a great chunk of html and a few bits of php where required dropped in it.

as for is this more work for the server? my understanding is that it's not, in fact echo'ing a very long string can actually slow things down.

I think we're talking tiny measurements of time here! I just find it easier to have plain html and insert the bits of PHP, rtaher than the other way round…

if I can find a definitive reference I'll post it here.

here's my html for the page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?= PAGE_TITLE ?></title>
<script type="text/javascript" src="<?= DIR_JS ?>sack.js"></script>
<script type="text/javascript" src="<?= DIR_JS ?>update_cal.js"></script>
<link rel="stylesheet" href="<?=DIR_CSS?>basic.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?=DIR_CSS?>calendar.css" type="text/css" media="screen">
</head>
<body>
<div id="wrapper">
<h2><?=$lang["title"]?></h2>
<?=$lang["inst"]?>
<!-- optional elements -->
<form method="get" action="<?=$_SERVER['PHP_SELF']?>">
<table cellpadding="1" cellspacing="1" width="100%" align="center">
<tr>
<td class="side"><?=$lang["num_months"]?>:</td>
<td class="data">
<select name="months_to_show" onchange="this.form.submit()">
<?=$list_months_to_show?>
</select>
</td>
</tr>
<tr>
<td class="side"><?=$lang["language"]?></td>
<td class="data">
<select name="lang" onchange="this.form.submit();">
<?=$list_lang?>
</select>
</td>
</tr>
</table>
</form>
<!-- end optional elements -->
<br>
<table width="100%" align="center" id="calendar">
<tr>
<?=$cal_months?>
<td colspan="3" align="center">
<br />
<small>
<img src="<?=DIR_IMAGES?>demo_off.png"alt="" /> <?=$lang["key_available"]?>
&nbsp;<img src="<?=DIR_IMAGES?>demo_on.png" alt="" /> <?=$lang["key_booked_all"]?>
&nbsp;<img src="<?=DIR_IMAGES?>demo_am.png" alt="" /> <?=$lang["key_booked_am"]?>
&nbsp;<img src="<?=DIR_IMAGES?>demo_pm.png" alt="" /> <?=$lang["key_booked_pm"]?>
</small>
</td>
</tr>
</table>
</div>
</body>
</html>
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: Half day bookings different key to choose

Postby chris » Fri Apr 04, 2008 3:36 pm

hm, it looks as though you are right:
Code: Select all

http://php.net/manual/en/language.basic-syntax.php
but I am very surprised - I always understood that going in and out of php was bad for the server - i have obviously been wrong all these years :(
I am now going to have to change my coding style :) It is going to be hard because I particularly dislike seeing all those php tags all over the place as I feel the make the code untidy and hard to read.
For example I find this (example from php.net):
Code: Select all
<?php
if ($expression) {
    ?>
    <strong>This is true.</strong>
    <?php
} else {
    ?>
    <strong>This is false.</strong>
    <?php
}
?>
much harder to read than this:
Code: Select all
<?php
if ($expression) {
    echo '<strong>This is true.</strong>';
} else {
    echo '<strong>This is false.</strong>';
}
?>

I would have said that it where both clearer and easier to understand (from a coding point of view) though it is clearly less efficient as regards the server.
You've just spoilt my day :(

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 » Fri Apr 04, 2008 3:53 pm

we've just been discussing it here: http://workalone.co.uk/mailman/listinfo/wauk_workalone.co.uk and we've concluded:

Depends on:
1) The relative amount of PHP and HTML code in the source file.
2) Your own personal preferences.
3) General readability.

Don't use short tags, - they're not good (conflicts
with XML, not enabled on some servers, deprecated in PHP, etc.).

I wouldn't worry about processing time at all, unless you're outputting
several megabytes of HTML code into one page.

Keeping HTML relatively pure with the minimum scripting markup is good if
you have separate people doing the PHP and the HTML. Use a template system
like smarty if you want to limit what the HTML person can do, otherwise
PHP works as a very-powerful template language ;)

Drupal uses PHP as its default template language, and does various
architectural things to separate code from presentation.

so my use of short tags should be avoided and

<title><?= PAGE_TITLE ?></title>
<script type="text/javascript" src="<?= DIR_JS ?>sack.js"></script>
<script type="text/javascript" src="<?= DIR_JS ?>update_cal.js"></script>
<link rel="stylesheet" href="<?=DIR_CSS?>basic.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?=DIR_CSS?>calendar.css" type="text/css" media="screen">

should look like:

<title><?php echo PAGE_TITLE; ?></title>
<script type="text/javascript" src="<?php echo DIR_JS; ?>sack.js"></script>
<script type="text/javascript" src="<?php echo DIR_JS; ?>update_cal.js"></script>
<link rel="stylesheet" href="<?php echo DIR_CSS; ?>basic.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo DIR_CSS; ?>calendar.css" type="text/css" media="screen">


I think the ultimate rule of thumb is that if it's a little bit of html in a lot of php echo it, if it's a few bits of php in a lot of html drop in and out…

if someone else is messing with your html, like designers, then much easier for them to work with the html, they're used to and ignore anything inside <?php … ?>

sorry to spoil your day! maybe my donation (later when I get my act together) will help change that!
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Next

Return to General

Who is online

Users browsing this forum: No registered users and 0 guests

cron