pop up external page in light box


What is it?

Facebox is a jQuery-based, Facebook-style lightbox which can display images, divs, or entire remote pages.

It’s simple to use and easy on the eyes. Download the tarball, view the examples, then start enjoying the curves.

Why another lightbox?

Because we wanted, nay, needed a Facebook-style lightbox on FamSpam.

Download

Requires jQuery 1.2.1.

You’ll need a loading image, close label, four corners, and solid border images in addition to the javascript and css files. All are included
in the tarball.

Download Facebox v1.3

Want to live on the edge? The code is kept in GitHub at http://github.com/defunkt/facebox

Help!

Need help? Join our Google Groups mailing list.

Images

View ‘images/stairs.jpg’ in the Facebox

The Code

<a href="images/stairs.jpg" rel="facebox">text</a>

Divs

View the ‘info’ div in the Facebox

The Code

<a href="#info" rel="facebox">text</a>

Ajaxes

View ‘remote.html’ in the Facebox

The Code

<a href="remote.html" rel="facebox">text</a>

Load Dependencies

Make sure jQuery is loaded before Facebox.


<script src="jquery.js" type="text/javascript"></script>

<link href="/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>

<script src="/facebox/facebox.js" type="text/javascript"></script>

Attach It onLoad

While calling facebox() on any anchor tag will do the trick, it’s easier to give your Faceboxy links a rel="facebox" and hit them all onLoad.


jQuery(document).ready(function($) {

$('a[rel*=facebox]').facebox()

})

Extra Classes

You can give the facebox container an extra class (to fine-tune the display of reusable remote pages)
with the facebox[.class] rel syntax.

Maybe your Terms and Conditions can be loaded standalone or via Facebox. When loaded in Facebox,
you might want to tweak some styles — like making the h1 positioned absolutely?
We do this on FamSpam.


View an an example which makes the remote.html page bigger and bolder using css.

The Code

<a href="remote.html" rel="facebox[.bolder]">text</a>

Controlling Facebox Programmatically

It’s possible to attain a higher level control over Facebox by calling methods directly.
The following will open the Facebox and insert the passed string into it:

Arbitrary Text


jQuery.facebox('something cool');

jQuery.facebox('something cool', 'my-groovy-style');

Remote files


jQuery.facebox({ ajax: 'remote.html' });

jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style');

Image


jQuery.facebox({ image: 'images/stairs.jpg' });

jQuery.facebox({ image: 'images/stairs.jpg' }, 'my-groovy-style');

A Page Element


jQuery.facebox({ div: '#box' });

jQuery.facebox({ div: '#box' }, 'my-groovy-style');

If you plan to fill the Facebox with the result of an Ajax call, you’ll want the loading graphic
displayed whilst your asynchronus task runs. This is the automatic behavior if the facebox()
method is passed a function.

Loading Image Displayed

 

jQuery.facebox(function() {

jQuery.get('code.js', function(data) {

jQuery.facebox('<textarea>' + data + '</textarea>')

})

})

Thanks & Contact

Thanks to Facebook for the idea and style. Thanks to Mindy Tchieu for her help in getting this working.

Comments, concerns, complaints, criticisms, confessions? Join our Google Groups mailing list

Getting Started with PHP Regular Expressions


 

The main purpose of regular expressions, also called regex or regexp, is to efficiently search for patterns in a given text. These search patterns are written using a special format which a regular expression parser understands.

Express-1 in Getting Started with PHP Regular Expressions

Regular expressions are originating from Unix systems, where a program was designed, called grep, to help users work with strings and manipulate text. By following a few basic rules, one can create very complex search patterns.

As an example, let’s say you’re given the task to check wether an e-mail or a telephone number has the correct form. Using a few simple commands these problems can easily be solved thanks to regular expressions. The syntax doesn’t always seems straightforward at first, but once you learn it, you’ll realize that you can do pretty complex searches easily, just by typing in a few characters and you’ll approach problems from a different perspective.

2. Perl Compatible Regular Expressions

