Wednesday, 27 February 2013

Ebooks for IT - free download


click below link to download free IT related eBooks (PDF format) and also search your favourite books.

Saturday, 2 February 2013

Searching text in a HTML table using jQuery


Searching text in a HTML table using jQuery

Filter Table
Here is the situation. You have a really long table with hundreds of rows and you want to filter the rows(instantly!) that contain a specific keyword in any of the table cells.
This article will show how this can be achieved with the help of jQuery.
View Demo
The HTML
Create a table with some rows with multiple cells. Put a textbox above the table in which search term will be entered.
<div class="tables">
 <p>
  <label for="search">
   <strong>Enter keyword to search </strong>
  </label>
  <input type="text" id="search"/>
  <label>e.g. bar, parking, tv</label>
 </p>
 <table width="100%" id="tblData" class="target" bgcolor="#ACAAFC">
  <tbody>
   <tr>
    <th width="10%">#</th>
    <th width="35%">Hotel Name</th>
    <th width="55%">Facilities</th>
   </tr>
   <tr>
    <td class="odd">1</td>
    <td class="odd">Manu Maharani</td>
    <td class="odd">Attached Bath, Bar, Swimming Pool, </td>
   </tr>
   <tr>
    <td class="even">2</td>
    <td class="even">Hill View</td>
    <td class="even">TV, In-Room Safe, Bar</td>
   </tr>
   <tr>
    <td class="odd">3</td>
    <td class="odd">Hotel Suba Galaxy</td>
    <td class="odd">Paid Internet Access, Coffee Shop, Spa</td>
   </tr>
   <tr>
    <td class="even">4</td>
    <td class="even">The Residence Hotel</td>
    <td class="even">Doctor on Call, Parking</td>
   </tr>
   <tr>
    <td class="odd">5</td>
    <td class="odd">The Taj</td>
    <td class="odd">Currency Exchange, Bar, Golf</td>
   </tr>
   <tr>
    <td class="even">6</td>
    <td class="even">Mumbai Grand</td>
    <td class="even">Jacuzzi, Spa, Coffee Shop</td>
   </tr>
   <tr>
    <td class="odd">7</td>
    <td class="odd">The Promenade</td>
    <td class="odd">Cable TV, Coffee Shop, Spa</td>
   </tr>
   <tr>
    <td class="even">8</td>
    <td class="even">Hotel Regency</td>
    <td class="even">Mini Bar,Golf, Spa, Sauna</td>
   </tr>
   <tr>
    <td class="odd">9</td>
    <td class="odd">Park Plaza</td>
    <td class="odd">Currency Exchange, Bar, Golf</td>
   </tr>
   <tr>
    <td class="even">10</td>
    <td class="even">The Mapple Inn</td>
    <td class="even">Jacuzzi, Spa, Coffee Shop</td>
   </tr>
   <tr>
    <td class="odd">11</td>
    <td class="odd">Cidade de Goa</td>
    <td class="odd">Cable TV, Coffee Shop, Spa</td>
   </tr>
   <tr>
    <td class="even">12</td>
    <td class="even">Saurabh Mountview</td>
    <td class="even">Doctor, Free Parking</td>
   </tr>
  </tbody>
 </table>
</div>
The CSS
Apply the following css to style the table and its cells.
body
{
 font-family:verdana,arial;
 font-size:13px;
 margin:0 auto;
 width:100%;
}
.tables
{
 border:1px solid #000;
 margin:0 auto;
 width:600px;
}
th,td
{
 padding:5px;
}
p
{
 background-color:#ACAAFC;
 padding:10px;
}
a
{
 color:#fff;
 text-decoration:none;
}
.even
{
 background-color:#fff;
 color:#343234;
}
.odd
{
 background-color:#DCDEFC;
 color:#343234;
}
The jQuery Code
$(document).ready(function()
{
 $('#search').keyup(function()
 {
  searchTable($(this).val());
 });
});

function searchTable(inputVal)
{
 var table = $('#tblData');
 table.find('tr').each(function(index, row)
 {
  var allCells = $(row).find('td');
  if(allCells.length > 0)
  {
   var found = false;
   allCells.each(function(index, td)
   {
    var regExp = new RegExp(inputVal, 'i');
    if(regExp.test($(td).text()))
    {
     found = true;
     return false;
    }
   });
   if(found == true)$(row).show();else $(row).hide();
  }
 });
}
View Demo
The jQuery code is simple. searchTable function is called on keyup of textbox. We search for all td elements in each row and then check for the inputted value. A regular expression is used to match the values. If a match is not found, we hide that row. Passing i as second parameter makes the search case-insensitive. Remove it if you want a case-sensitive search.
Another point to note is that this code will not work on nested tables i.e. if you have more tables inside cells.
Future enhancements will include developing it as a simple jQuery plugin and support for searching in nested tables.

