• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

should not this get fixed on code ranch?

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i am wondering if this is the correct behavior or not?

i was posting a reply for one of my topic, i had some code in my reply, so i selected that part and pressed code button and code starting and ending tags got added (which is correct).
however when i again clicked on code button (same part is selected) it did add one more code element. ideally if i have already added code blocks for some part of my reply it should not add code tags again on my second click, instead it should remove the already added code tags.

from user point of view also, on next click the tags should get removed, because if i want to add quote tag and by mistake i added code tag, i need to remove the quote tags manually.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will frequently see posts with multiple code blocks, so what you observed is actually the desired behavior.
 
Sheriff
Posts: 67595
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
I agree with Ulf -- I think the existing behavior is how it should work.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He is saying that if you have text selected, the tag script should be smart enough to know tags already exist for that selection and possibly to replace tags with newly chosen tags.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gregg Bolinger wrote:He is saying that if you have text selected, the tag script should be smart enough to know tags already exist for that selection and possibly to replace tags with newly chosen tags.



exactly.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

from user point of view also, on next click the tags should get removed, because if i want to add quote tag and by mistake i added code tag, i need to remove the quote tags manually.



I see what you are saying. What you are looking for is some kind of "toggle" behaviour with those tags. We don't have it and IMO it's not worth the implementation efforts because you can just use Ctrl + Z (undo) in your browser and the tag you accidentally added will be removed. I just tried the Ctrl + Z thing in my Firefox browser and it worked.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:... you can just use Ctrl + Z (undo) in your browser and the tag you accidentally added will be removed. I just tried the Ctrl + Z thing in my Firefox browser and it worked.


It didn't work in my Chrome, though. Fixing that would be great, but there are probably more important things to do.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:

Jaikiran Pai wrote:... you can just use Ctrl + Z (undo) in your browser and the tag you accidentally added will be removed. I just tried the Ctrl + Z thing in my Firefox browser and it worked.


It didn't work in my Chrome, though. Fixing that would be great, but there are probably more important things to do.



yes if i do ctrl+z in chrome it removes everything. :P
 
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just Javascript code. If you would like to change the behavior and donate that code to us, it is highly likely to make it into the site
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:It is just Javascript code. If you would like to change the behavior and donate that code to us, it is highly likely to make it into the site



Hi Jeanne

i would love to do that.
can you give me some pointers from where should i get start? i mean i am not sure what is the existing code for this in coderanch.

or you are saying that i should write some sample code and post that here?
 
Martin Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can go to the edit post page and have a look at its source. It includes some javascript files. One of these files contains the logic for adding the code tags. Also, the edit post page contains the code tag buttons, by inspecting them you'll find the name of the javascript method which does it.
 
Jeanne Boyarsky
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:You can go to the edit post page and have a look at its source. It includes some javascript files. One of these files contains the logic for adding the code tags. Also, the edit post page contains the code tag buttons, by inspecting them you'll find the name of the javascript method which does it.


Right. If you give sample code that requires us to do work to integrate, it goes on our queue. If yousay. "Here is exactly what to change" we copy/paste it in and verify. Tim Cooke did that recently to add support for starting code listings with line numbers other than one.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i have written code to check if code exist or not, can someone please put this code and verify?
if it works fine i will update the code with one more use case (removing the tags if they already exist).

here is what needs to be done.

Add the below method in post.js
"){
return false;
}
}
else{
return true;
}
}
[/code]
This method needs to be called in each method getting called inside function getPromptUbbData(textToWrap, eltag)

for example ::

";
}else{
return "";
}
}
[/code]

same should be done in the other methods also (ie. for List tag, img tag, Url tag etc)
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS: my script itself has [\code] tag in it which is making my reply formatted.

let me know if it is hard to read, i can PM the script to someone
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

is there any update on this?
did anyone try the script?

Thanks,
Punit
 
Jeanne Boyarsky
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yesterday was Sunday. Expect replies to take up to 24 hours during the week and longer on the weekend.

And yes, the post is messed up from the formatting. Can you email the file to me? (PM is going to have the same problem). I sent you a PM with my email.

 
Jeanne Boyarsky
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This change was accepted and will be in the next deployment. Enjoy your cow Punit!
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
Jeanne Boyarsky
author & internet detective
Posts: 40791
828
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Punit's change is now deployed.
 
Marshal
Posts: 5112
319
IntelliJ IDE Python Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Improvements to the Ranch are worth more just one cow. Have another one from me
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
reply
    Bookmark Topic Watch Topic
  • New Topic