“Hacking is bad, m’kay.”

I thought that it would only take me one more day for me to finish this CMS my company is building. 4 hours of code later everything is broken. 2 weeks of hard coding and hacking in every feature finally caught up to me. One thing breaks and you’re fucked. Without tests you can’t even tell whats breaking it.

Every problem I faced I just blew over with some retarded hacks. For instance, I have an array of all the products that I use to display the images and metadata. Then it becomes necessary to implement pagination. So I decide to just create a new array for every page. Then my indexing arrows don’t work. My genius inspired me to just multiply the index by the amount of products on the page, and then add the index.

Prefect code.

I’m then I added a jquery plugin to colorbox a menu and everything is fucked. What??!?! Another 4 hours of code later and my partner and I broke everything. We are straight gangsters. One last day of work becomes another week of work and way off schedule.

37845862

function showDCDetails(index)
{
	var pageOfChains = dcPagination(currentDcPage* dcPageSize, dcPageSize, allDC);
	var dc = pageOfChains[index];
	all_dc_index = ((currentDCPage * 7) + index);
	
	var all_dc = allDC[all_dc_index];
	console.log("allDC[all_dc_index]  ", allDC[all_dc_index]);
	var test = allDC[index];
	selected_dc = all_dc;
	$("#dc_chain_ul").empty();
	$("li").click(function() {
		$("a",this).addClass("selectedRow").parents().siblings().children().removeClass("selectedRow");
	});
	if (currentDcPage == 0) {
		$("#dc_title").val(dc.chainName);
	}else{
		$("#dc_title").val(all_dc.chainName);
	}
	
	
	// console.log("total items:",dc.items);
	console.log("HELLOOOOO", all_dc.items);
	
	for(var j = 0; j < all_dc.items.length; j++) 
	{
		console.log("ITEMS", all_dc.items);
		var row = $('<li></li>');
		if(j%2 == 0)
		{
			if (all_dc.items.length > 3) 
			{
				$("#deleteDCProductButton").show();
				$("#deleteDCProductButton").attr("onclick", "onRemoveProductPressed(\""+selected_dc.chainId+"\")");
			}
			else
			{	
				$("#deleteDCProductButton").hide();
			}

			// product
			var product = all_dc.items[j];
			populateRowWithProductIdAndIndex(product.productId,j);
			row.append($("<a><img id='prodRow"+j+"' onclick='showProductsForSelection("+j+")' src='img/no_product.png' width='320px' height='568px'></img></a>"));
			
		}
		else
		{
			// story
			var story = all_dc.items[j];
			row.append($("<textarea id='storyText"+j+"' onchange='onDCStoryChanged("+j+")' class='prodTextArea' rows='3'>"+story.body+"</textarea>"));
			
		}
		$('#dc_chain_ul').append(row);	
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s