Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2010, 12:25 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding Favorite java

hi i used to use this image and the link was

HTML Code:
<img id="reminder_{vb:raw favid}_toggler" src="clear.gif" class="reminder_toggler<vb:if condition="$show['fav']">_active</vb:if>" onclick="FAVReminder.Toggle({vb:raw favid});" title="<vb:if condition="$show['fav']">Remove Favorite<vb:else />Add Favorite</vb:if>" />
and the code in .js file code is:

PHP Code:
FAVReminder = new reminder();

function 
reminder()
{
    
this.Toggle = function(favid)
    {
        
SitePopup.Show('FAV Reminder',PHRASE_AJAX_RUNNING);
        
        
YAHOO.util.Connect.asyncRequest("POST""ajax.php", {
                
successthis.ProcessReminder,
                
failurethis.handle_ajax_error,
                
timeoutvB_Default_Timeout,
                
scopethis
            
}, SESSIONURL 'securitytoken=' SECURITYTOKEN '&do=togglereminder&favid=' favid);
            
    }
    
    
this.handle_ajax_error = function(ajax)
    {
        
//TODO: Something bad happened, try again
        
vBulletin_AJAX_Error_Handler(ajax);
    }
    
    
this.ProcessReminder = function(ajax)
    {
        if (
ajax.responseXML)
        {
            var 
error ajax_fetch_tag('error'ajax);
            var 
reminder ajax_fetch_tag('reminder'ajax);
            var 
nzbfavcache ajax_fetch_tag('favcache'ajax);
            var 
nzbid ajax_fetch_tag('favid'ajax);

            if (
error)
            {
                
SitePopup.Show('FAV Reminder...'error);
            }
            else
            {
                
SitePopup.Show('FAV Reminder'PHRASE_AJAX_COMPLETE);
                
SitePopup.TimerClose(1000);        
                

                if (
toggler fetch_object('reminder_' favid'_toggler'))
                {
                    
toggler.className 'reminder_toggler' + ( reminder == '' '_active' );
                    
toggler.title = ( reminder == 'Remove Favorite' 'Add Favorite' );

                }
                if (
togglertitle fetch_object('add_' favid '_remove'))
                {
                    
togglertitle.innerHTML = ( reminder == 'Remove Favorite' 'Add Favorite' );

                }
                if (
titlecell fetch_object('td_threadtitle_' favid), true)
                {
                    
reminderthreadhighlight(titlecell, ( reminder == 'remove' 'add' ),1);
                }
                if (
img fetch_object('reminder_' favid '_img'))
                {
                    
img.style.display = ( reminder == 'none' '' );
                }
            }
        }
    }
}

it used to work in vBulletin 3.8 and since i updated its not working can anyone please help me out on this thanks.
Reply With Quote
  #2  
Old 01-25-2010, 12:48 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With the code you posted you are not registering the variables.

This one to be exact: favid you may also have to register $show depending where you want to use it.

https://vborg.vbsupport.ru/showthread.php?t=228078
Reply With Quote
  #3  
Old 01-25-2010, 02:37 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is the hook that uses ajax_complete