Thursday, 31 January 2013

favicon working in all browsers

code goes here for favicon :

<link rel="icon" href="http://www.example.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://www.example.com/favicon.ico"
 type="image/x-icon" />

why doesn't the favicon for my site appear in IE7?
When
 I was at Microsoft, I was the developer tasked with fixing the Favicon 
story for IE7. The original IE6 behavior was to download the favicon 
once--when a user made a site a Favorite. I do not want to go too deep 
into the details of how this craziness works, but the key piece of 
information to understanding why it seemed so broken is this: a mapping 
between the url of the site the url for the site's Favicon would be 
stored in IE's History database and the actually bits of the icon would 
be stored in the temporary Internet files folder. Thus, if you cleared 
your history or your cache, or the item expired out of either one, the 
icon would be gone forever.

Fast-forward to IE7. It has been over
 two (three?) years since IE6 shipped. We want to implement tabbed 
browsing, and we want the tabs to display the correct Favicons. So I 
updated the Favicon code to always download the icon on a first visit. 
The code also remembers if there is no Favicon (404) or it was invalid 
in some way (ExtractIcon() failed). 

Here is a Mini-Faq (with one bonus question at the end) that I wrote 
while I was at Microsoft:

Q: How do I make a favicon appear for my site in IE7?
A:
 There are two ways. The first is to put a file in the root of your 
domain called favicon.ico. The second is to use a <link> tag with 
the rel="shortcut icon" value and the href value set to the URL for the 
Icon you wish to display.

Q: How often does IE download the favicon?
A:
 IE will download the icon when a user first visits the site. The icon 
is stored in the Temporary Internet Files folder on the client machine. 
Additional metadata about the favicon is stored in the user's Url 
History database. If either store is cleared, or items relating to the 
favicon have naturally expired, then the icon will be downloaded again 
on the next visit. If more than one page (or site) shares the same 
favicon, it is only downloaded once. IE takes great pains to download 
the icon as few times as possible to reduce load on the server.

Q: I see the wrong favicon for some sites I visit. How do I fix this?
A:
 If the history database has become corrupted in some way, this can 
happen. The simplest solution is just to use Delete Browsing History (on
 the Tools menu) to clear the cache and the history store. 

Q: I put a favicon.ico on my site as you described, but it still doesn't appear.
A:
 It must actually be a .ico (an Icon) file. Bitmaps, pngs, gifs, etc, 
will not work. IE7 will download your favicon to the Temporary Internet 
Files folder and call ExtractIcon() on the file. If this fails, we will 
show the default icon instead of your favicon.

Q: I verified that my favicon really is an icon, but it still doesn't appear.
A:
 Since IE loads your icon out of the Temporary Internet Files folder, it
 must be able to actually store it there. If you are setting the 
no-cache directive for the icon file, then IE will not be able to 
display your icon and will display the default icon instead. You can use
 Fiddler to verify.

Q: How do I create a different favicon for every page on my site?
A: Put a different tag on each page, pointing to a different icon.

Q: I changed my site's favicon to a different icon, but the old one still shows
 in IE. How do I force IE to update?
A:
 If you just put the favicon.ico file in the root of your domain, IE 
doesn't have any way of knowing if it changed. To force an update, you 
need to use a tag and point to a different filename than you previously 
used. The current filename is compared against the known filename stored
 in the Url History database. When IE sees the filename has changed, it 
will download your new icon. Alternatively, you can ask your users to 
clear their history and cache (Tools->Internet Options->Delete 
Browsing History), which will also force IE to download the new file.

Q: What is still broken?
A:
 Two things: (1) If you specify an alternate location via <link> 
tag, the href member must be fully-qualified and does not respect the 
<base> tag. (2) The <link> tag must have "shortcut icon" as 
the rel value, but this is in violation of the W3C spec that says 
whitespace in the rel tag denotes a list of values. IE treats "shortcut 
icon" as a single value. Luckily this still works for other browsers who
 see "shortcut" and ignore it and only pay attention to the "icon" 
string.

That should cover most of the questions I've received about favicons in IE7. 
If you have more questions, feel free to ask.



Thursday, 17 January 2013

JavaScript - Browser detect

JavaScript - Browser detect
Code goes here :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript - Browser detect</title>
<script>
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
  string: navigator.userAgent,
  subString: "iPhone",
  identity: "iPhone/iPod"
   },
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]

};
BrowserDetect.init();
</script>
</head>

<body>
<script>
document.write('You\'re using ' + BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS + '!');
</script>
</body>
</html>

Saturday, 12 January 2013

Windows XP Shortcuts

Keyboard shortcuts to work on the Windows XP Desktop
win+d Minimizes all open Windows and return to a clean desktop. Pressing it again restores the previous state.
------------------------------------------------------------------------------------------------
arrow keys The arrow keys navigate between objects on the desktop.
------------------------------------------------------------------------------------------------
home and end Activates the first object (top left corner) or the last object (bottom right corner) on the desktop.
------------------------------------------------------------------------------------------------
enter Launches the active object.
------------------------------------------------------------------------------------------------
+f10 Activates context menu of active object. Basically replaces the right mouse button. Once in the context menu, the arrow keys will navigate you to the desired menu item (or press any letter which shows as underlined); pressing enter activates whatever you want to in the context menu.
------------------------------------------------------------------------------------------------
F2 Changes the filename of a desktop icon. Press the arrow keys to go left or right if parts of the old filename should be kept.
------------------------------------------------------------------------------------------------
Hold key, navigate with arrow keys and hit space On the desktop, pressing and holding the key enables to highlight multiple items. Once pressed, move around with the arrow keys and press space for every item which should be highlighted. Hitting space a second time de-selects the item. Once everything is marked as desired, release the -key.
------------------------------------------------------------------------------------------------
+c, +x, +v, +c for copy, +x for cut and +v for paste should be an essential for everyone. If you so happen forget one or the other shortcut on this site, please stick with this most essential keyboard shortcut.
------------------------------------------------------------------------------------------------
alt+tab, alt++tab alt+tab Holding the alt key and continuously press tab to move forward between open applications or folders. Then release the key when the desired object is active to launch it. The same works backwards by adding to the shortcut combination: Hold alt and and then keep pressing tab moves backwards between open applications. The direction can be changed in at any time by pressing and releasing
------------------------------------------------------------------------------------------------
win+tab, win++tab then press enter Pressing +tab will navigate between object of the desktop: the desktop itself, the quick-launch bar (if activate) and the notification bar. This will not work when an Application Window is open, simply press win+d before pressing +tab. Again, the order can be reversed by adding to the combination: ++tab moves backwards. This is a good opportunity to access the notification bar without the mouse for example: Press win+d to get to the desktop, then ++tab to go directly to the Notification Bar, arrow left to go to the clock and press enter to open the Windows calendar without touching the mouse.
------------------------------------------------------------------------------------------------
a, b, c, ... Still on the desktop, pressing the initial letter of the name of any objects will highlight the respective application or folder. It is important to make sure that the focus is actually ON the desktop and not on the start button or taskbar. Simply press win+d twice if nothing is happening when pressing the initial letter and try it again.
------------------------------------------------------------------------------------------------
win+pause Access System Properties which holds system properties, computer name, device manager and so on.
------------------------------------------------------------------------------------------------
win+tab win++tab then press enter alt+tab is not the only way to navigate between open applications and windows. The win+tab keyboard shortcut is actually a more powerful way to switch between application than the good old" alt+tab. The difference is that win+tab is not opening a dedicated window for choosing the desired object: moving forward and backwards between applications is happening directly on the taskbar. To launch an application you press enter to activate the respective element. Combine it with and you reverse the order."
------------------------------------------------------------------------------------------------

To disable the access to USB port, in windows OS

To disable the access to USB port, in windows XP and 2000, follow the steps below
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. Locate, and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
4. In the right pane, double-click Start.
5. In the Value data box, type 4, click Hexadecimal (if it is not already selected), and then click OK.
6. Quit Registry Editor.

no control key to copy/paste

your code goes here :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>no control key to copy/paste</title>
<script language="javascript">
function whichButton(event)
{
if (event.button==2)//RIGHT CLICK
  {
  window.event.returnValue = false;
  }

}
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;

var msg = "Sorry, this functionality is disabled.";
if (parseInt(code)==17) //CTRL
{
alert(msg);
window.event.returnValue = false;
}
</script>
</head>
<body>
<form method="">
<strong>Not Allow Paste </strong><BR>
<input type="text" value="" onMouseDown="whichButton(event)"  onKeyDown="return noCTRL(event)"/>
</form>
</body>
</html>
no control key to copy/paste
Not Allow Paste