PHP has implemented quite a few regex functions which uses different parsing engines. There are two major parser in PHP. One called POSIX and the other PCRE or Perl Compatible Regular Expression.

The PHP function prefix for POSIX is ereg_. Since the release of PHP 5.3 this engine is deprecated, but let’s have a look at the more optimal and faster PCRE engine.

In PHP every PCRE function starts with preg_ such as preg_match or preg_replace. You can read the full function list in PHP’s documentation.

3. Basic Syntax

To use regular expressions first you need to learn the syntax. This syntax consists in a series of letters, numbers, dots, hyphens and special signs, which we can group together using different parentheses.

In PHP every regular expression pattern is defined as a string using the Perl format. In Perl, a regular expression pattern is written between forward slashes, such as /hello/. In PHP this will become a string, ‘/hello/’.

Now, let’s have a look at some operators, the basic building blocks of regular expressions

Operator Description
^ The circumflex symbol marks the beginning of a pattern, although in some cases it can be omitted
$ Same as with the circumflex symbol, the dollar sign marks the end of a search pattern
. The period matches any single character
? It will match the preceding pattern zero or one times
+ It will match the preceding pattern one or more times
* It will match the preceding pattern zero or more times
| Boolean OR
Matches a range of elements
() Groups a different pattern elements together
[] Matches any single character between the square brackets
{min, max} It is used to match exact character counts
\d Matches any single digit
\D Matches any single non digit caharcter
\w Matches any alpha numeric character including underscore (_)
\W Matches any non alpha numeric character excluding the underscore character
\s Matches whitespace character

As an addition in PHP the forward slash character is escaped using the simple slash \. Example: ‘/he\/llo/’

To have a brief understanding how these operators are used, let’s have a look at a few examples:

Example Description
‘/hello/’ It will match the word hello
‘/^hello/’ It will match hello at the start of a string. Possible matches are hello or helloworld, but not worldhello
‘/hello$/’ It will match hello at the end of a string.
‘/he.o/’ It will match any character between he and o. Possible matches are helo or heyo, but not hello
‘/he?llo/’ It will match either llo or hello
‘/hello+/’ It will match hello on or more time. E.g. hello or hellohello
‘/he*llo/’ Matches llo, hello or hehello, but not hellooo
‘/hello|world/’ It will either match the word hello or world
‘/(A-Z)/’ Using it with the hyphen character, this pattern will match every uppercase character from A to Z. E.g. A, B, C…
‘/[abc]/’ It will match any single character a, b or c
‘/abc{1}/’ Matches precisely one c character after the characters ab. E.g. matches abc, but not abcc
‘/abc{1,}/’ Matches one or more c character after the characters ab. E.g. matches abc or abcc
‘/abc{2,4}/’ Matches between two and four c character after the characters ab. E.g. matches abcc, abccc or abcccc, but not abc

Besides operators, there are regular expression modifiers, which can globally alter the behavior of search patterns.

The regex modifiers are placed after the pattern, like this ‘/hello/i’ and they consists of single letters such as i which marks a pattern case insensitive or x which ignores white-space characters. For a full list of modifiers please visit PHP’s online documentation.

The real power of regular expressions relies in combining these operators and modifiers, therefore creating rather complex search patterns.

4. Using Regex in PHP

Express-2 in Getting Started with PHP Regular Expressions

In PHP we have a total of nine PCRE functions which we can use. Here’s the list:

  • preg_filter – performs a regular expression search and replace
  • preg_grep – returns array entries that match a pattern
  • preg_last_error – returns the error code of the last PCRE regex execution
  • preg_match – perform a regular expression match
  • preg_match_all – perform a global regular expression match
  • preg_quote – quote regular expression characters
  • preg_replace – perform a regular expression search and replace
  • preg_replace_callback – perform a regular expression search and replace using a callback
  • preg_split – split string by a regular expression

The two most commonly used functions are preg_match and preg_replace.

Let’s begin by creating a test string on which we will perform our regular expression searches. The classical hello world should do it.

  1. $test_string‘hello world’;

If we simply want to search for the word hello or world then the search pattern would look something like this:

  1. preg_match(‘/hello/’$test_string);
  2. preg_match(‘/world/’$test_string);

If we wish to see if the string begins with the word hello, we would simply put the ^ character in the beginning of the search pattern like this:

  1. preg_match(‘/^hello/’$test_string);

Please note that regular expressions are case sensitive, the above pattern won’t match the word hElLo. If we want our pattern to be case insensitive we should apply the following modifier:

  1. preg_match(‘/^hello/i’$test_string);

Notice the character i at the end of the pattern after the forward slash.

Now let’s examine a more complex search pattern. What if we want to check that the first five characters in the string are alpha numeric characters.

  1. preg_match(‘/^[A-Za-z0-9]{5}/’$test_string);

Let’s dissect this search pattern. First, by using the caret character (^) we specify that the string must begin with an alpha numeric character. This is specified by [A-Za-z0-9].

A-Z means all the characters from A to Z followed by a-z which is the same except for lowercase character, this is important, because regular expressions are case sensitive. I think you’ll figure out by yourself what 0-9 means.

{5} simply tells the regex parser to count exactly five characters. If we put six instead of five, the parser wouldn’t match anything, because in our test string the word hello is five characters long, followed by a white-space character which in our case doesn’t count.

Also, this regular expression could be optimized to the following form:

  1. preg_match(‘/^\w{5}/’$test_string);

\w specifies any alpha numeric characters plus the underscore character (_).

6. Useful Regex Functions

Here are a few PHP functions using regular expressions which you could use on a daily basis.

Validate e-mail. This function will validate a given e-mail address string to see if it has the correct form.

  1. function validate_email($email_address)
  2. {
  3. if( !preg_match(“/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+
  4. ([a-zA-Z0-9\._-]+)+$/”$email_address))
  5. {
  6. return false;
  7. }
  8. return true;
  9. }

Validate a URL

  1. function validate_url($url)
  2. {
  3. return preg_match(‘|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?
  4. (/.*)?$|i’$url);
  5. }

Remove repeated words. I often found repeated words in a text, such as this this. This handy function will remove such duplicate words.

  1. function remove_duplicate_word($text)
  2. {
  3. return preg_replace(“/s(w+s)1/i”“$1”$text);
  4. }

Validate alpha numeric, dashes, underscores and spaces

  1. function validate_alpha($text)
  2. {
  3. return preg_match(“/^[A-Za-z0-9_- ]+$/”$text);
  4. }

Validate US ZIP codes

  1. function validate_zip($zip_code)
  2. {
  3. return preg_match(“/^([0-9]{5})(-[0-9]{4})?$/i”,$zip_code);
  4. }

7. Regex Cheat Sheet

Because cheat sheets are cool nowadays, below you can find a PCRE cheat sheet that you can run through quickly anytime you forget something.

Meta Characters

Description
^ Marks the start of a string
$ Marks the end of a string
. Matches any single character
| Boolean OR
() Group elements
[abc] Item in range (a,b or c)
[^abc] NOT in range (every character except a,b or c)
\s White-space character
a? Zero or one b characters. Equals to a{0,1}
a* Zero or more of a
a+ One or more of a
a{2} Exactly two of a
a{,5} Up to five of a
a{5,10} Between five to ten of a
\w Any alpha numeric character plus underscore. Equals to [A-Za-z0-9_]
\W Any non alpha numeric characters
\s Any white-space character
\S Any non white-space character
\d Any digits. Equals to [0-9]
\D Any non digits. Equals to [^0-9]

Pattern Modifiers

Description
i Ignore case
m Multiline mode
S Extra analysis of pattern
u Pattern is treated as UTF-8

8. Useful Readings

showing direction on map from two textbox and also getting alternative ways from json


file1.php

