PDA

View Full Version : View Object



Trinithis
05-20-2007, 04:58 PM
This is a script I came up with for site development. It provides a GUI for viewing objects, their properties, and their methods. Any variable type is acceptable.

HowTo:
Place this code at the beginning of your page and in your following scripts you
call the function viewObject(object, bool). The bool argument is optional and has
a default value of false. If explicitly set as true, the window the viewObject function
creates is minimized. viewObject creates a window that has all the inside stuff of the object
displayed, along with all their values (if there are any). You can drag the window by clicking
and holding down on the numbered box of the window's top right corner. The number in the box
signifies the number of times the function has been called. If that region is double clicked,
then the window minimizes. You can click on the bullets before each property to view that object
in a GUI window. Hitting Ctr+Shift+Z closes all the GUI windows. Crt+Shift+MouseClick views the object
that the mouse hovers over.

Edit: Both the key codes for both the shortcuts are customizable. You can add, change, and/or remove the key shortcuts for either command. There is a place early on in the source code with customizable variables.

Oh, and if the object has innerHTML, outerHTML, innerText, outerText, or textContent, the code does not display them due to speed issues. But that shouldn't be an issue. Just use other attributes, such as childNodes and nodeValue.

(Updated Code; you may have to recache the script.)

Source Code:
http://trinithis.awardspace.com/viewObject/viewObject.js

Demo:
http://trinithis.awardspace.com/viewObject/Test.html

If you so desire, you can make this in to a greasemonkey .user.js file, but seeing that I don't have greasemonkey, I won't do it. (I don't have greasemonkey because I have to use an old FF browser 1.0.7 since all the other ones I have tried hang my dial-up. Yes, dial-up. And I can't seem to find an old greasemonkey anymore...)

Twey
05-20-2007, 05:19 PM
You should provide a different shortcut... alt-click is taken by a lot of window managers.

djr33
05-20-2007, 09:52 PM
No functionality in safari and the layout seems wrong on the windows compared to FF. The close, etc. links work, but that's it. No keyboard input or anything with the mouse.

FF on mac has much of the same trouble, though a bit of limited functionality. the ctrl key on a mac is of a very different nature and actually enables right click with the mouse. This makes things weird.

Not testing on a PC and it might work great there. But on a mac, it's a mess.

Trinithis
05-20-2007, 10:57 PM
I've only tested it on FF 1.0.7, IE 6.0.28, and SBC Yahoo Browser 5.02 on windows. As I have no access to a mac, well I can't test it there.

When displayed in my IE, the boxes are slightly spaced apart due to whether or not the browser renders borders in or out of the elements, but to me it was not a big enough issue to "fix". So I decided to make FF my main focus in looks.

FF
http://img.photobucket.com/albums/v251/Trinithis/FF.gif

IE
http://img.photobucket.com/albums/v251/Trinithis/IE.gif


Any ideas for shortcut keys to use that would be good in general?

djr33
05-21-2007, 07:25 PM
Well, it's not exactly your fault that it doesn't work on a mac, but something to think about.

shift is a good key for both platforms and usually doesn't do much to the page.

control and alt are good, but then you run into problems on a mac, as said above. They also have system functions associated with them (mac and pc), so that's not good either.

Really, the simple answer here is that you shouldn't be doing what you're doing because the web is designed for presenting info for the most part, not interaction from the keyboard, etc.
It's a cool idea, so I'm not saying you're 'wrong', but browsers and such just aren't designed for this at this time.

I think the most important thing to remember is that some of these features are nice, but that there should always be a backup when they don't work, as you'll run into problems a lot. Having a close link instead of just the keyboard command is good, for example.

Another thing to keep in mind is the "find as you begin typing" feature in firefox (and similar functions) which, as a system/application command, SHOULD take precedence over anything you are using on the page itself.

Twey
05-21-2007, 07:27 PM
You could use a mouse sequence... double-click should do it since it's a debug feature. I don't know of any browser that performs a vital function with double-click.

Actually, wait, no. Opera does. Perhaps you could rig a key sequence -- press a then click?