PHP Code:
if ($_POST['do'] == 'togglefavreminder') {

     
$vbulletin->input->clean_gpc('p''favid'TYPE_UINT); 

function 
build_favcache()
{
    global 
$db$vbulletin;
    
    
$favcache = array();
    
    
$fcq $db->query_read("SELECT * FROM " TABLE_PREFIX "favorites WHERE userid='" $vbulletin->userinfo['userid'] . "'");
    while (
$fc $db->fetch_array($fcq))
    {
        
$favcache[$fc['favid']] = $fc['favid'];

    }

    
$favcache_o serialize($favcache);
        
$db->query_write("UPDATE " TABLE_PREFIX "user SET favcache='" addslashes($favcache_o) . "' WHERE userid='" $vbulletin->userinfo['userid'] . "'");
}

        
$favcache unserialize($vbulletin->userinfo['favcache']);

    
$cfcq $db->num_rows($db->query_read("SELECT * FROM " TABLE_PREFIX "favorites WHERE userid='" $vbulletin->userinfo['userid'] . "' AND favid='" $vbulletin->GPC['favid'] . "'"));
           

        if(
$cfcq 0) {
                
//$favid = $cfcq['favid'];

                
$db->query_write("DELETE FROM " TABLE_PREFIX "favorites WHERE userid='" $vbulletin->userinfo['userid'] . "' AND favid='" $vbulletin->GPC['favid'] . "' LIMIT 1");
                
$reminders "0";

        } else {

        
$db->query_write("INSERT INTO " TABLE_PREFIX "favorites (userid, favid, reminder) VALUES ('" $vbulletin->userinfo['userid'] . "', '" $vbulletin->GPC['favid'] . "', '1')");
                
$reminders "1";

    }

    
$xml = new vB_AJAX_XML_Builder($vbulletin'text/xml');    
        
$xml->add_group('reminder');
    
$xml->add_tag('favid'$vbulletin->GPC['favid']);
    
$xml->add_tag('error'$error);    
        
build_favcache();
      if (
$cfcq 0) {
          
$xml->add_tag('reminder''0');
          } else {
          
$xml->add_tag('reminder''1');
          }
          
$xml->add_tag('favcache'$favcache_o);
    
    
$xml->close_group();
    
$xml->print_xml(true);
    

Reply With Quote
  #4  
Old 01-31-2010, 01:35 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone able to help me out.
Reply With Quote
  #5  
Old 01-31-2010, 02:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you do what BBR suggested and register the variables for use in the template? I don't see anything in any of your code regarding that.

(PS. And it's javascript, not java. They are two different languages.)
Reply With Quote
  #6  
Old 01-31-2010, 03:00 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i have m8 here

PHP Code:
        $bits vB_Template::create('fav_threadbit');
                                
$bits->register('favid'$favid);
                                
$bits->register('show'$show);
        
$favbits .= $bits->render(); 
Reply With Quote
  #7  
Old 01-31-2010, 03:10 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And what do you see in the template? Where are you using $favbits afterwards? And is that variable registered for use in the template you are using it in?
Reply With Quote
  #8  
Old 01-31-2010, 04:00 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes cause the link is showing up

HTML Code:
<img id="reminder_15_toggler" src="clear.gif" class="reminder_toggler<vb:if condition="$show['fav']">_active</vb:if>" onclick="FAVReminder.Toggle(15);" title="<vb:if condition="$show['fav']">Remove Favorite<vb:else />Add Favorite</vb:if>" />
heres the code for the Show popup which used to come up to say the fav has been added

HTML Code:
<!-- Site Info Popup -->
<form action="javascript:void();" method="post" onsubmit="" id="siteinfo_popup_form">
    <input type="hidden" name="s" value="" />
    <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
    <div id="siteinfo_popup" style="display: none;">
        <div class="tborder">

            <div class="nzbhead" style="padding:6px; padding-left: 60px;">
                <img src="images/misc/close.png" alt="" onclick="SitePopup.Close()" style="cursor:pointer;float:right;margin-top:2px;" />
                <span id="siteinfo_popup_title">Info</span>
            </div>
            <div class="nzbalt" style="padding:10px;">
                <span id="siteinfo_popup_body" style="font-weight:bold;"></span>
            </div>
        </div>

    </div>
</form>
<script type="text/javascript">
<!--
Siteinfo_Popup = new Page_Popup('Siteinfo_Popup', 'siteinfo_popup', 500, 75, true);
//-->
</script>
<!-- / Site Info Popup -->
and the javascript

Code:
function Page_Popup(varname, elementid, popupwidth, overlayopacity, ignorereturn)
{
    this.elementid = elementid;
    this.varname = varname;
    this.timer;
    
    // position fixed for all except ie6 and lower...
    if (is_ie && !is_ie7 && !is_ie8)
    {
        this.enabled = false;
    }
    else
    {        
        this.enabled = true;
        
        if (popupelement = fetch_object(elementid))
        {
            if (popupwidth)
            {
                this.popupwidth = popupwidth + "px";
            }
            else
            {
                this.popupwidth = "400px";
            }
            
            var element_properties = {
                position: "fixed",
                width: this.popupwidth,
                top: "45%",
                left: "50%",
                marginLeft: "-" + (popupwidth/2) + "px",
                zIndex: "1000"
            };
            
            for (var property in element_properties)
            {
                if (YAHOO.lang.hasOwnProperty(element_properties, property))
                {
                    YAHOO.util.Dom.setStyle(popupelement, property, element_properties[property]);
                }
            }
            
            this.popupelement = popupelement;
            //this.popupelement.originalOpacity = YAHOO.util.Dom.getStyle(this.popupelement, 'opacity');
        }
        
        if (overlayopacity>1)
        {
            if (overlayopacity > 100)
            {
                overlayopacity = 100;
            }
            
            overlay = document.createElement('div');
            
            var overlay_properties = {
                top: "0px",
                left: "0px",
                right: "0px",
                bottom: "0px",
                display: "none",
                position: "fixed",
                backgroundColor: "#000000",
                opacity: '0.' + overlayopacity
            };

            for (var property in overlay_properties)
            {
                if (YAHOO.lang.hasOwnProperty(overlay_properties, property))
                {
                    YAHOO.util.Dom.setStyle(overlay, property, overlay_properties[property]);
                }
            }
            this.Overlay = overlay;
        }
    }
    
    this.Show = function()
    {
        returnvalue = true;
        if (this.enabled)
        {
            // Hide vbmenu because it doesn't get covered with overlay...
            vbmenu_hide();
            if (typeof this.popupelement != 'undefined')
            {
                YAHOO.util.Dom.setStyle(this.popupelement, "opacity", this.popupelement.originalOpacity);
                YAHOO.util.Dom.setStyle(this.popupelement, "display", "");
                returnvalue = false;
            }
            if (typeof this.Overlay != 'undefined')
            {
                YAHOO.util.Dom.setStyle(document.body.appendChild(this.Overlay), "display", "");
            }
        }
        if (!ignorereturn)
        {
            return returnvalue;
        }
    }
    
    this.Close = function()
    {
        if (this.enabled)
        {
            this.ClearTimer();
            if (typeof this.popupelement != 'undefined')
            {
                //this.Anim = new YAHOO.util.Anim(this.popupelement, {opacity:{to: 0}}, 0.25);
                //if (this.Anim.animate())
                //{
                    //this.Anim.onComplete.subscribe(this.DoClose, this, true);
                //}
                //else
                //{
                    this.DoClose();
                //}
            }            
        }
    }
    
    this.DoClose = function()
    {
        if (typeof this.popupelement != 'undefined')
        {
            YAHOO.util.Dom.setStyle(this.popupelement, "display", "none");
        }
        if (typeof this.Overlay != 'undefined')
        {
            //overlay = document.body.appendChild(this.Overlay);
            YAHOO.util.Dom.setStyle(document.body.appendChild(this.Overlay), "display", "none");
        }
    }
    
    this.TimerClose = function(waittime)
    {
        this.timer = window.setTimeout( this.varname + ".Close()", waittime );
    }
    
    this.ClearTimer = function()
    {
        if (this.timer)
        {
            window.clearTimeout(this.timer);
        }
    }
}

//
// Site Info Popup
//

SitePopup = new siteinfo_popup('Siteinfo_Popup','siteinfo_popup');

function siteinfo_popup(varname,elementid)
{
    this.elementid = elementid;
    this.varname = varname;
    this.CloseFunc = false;
    
    this.Show = function(title,text,timewait,func,closefunc,form)
    {
        if (func)
        {
            eval(func);
        }
        if (form)
        {
            if (formobj = fetch_object(this.elementid + '_form'))
            {
                formobj.name = (form['name'] ? form['name'] : '');
                formobj.action = (form['action'] ? form['action'] : '');
                formobj.onsubmit = (form['onsubmit'] ? form['onsubmit'] : '');
                formobj.method = (form['method'] ? form['method'] : '');
            }
        }
        if (closefunc)
        {
            this.CloseFunc = closefunc;
        }
        if (titleobj = fetch_object(this.elementid + '_title'))
        {
            titleobj.innerHTML = title;
        }
        if (bodyobj = fetch_object(this.elementid + '_body'))
        {
            bodyobj.innerHTML = text;
        }        
        eval(this.varname + '.Show()');
        
        if (timewait)
        {
            this.TimerClose(timewait);
        }
    }
    
    this.Close = function()
    {
        if (this.CloseFunc)
        {
            eval(this.CloseFunc);
        }
        eval(this.varname + '.Close()');
    }
    
    this.TimerClose = function(timewait)
    {
        eval(this.varname + '.TimerClose(' + timewait + ')');
    }
}
Reply With Quote
  #9  
Old 01-31-2010, 05:04 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Let me get this straight.... is this what is showing up in the page source? Or is this the template?

HTML Code:
<img id="reminder_15_toggler" src="clear.gif" class="reminder_toggler<vb:if condition="$show['fav']">_active</vb:if>" onclick="FAVReminder.Toggle(15);" title="<vb:if condition="$show['fav']">Remove Favorite<vb:else />Add Favorite</vb:if>" />
Reply With Quote
  #10  
Old 01-31-2010, 05:26 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is the page source:
HTML Code:
<img id="nzbreminder_201_toggler" src="clear.gif" class="nzbreminder_toggler" title="Add Favorite">
this is the template:
HTML Code:
<img id="reminder_{vb:raw favid}_toggler" src="clear.gif" class="reminder_toggler<vb:if condition="$show['fav']">_active</vb:if>" onclick="FAVReminder.Toggle({vb:raw favid});" title="<vb:if condition="$show['fav']">Remove Favorite<vb:else />Add Favorite</vb:if>" />
its getting the verible its just not doing the javascript and the ajax_hook part of the code.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:10 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08133 seconds
  • Memory Usage 2,357KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (6)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete