News:

SMF 2.1.2 has been released! Take it for a spin! Read more.

Main Menu

Select All & Copy Code To Clipboard

Started by karlbenson, October 14, 2007, 04:51:27 PM

Previous topic - Next topic

karlbenson



SELECT ALL AND COPY CODE TO CLIPBOARD v1.2
By Karl Benson



Introduction
This mod alters the output of the 'code' tag to include links to select all the code and to copy it to clipboard.

Requires 'Flash' to enabled by the browser (as the copying is done by a flash file called _clipboard.swf)

Tested in browsers
IE 6/7
Firefox 1/2
Opera (Select All does not work, but Copy To Clipboard works.)

Features
o Adds "Select Code" Link to each coded section
o Adds "Copy To Clipboard" Link to each coded section

There are no admin settings with this mod. To disable/remove it, you must uninstall it.

Installation
Installation affects source files and a javascript file which is called from the default theme for ALL themes, therefore NO theme edits will be required.
(unless there is a conflict with modifications OR if your not using a supported language)

There are TWO versions of this mod.
One for SMF 1.1.x versions and
one for SMF 2.0 Beta 1 (which is currently available to Charter Members).

If your using a language different than the ones supported this mod (listed below), then you will need to add the following to the Modifications.{language}.php for each theme (The language folder can be found eg Themes/{themename}/languages/)

FIND
?>
ADD BEFORE (and translate as necessary the language strings)
$txt['codeselectall'] = 'Select All';
$txt['codecopytoclipboard'] = 'Copy To Clipboard';
$txt['codedivider'] = '|';


Languages
o Currently Supports
- English/English-utf8
- English_British/English_British-utf8
- Turkish/Turkish-utf8 (Thanks to Kapadokyali & BadBoy)
- Spanish/Spanish-utf8 (Thanks to EgAr)
- Spanish_es/Spanish_es-utf8 (Thanks to EgAr)
- Greek/Greek-utf8 (Thanks to MinasC)
I welcome translations for any other languages which SMF Supports.
Please translate the following and post them in the modification topic.
$txt['codeselectall'] = 'Select All';
$txt['codecopytoclipboard'] = 'Copy To Clipboard';
$txt['codedivider'] = '|';


Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0 - 10th October 2007
o Initial release
1.1 - 20th October 2007
o Added languages
- Turkish/Turkish-utf8 (Thanks to Kapadokyali & BadBoy)
- English_British/English_British-utf8
- Spanish/Spanish-utf8 (Thanks to EgAr)
- Spanish_es/Spanish_es-utf8 (Thanks to EgAr)
1.2 - 22nd November 2007
o Added Greek/Greek-utf8 (Thanks to MinasC)

MinasC

wow man , productivity day today , right ?
thnx a lot !

karlbenson

They have all been approved today.
I created these in the past few days to 1-3 weeks.

and theres still 2 more to be fix then to be approved.

MinasC


karlbenson


MinasC

hey , i just tried to install and got an error : subs.php not found ! i think you have to change install.xml and put "Subs.php" instead of "subs.php" !

karlbenson

I was in the process of fixing it when you posted it.

Updated versions of 1.0 are not available via mod section.

MinasC

well ,

i installed it fine in one of my forums (i am still testing that one) but i got that text

$txt['codeselectall'] = 'Select All'; $txt['codecopytoclipboard'] ='Copy To Clipboard'; $txt['codedivider'] = '|';

at the top of my pages , and the mod doesn't show ! what's wrong ?
thnx !

karlbenson

This one is not my mods fault, but a bug in SMF on some server setups. :P

Open
Modifications.english.php (the location of this file is Themes/default/languages)

