Suggestions & Feedback
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsForum InformationSuggestions & Feedback

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 18th, 2005, 02:55 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
time saver

either add the following to the box as a default value or... add a javascript button that would pop it in.


these three lines reversed
[/highlight]

[highlight=php]


I think I'm getting carpal tunnel just from writing thoe two lines...

Reply With Quote
  #2  
Old November 19th, 2005, 03:01 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: time saver

Yeah..I think some javascript to add tags would be cool...will work on it.

Reply With Quote
  #3  
Old November 21st, 2005, 02:27 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

got some help from ababab but try this function

Code:
<script type="text/javascript">
<!-- hide this stuff from other browsers 
var x=0;
var tagname;
var tag;
var closetag;
function addtag(tagname)
{
	tag=("[" + tagname + "]");
	closetag="n[/" + tagname + "]n";
	x++
	if (x == 1){
		document.getElementById("a").value+=tag;
	}else{
		x = 0; 
		document.getElementById("a").value+=closetag;
	}
}
// end hiding  -->
</script>


php Code:
Original - php Code
  1.  
  2. // in the page just name the textarea "a"
  3. <form>
  4. <input type="button" value="[highlight=php]" onclick="addtag('php')">
  5. <textarea id="a" name="textarea" cols="40" rows="10" value=""></textarea>
  6. </form>


it's probably not the most elegant solution but it works. I probably should have used the document object model to drill down through the form to get to the text area but I'm rusty at javascript and ababad's code originaly was tweaking a div not a text area.

here it is in action:
http://www.azwc.com/cw/
I tried to make it dynamic so that you could put the other tags like <code> on it's own button.

Reply With Quote
  #4  
Old November 21st, 2005, 02:37 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

I tweaked it a little and here it is with multiple buttons

http://www.azwc.com/cw/javascripttest3.html

Reply With Quote
  #5  
Old November 22nd, 2005, 12:45 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: time saver

I guess the one issue I have with it is that is takes the cursor out of the text box after inserting the tags. Could it leave the cursor after the tag when done?

Reply With Quote
  #6  
Old November 22nd, 2005, 08:14 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

took me a minute to figure out how to get the cursor at the end of the text, the only thing you'll need to do is change the index of the form element to correspond with where the text area is in the form. For some reason it's not working if the very first thing you do is hit a button it places the focus before the button but if you already typed anything else it puts the cursor on the next line. maybe someone better at javascript than me knows why this is. I'll post in client side forum and see what people have to say.

here it is working:
www.azwc.com/cw/javascripttest3.html

Code:
<script type="text/javascript">
<!-- hide this stuff from other browsers 
var x=0;
var tagname;
var tag;
var closetag;
var cnt;
function addtag(tagname)
{
	tag=("[" + tagname + "]n");
	closetag="n[/" + tagname + "]n";
	x++
	if (x == 1){
		document.getElementById("a").value+=tag;
	}else{
		x = 0; 
		document.getElementById("a").value+=closetag;
	}
        cnt = document.getElementById("a").length;
	document.getElementById("a").focus(cnt);

}
// end hiding  -->
</script>
<body>
<form>
<input type="button" value="[highlight=php]" onclick="addtag('php')">
<input type="button" value="[code]" onclick="addtag('code')">
<input type="button" value="[quote]" onclick="addtag('quote')">
</br>
<textarea id="a" name="textarea" cols="40" rows="10" value=""></textarea>
</form>

Reply With Quote
  #7  
Old November 22nd, 2005, 09:10 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

ok I think I got it now:

Code:
<script type="text/javascript">
<!-- hide this stuff from other browsers 
var x=0;
var tagname;
var tag;
var closetag;
var cnt;
function addtag(tagname)
{
	tag=("[" + tagname + "]n");
	closetag="n[/" + tagname + "]n";
	x++
	if (x == 1){
		document.getElementById("a").focus();
		document.getElementById("a").value+=tag;
	}else{
		x = 0; 
		document.getElementById("a").focus();
		document.getElementById("a").value+=closetag;
	}

}
// end hiding  -->
</script>
<body>
<form>
<input type="button" value="[highlight=php]" onclick="addtag('php')">
<input type="button" value="[code]" onclick="addtag('code')">
<input type="button" value="[quote]" onclick="addtag('quote')">
</br>
<textarea id="a" name="textarea" cols="40" rows="10" value=""></textarea>
</form>


