Javascript

Javascript : Parsing URL Query Params

Posted on Updated on

Parsing the URL query string in plain Javascript , code snippet below :

function getUrlVars() {

var vars = [], hash;

var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) +
1).split(‘&’);

        for(var i = 0;  i < hashes.length;  i++){

hash = hashes[i].split(‘=’);

hash = hashes[i].split(‘=’);

vars.push(hash[0]); vars[hash[0]] = hash[1];

}

      return vars;

}

Advertisements

JQuery : DataGrid with AJAX response using jeasyui API

Posted on Updated on

API Documentation :  https://www.jeasyui.com/documentation/index.php

<link rel=”stylesheet” type=”text/css” href=”themes/bootstrap/easyui.css”>

<link rel=”stylesheet” type=”text/css” href=”themes/icon.css”>

http://jquery.min.js

http://jquery.easyui.min.js http://datagrid-detailview.js

 

$(function(){$(function(){

$(‘#tt’).datagrid({

title:’Search Results :’,

width:1000,

height:400,

style:’margin-left:500px;margin-top:200px;’,

remoteSort:false,

singleSelect:true,

nowrap:false,

fitColumns:true,

loadMsg:’Please wait loading….’,

pagination:true,

url:”,//REST Service

columns:[[

{field:’uniqueid’,title:’Unique Id’,align:’center’,width:50},

{field:’filename’,title:’File Name’,width:120,align:’center’,sortable:true}, {field:’version’,title:’Version’,width:80,align:’center’,sortable:true}, {field:’softwaretype’,title:’Software Type’,width:80,align:’center’,sortable:true,formatter:formatsoftwaretype}, {field:’operatingsystem’,title:’Operating System’,width:80,align:’center’,sortable:true,formatter:formatostype}, {field:’productname’,title:’Product Name’,width:80,align:’center’,sortable:true}, {field:’entitled’,title:’Entitled?’,width:40,align:’center’,sortable:true}, {field:’accountnumber’,title:’Account Num’,width:60,align:’center’}, {field:’publishdate’,title:’Publish Date’,width:60,align:’center’}, {field:’downloadurl’,title:’Download’,width:70,align:’center’

} });

 });

HTML Code :

<body><body> <table id=”tt” ></table></body>

AngularJS : $scope and $rootScope

Posted on

$scope is an object that is accessible from current component e.g Controller, Service only. $rootScope refers to an object which is accessible from everywhere of the application we can say it is a global scope of variable.

You can think $rootScope as global variable and $scope as local variables.

blog

Javascript : Difference between == and ===

Posted on

JavaScript has both strict and type-converting equality comparison.

  • Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.
  • Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
  • Two Boolean operands are strictly equal if both are true or both are false.
  • Two objects are strictly equal if they refer to the same Object.

 

Lets take an example – 

if(0 == false ) {

console.log(“inside if”);

}

Here the type conversion happens first and then comparison is done , Hence the condition is true and inside if will be printed on the browser console .

Now ,

if(0 === false ) {

console.log(“inside if”);

}

Here type conversion does not happen , Hence the if condition is false , thread will not go inside if condition .

 

Other Examples in same way –

1 == “1” // true, automatic type conversion for value only
1 === “1” // false, because they are of a different type
null == undefined // true
null === undefined // false