Speed Optimization, and updates for GOOPJS

October 5th, 2009

Yesterday I discovered something interesting in programming. When the owner/lead programmer of a framework/project writes code, he/she don’t optimize it after wards. The programmer just continues to develop on top of the existing code, adding enhancements, without improving the existing code.

I found an article on OSFlash that discusses how to optimize Flash’s Actionscript 3 language. There are several other links on that page that link to other developer’s blog experiences and finds on speed optimization. I HIGHLY suggest ALL developers to read and look into it, as well as doing their own speed test experiments (it can be quite fun actually).

I used the tips and tricks in the OSFlash article towards my GOOPJS framework, to optimize speed and memory. Using the keyword ‘var’ less when declaring a variable to save memory and time was a big help. It seems to run the tween method/animation a bit smoother. Other little fixes I did to save file size, was removing unneeded quotes for objects properties. I also implemented an Object called Overlay which opens a div on top of the page, a Class called AllowTabs, to allow tabs in textareas, rewrote the DOM Object to run more efficient and be called sooner, and other little small fixes.

GOOPJS still remains as one of the smallest Javascript frameworks out there, with a lot of commonly used effects, functions, methods, objects, and classes for programmers when developing their site. The others don’t have them built in (some do, some don’t). I believe MooTools is around 65KB, jQuery is around 55KB, and GOOPJS is 42KB at the moment.

Blog > GOOPJS > Javascript

GOOPJS Framework

May 21st, 2009

First of all, wow… its been a long time since I have posted a blog entry. Many apologizes to everyone out there. Life right now for me is getting busier and more complicated.

The past couple of months I have been working on my own Javascript framework like MooTools and jQuery.

I am calling it GOOPJS.

Read the rest of this entry »

GOOPJS > Javascript

Introducing GOOPTracker

December 14th, 2008

GOOPTracker is an ad click tracker for publishers who have ads on their site(s). This is an alternative solution to other ad click scripts such as ClickAider and AsRep to name a few.

So what makes this one different from the others?
To start, its free. The code isn’t encrypted or hard to look through… you can easily understand what is going on through the lines of the code and I have made comments throughout it as well. You don’t need to sign up, or pay; you just download the files, configure/modify it ever so slightly to fit your needs (if you want), that is all. The script is MIT License, but I appreciate any enhancements or updates you have done to the code to help not me but everyone.

Read the rest of this entry »

GOOPTracker > Javascript > PHP

Upload Multiple Files

August 11th, 2008

Recently, I have been working on a project that involved uploading multiple files to the server with PHP. There are several ways to go about doing this: 1) Upload each image one at a time (but that really isn’t a multi uploading way) or 2) Place all the images in an array. Option 1 is pretty much ruled out because you aren’t uploading multiple images at once; And Option 2 is the way to go because that is the purpose of this tutorial, but there is a small problem that you might not be aware: over exceeding the posted max file size that is set in your php.ini file. Assuming you don’t have your own server, and depending on your host, you might be able to ask them to bump this up to a more reasonable amount other than the default 2MB. But usually you are limited because you most likely have a shared web host and they don’t want you to upload too large of a file to disturb the other users on that server, or they don’t want you to take too much space. Which is understandable.

So my solution was to upload each image at a time without leaving the page. How is this possible? With iFrames. I did a simple add and remove row with Javascript, allowing the user to select how many and what files to upload. Once the user selected all the desired files, I use Javascript again to check if all the files had the correct extension (.png in this case), then submit each form at a time after the other one got completed. I am not going to bother to explain the code the this time around, because I believe the explanation is well enough the code to understand.

Here is the sample
(of course the files aren’t being uploaded… just the page refreshes letting you know if it worked correctly or not).

And here are the files used to do the magic: zip

Javascript > PHP


July 24th, 2008

When dealing with forms its very important to validate what the user entered so you don’t get false email address, phone number, zip code, etc. There are multiple ways to validate what the user entered in the input field of your form(s). The way I suggest and I am going to share with you is through Javascript. I wrote a nifty little function called validate which takes the two required parameters, the first being what you want validate, and the second is the value or string to validate/test it with. Here is the function:

function validate(what,str) {
if(what == “email”) {
// sample@sample.com
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return filter.test(str);
} else if(what == “phone”) {
// (123) 456-7890
var filter = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
return filter.test(str);
} else if(what == “num”) {
// must be a number, or can’t be zero
if((str / str) == 1 && str != 0) { return true; }
else { return false; }
} else if(what == “zip”) {
// 12345 or 12345-1234
var filter = /\d{5}(-\d{4})?/;
return filter.test(str);
} else if(what == “date”) {
var filter = /^([1-9]|0[1-9]|1[012])\D([1-9]|0[1-9]|[12][0-9]|3[01])\D(19[0-9][0-9]|20[0-9][0-9])$/;
return filter.test(str);
} else if(what == “url”) {
// http://www.sample.com or www.sample.com
var filter = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return filter.test(str);
} else if(what == “ext”) {
// personally, I only accept images with jpg/jpeg, gif, or png format. But this can anything to your liking
str = str.toLowerCase();
if(str.lastIndexOf(“.jpg”) == -1 && str.lastIndexOf(“.jpeg”) == -1 && str.lastIndexOf(“.gif”) == -1 && str.lastIndexOf(“.png”) == -1) { return false; }
else { return true; }

This function does a lot different validating and testing, and of course this can continue to grow to your pleasing. As of now, the function is set up to return either true or false. I suggest keeping it this way if you plan adding or changing some of the regular expression checking. This is how to use the function:

// get the phone value from the form
var phone = document.forms[0].phone.value;

// validate the phone number
if(!validate(“phone”,phone)) {
alert(“Invalid Phone Number entered”);

If the phone number is invalid, then it will do an alert telling the user that they didn’t enter the correct syntax for the phone number. If it was entered correctly then it was entered correctly and javascript will continue with the rest of the script.

I hope you find this useful. Enjoy!

Javascript > Website