increasing code-box

Started by Hondo, April 29, 2006, 03:28:58 PM

Previous topic - Next topic

Hondo

Hi,
I tried to modify the height of the div-container where code is displayed. It´s not a problem when only 1 codepart in the thread is, but when more it don´t work.
Her is my code in subs.php function parse_bbc():
array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<script type="text/javascript" language="JavaScript">function height(s){document.getElementsByTagName("div")["code"].style.height = s;}</script><div class="codeheader" align="left" style="margin-left: 20px; width: 85%">' . $txt['smf238'] . ':
<a style="text-decoration: none" href="javascript:height(\'20em\')"><font size="2"><b>&laquo;</b></font></a>&nbsp;&nbsp;<a style="text-decoration: none" href="javascript:height(\'40em\')"><font size="2"><b>&raquo;</b></font></a>&nbsp;&nbsp;<a style="text-decoration: none" href="javascript:height(\'80em\')"><font size="2"><b>&raquo;&raquo;</b></font></a>&nbsp;&nbsp;<a style="text-decoration: none" href="javascript:height(\'120em\')"><font size="2"><b>&raquo;&raquo;&raquo;</b></font></a></div><div id="code" class="code" align="left" style="margin-left: 20px">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',


The error occur when more than 1 div-box have the id=code.
I tried to give them an other id, a random value. But it can not work cauz the whole thread will parse. So every div-container with code has the same id. It is the same with an other hack where I make the text bigger in the code-box.
Here is a sample thread with 1 code-box where you see what I mean. This is helpful for long listings to decrease or increase the height of the code-box:
http://www.mkportal-support.de/forum/index.php?topic=538.0

Andreas

Hondo

Hi,
no one a idea about it?

Andreas

jacortina

Couldn't you just change the style sheet?

Find this in style.css:


/* A code block - maybe even PHP ;). */
.code
{


Increase width to 99% if you like and add a min-height line ('min-height: 5em;' should force a minimum of 5 lines in the code box even if it includes a number of blank lines).


Hondo

Hi,
I see you don´t understand the problem.

Andreas

jacortina

Then I thank you for explaining it.

Hondo

Hi,
what other should I say? I´m sorry but you realy don´t understand the problem. Its not a problem with the style, it´s javascript.

The problem is after the message is parsed in function parse_bbc() with my hack the code-boxes has all the same id (random value) But I need diffenrent id´s.

My first Idea was to place a placeholder instead of the id and later I replace it with different random values - but how?

Andreas

jacortina

The problem listed in the title of this thread is 'Increasing Code Box'.

If you're not trying to do that, then I would suggest you use a different title.

Hondo

Hi,
why? read my description or do you only read the title and than answer? I hope not.
Of cause I want to increase (or decreas) the code box but not constant but dynamicaly by manipulate the style from the codebox with javascript.

Andreas

Advertisement: