Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Easy Selection with Line Numbers MOD by WinRules.

Aloittaja Phphelp, syyskuu 01, 2013, 04:28:59 IP

« edellinen - seuraava »

Phphelp

I would post this in tip and tricks, but for some reason I don't have access to create new topics their..

Here's winrules mod:

http://custom.simplemachines.org/mods/index.php?mod=356

The problem with selecting code with line numbers is that it copies the line numbers which is awful, but it's nice to have for a display.

So I changed his addLineNumbers routine to this.  Basically creating a table with 2 TD's that will allow you to easily select all the contents of 1 TD or the Other.


function addLineNumbers($code)
{
$lines = explode('<br />', $code);
$code = '<table style="width:100%"><tr><td style="width:15px;text-align:left">';
$code2 = '<td style="text-align:left">';
$spaces = strlen(count($lines));
$spacesoutput = '';
for ($n = 1; $n <= $spaces; $n++)
$spacesoutput .= '&nbsp;';
$i = 1;
$len = 1;
foreach ($lines as $line)
{
if (strlen($i) != $len)
{
$spaces--;
$len++;
$spacesoutput = '';
for ($n = 1; $n <= $spaces; $n++)
$spacesoutput .= '&nbsp;';
}
$code .= '<span style="color: #FF9900">' . $i . '</span><br />';
$code2 .=  $spacesoutput . $line . '<br />';
$i++;
}
$code .= '</td><td>' . $code2;
$code .= '</td?</tr></table>';
return $code;
}


Advertisement: