473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Code review

Out of curiosity, did anyone review the second attempt I made at the DOM 2
Events wrapper, posted at the end of last month? I posted it in the
previous thread rather than a new one and I have the feeling that it might
have been missed (either that, or it's so dire that no-one wants to touch
it :)

Subject: DOM 2 Events emulator (was: Executing in the context of
calling function)
Date: Wed, 31 Mar 2004 00:15:01 GMT
Msg-ID: <op**************@news-text.blueyonder.co.uk>

By the way, stripping whitespace and comments (many thanks to Douglas
Crockford for his JSMIN program) reduces the combined file size by half.

Though I state that all five files are required, that's not technically
true; core.js and domEvents.js are required, whereas the other three are
plug-ins. However, mouseEvents.js is dependent on uiEvents.js.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #1
6 1563
Michael Winter wrote:
Out of curiosity, did anyone review the second attempt I made at the DOM
2 Events wrapper, posted at the end of last month? I posted it in the
previous thread rather than a new one and I have the feeling that it
might have been missed (either that, or it's so dire that no-one wants
to touch it :)

Subject: DOM 2 Events emulator (was: Executing in the context of
calling function)
Date: Wed, 31 Mar 2004 00:15:01 GMT
Msg-ID: <op**************@news-text.blueyonder.co.uk>

By the way, stripping whitespace and comments (many thanks to Douglas
Crockford for his JSMIN program) reduces the combined file size by half.

Though I state that all five files are required, that's not technically
true; core.js and domEvents.js are required, whereas the other three are
plug-ins. However, mouseEvents.js is dependent on uiEvents.js.

Mike


I can't say I'd be good enough to make an opinion, but I was curious to
have a look - I did a search on google for the msg id and it didn't
return... Have I done something wrong?

http://groups.google.ca/groups?hl=en...uk&btnG=Search

randelld
Jul 23 '05 #2
On Sat, 17 Apr 2004 02:24:02 GMT, Reply Via Newsgroup
<re****************@please.com> wrote:

[snip]
I can't say I'd be good enough to make an opinion, but I was curious to
have a look - I did a search on google for the msg id and it didn't
return... Have I done something wrong?


You have to enter the message ID as a special field (easiest in advanced
search). Try

<URL:http://groups.google.ca/gr************************************************ ********************************************@news-text.blueyonder.co.uk&lr=&hl=en>

Enjoy! :D

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #3

"Michael Winter" <M.******@blueyonder.co.invalid> kirjoitti viestissä
news:op**************@news-text.blueyonder.co.uk...
Out of curiosity, did anyone review the second attempt I made at the DOM 2
Events wrapper, posted at the end of last month?


