SMF - open new window java script inside <php ?> tags - how to rewrite the code?

33 views
Skip to first unread message

alexand...@gmx.de

unread,
Oct 17, 2014, 2:49:10 PM10/17/14
to ajax...@googlegroups.com
hello,

i use the integration version for smf 2.x. i want to open the chat in a new window via java script. the code has to be added to my theme's index.template.php, ehre all java scripts are placed within <php ?> tags. unfortunately i really suck at java. :-( could any one please help me, please?

this is the code i want to add:

<script type="text/javascript">
       
// <![CDATA[
               
function openWindow(url,width,height,options,name) {
                        width
= width ? width : 800;
                        height
= height ? height : 600;
                        options
= options ? options : 'resizable=yes';
                        name
= name ? name : 'openWindow';
                        window
.open(
                                url
,
                                name
,
                               
'screenX='+(screen.width-width)/2+',screenY='+(screen.height-height)/2+',width='+width+',height='+height+','+options
                       
)
               
}
       
// ]]>
</script>

this is the part of my index.template.php containing the scripts:

// Here comes the JavaScript bits!
    echo
'
    <script type="text/javascript" src="'
, $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
    <script type="text/javascript" src="'
, $settings['theme_url'], '/scripts/theme.js?fin20"></script>
    <script type="text/javascript"><!-- // --><![CDATA[
        var smf_theme_url = "'
, $settings['theme_url'], '";
        var smf_default_theme_url = "'
, $settings['default_theme_url'], '";
        var smf_images_url = "'
, $settings['images_url'], '";
        var smf_scripturl = "'
, $scripturl, '";
        var smf_iso_case_folding = '
, $context['server']['iso_case_folding'] ? 'true' : 'false', ';
        var smf_charset = "'
, $context['character_set'], '";', $context['show_pm_popup'] ? '
        var fPmPopup = function ()
        {
            if (confirm("'
. $txt['show_personal_messages'] . '"))
                window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm");
        }
        addLoadEvent(fPmPopup);'
: '', '
        var ajax_notification_text = "'
, $txt['ajax_in_progress'], '";
        var ajax_notification_cancel_text = "'
, $txt['modify_cancel'], '";
    // ]]></script>    '
;  
    echo
'

so... how to rewirte the first script to make it work inside those echo tags?

thank you in advance!
Reply all
Reply to author
Forward
0 new messages