Thread: Add-On Releases - vBGamEz - game monitoring script
View Single Post
  #268  
Old 05-01-2014, 08:26 PM
Bestrafung Bestrafung is offline
 
Join Date: Aug 2009
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I spoke too soon. I have a basic page with multiple servers on the same page. Auto refresh doesn't work but I'm not going to fix it because I don't want it to. Eventually I want it refresh on page load for cron jobs but also have the manual update buttons. In order to have multiple servers on the page I made a new JS function copying the existing but adding serverid where appropriate and then added the serverid to the HTML code. The first refresh works but the AJAX rewrites the HTML from id="vbg_updater9" back to id="vbg_updater" breaking any subsequent refresh attempts. If someone could point me in the correct direction I could continue on and would much appreciate it. Eventually once the barebones are worked out I'll make into an actual VB page + template. I just need to learn how to setup a VB settings to select which server IDs to use. If anyone is interested in the final script (if it's ever finished) let me know.

New JS function, I've colored the changes to make it easier:
Code:
function vbg_update_eventserver(serverid, isvb3)
{
    var sort_option = fetch_object('vbg_sort_players').value;
	var order_option = fetch_object('vbg_order_players').value;
	
    fetch_object('vbg_updater' + serverid).style.display = '';
    var sUrl = vbgamez_path;
    var postData = 'do=view&id=' + serverid + '&ajax=1&securitytoken=' + SECURITYTOKEN + '&sort_by_field=' + sort_option + '&order=' + order_option;
    var handleSuccess = function(o)
    {
        if(o.responseText !== undefined)
        {
               if(o.responseText == '') { return false; }

               fetch_object('vbg_serverinfo' + serverid).innerHTML = o.responseText;

        }
    }
    var handleFailure = function(o)
    {
        if(o.responseText !== undefined)
        {
            alert(o.responseText);
        }
    }
    var callback =
    {
        success: handleSuccess,
        failure: handleFailure,
        timeout: vB_Default_Timeout
    };
    YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}
Example HTML block:
Code:
          <!-- Begin game block -->
          <div class="vbgamezlist_full">
            <div id="vbg_serverinfo9" class="block">
              <h2 class="blockhead">
                <img src="images/site_icons/network.png" alt="" />Server 1
				<span id="vbg_updater9" style="display:none;"><img src="images/theme/misc/13x13progress.gif" alt="Updating..." title="Updating..."/></span>
				<a href="javascript://"  onclick="vbg_update_eventserver(9);" class="blockheadinfo">Update</a>
			  </h2>
			  <div class="blockbody">
				<ul class="blockrow">
                  <li class="sgicon floatcontainer owngroup">
                    <div class="leftcol" id="left_column" id="lightbox_leftcol">
                        <center>
                            <div class="sgicon" style="background-image:url(images/vbgamez/map_overlay.gif); background-repeat:no-repeat; background-position:center; width:135px; height:135px;">
                                <a href="/vbgamez.php?do=showmap&amp;type=cmw&amp;game=chivalrymedievalwarfare&amp;map=aoclts-moor_p&amp;status=1" rel="Lightbox_9" id="attachment9"><img alt="" class="sgicon" src="images/vbgamez/maps/cmw/aoclts_moor_p.jpg" height="135" width="135"/></a>
                            </div>
                        </center>
                    
                        <ul class="controls">
                            <li><a class="textcontrol" rel="nofollow" href="steam://run/219640/en/xxx.xxx.xxx.xxx:7777"><img src="images/site_icons/add.png" alt=""/> Logon to server&nbsp;&nbsp;</a></li>
                        </ul>
                    </div>
                    
                    <div class="maincol">
                        <p class="description">Server status: <b>Online</b></p>
                        <p class="description">Game: <a href="/vbgamez_search.php?do=dosearch&amp;map=aoclts-moor_p&amp;game=cmw&amp;additional_game=chivalrymedievalwarfare" rel="nofollow"><b>Chivalry: Medieval Warfare</b></a></p>
                        <p class="description">IP: <a href="steam://run/219640/en/xxx.xxx.xxx.xxx:7777"><b>xxx.xxx.xxx.xxx:7777</b></a>&nbsp;</p>
                        <p class="description">Map: <b>aoclts-moor_p</b></p>
                        <p class="description">Players: <b>0/3</b></p>
                        <p class="description">Rating: <b><span id="rating_9">0</span></b>
                            <a href="/vbgamez.php?do=ratingminus&amp;serverid=9" onclick="vbg_rate(9, 'minus'); return false;"><img style="vertical-align: middle;" src="/images/theme/cms/arrow_down.png" alt="" /></a>
                            <a href="/vbgamez.php?do=ratingplus&amp;serverid=9" onclick="vbg_rate(9, 'plus'); return false;"><img style="vertical-align: middle;" src="/images/theme/cms/arrow_up.png" alt="" /></a>
                        </p>
                        <p class="description">Views: <b>14</b></p>
                        <p class="description"><a href="javascript://" onclick="vbg_detalis(9);">View server settings</a></p>
                        <hr />
                        Now playing: <b>0</b>
                    </div>
                  </li>
                  <input type="hidden" name="vbg_sort_players" id="vbg_sort_players" value="name">
                  <input type="hidden" name="vbg_order_players" id="vbg_order_players" value="desc">
                </ul>
              </div>
            </div>
          </div>
          <!-- End game block -->
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01240 seconds
  • Memory Usage 1,800KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete