Skip to main content

Posts

Showing posts with the label javascript

Disconnected Architecture

Being a .Net Developer and using the open technologies, I have lots of options of taking the advantage of the framework but once you started growing in your career, more then What technology you use? the question become How the technology is used ? and that is Architecture. An architecture of a something you are implementing is very important once you start writing the code. If you are writing a mobile application that needs to be cross browser compatible and can work on on any mobile device, you need to follow the modern architecture that is getting common across all the application. The architecture should use SPA (Single Page Application) and REST api's and should be devoid of any stored proc to avoid complexity. Let's start with why to use SPA, A SPA is written in HTML5, JS, CSS3 and lots of other JS libraries. The other JS libraries has some basic needed libraries like .less or .sass for css maintenance, Require JS for correct Integration of code and ofcourse ...

Decoding the date sorting in Javascript, efficient faster and native way.

Coming from the previous post  (   http://www.developerscloud.org/2014/05/decoding-underscore-js-sortby-sorting.html ) ,  where we have used the underscore to sort the array, with the limitation of sorting in descending order, I will show you in below post how to sort effectively using javascript native functionality. Lets use the same array we have in the previous post. var datesArray = ['6-01-2014','2-01-2014', '4-01-2014', '5-01-2014', '3-01-2014', '1-01-2014']; datesArray is now [" 6-01-2014 ", " 2-01-2014 ", " 4-01-2014 ", " 5-01-2014 ", " 3-01-2014 ", " 1-01-2014 "] Running the for loop making each item of array a date type object. for(var i = 0; i< datesArray.length; i++){ datesArray[i] = new Date(datesArray [i]); } After which datesArray will become [Sun Jun 01 2014 00:00:00 GMT+0530 (India Standard Time), Sat Feb 01 2014 00:...

Decoding underscore js SortBy - Sorting in javascript

Sorting can be the developers worst nightmare especially if it is done in more then one field. So what can help, recently doing research on it I came across underscore js sortBy (underscorejs.org/#sortBy) function which will help you to sort the array very effectively. So I was going through the documentation and found it very useful, but there are one drawback of it. Will let you know that: How to order in Ascending Order _.sortBy([6, 2, 4, 5, 3, 1], function(num){ return num }); [ 1 , 2 , 3 , 4 , 5 , 6 ] How to order in Descending Order _.sortBy([6, 2, 4, 5, 3, 1], function(num){ return -num }); [ 6 , 5 , 4 , 3 , 2 , 1 ] The underscore sort by will also work with string literals Ascending _.sortBy(['6','2', '4', '5', '3', '1'], function(num){ return num }); [ " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " ] Descending _.sortBy(['6','2'...

Refresh the Jquery Css for a HTML control using knockout in Javascript.

If you are a JavaScript developer then you might have come across a situation where you load your HTML controls after the page load has happen, which is like dynamic binding of controls. And then you see your input type text doesn't have the proper Css as other inputs. You also load select (dropdown)  that also doesn't have the proper css. You are in chrome and press F-12 to inspect the element, y ou see that nothing is there in control, it is not applying the JQuery css. But the controls that are loaded in page load have it. What to do, no options just to manually copy the CSS classes. VERY BAD IDEA? Just do this, In HTML < input type ="date" data-bind ="i nputsRefresh: $element, value: $data.EndDate " /> and in JS binding handler

JavaScript is too cool and so is the inheritance.

I can say million words about Javascript, it is so cool. We will start with the   inheritance  in the JAVASCRIPT which will make our concepts a little shaky as it implements prototypical inheritance which are not bad the point is we are not used to code in JS. As almost everyone in this world are from JAVA or .NET background. Inheritance is an important topic in most programming languages. In the classical languages (such as Java), inheritance (or extends) provides two useful  services. First, it is a form of code reuse. If a new class is mostly similar to an existing  class, youonly have to specify the differences. Patterns of code reuse are extremely  important because they have the potential to significantly reduce the cost of software  development. The other benefit of classical inheritance is that it includes the  specification of a system of types.  This mostly frees the programmer from having to  write exp...

Grunt - A command line JavaScript task runner.

Grunt is a JavaScript task runner that will help you to mini-fy the various JS files. It will make your work really less while performing repetitive tasks like minification, compilation, unit testing, linting, etc with just few lines of code you need to write in command prompt. Grunt is a task-based command line build tool for JavaScript projects. If you have a Javascript and html based project that used MVVM model and you have millions of lines of code to minimize then grunt is the key for you. Some of the p lugins Grunt can enjoy. Some of the big IT companies that uses grunt.. and Below is the starter guide provided by grunt official website to keep you jump started. have fun in grunting.  Getting started: Grunt and Grunt plugins are installed and managed via  npm , the  Node.js  package manager. Grunt 0.4.x requires Node.js version  >= 0.8.0 . Installing the CLI In order to get started, you'll want to in...

Rise, Fall and Struggle of Microsoft .Net [Article]

Some years ago there was a guy named Vinod Khosla from IIT- Delhi and Stanford. This awesome guy co-founded Sun Microsystem. Sun Microsystem as we all know is fully undertaken by Oracle. But Sun Microsystem came up with a fantastic language called Java. This language was becoming too famous and popular since its birth and by 90's its JAVA, JAVA and only JAVA everywhere. Microsoft who was struggling with the PC market at that time want's to capture the opportunity and Microsoft was building everything like the OS  and Office and Java was taking the credit of so called windows application so then MICROSOFT plans to launch its own language. Yes, so think back a decade or so ago. As you may recall, .Net was supposed to be much more than just the next version of Windows DNA or COM+ or COM. It was supposed to destroy Java, extend the Windows platform, and secure the Microsoft monopoly for another decade or two. But then what happened after the DOT COM BUBBLE. Rise Like m...

HTML and JavaScript Validated form (Simple and Easy)

Hi, In the following web form we have used a simple HTML table and Inline CSS styling, the validation is done via java-script, its vulnerable to threats coz anyone can copy your form from browser and send some idiotic data in it, but good for beginners, all we need is captcha in it to make it more effective. The submit button do nothing, it doesn't have any db call attached with it, so don't worry you can add as much dummy data in it to check the validations. I have taken almost all the required validation and you can take the native code by saving the web page, open it in notepad, search for 'A simple WEB form'. Enjoy...