view here: www.azwc.com/cw/javascripttest2.html

Reply With Quote
  #8  
Old November 24th, 2005, 11:51 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: time saver

Hmm..for me it puts the cursor before that tag no matter if I type something or not first...

Reply With Quote
  #9  
Old November 25th, 2005, 05:56 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

hmmm, how can that be? what browser? I tried IE and firefox.

this link?

www.azwc.com/cw/javascripttest2.html

Reply With Quote
  #10  
Old November 25th, 2005, 08:36 AM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,326 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 15677 Folding Title: Novice Folder
Time spent in forums: 6 Days 9 h 32 m 40 sec
Reputation Power: 4
RE: time saver

Opera 8.5:

Cursor always goes to the start of the tag, and the tag isn't inserted where the cursor is but always into the end. I think this feature is very neatly done in Wordpress, you might want to consider examining it.

Reply With Quote
  #11  
Old November 25th, 2005, 01:27 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

I'll take a look when I have a little more time, I probably should have downloaded a forum script and seen how they did it but I figured I could throw it together pretty quick.

As for the tag going on the end of the text that's the expected behavior, I didn't even think about someone wanting to put tags in the middle of the code, you could always type them manually or cut and paste I guess. Both firefox and IE put the cursor on the line after the tag in all cases.

is there a link to what you mean I didn't see the buttons.

Reply With Quote
  #12  
Old November 25th, 2005, 01:43 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,326 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 15677 Folding Title: Novice Folder
Time spent in forums: 6 Days 9 h 32 m 40 sec
Reputation Power: 4
RE: RE: time saver


Quote:
As for the tag going on the end of the text that's the expected behavior, I didn't even think about someone wanting to put tags in the middle of the code


It's so easy to forget when starting to type code. It would be convenient

Quote:
is there a link to what you mean I didn't see the buttons.


Link to what? Wordpress' page that contains the code? I can upload it somewhere and link there if you meant it.

Reply With Quote
  #13  
Old November 25th, 2005, 03:05 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: time saver

just my two cents...

1) you have to click the button twice, once for the starting tag and again for the ending tag. one click should throw in both tags otherwise it's not all that "convenient." and the cursor should therefore start inbetween the tags.

2) i should be able to highlight a block of text and then click the button, and it will place the tags around my text rather than at either end of it.

Reply With Quote
  #14  
Old November 25th, 2005, 04:27 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: time saver

I'm more than happy to take anyones input on how to get it done, I just thought it was a cool idea and figured we could help Matt get it done.

I kinda suck at the DOM because I rarely do much javascript so I have to muddle through it. Is there a property of the method focus() that would allow me to set the position of the cursor between the tags? writing the code the put both tags at once would be easy and I tried to get the length of the field and subtract the length of the second tag and put the cursor at that point by entering calling focus(cnt-taglength) but that didn't work.

tkark, I looked around at the wordpress site but I couldn't find a place where I could fill ina form and thus see the code without registering or downloading the whole script for offsite use (that seemed to be an option but I'm not sure). If you can paste the code they're using I ould love to see it and I'll tweak it until I have it working in IE, safari, firefox.

Reply With Quote
  #15  
Old November 25th, 2005, 06:46 PM
tkarkkainen's Avatar
tkarkkainen tkarkkainen is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: Finland
Posts: 2,326 tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)tkarkkainen User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 15677 Folding Title: Novice Folder
Time spent in forums: 6 Days 9 h 32 m 40 sec
Reputation Power: 4
RE: time saver

I removed some parts of the page, but the essential should still be there: http://haukku.mine.nu/~tohoq/wp/

Reply With Quote