Tag Archive for Javascript

Updates to Facebook Javascript SDK for OAuth 2.0

If you’ve recently realized that maybe your current Facebook application is no longer working I have a few areas of your code to check. Like me if you failed to realize that December 13th, 2011 was the deadline for Facebook supporting OAuth 1.0 in it’s Javascript SDK then the following are likely the root causes: “perms” is now to be…

Manipulating Javascript Dates

today = new Date(); year = today.getFullYear(); month = today.getMonth(); day = today.getDate(); my_date = new Date(year, month, day – 23); This will create a new date 23 days in the past. What is really useful is that you don’t have to do the additional math to calculate the date within a past month or year. Javascript will do it…

Comparison Function in Javascript

This function is a simple comparison in order to sort an array based on high to low rather than the default low to high. function mycomparator(a,b) { return parseInt(a) – parseInt(b); } //Use this with a sort function onSaleThisWeek.sort(mycomparator);

Array Search in Javascript

This is just a simple array search function function searchArray(arr, val) { inArray = false; for (i = 0; i < arr.length; i++) if (val == arr[i]) inArray = true; return inArray; }