• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

submitting site code patches

 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No promises, but if you send the patches along I will see if I can incorporate them. We definitely appreciate the offer.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just email it all to me.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
w00t! working (as I define it) code tags. Thanks Ernest.
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



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

- Manish
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another Safari hopeful here. Let me know if I can help Ulf.
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Thankyou. Very nice.

Regards, Andrew
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I just used the "Highlight" and bold feature.
Very nice.

Thanks.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wanted to say that I've been using this a lot and am loving it. Thanks Max!
 
reply
    Bookmark Topic Watch Topic
  • New Topic