Blog

  • Write a simple http-server using nodejs

    This an quick guide to create an http web server using nodeJS.Download and Install NodeJSIf you haven’t installed Node yet, download the latest stable release of NodeJS from https://nodejs.org and install using all the default options.Create a package.json file in your website root folder. And add the following,{ "name": "<project-name>", "version": "1.0.0", "url": "<project-documentation-url>", "git": "<project-github-repo-url>", "private": true, "designer": "<author-name>", "designerURL": "<author-website-url>", "license": "Apache License, Version 2.0", "licenseURL": "<project-licesnse-url>", "scripts":{ "start": "node index.js" }, "dependencies": { "express":"^4.15.3", "copy": "0.3.0" }...
  • Batch Download Using Javascript

    So here is the requirement, just think you have a website with an image album and you want to extract all the images at once. Right now you have to go through each image thumbnail and click to open the original size image and then you have to manuallysave each image one by one.So here is an quick way to overcome this using Chrome developer tools console.Note:- This might not work for some websites where it has protected imagesBelow is a sample code for websites which use jquery. But we can use the same logic and write a raw javascript script.JavaScript (jQuery)$('div.img').each(function(){ // Write some logic to capture the url of the original image of each element // This is the part you have to figure how to find the image url. // This is completely depends on the website im...
  • Inject HTML Partial By Detecting Comment Block

    Well here is an quick method to do it. See the example below.Sample HTML<!-- [UUF-ZONE]{"name": "contents","zone": "start"} --><div>Contents Zone</div><!-- [UUF-ZONE]{"name": "contents","zone": "end"} --><br><br><!-- [UUF-ZONE]{"name": "footer","zone": "start"} --><div>Footer Zone</div><!-- [UUF-ZONE]{"name": "footer","zone": "end"} -->JavaScript/jQuery Code$(function() { var commentsObj = {}; $("*").contents().filter(function(){ return this.nodeName == '#comment'; }).each(function(i, e){ var commentName = e.nodeValue; if(commentName.indexOf('[UUF-ZONE]') >= 0){ var commentValue = commentName.replace('[UUF-ZONE]', ''); commentValue = JSON.parse(commentValue); if(...
  • Writing a Javascript Plugin

    This is an quick way of start writing a raw javacript component plugin. And see below how the usage works.Usage:This will just show a popup window with a content in it.var newMessage = new popupMessage({ content: '<p>Hello World!</p>',});newMessage.show();Sample Plugin:Javscript plugin for toggle popup div with some dynamic content. popupMessage.js/*! * popupMessage v1.0.0 (http://jeradrutnam.com) * Copyright 2016 Jerad Rutnam. * Licensed under the MIT license */(function() { /** * @description Constructor */ this.popupMessage = function() { // Global references this.btnClose = null; this.modal = null; this.overlay = null; // Default options var defaults = { className: 'default-class', btnClos...
  • Version specific CSS for Microsoft IE

    Here are few methods to target Microsoft Internet Explorer. Most are provided by Microsoft for their browser versions,IE Conditional Comments for Internet Explorer 9 & Below<!--[if lt IE 7]> <html class="ie ie6"> <![endif]--><!--[if IE 7]> <html class="ie ie7> <![endif]--><!--[if IE 8]> <html class="ie ie8"> <![endif]--><!--[if IE 9]> <html class="ie ie9"> <![endif]--><!--[if gt IE 9]> <html class="ie"> <![endif]--><!--[if !IE]><!--> <html> <!--<![endif]--><!--[if IE]> <link rel="stylesheet" type="text/css" href="ie-only.css" /><![endif]-->IE CSS Hacks for Internet Explorer 8 & Below/* For IE 8 & Lower css...