1 (edited by bingiman 2007-04-24 21:34)

Topic: I need some assistance with a popup script

I am currently trying to get a popup smiley script to function but I am a bit lost.

Here is what I have so far. I made an external file called: popup.php and a link in post.php. I am using the easy_bbcode mod and it works as far as displaying the smiley's. The problem is that I can't insert the smiley's when I click on them. I have pasted the code I am using and it is the same working code I have been using in the normal fashion, which by the way works. Can someone please tell me what I need to do to get it to work.

popup.php

<?php

define('PUN_ROOT', './');

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'include/common.php';
 
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>Smileys</title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />

<?php
 if (!isset($bbcode_form))
    $bbcode_form = 'post';
if (!isset($bbcode_field))
    $bbcode_field = 'req_message';
?>


                        <script type="text/javascript">
                        <!--
                            function insert_text(open, close)
                            {
                                msgfield = (document.all) ? document.all.req_message : document.forms['<?php echo $bbcode_form ?>']['<?php echo $bbcode_field ?>'];

                                // IE support
                                if (document.selection && document.selection.createRange)
                                {
                                    msgfield.focus();
                                    sel = document.selection.createRange();
                                    sel.text = open + sel.text + close;
                                    msgfield.focus();
                                }

                                // Moz support
                                else if (msgfield.selectionStart || msgfield.selectionStart == '0')
                                {
                                    var startPos = msgfield.selectionStart;
                                    var endPos = msgfield.selectionEnd;

                                    msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
                                    msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
                                    msgfield.focus();
                                }

                                // Fallback support for other browsers
                                else
                                {
                                    msgfield.value += open + close;
                                    msgfield.focus();
                                }

                                return;
                            }

                        -->
                        </script>

 </head>

<?php
 
// Display the smiley set
require_once PUN_ROOT.'include/parser.php';

$smiley_dups = array();
$num_smilies = count($smiley_text);
for ($i = 0; $i < $num_smilies; ++$i)
{
    // Is there a smiley at the current index?
    if (!isset($smiley_text[$i]))
        continue;

    if (!in_array($smiley_img[$i], $smiley_dups))
        echo "\t\t\t\t\t\t\t".'<a style="cursor: pointer;" onclick="insert_text(\''.$smiley_text[$i].'\', \'\')"><img src="img/smilies/'.$smiley_img[$i].'" title="'.$smiley_img[$i].'" alt="'.$smiley_text[$i].'" /></a>'."\n";

    $smiley_dups[] = $smiley_img[$i];
}

Thanks in advance for any help here.

Re: I need some assistance with a popup script

Can someone please give me some guidance on this post.

Re: I need some assistance with a popup script

Well, I guess no one wants to help me out here. I actualyl got it working but I need to know something. I am calling the stylesheet from the popup.php file I created but I don't understand why it won't use the <H2> for the block headers. I actually have to add the following to the file itself.

<style type="text/css">
<!--
BODY {MARGIN: 5% 5% 1% 5%; font: 10px Verdana, Arial, Helvetica, sans-serif}
H2 {MARGIN: 0; COLOR: #FFFFFF; BACKGROUND-COLOR: #B84623; FONT-SIZE: 1.1em; PADDING: 5px}
-->
</style>

Also, is there a variable I can use instead of using the background-color etc..for example can I or is there something else I can use like $bg_color etc..

Thanks

Re: I need some assistance with a popup script

bingiman wrote:

Also, is there a variable I can use instead of using the background-color etc..for example can I or is there something else I can use like $bg_color etc..

No, there is not.

bingiman wrote:

it won't use the <H2> for the block headers.

H2 on its own won't get you block headers; look at some of PunBB's markup to see what will.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: I need some assistance with a popup script

thanks pogenwurst. I used pun as the class on the main DIV and that sorted it out.

Bingiman