========================================================================

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”initial-scale=1.0, user-scalable=no”/>
<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″/>
<title>Google Maps JavaScript API v3 Example: Directions Waypoints</title>
<link href=”http://code.google.com/apis/maps/documentation/javascript/examples/standard.css&#8221; rel=”stylesheet” type=”text/css” />
<link rel=”stylesheet” type=”text/css” href=”http://carshare.vervesys.com//css/redmond/jquery-ui-1.8.1.custom.css&#8221; media=”screen” />
<link rel=”stylesheet” type=”text/css” href=”http://carshare.vervesys.com//css/coVoiturage.css&#8221; media=”screen” />
<!–AUTHOR : HARISH PATIL
DATE : 07-MARCH-2011
DESCR : GETTING DISTANCE–>

<script src=”http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAxfM792nyXR7woBqjAj9EPhRHvOZxbfYMBkr56pDT3TCnqDxE_RQyQt5acukouEbxsJtR6uKxEqImhQ&#8221; type=”text/javascript”></script>
<script type=”text/javascript” src=”http://maps.google.com/maps/api/js?sensor=false”></script&gt;
<!–AJAX–>
<script type=”text/javascript”>
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var geocoder;
var side_bar_html = “”;
var gmarkers = [];
var htmls = [];
var i = 0;

function initialize() {

geocoder = new GClientGeocoder();
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(41.850033, -87.6500523);
var myOptions = {
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById(“map_canvas”), myOptions);
directionsDisplay.setMap(map);

}
function stripVowelAccent(str)
{
var s=str;

var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

var repChar=[‘A’,’a’,’E’,’e’,’I’,’i’,’O’,’o’,’U’,’u’];

for(var i=0; i<rExps.length; i++)
s=s.replace(rExps[i],repChar[i]);

return s;
}
function calcRoute(start,end,waypoints,flag) {
//alert(waypoints);

var waypts = [];

if(waypoints !=null && waypoints !=”)
waypts.push({
location:waypoints,
stopover:true});

var request = {
origin: start,
destination: end,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};

directionsService.route(request, function(response, status) {
if(status==google.maps.DirectionsStatus.ZERO_RESULTS)
{
alert(“Sorry, There is no result found.Please provide more specification or valid address.”);
}
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
if(flag==’0′)
{

<!–    ===================================================================================================–>
document.getElementById(‘loading’).style.display=’block’;

var url ='<?php echo config_item(‘base_url’);?>/gethint.php?address1=’+stripVowelAccent(start)+’&address2=’+stripVowelAccent(end)+’&a=’+Math.random();

var ajaxReq = getXmlHttpRequestObject();

if(ajaxReq.readyState == 4 || ajaxReq.readyState == 0)
{

ajaxReq.open(“post”, url, true);
ajaxReq.onreadystatechange = function()
{

if(ajaxReq.readyState == 4 && ajaxReq.status == 200)
{

var doc=ajaxReq.responseText;
//alert(doc);
//alert(doc);

<!–=================================XXXXXXXXXXXXXXXXXXXXXXXXXXX=====================================–>
// === Parse the JSON document ===
var jsonData = eval(‘(‘ + doc + ‘)’);
side_bar_html=””;
// === Plot the markers ===

for (var i=0; i<jsonData.routes.length;i++)
{
// var point = new GLatLng(jsonData.routes[0].legs[0].steps[i].start_location.lat, jsonData.routes[0].legs[0].steps[i].start_location.lng);
//         alert(jsonData.routes.length);
var lable=””;
var start=””;
var end=””;
var via_waypoint=””;
var via_waypoint_address=””;
var distance=””;
var times=””;

start=jsonData.routes[i].legs[0].start_address;
end=jsonData.routes[i].legs[0].end_address;
distance=jsonData.routes[i].legs[0].distance.text;
times=jsonData.routes[i].legs[0].duration.text;

if(jsonData.routes[i].legs[0].via_waypoint.length>0)
{

via_waypoint=jsonData.routes[i].legs[0].via_waypoint[0].location.lat+” “+jsonData.routes[i].legs[0].via_waypoint[0].location.lng;
point = new GLatLng(jsonData.routes[i].legs[0].via_waypoint[0].location.lat,jsonData.routes[i].legs[0].via_waypoint[0].location.lng);

side_bar_html += ‘ <input type=”radio” name=”waypoints” onclick=”selectWay(\”+start+’\’,\”+end+’\’,\”+via_waypoint+’\’,\”+distance+’\’);” value=”‘+distance+'” />Way ‘+(i+1)+’ : ‘+’ Distance (‘+distance+’) Times (‘+times+’)<br/>’;
//   side_bar_html += start+”     “+end+”     “+distance+”     “+via_waypoint+”<br>”;
}
else
{

via_waypoint=”;
//point = new GLatLng(jsonData.routes[i].legs[0].via_waypoint[0].location.lat,jsonData.routes[i].legs[0].via_waypoint[0].location.lng);

side_bar_html += ‘ <input type=”radio” name=”waypoints”  onclick=”selectWay(\”+start+’\’,\”+end+’\’,\”+via_waypoint+’\’,\”+distance+’\’);” value=”‘+distance+'” />Way ‘+(i+1)+’ : ‘+’ Distance (‘+distance+’) Times (‘+times+’)<br/>’;
//   side_bar_html += start+”     “+end+”     “+distance+”     “+via_waypoint+”<br>”;
}

}
side_bar_html=side_bar_html+'<br/><input type=”button” name=”submit” onclick=”return post_value();” value=”Submit” />’;
document.getElementById(“side_bar”).innerHTML = side_bar_html;
document.getElementById(‘loading’).style.display=’none’;
<!–================================XXXXXXXXXXXXXXXXXXXXXXXXXXXX=====================================–>

}
}
ajaxReq.send(null);
}
<!–            ===================================================================================================–>

}
}
});

}

<!–  ================================================–>

function getFirst()
{

var start = document.getElementById(“start”).value;
geocoder.getLocations(start, getSecond);
}
function getSecond(response)
{

var end = document.getElementById(“end”).value;
if (!response || response.Status.code != 200) {
alert(“Sorry, we were unable to geocode that address”);
}
else
{
place = response.Placemark[0];
if(place.AddressDetails.Country.CountryNameCode==”US” || place.AddressDetails.Country.CountryNameCode==”CA”)
{
geocoder.getLocations(end,hello);
}
else
{
alert(‘Departure is out of CANADA and USA location’);
}
}
}
function hello(response)
{

if (!response || response.Status.code != 200) {
alert(“Sorry, we were unable to geocode that address”);
}
else
{
place = response.Placemark[0];
if(place.AddressDetails.Country.CountryNameCode==”CA” || place.AddressDetails.Country.CountryNameCode==”US”)
{
var start = document.getElementById(“start”).value;
var end = document.getElementById(“end”).value;

calcRoute(start,end,”,’0′);

}
else
{
alert(‘Arrival is out of CANADA and USA location’);
}

}
}

<!–==============================================================================================================–>

// ================================================================
// === Define the function thats going to process the JSON file ===
function process_it (doc)
{

//alert(doc);

// === Parse the JSON document ===
var jsonData = eval(‘(‘ + doc + ‘)’);
side_bar_html=””;
// === Plot the markers ===

for (var i=0; i<jsonData.routes.length;i++)
{
// var point = new GLatLng(jsonData.routes[0].legs[0].steps[i].start_location.lat, jsonData.routes[0].legs[0].steps[i].start_location.lng);
//         alert(jsonData.routes.length);
var lable=””;
var start=””;
var end=””;
var via_waypoint=””;
var via_waypoint_address=””;
var distance=””;
var times=””;

start=jsonData.routes[i].legs[0].start_address;
end=jsonData.routes[i].legs[0].end_address;
distance=jsonData.routes[i].legs[0].distance.text;
times=jsonData.routes[i].legs[0].duration.text;

if(jsonData.routes[i].legs[0].via_waypoint.length>0)
{

via_waypoint=jsonData.routes[i].legs[0].via_waypoint[0].location.lat+” “+jsonData.routes[i].legs[0].via_waypoint[0].location.lng;
point = new GLatLng(jsonData.routes[i].legs[0].via_waypoint[0].location.lat,jsonData.routes[i].legs[0].via_waypoint[0].location.lng);

side_bar_html += ‘ <input type=”radio” name=”waypoints” onclick=”selectWay(\”+start+’\’,\”+end+’\’,\”+via_waypoint+’\’,\”+distance+’\’);” value=”‘+distance+'” />Way ‘+(i+1)+’ : ‘+’ Distance (‘+distance+’) Times (‘+times+’)<br/>’;
//   side_bar_html += start+”     “+end+”     “+distance+”     “+via_waypoint+”<br>”;
}
else
{

via_waypoint=”;
//point = new GLatLng(jsonData.routes[i].legs[0].via_waypoint[0].location.lat,jsonData.routes[i].legs[0].via_waypoint[0].location.lng);

side_bar_html += ‘ <input type=”radio” name=”waypoints” id=”temp_waypoints” onclick=”selectWay(\”+start+’\’,\”+end+’\’,\”+via_waypoint+’\’,\”+distance+’\’);” value=”‘+distance+'” />Way ‘+(i+1)+’ : ‘+’ Distance (‘+distance+’) Times (‘+times+’)<br/>’;
//   side_bar_html += start+”     “+end+”     “+distance+”     “+via_waypoint+”<br>”;
}

}
side_bar_html=side_bar_html+'<br/><input type=”button” onclick=”return post_value();” name=”submit” value=”Submit” />’;
document.getElementById(“side_bar”).innerHTML = side_bar_html;
document.getElementById(‘loading’).style.display=’none’;

}

function selectWay(start,end,waypoints,distance)
{
document.getElementById(“address1”).value = start;
document.getElementById(“address2″).value = end;
document.getElementById(‘waypoints’).value=waypoints;
document.getElementById(‘miledistance’).value=distance;
calcRoute(start,end,waypoints,’1′);
}

</script>
<script langauge=”javascript”>
function post_value(){
var len=document.frmvalue.waypoints.length;
var flag=false;
for(var i=0;i<len;i++){
if(document.frmvalue.waypoints[i].checked==true){
flag=true;
}
}

if(flag==false)
{
alert(‘Please select atleast one route’);
return false;
}
else
{
opener.document.formOfferTrip.miledistance.value = document.frmvalue.miledistance.value;
opener.document.formOfferTrip.departureWaypoint.value = document.frmvalue.address1.value;
opener.document.formOfferTrip.arrivalWaypoint.value = document.frmvalue.address2.value;
opener.document.formOfferTrip.waypoints.value = document.frmvalue.waypoints_1.value;
var html='<label name=”lbl2″ id=”lbl2″ style=”margin-top:-6px”>Distance : </label>’+document.frmvalue.miledistance.value;
opener.document.getElementById(‘distance_section’).style.display=’block’;
opener.document.getElementById(‘distance_section’).innerHTML = html;
self.close();
}
}
</script>
<!–AJAX–>

<script type=”text/javascript”>

function getXmlHttpRequestObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
return new ActiveXObject(“Microsoft.XMLHTTP”);
}
else
{
alert(“Please upgrade your browser. The current version does not support the booking request.”);
}
}

</script>

<!–END–>
</head>
<body style=”background-color:#63caf3;” onLoad=”initialize();”>

<div style=”background-color:#8fd9f7″>

<div id=”directions_panel” style=”margin:20px;background-color:#FFEE77;display:none;” style=”background-color:#63caf3;”></div>
<div style=”float:right”>

</div>
<table width=”100%” border=”0″>
<tr>
<td style=”width:35%;”>
<form action=”” name=”frm”>
<table align=”center” border=”none” style=”border:0″>
<tr>
<td><label for=”departureCity”>Departure</label></td>
<td><input type=”text” name=”address1″ id=”start” value=”” /></td>
</tr>
<tr>
<td><label for=”departureCity”>Arrival</label></td>
<td><input type=”text” name=”address2″ id=”end” value=””  /></td>
</tr>
<tr>
<td colspan=”2″ align=”center”><input type=”hidden” name=”oper” value=”search” />
<button type=”button” onClick=”getFirst();” value=”button” style=”color:#FFFFFF;height:20px;” >&nbsp;Search</button>
</td>
</tr>
</table>
</form>
</td>
<td>
<form name=”frmvalue” action=”<?php echo config_item(‘base_url’);?>/index.php/trip/displayOffer” method=”post”>
<div id=”side_bar”></div>
<input type=”hidden” name=”miledistance” id=”miledistance” value=”” />
<input type=”hidden” name=”address1″ id=”address1″ value=”” />
<input type=”hidden” name=”address2″ id=”address2″ value=””  />
<input type=”hidden” name=”waypoints_1″ id=”waypoints” value=””  />

</form>
<div id=”loading”  style=” text-align:center;border:none;z-index:1;display:none;”>
<img src=”http://carshare.vervesys.com/ajax-loader_new.gif&#8221; style=”border:none;”>
</div>

</td>
</tr>
<tr>
<td colspan=”2″ style=”width:100%;height:500px;” ><div id=”map_canvas” style=”float:left;width:100%;height:500px;”></div> </td>
</tr>
</table>
<input type=”hidden” name=”filename” id=”filename” value=””/>
</div>

</body>
</html>
================================================================================

gethint.php

=================================================================================
<?php

$address1=trim($_REQUEST[“address1”]);
$address2=trim($_REQUEST[“address2″]);

$Url=”http://maps.googleapis.com/maps/api/directions/json?origin=&#8221;.$address1.”&destination=”.$address2.”&sensor=false&alternatives=true”;//exit;
$Url=str_replace(” “,”%20″,$Url);
//http://maps.googleapis.com/maps/api/directions/json?origin=Seneca Planetarium Seneca College, 1750 Finch Ave E, Toronto, Toronto Division, Ontario M2J 5G3, Canada&destination=ny,us&sensor=false&alternatives=true
// create a new curl resource

//    $Url=”http://maps.googleapis.com/maps/api/directions/json?origin=Seneca%20Planetarium%20Seneca%20College,%201750%20Finch%20Ave%20E,%20Toronto,%20Toronto%20Division,%20Ontario%20M2J%205G3,%20Canada&destination=ny,us&sensor=false&alternatives=true&#8221;;

$ch = curl_init();
// set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt ($ch, CURLOPT_POST, 1);
// set referer:

// user agent:
//curl_setopt($ch, CURLOPT_USERAGENT, “MozillaXYZ/1.0”);

// remove header? 0 = yes, 1 = no
curl_setopt($ch, CURLOPT_HEADER, 0);

// should curl return or print the data? true = return, false = print
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// timeout in seconds
//    curl_setopt($ch, CURLOPT_TIMEOUT, 1000);

// download the given URL, and return output
$output = curl_exec($ch);
/*$filename = “json/”.time().”.json”;

$handle = fopen($filename, ‘w+’);
chmod($handle,’777′);
if($handle)
{

if(!fwrite($handle, $output))
die(“couldn’t write to file.”);

}*/

curl_close($ch);
//echo $filename;

echo $output;
//echo $output;

?>

convert accentuated characters of french into english


function stripVowelAccent(str)
{
var s=str;

var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

var repChar=[‘A’,’a’,’E’,’e’,’I’,’i’,’O’,’o’,’U’,’u’];

for(var i=0; i<rExps.length; i++)
s=s.replace(rExps[i],repChar[i]);

return s;
}

Issue of FCK Editor in IE7


Hi Friends….

I noted one minor issue in FCK Editor on IE7.

When i press enter for new line in editor ,at that time, it puts <P> Capital “P” tag in database.

For example

<P>this is content</P>

<P>thi is second line</P>

But at time of view the content , it shows  following this things

<P>this is content</P>

<br/>

<P>thi is second line</P>

Notes:

IE7 automatically appends <br/> tag when it found </P> Capital “P” Tag.

Solution:

Please replace <P> Capital tag with small <p> tag.