Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

should not this get fixed on code ranch?  RSS feed

 
Punit Jain
Ranch Hand
Posts: 1060
2
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will frequently see posts with multiple code blocks, so what you observed is actually the desired behavior.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ulf -- I think the existing behavior is how it should work.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • 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.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • 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 Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Thanks,
Punit
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit's change is now deployed.
 
Tim Cooke
Marshal
Posts: 3838
221
Clojure IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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: 1060
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!