Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 12-12-2008, 03:42 PM Quoting with JS
Super Talker

Posts: 102
Trades: 0
I have no clue and this would be my 1st time even touching JS so can someone spoon feed me but still teach me how to quote lines of text with JS? like I want the user to click a button and have something pop up that they can copy and it would have the quoted post content on it.

Last edited by Aaron™; 12-12-2008 at 03:44 PM..
Aaron™ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-12-2008, 04:10 PM Re: Quoting with JS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
depends on how you envisage what you are going to do.

would it be something like the posting system on forums such as here?
Or something like I have for code snippets? http://www.modtalk.co.uk/article/c-a...gn/dhtml-tabs/
(click on the text "Click to switch code view" in the code box header)

Or something else?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2008, 04:56 PM Re: Quoting with JS
Super Talker

Posts: 102
Trades: 0
Well I want something like you click a button near someones post and it pop-ups a new window with the post on it and with the "[quote]" at the beginning and end.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 12-12-2008, 05:16 PM Re: Quoting with JS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Actually that would be better done with server side script, and the button passes the post id to be quoted, then the page generating script reads the post data from the database and inserts it into the <textarea> of the editor.

exactly like the "Quote" works here. ( /newreply.php?do=newreply&p=812245 )
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2008, 06:13 PM Re: Quoting with JS
Super Talker

Posts: 102
Trades: 0
Well I would just rather go with the button that prompts the post and the post ID would be easily implemented, or should be.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 12-12-2008, 08:39 PM Re: Quoting with JS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
function addQuote(p_iID) {
    var l_sTag = "quote";
    var l_sQuoted = document.getElementById(p_iID).innerHTML;
    document.formname.textareaname.value = "[" + l_sTag +"]" + l_sQuoted + "[/" + l_sTag +"]";
}
code to go on the button to get the text to be quoted;

Code:
onclick="addQuote(ID_of_post_container)"
That will replace ANY text already in the textarea with the quoted text, Inserting the text at the cursor point is somewhat more complicated.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2008, 11:31 PM Re: Quoting with JS
Super Talker

Posts: 102
Trades: 0
There is no text area on the thread, just posts and a button to reply. So I need them to copy the text in the popup.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Old 12-13-2008, 09:25 AM Re: Quoting with JS
Experienced Talker

Posts: 39
Name: Richard
Trades: 0
for JS is classpatch needed?
MasterBennett is offline
Reply With Quote
View Public Profile
 
Old 12-13-2008, 09:31 AM Re: Quoting with JS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I bet you thought this is a very simple thing with an "alert" or "prompt" dialog

See it working at -> http://www.modtalk.co.uk/_site/code/...pt/post-quote/

HTML Code:
<div id="post_123456" class="post"><div class="post_header"><span id="quote_123456" class="btn_up" onclick="addQuote(this.id)" onmousedown="this.className='btn_down'" onmouseup="this.className='btn_up'">Quote</span></div>
<div id="text_123456">This is some text that will be quoted into the next post.
<br>
<br>
This is a second line.

some more text following line breaks</div>
</div>
Code:
<script type="text/javascript">
var m_bSet = false;

function addQuote(p_iID) {
if (!m_bSet) {
var l_sTxtID = p_iID.replace("quote","text");
var l_sPostID = p_iID.replace("quote","post");
var l_oPost = document.getElementById(l_sPostID).id;
var l_oLB = document.createElement("br");

    var l_sTag = "quote";
    var l_sQuoted = document.getElementById(l_sTxtID).innerHTML;
		l_sQuoted = "[" + l_sTag +"]" + l_sQuoted + "[/" + l_sTag +"]";

	var l_oHolder = document.createElement("div");
		l_oHolder.setAttribute("id","holder");
	document.getElementById(l_oPost).appendChild(l_oHolder);

	var l_oNewTextArea = document.createElement("textarea");
		l_oNewTextArea.setAttribute("cols","60");
		l_oNewTextArea.setAttribute("rows","5");
		l_oNewTextArea.setAttribute("name","postquote");
		l_oNewTextArea.setAttribute("id","postquote");
	var l_oNewFieldLabel = document.createElement("label");
		l_oNewFieldLabel.setAttribute("for",l_oNewTextArea.id);
		l_oNewFieldLabel.innerHTML = "Copy the text below ";
	var l_oCloseQuote = document.createElement("span");
		l_oCloseQuote.setAttribute("class","btn_close");
		l_oCloseQuote.setAttribute("id",p_iID.replace("quote","close"));
		l_oCloseQuote.innerHTML = "Close";
		l_oNewFieldLabel.appendChild(l_oCloseQuote)
			
	document.getElementById("holder").appendChild(l_oNewFieldLabel);
	document.getElementById("holder").appendChild(l_oLB);
	document.getElementById("holder").appendChild(l_oNewTextArea);
		l_oNewTextArea.value = l_sQuoted;
		l_oNewTextArea.setAttribute("onclick","this.select()");
	document.getElementById("postquote").onclick = function() {this.select();};
		l_oCloseQuote.setAttribute("onclick","removeQuote(this.id)");
	document.getElementById(p_iID.replace("quote","close")).onclick = function() {removeQuote(this.id);};
	m_bSet = true;
}
}

function removeQuote(p_iID) {
var l_sQuoteID = p_iID.replace("close","post");
var l_oQuote = document.getElementById(l_sQuoteID);
var l_oHolder = document.getElementById("holder");
	l_oQuote.removeChild(l_oHolder);
	m_bSet = false;
}
</script>
This code can only handle a single post being quoted at any one time (only one set variable)

I'll leave you to put it into a "popup" if you wish
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-13-2008, 04:10 PM Re: Quoting with JS
Super Talker

Posts: 102
Trades: 0
Thanks, some small editing and I should have it 100% of what I need.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Quoting with JS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41876 seconds with 12 queries