Making sure no text strings like those you posted are;
above <?php (which needs to be the first thing in the file)
below ?> (which needs to be the last thing in the file [on a line of its own]

if your using utf8, you will need to do the same for
Modifications.english-utf8.php


edi67

i was searching this by AGEssss thxxxxx   work ok for now
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

MinasC

Quote from: karlbenson on October 14, 2007, 06:59:54 PM
This one is not my mods fault, but a bug in SMF on some server setups. :P

Open
Modifications.english.php (the location of this file is Themes/default/languages)

Making sure no text strings like those you posted are;
above <?php (which needs to be the first thing in the file)
below ?> (which needs to be the last thing in the file [on a line of its own]

if your using utf8, you will need to do the same for
Modifications.english-utf8.php



done , all ok ! thnx !

(by the way , i installed 4 of the mods you posted yesterday and they are all great ! my congrats man !!!)

Badboy

Nice mod.

Here are the Turkish and Turkish-utf8 translations


Code (Turkish) Select
$txt['codeselectall'] = 'Hepsini Seç';
$txt['codecopytoclipboard'] = 'Panoya Kopyala';
$txt['codedivider'] = '|';


Code (Turkish-utf8) Select
$txt['codeselectall'] = 'Hepsini Seç';
$txt['codecopytoclipboard'] = 'Panoya Kopyala';
$txt['codedivider'] = '|';
Nothing is true, everything is permitted.

EgAr

Hi, for

spanish  ,  spanish_es , spanish-utf8 , spanish_es-utf8


$txt['codeselectall'] = 'Seleccionar todo';
$txt['codecopytoclipboard'] = 'Copiar al Portapapeles';
$txt['codedivider'] = '|';




Saludos   :D

karlbenson

gracias.

I've now uploaded v1.1. to add all the languages I've had submitted.

1.1 - 20th October 2007
o Added languages
- Turkish/Turkish-utf8 (Thanks to Kapadokyali & BadBoy)
- English_British/English_British-utf8
- Spanish/Spanish-utf8 (Thanks to EgAr)
- Spanish_es/Spanish_es-utf8 (Thanks to EgAr)

MinasC

here is the greek translation :

$txt['codeselectall'] = 'Επιλογή Όλων';
$txt['codecopytoclipboard'] = 'Αντιγραφή στον Πίνακα';
$txt['codedivider'] = '|';

karlbenson

Thanks MinasC

I've uploaded v1.2 with theGreek Language strings inside

1.2 - 22nd November 2007
o Added Greek/Greek-utf8 (Thanks to MinasC)

MinasC


falguni1


karlbenson

It adds two links to the 'code' box.

One to 'select all' the contents of the code box.
Second to Copy it to Clipboard (so you can paste it elsewhere)

falguni1


karlbenson

Are you using a language supported by the mod?
Are you getting any errors in your error log?
Can you link me to a url/page on your forum where url tags are installed?


karlbenson

Something has gone wrong with SMF package manager.
Its inserted the language strings in the wrong place in the file.

Its not a bug with this mod (or my buy me a beer mod), but for some unknown reason it happens with smf.

Open
Themes/default/Languages/Modifications.english.php

Make sure <?php is at the VERY TOP at the file on its OWN line
and
?> is at the very bottom of the file on its OWN line.

(so as necessary move any language strings in-between).

Do the same for
Themes/default/Languages/Modifications.english-utf8.php
if your using utf8.

And for any other languages you may be using.

au8ust

Hm... Weird :( I can't use it in Firefox, Select All and Copy To Clipboard are not working at all. It's working in IE for Select All only.

Any idea?

karlbenson

The mod has been tested in firefox.

In firefox Goto
Tools > Error console

is it giving you any error?

Is flash enabled in Firefox?

au8ust

Okay I'll try that

BTW, below is Thai and Lao translation ;)


<file name="$languagedir/Modifications.thai-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['codeselectall'] = 'เลือกทั้งหมด';
$txt['codecopytoclipboard'] = 'สำเนาไว้ใน Clipboard';
$txt['codedivider'] = '|';
]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.lao-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['codeselectall'] = 'ເລືອກທັງຫມົດ';
$txt['codecopytoclipboard'] = 'ສຳເນົາໄວ້ໃນ Clipboard';
$txt['codedivider'] = '|';
]]></add>
</operation>
</file>

au8ust

Quote from: karlbenson on January 07, 2008, 12:53:40 AM
The mod has been tested in firefox.

In firefox Goto
Tools > Error console

is it giving you any error?

Is flash enabled in Firefox?

