Posts

Showing posts with the label JavaScript

Best site to test Regular Expression.

Click here for   Best site to test Regular Expression.

JavaScript Regex Cheatsheet

Regular Expression Basics . Any character except newline a The character a ab The string ab a|b a or b a* 0 or more a's \ Escapes a special character Regular Expression Quantifiers * 0 or more + 1 or more ? 0 or 1 {2} Exactly 2 {2, 5} Between 2 and 5 {2,} 2 or more Default is greedy. Append ? for reluctant. Regular Expression Groups (...) Capturing group (?:...) Non-capturing group \Y Match the Y'th captured group Regular Expression Character Classes [ab-d] One character of: a, b, c, d [^ab-d] One character except: a, b, c, d [\b] Backspace character \d One digit \D One non-digit \s One whitespace \S One non-whitespace \w One word character \W One non-word character Regular Expression Assertions ^ Start of string $ End of string \b Word boundary \B Non-word boundary (?=...) Positive lookahead (?!...) Negative lookahead Regular Expression Flags g Global Match i Ignore case m ^ and $ match start and end of line Regular Expres...

How to track field value changes on form using JQuery?

Below code can track all input fields on form like text, password, check box, select option etc. $('form :input').change(function(){ console.log("Field changed."); });

How to extend Liferay 6.2 session timeout by AJAX call?

There are lot of solutions present on Liferay forum, stackoverflow and many more can be found on google but all are very difficult, not clear and also not working.... So I found a simple solution which is working and I am sharing it with you people, and hope you will find it helpful!!! You just have to add below line to each AJAX call success at client side (in JavaScipt / JQuery / AngularJS). Liferay.Session.extend();

How to get context path in JQuery?

Suppose you want to get your context path in JS/JQuery on clicking an Button like, In JSP/HTML:- <input type="button" id="myButton"> In JQuery :- $('# myButton ').click(function() { console.log( myC ontextPath ); }); Then you can pass values to JS/JQuery as, <input type="button" id="myButton" myContextPath="${pageContext.request.contextPath}"> Then in JS/JQuery you can write as, $('# myButton ').click(function() {         var  myC ontextPath  = $(this).attr(' myC ontextPath '); console.log( myC ontextPath ); });

Login with Facebook example.

Below is the code for logging our application using Facebook. Note: Please change appId : ' 45366235237356756 ' with your Facebook application ID. <div id="fb-root"></div> <script> //Load the Facebook JS SDK (function(d) { var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) { return; } js = d.createElement('script'); js.id = id; js.async = true; js.src = "http://connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); // Init the SDK upon load window.fbAsyncInit = function() { FB.init({ appId : ' 45366235237356756 ', // App ID status : true, // check login status cookie : true, // enable cookie...