Archive for the ‘JavaScript’ Category


Many a times we come across a business case where we need to add multiple markers to Google Map. When markers added on map cross a thousand mark it slows down Google Map big time. In order to handle this scenario, I came up with my custom approach which I have tested with about 10000 points on the map.

(more…)

Beautify XML String in JavaScript

Posted: September 28, 2015 by Sagar Wasule in JavaScript
Tags: ,

Ok so here is a scenario where for requirement I had to properly indent the string xml viz, beautify the xml string with proper indentation.

function formatXml(xml) {

var formatted = '';
var reg = /(>)\s*(<)(\/*)/g;
xml = xml.replace(/\r|\n/g, ''); //deleting already existing whitespaces
xml = xml.replace(reg, '$1\r\n$2$3');
var pad = 0;
jQuery.each(xml.split('\r\n'), function (index, node) {
var indent = 0;
if (node.match(/.+]*>$/)) {
indent = 0;
} else if (node.match(/^<\/\w/)) {
if (pad != 0) {
pad -= 1;
}
} else if (node.match(/^]*[^\/]>.*$/)) {
indent = 1;
} else {
indent = 0;
}

var padding = '';
for (var i = 0; i < pad; i++) {
padding += ' ';
}

formatted += padding + node + '\r\n';
pad += indent;
});

return formatted;
}


So you’ve heard about AngularJS, but you’re not exactly sure how to get started with it?
This tutorial is for you.

AngularJS

AngularJS

This tutorial is going to go through all of the key fundamentals you need to know about the AngularJS SPA (Single Page Application) framework.
My name is Sagar Wasule and I’ll be walking you through some of the key concept which I wish will clear your doubts regarding AngularJS.

Here in this series of articles we will be focusing 100% on AngularJS.

I will provide you with some demos with the help of that I will explain you key concepts of AngularJS.
I came across AngularJS while discussion with my friend about various JavaScript libraries that are available in the programming world. I was really excited to know about this library being developed by Google.

(more…)

Routing in AngularJS

Posted: September 6, 2013 by Sagar Wasule in AngularJs, JavaScript, Programming Concepts
Tags: ,

Here I’m back with a simple implementation of routing in AngularJS

AngularJS

AngularJS

(more…)


In this post I will try to explain how we can exchange data between the 2 controllers in AngularJS using Services.

AngularJS

AngularJS


(more…)


Finally the AngularJS team as provided the onFocus edit functionality in their plugin for Grid. The plugin that we will need to be used is ngGrid plugin you can check out this on AngularJS grid team website. The URL for the same is :http://angular-ui.github.io/ng-grid/

AngularJS

AngularJS


  (more…)


This scenario occured to me when the data returned from a WebMethod was huge. The WebMethod would return the data from its scope but in ajax call the response was accepted in error block. This ajax call was written in Extjs. The plugin used for ExtJs was 4.1

  (more…)

jQuery Grid View

Posted: June 7, 2013 by Sagar Wasule in JavaScript, jQuery, Programming Concepts
Tags: ,

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

Here is a POC that I have implemented for a Grid in jQuery.

(more…)


So this is the issue that most of the developers might be facing on day to day basis while development in javascript.
The issue is even after you made changes in your javascript file but still the old Javascript file is refered, which bugs your mind big time.
A simple solution to this issue is to clear the browser cache and run the application again, but this again is frustrating when your are under pressure to meet deadlines.

So I bring to you a good and simple solution to the issue.
Note: As I’m a .Net developer and uses Visual Studio 2010 I have tested this in Visual Studio 4.0 Environment with Internet Explorer and Google Chrome as browsers.

We generally refer our javascript file as below :

<script language=”javascript” src=”/scripts/myJavaScript.js” type=”text/javascript”></script>

I changed this reference to somewhat like I have mentioned here :

<script src=”@Url.Content(“~/Scripts/myJavaScript.js?” + DateTime.Now.ToString(“ddMMHHmmss”))” type=”text/javascript”></script>

And this works !!!!

NOTE: I implemented this and it worked for MVC3 Razor Engine application.

I have been saved from lot of frustration while development in script files. Hope this will save developers from some frustration.

JavaScript Keycodes

Posted: May 21, 2013 by Sagar Wasule in JavaScript, Programming Concepts
Tags: ,

Javascript is often used on the browser client side to perform simple tasks that would otherwise require a full postback to the server. Many of those simple tasks involve processing text or characters entered into a form element on a web page, and it is often necessary to know the javascript keycode associated with a character.

(more…)