PHPFusion\Forums\Threads\ViewThread::set_ThreadJs PHP Метод

set_ThreadJs() приватный Метод

private set_ThreadJs ( )
    private function set_ThreadJs()
    {
        $viewthread_js = '';
        //javascript to footer
        $highlight_js = "";
        $colorbox_js = "";
        $edit_reason_js = '';
        /** javascript **/
        // highlight jQuery plugin
        if (isset($_GET['highlight'])) {
            $words = explode(" ", urldecode($_GET['highlight']));
            $higlight = "";
            $i = 1;
            $c_words = count($words);
            foreach ($words as $hlight) {
                $hlight = htmlentities($hlight, ENT_QUOTES);
                $higlight .= "'" . $hlight . "'";
                $higlight .= $i < $c_words ? "," : "";
                $i++;
            }
            add_to_head("<script type='text/javascript' src='" . INCLUDES . "jquery/jquery.highlight.js'></script>");
            $highlight_js .= "\$('.search_result').highlight([" . $higlight . "],{wordsOnly:true});";
            $highlight_js .= "\$('.highlight').css({backgroundColor:'#FFFF88'});";
            //better via theme or settings
        }
        $edit_reason_js .= "\n\t\t\t\$('.reason_div').hide();\n\t\t\t\$('div').find('.reason_button').css({cursor: 'pointer' });\n\t\t\t\$('.reason_button').bind('click', function(e) {\n\t\t\t\tvar target = \$(this).data('target');\n\t\t\t\t\$('#'+target).stop().slideToggle('fast');\n\t\t\t});\n\t\t\t";
        // viewthread javascript, moved to footer
        if (!empty($highlight_js) || !empty($colorbox_js) || !empty($edit_reason_js)) {
            $viewthread_js .= $highlight_js . $colorbox_js . $edit_reason_js;
        }
        $viewthread_js .= "\$('a[href=#top]').click(function(){";
        $viewthread_js .= "\$('html, body').animate({scrollTop:0}, 'slow');";
        $viewthread_js .= "return false;";
        $viewthread_js .= "});";
        $viewthread_js .= "});";
        // below functions could be made more unobtrusive thanks to jQuery, giving a more accessible cms
        $viewthread_js .= "function jumpforum(forum_id){";
        $viewthread_js .= "document.location.href='" . INFUSIONS . "forum/viewforum.php?forum_id='+forum_id;";
        $viewthread_js .= "}";
        if (iMOD) {
            // only moderators need this javascript
            $viewthread_js .= "function setChecked(frmName,chkName,val){";
            $viewthread_js .= "dml=document.forms[frmName];";
            $viewthread_js .= "len=dml.elements.length;";
            $viewthread_js .= "for(i=0;i<len;i++){";
            $viewthread_js .= "if(dml.elements[i].name==chkName){";
            $viewthread_js .= "dml.elements[i].checked=val;";
            $viewthread_js .= "}";
            $viewthread_js .= "}";
            $viewthread_js .= "}";
        }
        //$viewthread_js .= "/*]]>*/";
        //$viewthread_js .= "</script>";
        add_to_jquery($viewthread_js);
    }