Category Archives: javascript

Cycle

function clearValueTab()
{
	var ITD="";
	for(var i1 = 0; i1 < 3; i1++)
		for(var i2 = 0; i2 < 2; i2++)
			for(var i3 = 0; i3 < 2; i3++)
				for(var i4 = 0; i4 < 2; i4++)
				{
					ITD=(i1==0?'N':(i1==1?'S':'F'))
						+(i2==0?'N':'S')
						+(i3==0?'N':'S')
						+(i4==0?'N':'S');
					if(document.getElementById(ITD+"_T"))
						document.getElementById(ITD+"_T")
							.parentNode.style.display="none";	
				}
}

Hope that this stuff works. I’m not going to touch it.

Just found in the codebase of the big TLC company

Advertisements

With or without CRM

	var ccNoCRM=[
		 [0,-1,-1,-1,-1],
		 [1,1,1,0,0],
		 [2,1,1,0,0],
		 [3,1,1,0,0],
		 [4,1,1,0,0],
		 [5,0,0,0,0],
		 [6,0,0,0,0],
		 [7,0,0,0,0]
		];

	var ccYesCRM=[
		   [0,-1,-1,-1,-1],
		   [1,1,1,0,0],
		   [2,1,1,0,0],
		   [3,1,1,0,0],
		   [4,1,1,0,0],
		   [5,0,0,0,0],
		   [6,0,0,0,0],
		   [7,0,0,0,0]
		  ];

I think, it sunk my cruiser :/

Just found in the codebase of the big TLC Company


There’re not going to be…

… more than one thousand!

	var i;
	for (i = 0; i < 1000; i++){
		if (document.getElementById('row_' + i) != null){
			...
		}
	}

If you have to roll through a table, and you don’t know how many elements it has, choose an arbitrary high number and check for nulliness, all right.

In the codebase of the Big Bank


Date parsing perversion /3

If you have to remove 15 days from a date, which way you’re going to take?

   	switch(endMonth) 
   	{
		case '01':
			startDay = startDay = 31 - (15 - endDay);
			startMonth = '12';
			startYear = endYear - 1;
			break;
		
		case '02':
			startDay = startDay = 31 - (15 - endDay);
			startMonth = '01';
			startYear = endYear;
			break;
			
		case '03':
			var isBisestile = startYear%4;
			var offset = (isBisestile == 0)? 29: 28;		
			
			startDay = offset - (15 - endDay);
			startMonth = '02';
			startYear = endYear;
			break;
			
		case '04':
			startDay = 31 - (15 - endDay);
			startMonth = '03';
			startYear = endYear;
			break;
			
		case '05':
			startDay = 30 - (15 - endDay);
			startMonth = '04';
			startYear = endYear;
			break;
			
		case '06':
			startDay = 31 - (15 - endDay);
			startMonth = '05';
			startYear = endYear;
			break;
			
		case '07':
			startDay = 30 - (15 - endDay);
			startMonth = '06';
			startYear = endYear;
			break;
			
		case '08':
			startDay = 31 - (15 - endDay);
			startMonth = '07';
			startYear = endYear;
			break;
			
		case '09':
			startDay = 31 - (15 - endDay);
			startMonth = '08';
			startYear = endYear;
			break;
			
		case '10':
			startDay = 30 - (15 - endDay);
			startMonth = '09';
			startYear = endYear;
			break;
			
		case '11':
			startDay = 31 - (15 - endDay);
			startMonth = '10';
			startYear = endYear;
			break;
			
		case '12':
			startDay = 30 - (15 - endDay);
			startMonth = '11';
			startYear = endYear;
			break;   				
    }

I hope not this one.

Many thanks to the Big Bank for providing me such gems