Saturday, May 25, 2013

Finished design and js annoyances

Today I spent majority of my time browsing wj/hf/tbn and fixing an older html template.  Btw here's the website that I finished recently:

I know you might not like the design but that was all by the person that provided it too me.  All I did was code it exactly the way he specified (and there were plenty of specifications).

Other than that while fixing another template I found that when you get a repeating decimal in js you'll just get the NaN result.  While trying to resize images according to the width of the container they were in and their margin-right I kept getting the damn NaN.  I tried avoiding it but eventually gave up ending with this code:
var imageCount = $('.slider-wrapper img').length;
var marginRight = $('#thumbnails div').css('margin-right').replace('px', '');
var width = $('#thumbnails').css('width').replace('px', '');
var thumbLength;

width = width - (imageCount * marginRight);
thumbLength = width / imageCount;
$('#thumbnails div').css('width', ((+thumbLength).toFixed(1)).replace(/^-?\d*\.?|0+$/g, '').length);


This line: ((+thumbLength).toFixed(1)).replace(/^-?\d*\.?|0+$/g, '').length
Was supposed to round for me so it wouldn't return that NaN but that didn't work.  It would just return 1.  btw I've also tried Math.Round, Floor, and Ceil and none of them worked either.  I'm just really aggravated that js doesn't have something to round off repeating decimals automatically like many other languages have.

Other than that I've been looking to buy a high potential (for earnings from adsense) website for cheap.  I didn't expect to find any today but I'm going to keep an eye open for any good deals.  It'd be nice to get a website where majority of the work is done and I only need to mod a couple things to start earning.  I'm too tired to really code anything today so I'm going back to browsing till I pass out.  Pce.

No comments:

Post a Comment