txt

Linux commands and code snippets collection

  • Home
  • About

Tag Archives: js

29 Sep

Finding the Factorial using Recursion

Finding the Factorial using Recursion in javascript.


function factorial(x) {
	if(x <= 1) return 1;
	return x*factorial(x-1);
}
factorial(5);
Binny V A Posted in Code, JavaScript Code, factorial, javscript, js, recursion Leave a comment
28 Oct

Chainable interface in JavaScript

Creating Chainable interfaces in javascript…


(function() {
	function _init() {
		return this;
	}
	
	_init.prototype = {
		"myFunction": function() {
			return this;
		}
		
		// Put all the functions here - make sure all 'return this;'
	}
	
	chainer = function() {
		return new _init();
	}
})();

Roll out your own JavaScript Interfaces

[tags][/tags]

Binny V A Posted in Code, JavaScript chain, interface, JavaScript, jquery, js, return, this Leave a comment
16 Oct

Execute JavaScript files using Rhino

The command to execute a javascript file using rhino.


java -jar /path/to/custom_rhino.jar JS_File.js

Get Custom Rhino(From Dojo Library)

Binny V A Posted in Command Line, JavaScript command, execute, JavaScript, js, rhino Leave a comment
23 Jun

Find Element’s Position using JavaScript

Find the position of an element using javascript


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

Original Article

Binny V A Posted in Code, JavaScript coordinates, dom, element, JavaScript, js, offset, position, xy 15 Comments

Post navigation

Archives

  • October 2017
  • November 2015
  • August 2014
  • November 2013
  • August 2012
  • May 2012
  • March 2012
  • October 2011
  • August 2011
  • January 2011
  • October 2010
  • October 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007

Meta

  • Log in
Fruitful theme by fruitfulcode Powered by: WordPress
↑