Saturday, 12 October 2013

querySelector in javascript

Syntax

element = document.querySelector(selectors);
where
  • selectors is a string containing one or more CSS selectors separated by commas.

Example

In this example, the first element in the document with the class "myclass" is returned:
var el = document.querySelector(".myclass");
Returns null if no matches are found; otherwise, it returns the first matching element.
If the selector matches an ID and this ID is erroneously used several times in the document, it returns the first matching element.
Throws a SYNTAX_ERR exception if the specified group of selectors is invalid.
querySelector() was introduced in the Selectors API.
The string argument pass to querySelector must follow the CSS syntax. To match ID or selectors that do not follow the CSS syntax (by using a colon or space inappropriately for example), it's mandatory to escape the wrong character with a double back slash:
<div id="foo\bar"></div>
<div id="foo:bar"></div>

<script>
document.querySelector('#foo\bar')    // Does not match anything
document.querySelector('#foo\\\\bar') // Match the first div
document.querySelector('#foo:bar')     // Does not match anything
document.querySelector('#foo\\:bar')   // Match the second div
</script>

set indeterminate checkbox using jquery


$("#checkall").prop("indeterminate",true);

Thursday, 10 October 2013

jquery selecter tips

Increase Specificity from Left to Right

A little knowledge of jQuery’s selector engine is useful. It works from the last selector first so, in older browsers, a query such as:

$("p#intro em");
loads every em element into an array. It then works up the parents of each node and rejects those where p#intro cannot be found. The query will be particularly inefficient if you have hundreds of emtags on the page.
Depending on your document, the query can be optimized by retrieving the best-qualified selector first. It can then be used as a starting point for child selectors, e.g.

$("em", $("p#intro")); // or
$("p#intro").find("em");

Monday, 9 September 2013

Using require() vs. define()

 both require() and define() to load dependencies. Understanding the difference between those two functions is essential to managing dependencies. The require() function is used to run immediate functionalities, while define() is used to define modules for use in multiple locations.

Wednesday, 21 August 2013

jquery Is vs hasClass

The is is multi-purpose, you can for example do is('.class')is(':checked'), etc which means ishas more to do where is hasClass is limited which only checks for a class being set or not.
Hence, hasClass should be faster if performance at any level is your priority.
You can always validate performance on this site as well over multiple browsers: jsperf.com ...These are some test cases to browse: jsperf.com/browse

Thursday, 15 August 2013

Cache Memory


Cache memory (pronounced as “cash”) is placed between CPU and main memory. It is a semi-conductor memory consisting of static RAMs. It is a special and very high speed memory called a cache used to increase the speed of processing by making current program and data available to the CPU at a rapid rate.

It stores instruction, codes, and data, which are to be currently executed by the CPU. It is used to reduce the average access time for instruction and data, which are normally stored in the main memory. A cache memory also needs a cache controller for which cache controller ICs are available.

The technique of accessing a cache memory differs from that of main memory. It work according to ‘hit and miss’ on the matching of addresses from main memory to CPU and to it.

Cache memory is placed at two-three levels: first, second, and third level as L1, L2 and L3. Some microprocessor contains L1 and L2 and some contains L1, L2 and L3 within the microprocessor. Cache within the microprocessor is internal cache and outside the processor is external cache. So we can say cache memory in computer system is to compensate the speed difference between the main memory access time and processor logic. The use of cache memory lets the processor work in its actual speed.

Thursday, 8 August 2013

Prevent double form submission in jquery

Function Debouncing with Underscore.js

Double submission in a form is the worst thing that can happen to you. Fortunately with the _.debounce() method it's easy to prevent it. What you have to do is set the third parameter of the debounce() method to true. This way, the function is triggered when you click the submit button but it won't be triggered again in case the submit button is clicked the second time in quick succession (double submission).
// prevent double click
$('button.my-button').on('click', _.debounce(function() {
    console.log('clicked')

    // code to handle form submition

}, 500, true)

Monday, 5 August 2013

redirect website when javascript disable

  <noscript><meta http-equiv="Refresh" content="1;url=enablejavascript.html" /></noscript>

Wednesday, 31 July 2013

Elements are removed from HTML5

Removed Elements

The following HTML 4.01 elements are removed from HTML5:
  • <acronym>
  • <applet>
  • <basefont>
  • <big>
  • <center>
  • <dir>
  • <font>
  • <frame>
  • <frameset>
  • <noframes>
  • <strike>
  • <tt>

Wednesday, 17 July 2013

multiple CSS properties select in jquery

Q)  Is it possible to get value of multiple CSS properties in single statement?

Q)  multiple CSS properties in single statement

Q)  Select multiple CSS properties in jquery

 
Answers :   Well, before jQuery 1.9 release it was not possible but one of the new feature of jQuery 1.9                       was .css() multi-property getter.


var Collection = $("#login").css([ "width", "height", "backgroundColor" ]);

Collection will be an array and it will look something like this

{ 
  width: "100px", 
  height: "200px", 
  backgroundColor: "#FF00FF" 
}

Tuesday, 16 July 2013

prevent country specific redirection in blog

 If you want to prevent this country specific redirection then follow the steps given below.
Step 1 
Goto 'Design' from your blogger dashboard.
Step 2
Then select 'Edit HTML'.
Step 3
Find <Head> and paste the code given below right below it. 

<script type='text/javascript'> var str= window.location.href.toString(); if ((str.indexOf('.com/'))=='-1') { var str1=str.substring(str.lastIndexOf(".blogspot.")); if (str1.indexOf('/')=='-1') { var str2=str1; } else { var str2=str1.substring(0,str1.indexOf('/')+1); } window.location.href =window.location.href.toString().replace(str2,'.blogspot.com/ncr/'); } </script>

Tuesday, 2 July 2013

memcached for windows 7 download

    Download link
     memcached (32 bit)   https://www.box.com/s/0mybpplvz60f62dveoq7

      msvcr71.dll 
       http://www.dll-files.com/msvcr71.zip?0WJeVBVKmR

Extract msvcr71.dll from msvcr71.zip. We recommend that you extract msvcr71.dll to the installation directory of the program that is requesting msvcr71.dll.
If that doesn't work, you will have to extract msvcr71.dll to your system directory. By default, this is:
C:\Windows\System (Windows 95/98/Me)
C:\WINNT\System32 (Windows NT/2000)
C:\Windows\System32 (Windows XP, Vista, 7)
If you use a 64-bit version of Windows, you should also place msvcr71.dll inC:\Windows\SysWOW64\
Make sure overwrite any existing files (but make a backup copy of the original file).
Reboot your computer.
If the problem still occurs, try the following:
Open Windows Start menu and select "Run...".
Type CMD and press Enter (or if you use Windows ME, type COMMAND)).
Type regsvr32 msvcr71.dll and press Enter.

Monday, 24 June 2013

iis web site host local network


  in windows 7 your Firewall needs to be configured to accept incoming calls on TCP Port 80
  1. go to windows firewall with advance security
  2. Inbound Rules -> Action -> New Rule
  3. select Predefined radio button and then select the last item - World Wide Web Services(Http)
  4. click next and leave the next steps as they are (allow the connection)