Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 Click to Copy Code
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 10 April 2009 :  02:44:33  Show Profile  Reply with Quote
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.

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  03:00:25  Show Profile  Visit HuwR's Homepage  Reply with Quote
if you think it would be heavily used feature, it is strange that nobody has asked for it before

Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 10 April 2009 :  04:14:51  Show Profile  Reply with Quote
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.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 10 April 2009 :  04:36:07  Show Profile  Reply with Quote
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.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 10 April 2009 04:36:31
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  05:04:57  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  08:34:52  Show Profile  Visit SiSL's Homepage  Reply with Quote
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.

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 10 April 2009 08:45:31
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  09:26:40  Show Profile  Visit HuwR's Homepage  Reply with Quote
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.
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  09:55:16  Show Profile  Visit SiSL's Homepage  Reply with Quote
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:



CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 10 April 2009 10:37:39
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  10:40:26  Show Profile  Visit HuwR's Homepage  Reply with Quote
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 )
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  10:41:51  Show Profile  Visit SiSL's Homepage  Reply with Quote
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

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  10:43:34  Show Profile  Visit HuwR's Homepage  Reply with Quote
perhaps you should package your code into a usable MOD
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  10:46:49  Show Profile  Visit SiSL's Homepage  Reply with Quote
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.

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  10:49:13  Show Profile  Visit HuwR's Homepage  Reply with Quote
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)
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  11:33:33  Show Profile  Visit SiSL's Homepage  Reply with Quote
Oh well, here goes with a nice detailed Readme in it
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=68515

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 April 2009 :  11:39:25  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page

SiSL
Average Member

Turkey
671 Posts

Posted - 10 April 2009 :  11:46:35  Show Profile  Visit SiSL's Homepage  Reply with Quote
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?

CHIP Online Forum

My Mods
Select All Code | Fix a vulnerability for your private messages | Avatar Categories W/ Avatar Gallery Mod | Complaint Manager
Admin Level Revisited | Merge Forums | No More Nested Quotes Mod

Edited by - SiSL on 10 April 2009 12:08:06
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000 Version 3.4.07