Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 Click to Copy Code

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Carefree Posted - 10 April 2009 : 02:44:33
I'd like to have a "click to copy" for the code box/list - either a button or simply a link. Considering how much code is posted here, that would be a heavily used feature.
15   L A T E S T    R E P L I E S    (Newest First)
HuwR Posted - 10 April 2009 : 14:25:33
quote:
PS: Oh and while at it, how do you deal with tabs in <CODE>? I made a few as you have seen in screenshot, but I like PRE's tab assignment better... Is there a more stylish way?


there is no such thing as a tab in html whitespace is preserved either by using the <pre> tag or using the css white-space:pre
SiSL Posted - 10 April 2009 : 11:46:35
That's be nice to have some native Snitz colors and style in it, since my forums are heavily CSS modified, I can't test it enough to fit, so I can update a native CSS in it after you picked best fit for Snitz.

PS: Oh and while at it, how do you deal with tabs in <CODE>? I made a few as you have seen in screenshot, but I like PRE's tab assignment better... Is there a more stylish way?
HuwR Posted - 10 April 2009 : 11:39:25
cool, well done, will maybe try and implement it here while I am waiting for the rain to stop so I can get down the allotment
SiSL Posted - 10 April 2009 : 11:33:33
Oh well, here goes with a nice detailed Readme in it
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=68515
HuwR Posted - 10 April 2009 : 10:49:13
just give your tags classes and then the styling can be left up to the person to implement (maybe just include a css file with empty definitions that can be stuck in inc_header with the js file)
SiSL Posted - 10 April 2009 : 10:46:49
quote:
Originally posted by HuwR

perhaps you should package your code into a usable MOD



Good idea, I think have to add this JS to head on inc_header and some styles to it along.
HuwR Posted - 10 April 2009 : 10:43:34
perhaps you should package your code into a usable MOD
SiSL Posted - 10 April 2009 : 10:41:51
quote:
Originally posted by HuwR

to be honest I used <code> too but in the .net version it ceates you a text file to download which is why I needed to add ID's to the code tags (copy text to the clipbaord can be a pain in the ass these days in a web browser )



Ahah good idea tho, I have to work on that for sake of good ol' classic ASP :p
HuwR Posted - 10 April 2009 : 10:40:26
to be honest I used <code> too but in the .net version it ceates you a text file to download which is why I needed to add ID's to the code tags (copy text to the clipbaord can be a pain in the ass these days in a web browser )
SiSL Posted - 10 April 2009 : 09:55:16
HuWR, I think you are mentioning about assigning ID or such to this, right?

I basically retain from ID method if you did so, following works with even you have thousand codes in same post or multi-posts, quite simple really: All you have to do add following javascript in HEAD or external JS anywhere and change your replace code function to replace different line.

Here is Javascript:

function kodSec(a)
{
	// Kod Satırının ID'si
	var e = a.parentNode.parentNode.getElementsByTagName('PRE')[0];
	
	// IE değilse
	if (window.getSelection)
	{
		var s = window.getSelection();
		// Safari
		if (s.setBaseAndExtent)
		{
			s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
		}
		// Firefox ve Opera
		else
		{
			var r = document.createRange();
			r.selectNodeContents(e);
			s.removeAllRanges();
			s.addRange(r);
		}
	}
	// Bazı eski browserlar
	else if (document.getSelection)
	{
		var s = document.getSelection();
		var r = document.createRange();
		r.selectNodeContents(e);
		s.removeAllRanges();
		s.addRange(r);
	}
	// IE
	else if (document.selection)
	{
		var r = document.body.createTextRange();
		r.moveToElementText(e);
		r.select();
	}
}


And here is how I made inc_func_common to replace it...

<dl class="code">
<dt><strong>Kod:</strong> <a href="#" onclick="kodSec(this); return false;">Tüm Kodu Seç</a></dt>
					<dd><pre class="codepre">... insert your code here .... </pre></dd></dl>


In other words:

Replace [code] with <dl class="code"><dt><strong>Kod:</strong> <a href="#" onclick="kodSec(this); return false;">Tüm Kodu Seç</a></dt><dd><pre class="codepre">

and

Replace [/code] with </pre></dd></dl>


Since it is same code for any "code" wraps, you don't need to assign any id or such to this function. Basically, kodSec function gets first child PRE below anchor that triggered script and selects all in it.

*cough* sorry for Turkish, I just pasted it, kodSec means "selectCode" and Tüm Kodu Seç is "Select All code" , you can assign width max width etc. later with any CSS as well. Later I did modification to my original like instead of PRE, I used <CODE> but ofcourse because PRE is a PITA element for CSS modifying but that's probably you would oppose to :p

After that I modified same in Spoiler tag but this time not to select but to hide show a div inside etc. Limitless I guess for such containers...

with my CSS and such, it looks like this:




Also in multi-code enviroment:


HuwR Posted - 10 April 2009 : 09:26:40
quote:
And about copy click to copy code feature, it'd be nice considering caret/text selection behaviours vary in browsers it may get annoying on long codes, and as MOD to be honest. Eitherway, it is just a few lines of code which can be easily made into a MOD.
it is not actually as simple as you suggest, try it and see I implemented it in the .net version and it wasn't trivial especially if you have multiple code sections in a post.
SiSL Posted - 10 April 2009 : 08:34:52
If you want MORE than Business-limited website, you have to design your site even for dummiest can do something. Yes, that includes that has no idea who has how to copy and paste. Well, I can understand idealist ideas of "not dumbing down" but this is another business, and more customers comes with more visitors. In the end, if idealist ideas worked, Linux would be more than 1% of overall pc's and not cry over why MS has that much ratio, Communism would be at half of the world.... I mean, then let's remove "smileys" since people can express themselves with words too

And about copy click to copy code feature, it'd be nice considering caret/text selection behaviours vary in browsers it may get annoying on long codes, and as MOD to be honest. Eitherway, it is just a few lines of code which can be easily made into a MOD.

And shaggy, while I'm also in mood of "WHY NEED" for many things in my work, believe me even most hardcore comptuer geeks would not whine about why it is added and like such feature. It's a feature and would not "decrease performance" than current since it is just a replace function with a javascript addition. And people no matter how experienced in computers, always love things that make their job easier.

I'm using that in my new forums, along with Hide/Show spoilers type.
HuwR Posted - 10 April 2009 : 05:04:57
quote:
The trend actually continues today where you see icons on websites encouraging people to post pages to Digg/Facebook/Stumbleupon/Whatever; again, if I've managed to join any of those websites, it's a safe bet that I know how to post a webpage to them all on my own, I might even have a bookmarklet that I use to do just that.


that is not true at all, I know plenty of people who have joind sites like twitter and diggit but wouldn't have the first clue how to add a link to the site
Shaggy Posted - 10 April 2009 : 04:36:07
quote:
Originally posted by Carefree
If there were a click-to-copy option, would YOU manually quote/highlight/right-click-copy (or Ctrl-C)?
Just to be devil's advocate here, I would and do.

<personal rant>
There was a trend in the late 90s/early 00s which used to annoy me no end and that was to assume your visitors didn't have the first clue how to operate their browser's and you used to see icons all over websites duplicating the functionality of the back, forward, set homepage, add to favourites and print buttons. I never, ever used those buttons as a visitor to a site as I found them to be patronising - if I'm savvy enough to be able to find your website then it's a safe bet I know the basics of how my browser works. (Unfortunately, as a developer, I sometimes didn't have a choice about whether or not I added them to a site).

The trend actually continues today where you see icons on websites encouraging people to post pages to Digg/Facebook/Stumbleupon/Whatever; again, if I've managed to join any of those websites, it's a safe bet that I know how to post a webpage to them all on my own, I might even have a bookmarklet that I use to do just that.

And it's the same thing here, if I've made it as far as a forum and am reading a topic related to coding, I definitely know how to copy & paste.
</personal rant>

Sorry for going off on one there but I seem to have found myself on a crusade recently against the dumbing down of the internet and find myself venting in the strangest places. That's all just personal opinion/food for thought and in no way to be interpreted as an attack on you or your opinions on this matter.

Carefree Posted - 10 April 2009 : 04:14:51
If there were a click-to-copy option, would YOU manually quote/highlight/right-click-copy (or Ctrl-C)? Personally, I doubt anyone would. So for each piece of code * quantity of users who are interested in a particular mod or security fix, there would be that many users of a click-to-copy.

I've been using Snitz for 7-8 years, and I never thought of asking for it until today, myself. But I know I'd have used it for the last 1000 or so pieces of code that I've copied to look at.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000 Version 3.4.07