aspose file tools*
The moose likes Ranch Office and the fly likes submitting site code patches Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "submitting site code patches" Watch "submitting site code patches" New topic
Author

submitting site code patches

Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
I would like to submit a code patch for the JavaScript functions on this site regarding the posting screen. These patches would fix both the DoSmilie and DoPrompt functions so that a) tags and smilies are added where the cursor is b) if you have text selected it wraps it in with the tag you want.

I have tested and used these functions extensively in IE, Firefox and Opera. These patched functions work as I described above in IE and Firefox and in other browsers they revert to the current behaviour.

If I submitted these patches along with a link to a HTML version of the exact posting page from this site so that anyone who wished could verify that they work would it at all be possible to incorporate them into the site?

Because the non wrap (especially for the code tags) really throws me mainly because it is fairly standard to have the tags wrap.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

No promises, but if you send the patches along I will see if I can incorporate them. We definitely appreciate the offer.


[Jess in Action][AskingGoodQuestions]
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Ernest,

Thanks for letting me know. I will post the code here most likely later today once I test my retrofitted code fully.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Okay as promised here is the basic code. I will going to send a personal message to Ernest with a link to a site where I have a test version of the post page up.

Just to mention I have tested on IE and Firefox on Windows and it works fine on both. It should support IE and Gecko browsers mainly... however it will not break on other browsers... just revert to the behaviour as it is now.

I also incorporated all the prompts and such exactly as they were before.

All that is needed to make it work is to add the two functions below and then replace the current DoPrompt function with the new one that calls the new functions. So none of the rest of the form code on the page needs to be touched in any way to incorporate the script.

Okay the code was here but whoops that won't work.. since it contains a bunch of UBB tags it gets eaten by the post.

Hmmmm.
[ December 20, 2005: Message edited by: Maximilian Stocker ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Just email it all to me.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by Ernest Friedman-Hill:
Just email it all to me.


Ahh sorry. I just saw this. I just PMed you the links to the site and the code.

Should I email instead?
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Okay I deleted the PM and sent it by email instead. Sorry if you get both... it will be coming from myname @ gmail.com
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by Maximilian Stocker:
Okay I deleted the PM and sent it by email instead. Sorry if you get both... it will be coming from myname @ gmail.com


Ummm just sort of wondering if you had gotten my email from Tuesday.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes, sorry. With the holidays coming, things are falling off my desk at an alarming rate. I will drop you a line with details.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

OK, Max, your JavaScript mods are deployed and working fine. I like it!

Anybody notices any problems with composing, replying, or editing messages, let me know ASAP.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
w00t! working (as I define it) code tags. Thanks Ernest.
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Originally posted by Maximilian Stocker:
w00t! working (as I define it) code tags. Thanks Ernest.


Well, thanks to you Maximilian for your patches!!!

- Manish
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
Thanks a bunch, Maximilian. That's a very good addition.

You indicated earlier that it might not work with other browsers. I'm particularly interested in Safari, and might have a look at it. Could you post a brief blurb on where you think the brower-dependencies come into play?


Ping & DNS - my free Android networking tools app
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Great stuff Max, thank you!

Another little caveat for Mac fans... On OS 10.3.9 using Firefox 1.0.6, the code tags work great with selected text, but the graemlins still get tacked on to the end, not at the cursor insertion point.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Another Safari hopeful here. Let me know if I can help Ulf.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by Pauline McNamara:
Great stuff Max, thank you!

Another little caveat for Mac fans... On OS 10.3.9 using Firefox 1.0.6, the code tags work great with selected text, but the graemlins still get tacked on to the end, not at the cursor insertion point.


Just to note that is not a Mac or Firefox thing. But I did not actually make the emotes/gremlins code. Partially I was concerned that it's behaviour would throw people off... actually I don't know why I did that.

Anyway point being is that only the taggy things work.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Ulf, Bear and others interested,

If you look at the source for the posting page you will see two Javascript methods. DoPrompt and buildTag.

Don't worry about buildTag it is a generic function that constructs the text to be inserted. The function that is dependent is doPrompt.

Now it doesn't actually do browser detection per se. Instead there is an if/else if/else statement that attempts to select the range of text selected in the textarea. The critical lines are



which evaluates to true if the browser is IE

and



which evaluates to true on gecko (Firefox) browsers

then everything else falls through to the else case. So the detection is more one of "Browser do you understand what X means?" And if it doesn't then we can't use it.

So if there is something that Safari understands then certainly it can be added as another else if case. But I don't know what that would be. I do have access to a OSX system with Safari on it so if someone could provide the basics I can put it into the existing code and test it.

Hopefully this helps.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11431
    
  85

Originally posted by Maximilian Stocker:
w00t! working (as I define it) code tags. Thanks Ernest.


Thankyou. Very nice.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yes, I just used the "Highlight" and bold feature.
Very nice.

Thanks.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
After doing some research it looks like Safari can't get at the selection through JavaScript. Something may be in the works, but details are sketchy, and no release date has been set. So, for the time being, we're out of luck.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
Bad timing of my previous post - I just updated Safari to 1.3.2 (this is on OS X 10.3; I think it's version 2.0.3 on 10.4), and now the selection changes work.

Thanks again Maximilian!
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Just wanted to say that I've been using this a lot and am loving it. Thanks Max!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submitting site code patches