Page 1 of 1

[DEV] Better Prompt 4 BBCodes v.0.0.2

PostPosted: 16 Oct 2012, 02:27
by iamthestreets
is it possible to make a prompt for a custom bbcode? for example youtube? i have made all the edits to your code but when i click on my youtube bbcode i get no promt.

Here is what i did.
editor.js
Code: Select all
// Open tag
        // insert_text(bbopen + bbclose);

        // Better Prompt 4 BBCodes / 4seven / 2011

        // img
        if (bbopen == '[img]')
        {
        jPrompt(img_wiz_2, '', img_wiz_1, function(img){
        if(img){
        setCaretPosition(caret_pos);
        insert_text('[img]' + img + '[/img]');}
        });
        }
      
        // url
        else if (bbopen == '[url]')
        {
        jPrompt(url_wiz_2, '', url_wiz_1, function(url_title){
        if(url_title){
        jPrompt(url_wiz_3, '', url_wiz_1, function(url){
        if(url_title&&url){
        setCaretPosition(caret_pos);
        insert_text('[url=' + url + ']' + url_title + '[/url]');}
        });
        }
        });
        }

        // flash
        else if (bbopen == '[flash=]')
        {
        jPrompt(fla_wiz_2, '', fla_wiz_1, function(flash_width){
        if(flash_width){
        jPrompt(fla_wiz_3, '', fla_wiz_1, function(flash_height){
        if(flash_width&&flash_height){
        jPrompt(fla_wiz_4, '', fla_wiz_1, function(flash_url){
        if(flash_width&&flash_height&&flash_url){
        setCaretPosition(caret_pos);
        insert_text('[flash=' + flash_width + ',' + flash_height + ']' + flash_url + '[/flash]');}
        });
        }
        });
        }
        });
        }
      
      // YouTube
        else if (bbopen == '[youtube]')
        {
        jPrompt(ytb_wiz_2, '', ytb_wiz_1, function(youtube){
        if(youtube){
        setCaretPosition(caret_pos);
        insert_text('[youtube]' + youtube + '[/youtube]');}
        });
        }
        });
        }
        });
        }
        });
        }
      
        // Better Prompt 4 BBCodes / 4seven / 2011

        else{

        insert_text(bbopen + bbclose);}


posting_buttons.html
Code: Select all
<script type="text/javascript">
// <![CDATA[
   // Better Prompt 4 BBCodes / 4seven / 2011
   // img
   var img_wiz_1  = "{LA_IMG_WIZ_1}";
   var img_wiz_2  = "{LA_IMG_WIZ_2}";
   // url
   var url_wiz_1  = "{LA_URL_WIZ_1}";
   var url_wiz_2  = "{LA_URL_WIZ_2}";
   var url_wiz_3  = "{LA_URL_WIZ_3}";
   // flash
   var fla_wiz_1  = "{LA_FLA_WIZ_1}";
   var fla_wiz_2  = "{LA_FLA_WIZ_2}";
   var fla_wiz_3  = "{LA_FLA_WIZ_3}";
   var fla_wiz_4  = "{LA_FLA_WIZ_4}";
   // youtube
   var ytb_wiz_1  = "{LA_YTB_WIZ_1}";
   var ytb_wiz_2  = "{LA_YTB_WIZ_2}";
   // ok + cancel
   var bb_wiz_ok  = "{LA_BB_WIZ_OK}";
   var bb_wiz_ca  = "{LA_BB_WIZ_CA}";
   // Better Prompt 4 BBCodes / 4seven / 2011
// ]]>
</script>

<script type="text/javascript" src="jquery/jquery.alerts.js"></script>


lang_better_prompt.php
Code: Select all
    $lang array_merge($lang, array(
    
// img
    
'IMG_WIZ_1'           => 'Img BBCode Wizard',
    
'IMG_WIZ_2'           => 'Enter Img URL',
    
// url
    
'URL_WIZ_1'           => 'URL BBCode Wizard',
    
'URL_WIZ_2'           => 'Enter URL Title',
    
'URL_WIZ_3'           => 'Enter URL',
    
// flash
    
'FLA_WIZ_1'           => 'Flash BBCode Wizard',
    
'FLA_WIZ_2'           => 'Enter width of Flash File',
    
'FLA_WIZ_3'           => 'Enter height of Flash File',
    
'FLA_WIZ_4'           => 'Enter URL of Flash File',
    
// youtube
    
'YTB_WIZ_1'              => 'YouTube BBCode',
    
'YTB_WIZ_2'              => 'Enter YouTube URL',
    
// ok + cancel
    
'BB_WIZ_OK'           => '&nbsp;OK&nbsp;',
    
'BB_WIZ_CA'           => '&nbsp;Cancel&nbsp;'
    
)); 


What am i missing? (yes i have already created a custom bbcode for youtube)

Re: [DEV] Better Prompt 4 BBCodes v.0.0.2

PostPosted: 16 Oct 2012, 02:31
by 4seven
Normally you can adapt each BBCode, if you transform it syntactical right.

find in your edits

Code: Select all
          // YouTube
            else if (bbopen == '[youtube]')
            {
            jPrompt(ytb_wiz_2, '', ytb_wiz_1, function(youtube){
            if(youtube){
            setCaretPosition(caret_pos);
            insert_text('[youtube]' + youtube + '[/youtube]');}
            });
            }
            });
            }
            });
            }
            });
            


replace with

Code: Select all
          // YouTube
            else if (bbopen == '[youtube]')
            {
            jPrompt(ytb_wiz_2, '', ytb_wiz_1, function(youtube){
            if(youtube){
            setCaretPosition(caret_pos);
            insert_text('[youtube]' + youtube + '[/youtube]');}
            });
            

just take a look with eg notepad++ for unclosed or unneeded brackets.