I was interested, but (the famous, frightening 'but' : ( )

the code was so long that started thinking that loading so large a library
always makes my pages too clumsy.

There is a need to have a good simple template for cross browser event
handling without needing to think and create everything from scratch every
time.

What about

http://developer.apple.com/internet/...entmodels.html

especially the code snippet in the end:

// shared function
function getTargetElement(evt) {
var elem
if (evt.target) {
elem = (evt.target.nodeType == 3) ? evt.target.parentNode :
evt.target
} else {
elem = evt.srcElement
}
return elem

}

function functionName(evt) {
evt = (evt) ? evt : ((window.event) ? window.event : "")
if (evt) {
var elem = getTargetElement(evt)
if (elem) {
// process event here
}
}
}


Jul 23 '05 #4
Michael Winter wrote:
On Sat, 17 Apr 2004 02:24:02 GMT, Reply Via Newsgroup
<re****************@please.com> wrote:

[snip]
I can't say I'd be good enough to make an opinion, but I was curious
to have a look - I did a search on google for the msg id and it didn't
return... Have I done something wrong?

You have to enter the message ID as a special field (easiest in advanced
search). Try

<URL:http://groups.google.ca/gr************************************************ ********************************************@news-text.blueyonder.co.uk&lr=&hl=en>
Enjoy! :D

Mike


Thanks for that - I found the original post but don't think I can really
comment on the code (though I can learn from it) due to my lack of
experience. I do understand your objective though, and for that, I
applaud your efforts.

I know the code had to be purged of comments, and abbreviations used
where possible to help with its overall physical file size but that
makes life more difficult for someone like me to understand its proper
usage... I always prefer comments to be part of my code, not seperate as
it helps when I read/learn from someone elses code as I can follow the
full program flow without seperate pages/windows.

I am going to try and learn from your code - I am not talking about
robbing your code, but specifically, learning from its structure and
function/method usage.

As a side note - I might get flamed for this however I would think your
code might prove very useful with intranets, as opposed to over the
internet as generally I have found intranet bandwidth, while not open to
abuse, is generally more plentiful and an 18k size is manageable on most
networks...

Anyway... I do hope your hard work gets some constructive comments...

cheers
randelld
Jul 23 '05 #5
On Sat, 17 Apr 2004 08:38:06 +0300, optimistx
<op*************@hotmail.com> wrote:
"Michael Winter" <M.******@blueyonder.co.invalid> kirjoitti viestissä
news:op**************@news-text.blueyonder.co.uk...
Out of curiosity, did anyone review the second attempt I made at the
DOM 2 Events wrapper, posted at the end of last month?
I was interested, but (the famous, frightening 'but' : ( )

the code was so long that started thinking that loading so large a
library always makes my pages too clumsy.


I know. The sheer enormity of the script is of major concern, but I don't
see how to reduce its size but still maintain its functionality. The
script is currently the only way to use event capturing with IE. I also
recently discovered that Mozilla and IE mishandle event propagation when a
listener causes changes to the document along the event path. The latter
means that I'll have to *add* code to the current set to bring them into
line with the specification.
There is a need to have a good simple template for cross browser event
handling without needing to think and create everything from scratch
every time.
The script, as posted, is well-suited for complex interaction, but it is
over-kill for simple listener registration. All that should be needed is a
way to add multiple listeners to, and remove said listeners from, the same
element (for the same event type), and to normalise the event interfaces.
The former won't take that much code, but the latter makes up the bulk of
the current script. If normalisation is made optional (if you only want to
add and remove listeners), you still might be looking at about 4KBs
(guess).

I'll see if I can break it down into smaller modules.
What about

http://developer.apple.com/internet/...entmodels.html


[snipped code]

Going by what they're talking about (rather than what they're coding),
that could be simplified to

function functionName( evt ) {
if( evt = evt || window.event ) {
/* Use "this" in place of "elem" */
}
}

Though by some bizarre twist of fate, you can't do that when you use
element.attachEvent() as IE doesn't set the this operator correctly, which
is why I avoid it in my code (though it can be rectified with additional
code).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #6
On Sat, 17 Apr 2004 21:17:28 GMT, Reply Via Newsgroup
<re****************@please.com> wrote:

[snip]
Thanks for that - I found the original post but don't think I can really
comment on the code (though I can learn from it) due to my lack of
experience. I do understand your objective though, and for that, I
applaud your efforts.

I know the code had to be purged of comments, and abbreviations used
where possible to help with its overall physical file size but that
makes life more difficult for someone like me to understand its proper
usage... I always prefer comments to be part of my code, not seperate as
it helps when I read/learn from someone elses code as I can follow the
full program flow without seperate pages/windows.
It's not for the faint of heart, is it. :) As I need to make some hefty
revisions due to some browser quirks I found yesterday, I'll see about
making the code more readable.
I am going to try and learn from your code - I am not talking about
robbing your code, but specifically, learning from its structure and
function/method usage.
Go right ahead. Most of the structure uses stardard patterns that take
advantage of common language features. Furthermore, part of the code is
based on Richard Cornford's first post in the original thread (thank's
again Richard), which I've since modified[1].
As a side note - I might get flamed for this however I would think your
code might prove very useful with intranets, as opposed to over the
internet as generally I have found intranet bandwidth, while not open to
abuse, is generally more plentiful and an 18k size is manageable on most
networks...


Depending on what's actually used, the total size should vary between 6.7
and 9.1KBs. However, as the library is extensible (event groups, such as
keyboard events, can be added) a larger module would change that.

Mike
[1] I don't believe there were any strings attached to it. My
acknowledgments to Lasse and Richard were out of genuine thanks, as well
as courtesy.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arvie | last post by:
I need some advice guys.. I am proposing that we get someone to do a complete audit/review of our Java application codebase, about 1000 JSPs/Servlets and 100 EJBs. If I get firms to submit...
0
by: gs-code-review-bounces | last post by:
Your mail to 'gs-code-review' with the subject Re: Application Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a...
18
by: Ben Hanson | last post by:
I have created an open source Notepad program for Windows in C++ that allows search and replace using regular expressions (and a few other extras). It is located at...
19
by: Swaregirl | last post by:
Hello, I would like to build a website using ASP.NET. I would like website visitors to be able to download code that I would like to make available to them and that would be residing on my...
3
by: Filippo | last post by:
Hi, In my organization we would like to activate a code review system, in wich a developer have to pass a review from a reviewer before check in the modified files in source safe. Is there any way...
239
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my...
3
by: JeanDean | last post by:
I am looking for freeware tool which can review the c++ code(compiled on g++). Please share your experiences and details obout the usage of the tool.
10
by: Jo | last post by:
Hi there: I m wondering what can I do to improve my code, everytime I am coding I feel like it could be done better. I started on c# a good months ago and feel conformtable but sometimes I Need...
4
maxx233
by: maxx233 | last post by:
Hello all, I'm new to OO design and have a question regarding where I should place some code. Here's a simplified situation: I'm making an app to do create, submit, and track employee reviews...
0
by: corey | last post by:
Secure Bytes audit and vulnerability assessment software Secure Auditor named “Versatile tool” and earn “Five Star Ratings” in SC Magazine Group Test Secure Bytes is really pleased to share this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.