Okay, it causes from Flashblock extension so I disable it and Select All is working fine now :)

For the Copy to Clipboard shows these errors

Warning: Error in parsing value for property 'opacity'.  Declaration dropped.
Source File: http://mydomain.tld/webboard/index.php/topic,72.msg83.html#msg83
Line: 0
Warning: Error in parsing value for property 'opacity'.  Declaration dropped.
Source File: http://mydomain.tld/webboard/index.php/topic,72.msg83.html#msg83
Line: 0

karlbenson

So the Copy to Clipboard bit still isnt working?

The mod doesnt do anything for opacity.
They are probably related to some other javascript on your page.

ne.miguelito


au8ust

NWM, I will use only the Copy All ;)

Thanks for the MOD!

karlbenson

I have reuploaded this mod and screenshots for it.

I am in the process of doing it for ALL my other mods aswell.  Please bear with me.

Teunel

Hi, Thanks for this great mod. I have one question though.

I have changed my forum a lot, and when I post a topic, it automatically shows the content in a Code box. I'm not using the code tags, I just placed the code divs in my Display.Template.php. An example can be seen here: http://www.krabbelplaatjes.com/grappig/lol-t1201.0.html
Now, I want to show the Select all and Copy to that code box too, but it isn't really working. What do I have to modify to get this working? I tried looking at the source and adding the Javascript in there manually, but this isn't working.

Here is a Dutch translation:

$txt['codeselectall'] = 'Selecteer Alles';
$txt['codecopytoclipboard'] = 'Kopieer naar Klembord';
$txt['codedivider'] = '|';

karlbenson

It wouldn't be easy.
The javascript is built on basis of the default code <div>s

I cannot provide support for customizing it.

Teunel

Ok, then I will take a look at it myself when I can find some time! :D Thanks anyway for the great mod!

Darknico

#34
Good mod!!!
Thanks!

It is possible for tag [php][/php] ?
Italian SMF - Supporto Italiano per la board SMF - Ci trovate tutti li!! :)


Kimmie

Hi Karl, seems this is my week to "bug" you... heehehe

I tried to install this mod via package manager and got this:

1. Execute Modification ./Themes/default/script.js Test successful
2. Execute Modification ./Sources/Subs.php Test failed
3. Execute Modification ./Themes/default/languages/Modifications.english.php Test successful
4. Execute Modification ./Themes/default/languages/Modifications.english-utf8.php Skipping file
5. Execute Modification ./Themes/default/languages/Modifications.english_british.php Skipping file
6. Execute Modification ./Themes/default/languages/Modifications.english_british-utf8.php Skipping file
7. Execute Modification ./Themes/default/languages/Modifications.turkish.php Skipping file
8. Execute Modification ./Themes/default/languages/Modifications.turkish-utf8.php Skipping file
9. Execute Modification ./Themes/default/languages/Modifications.spanish.php Skipping file
10. Execute Modification ./Themes/default/languages/Modifications.spanish-utf8.php Skipping file
11. Execute Modification ./Themes/default/languages/Modifications.spanish_es.php Skipping file
12. Execute Modification ./Themes/default/languages/Modifications.spanish_es-utf8.php Skipping file
13. Execute Modification ./Themes/default/languages/Modifications.greek.php Skipping file
14. Execute Modification ./Themes/default/languages/Modifications.greek-utf8.php Skipping file
15. Extract File ./_clipboard.swf


Would the fact I am using 1.1.5 be the issue since you stated that no manual theme edits were needed with this one? I wanted to ask and see what you thought before I tried manually installing it and screwing up something..lol.

karlbenson

It must be conflicting with another mod.

Its not a theme edit. Its a conflict. The only solution is to do it manually.

Kimmie

ew I was afraid of that...ok one more question and I will leave you alone (for a while anyways..hehe).

In a case like this, which way do you recommend I do it:

1. Install it via package manager and then edit the Subs.php file and make the edits
2. Install the whole thing manually

