fabriciocs / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

Proper Object Structure & Code Shrink #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following is a more proper rendering of the object and it cuts the
script size by about 20%. I could not find any way to mail this or check it
in so I have posted it here...

I have consolidated the two util objects and moved them inside the object
creator function. Thus creating private methods. Since there was only one
constructor remaining I and removed the deconcepts namespace and alias
code. One could easily add the deconcepts namespace again if they felt it
was important. However, since practically all examples use the alias I
opted not to include it.

I removed the backwards compatibility aliasing as well. The
deconcepts.util.getRequestParameter has been made a private call and I
suspect that the nobody much uses the FlashObject alias anymore. The
FlashObject could also be readded although I see no reason to support
ancient history when it is a simple search replace to upgrade.

I've tried to optimise this code by limiting the number of functions that
were called and therefore speeding it up a small amount. I've also replaced
the function getVariablePairs with a function getFlashvars. which is
basically the same but adds the join('&') inside the function instead of
outside where it was called before.

I've removed many unnecessary parenthesis and curly brackets to streamline
the code. All one-line loops no longer have parenthesis. In addition I've
consolidated several statements preceeded by variable declarations. There
were also many inconsistent format mistakes that I tried to a single style.
This code should be much easier to extend since the code is no longer
fragmented.

Finally, I added a new function for adding multiple flashvars to allow for
more terse code at the user level:

SWFObject.addFlashvars({
somevar: 'value',
somethingelse: 'Something else',
etc: true
});

I hope all of these enhancements are to your liking...

- Micon Frink

Original issue reported on code.google.com by rodni...@gmail.com on 21 Jan 2008 at 11:49

Attachments:

GoogleCodeExporter commented 9 years ago
This is wrongly listed as a defect. Sorry...

Original comment by rodni...@gmail.com on 21 Jan 2008 at 11:50

GoogleCodeExporter commented 9 years ago
There was a problem with my previous file. A variable has been misnamed. Here 
is the
correction...

Original comment by rodni...@gmail.com on 21 Jan 2008 at 11:57

Attachments:

GoogleCodeExporter commented 9 years ago
I think you have done an update on SWFObject 1.5 en named it SWFObject 2.0?

Please note that this is a SWFObject 2.0 issue system only an that its code 
base is
entirely different from SWFObject 1.5.

Original comment by bobbyvandersluis on 21 Jan 2008 at 4:14

GoogleCodeExporter commented 9 years ago
I was not aware of that. Thanks...

Where is the 2.0 code?

Original comment by rodni...@gmail.com on 25 Jan 2008 at 6:51

GoogleCodeExporter commented 9 years ago
Nevermind found it. Not familiar with Google Code...

Original comment by rodni...@gmail.com on 25 Jan 2008 at 6:52