Author |
Topic |
Carefree
Advanced Member
Philippines
4207 Posts |
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. |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 10 April 2009 : 03:00:25
|
if you think it would be heavily used feature, it is strange that nobody has asked for it before
|
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
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. |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
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.
|
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 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
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 |
|
|
SiSL
Average Member
Turkey
671 Posts |
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. |
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 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
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
Average Member
Turkey
671 Posts |
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:
|
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 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
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
Average Member
Turkey
671 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 10 April 2009 : 10:43:34
|
perhaps you should package your code into a usable MOD |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
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
Average Member
Turkey
671 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
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
Average Member
Turkey
671 Posts |
|
Topic |
|