I am not sure if it really makes a difference but I wanted to ask your professional opinion as to what you think the best way would be. I guess I just need clarification tht if I do it the #1 way, can I be assurred tht it will make the correct edits to the other files? (this is me trying to learn how to do this so I dont have to keep asking hehehe). In most cases I usualy dont have to do manual edits cuz my theme uses mostly the default files - so I havent had a whole lot of practice with manual edits and I want to make sure I do it right. :)

Thanks for ALL your help. Your mods are some of the best I have used (and I have several lol)

karlbenson

Thanks.

Generally I'd recommend installing it entirely manually.
But I've done it the other method too.

So its your choice.
Although I would recommend taking full backups of your files and your database before proceeding with such changes.


Kimmie

HI its me again :). Im not sure how to explain this so I will start from the beginning..hehe.

I decide to install the mod via the package manager and then modify the Subs file (less for me to mess up  lol). No errors in the error log, however, the mod isnt working. It hasnt made any changes to the "code" part. Since I have other mods that affect that file - some of the code is in the same section that this mod changes, I couldnt replace that entire section with what the parser said to because it would mess up the other mod(s) that also use that section, so what I did was compare what code you added to that area with what is in my original subs file and made the necessary changes. Basically all I saw that was different was these two sections of code:

// SELECT ALL AND COPY CODE TO CLIPBOARD MOD
static $codecounter = 0;
$codecounter++;
$data = \'<div class="codeheader">\' . $txt[\'smf238\'] . \': \'
.\'<a href="javascript:void(0)" title="\'.$txt[\'codeselectall\'].\'" onclick="javascript:selectall(\\\'code_a\'.$codecounter.\'\\\');return false;">\'.$txt[\'codeselectall\'].\'</a>\'
.\' \'.$txt[\'codedivider\'].\' <a href="javascript:void(0)" title="\'.$txt[\'codecopytoclipboard\'].\'" onclick="javascript:copy(\\\'code_a\'.$codecounter.\'\\\');return false;">\'.$txt[\'codecopytoclipboard\'].\'</a>\'
.\'</div><div class="code" id="code_a\'.$codecounter.\'">\' . ($context[\'browser\'][\'is_gecko\'] ? \'<pre style="margin-top: 0; display: inline;">\'.$data.\'</pre>\' : $data) . \'</div>\';
// END OF SELECT ALL AND COPY TO CLIPBOARD MOD


AND

// SELECT ALL AND COPY CODE TO CLIPBOARD MOD
static $codecounter = 0;
$codecounter++;
$data[0] = \'<div class="codeheader">\' . $txt[\'smf238\'] . \': (\'.$data[1].\') \'
.\'<a href="javascript:void(0)" title="\'.$txt[\'codeselectall\'].\'" onclick="javascript:selectall(\\\'code_b\'.$codecounter.\'\\\');return false;">\'.$txt[\'codeselectall\'].\'</a>\'
.\' \'.$txt[\'codedivider\'].\' <a href="javascript:void(0)" title="\'.$txt[\'codecopytoclipboard\'].\'" onclick="javascript:copy(\\\'code_b\'.$codecounter.\'\\\');return false;">\'.$txt[\'codecopytoclipboard\'].\'</a>\'
.\'</div><div class="code" id="code_b\'.$codecounter.\'">\' . ($context[\'browser\'][\'is_gecko\'] ? \'<pre style="margin-top: 0; display: inline;">\'.$data[0].\'</pre>\' : $data[0]) . \'</div>\';
// END OF SELECT ALL AND COPY TO CLIPBOARD MOD


I added them directly after both of these codes in that file just like the parser said to:

// Fix the PHP code stuff...
$data[0] = str_replace("<pre style=\"display: inline;\">\t</pre>", "\t", implode(\'\', $php_parts));


Could you take a look at my Subs.php file and see if you see anything I missed? It would be greatly appreciated if you could :).

The 1st attachment is my Subs file BEFORE installing the mod. The second one is after I made the edit.

fdLP.

bumping it , need it fixed , its not working , it doesnt copy the text when it select it .. Using 1.1.9 (sorry if its aint allowed)


Gaming-Devs.com | New Programming Forum

fdLP.

anyone got a similar mod working on 1.1.9?


Gaming-Devs.com | New Programming Forum

Advertisement: