Parsing data from an array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var arrayforPrinting = [{
    "firstName": "Soumya",
        "lastName": "Ghosh",
        "profession": "Developer",
        "type": "red"
}, {
    "firstName": "Sherry",
        "lastName": "Krieg",
        "profession": "Therapist",
        "type": "white"
}, {
    "firstName": "Snoop",
        "lastName": "Krieg",
        "profession": "Dog",
        "type": "blue"
}
 
];
 
var html = "";
 
$.each(arrayforPrinting, function () {
    html += '<tr><td>' + this.firstName + '</td>';
    html += '<td>' + this.lastName + '</td>';
    html += '<td>' + this.profession + '</td>';
    html += '<td style="background:' + this.type + '"></td><tr>';
});
 
$('.dataTable').append(html);
I am grabbing the data feed at a client side variable and then iterating through the object to print the data as a list

Blocking Redirect based on excluded IP

1
2
3
4
5
6
7
8
9
10
11
12
13
var redirectIPExcludeList = ["213.235.0.105","213.235.0.106",
"86.12.149.50","79.173.148.50","207.164.206.66","1.0.0.255"]
var returnedIp = "213.235.0.106"
 
for(var i =0; i< redirectIPExcludeList.length; i++){
    if(returnedIp != redirectIPExcludeList[i]){
        alert('failed : '+ redirectIPExcludeList[i] + ' != ' +returnedIp );
    }else{
        alert('Perfect Match : '+ redirectIPExcludeList[i] + ' = ' +returnedIp);
        break;
    }
 
}
This was built in demandware. I developed a framework where the business managers from our global offices entered their IP addresses to prevent the default redirect. The redirect project works on an idea to check the clients IP address and then redirect the user to the respective country website. If the IP is coming from the US and the excluded list no redirect happens.

Select checkbox with a div

1
2
3


JS snippet
1
2
3
4
$('.trigger').click(function(){
    $('input[type=checkbox]').prop('checked', false);
    $('input[type=checkbox]').eq($(this).index('.trigger')).prop('checked', true);
});
I built this piece real quick to accommodate a requirement where the users would make on screen selections by clicking images. This was built to do an online promotion for hair treatment product where the user would make selection by clicking product image. In the background the would get registered as a form input which then will get sent to the marketing team along with the users other credentials, such as address and email.

Data Visualization

dataviz Visualizing NYC buildings with oil boilers, including fuel consumption. Circle radius is directly proportional to the consumption.

Digital countdown clock

: : :
This project was developed to show a count down clock for ninewest.com black friday promotion. These type of applications can be very effective for any time based events. A typical example can be to illustrate how much time left for an ongoing auction on ebay.

JS sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
setInterval(function () {
    var future = new Date("Mar 05 2014 21:15:00 GMT+0200");
    var now = new Date();
    var difference = Math.floor((future.getTime() - now.getTime()) / 1000);
 
    var seconds = fixIntegers(difference % 60);
    difference = Math.floor(difference / 60);
 
    var minutes = fixIntegers(difference % 60);
    difference = Math.floor(difference / 60);
 
    var hours = fixIntegers(difference % 24);
    difference = Math.floor(difference / 24);
 
    var days = difference;
 
    $(".seconds").text(seconds + "s");
    $(".minutes").text(minutes + "m");
    $(".hours").text(hours + "h");
    $(".days").text(days + "d");
}, 1000);
 
function fixIntegers(integer) {
    if (integer < 0) integer = 0;
    if (integer < 10) return "0" + integer;
    return "" + integer;
}
}