Exemplo n.º 1
0
    private static function footerScripts()
    {
        global $User, $Locale;
        $jsVersion = 4;
        // increment this to force clients to reload their JS files
        $buf = '';
        // onlineUsers, for the online icons
        $statsDir = libCache::dirName('stats');
        $onlineFile = l_s($statsDir . '/onlineUsers.json');
        if (file_exists($onlineFile)) {
            $buf .= '<script type="text/javascript" src="' . STATICSRV . $onlineFile . '"></script>';
        } else {
            $buf .= '<script type="text/javascript">onlineUsers = $A([ ]);</script>';
        }
        if (!is_object($User)) {
            return $buf;
        } elseif ($User->type['User']) {
            // Muted users
            $gameMutePairs = array();
            foreach ($User->getMuteCountries() as $gameMutePair) {
                $gameMutePairs[] = '[' . $gameMutePair[0] . ',' . $gameMutePair[1] . ']';
            }
            $buf .= '
			<script type="text/javascript">
			muteUsers = $A([' . implode(',', $User->getMuteUsers()) . ']);
			muteCountries = $A([' . implode(',', $gameMutePairs) . ']);
			muteThreads = $A([' . implode(',', $User->getMuteThreads()) . ']);
			</script>';
            unset($gameMutePairs);
            self::$footerIncludes[] = l_j('mute.js');
            self::$footerScript[] = l_jf('muteAll') . '();';
            // Participated threads
            $cacheUserParticipatedThreadIDsFilename = libCache::dirID('users', $User->id) . '/readThreads.js';
            if (file_exists($cacheUserParticipatedThreadIDsFilename)) {
                $buf .= '<script type="text/javascript" src="' . STATICSRV . $cacheUserParticipatedThreadIDsFilename . '?nocache=' . rand(0, 999999) . '"></script>';
                libHTML::$footerScript[] = l_jf('setForumParticipatedIcons') . '();';
            }
        }
        if (is_object($Locale)) {
            $Locale->onFinish();
        }
        // Add the javascript includes:
        $footerIncludes = array();
        $footerIncludes[] = l_j('../locales/layer.js');
        $footerIncludes[] = l_j('../locales/English/layer.js');
        $footerIncludes[] = l_j('contrib/sprintf.js');
        $footerIncludes[] = l_j('utility.js');
        $footerIncludes[] = l_j('cacheUpdate.js');
        $footerIncludes[] = l_j('timeHandler.js');
        $footerIncludes[] = l_j('forum.js');
        $footerIncludes[] = l_j('Color.Vision.Daltonize.js');
        // Don't localize all the footer includes here, as some of them may be dynamically generated
        foreach (array_merge($footerIncludes, self::$footerIncludes) as $includeJS) {
            // Add on the dynamically added includes
            $buf .= '<script type="text/javascript" src="' . STATICSRV . JSDIR . '/' . $includeJS . '?ver=' . $jsVersion . '"></script>';
        }
        // Utility (error detection, message protection), HTML post-processing,
        // time handling functions. Only logged-in users need to run these
        $buf .= '
		<script type="text/javascript">
			var UserClass = function () {
				this.id=' . $User->id . ';
				this.username="******";
				this.points=' . $User->points . '
				this.lastMessageIDViewed=' . $User->lastMessageIDViewed . ';
				this.timeLastSessionEnded=' . $User->timeLastSessionEnded . ';
				this.token="' . md5(Config::$secret . $User->id . 'Array') . '";
			}
			User = new UserClass();
			
			WEBDIP_DEBUG=' . (Config::$debug ? 'true' : 'false') . ';

			document.observe("dom:loaded", function() {
			
				try {
					' . l_jf('Locale.onLoad') . '();
					
					' . l_jf('onlineUsers.push') . '(User.id);
	
					' . l_jf('setUserOnlineIcons') . '();
					' . l_jf('setForumMessageIcons') . '();
					' . l_jf('setPostsItalicized') . '();
					' . l_jf('updateTimestamps') . '();
					' . l_jf('updateUTCOffset') . '();
					' . l_jf('updateTimers') . '();
	
					' . implode("\n", self::$footerScript) . '
					
					' . l_jf('Locale.afterLoad') . '();
				}
				catch( e ) {
				' . (Config::$debug ? 'alert(e);' : '') . '
				}
			}, this);
		</script>
		';
        if (Config::$debug) {
            $buf .= '<br /><strong>JavaScript localization lookup failures:</strong><br /><span id="jsLocalizationDebug"></span>';
        }
        return $buf;
    }
Exemplo n.º 2
0
 /**
  * The location of the territories JSON file which gives the order-generation JavaScript the board layout it needs.
  * Some variants need to extend this function to point to another variant which defines their shared map.
  *
  * @return string
  */
 public function territoriesJSONFile()
 {
     return l_j(libVariant::cacheDir($this->name) . '/territories.js');
 }
Exemplo n.º 3
0
 protected function jsInitForm()
 {
     libHTML::$footerIncludes[] = l_j('orders/form.js');
     libHTML::$footerScript[] = l_jf('OrdersHTML.formInit') . '(context, contextKey);';
 }
Exemplo n.º 4
0
 protected function mapJS($mapTurn)
 {
     libHTML::$footerScript[] = 'turnToText=' . $this->Variant->turnAsDateJS() . "\r\n\t\tmapArrows({$mapTurn},{$mapTurn});\r\n\t\t";
     libHTML::$footerIncludes[] = l_j('mapUI.js');
 }
Exemplo n.º 5
0
        print file_get_contents(libCache::dirName('forum') . '/home-forum.html');
    } else {
        $buf_home_forum = libHome::forumNew();
        file_put_contents(libCache::dirName('forum') . '/home-forum.html', $buf_home_forum);
        print $buf_home_forum;
    }
    print '</td>';
    print '<td class="homeSplit"></td>';
    print '<td class="homeGameNotices">';
    /*$buf = libHome::PMs();
    	if(strlen($buf))
    		print '<div class="homeHeader">Private messages</div>'.$buf;
    	*/
    print '<div class="homeHeader">' . l_t('Notices') . ' <a href="index.php?notices=on">' . libHTML::link() . '</a></div>';
    print libHome::Notice();
    print '</td>';
    print '<td class="homeSplit"></td>';
    print '<td class="homeGamesStats">';
    print '<div class="homeHeader">' . l_t('My games') . ' <a href="gamelistings.php?page=1&gamelistType=My games">' . libHTML::link() . '</a></div>';
    print libHome::gameNotifyBlock();
    print '<div class="homeHeader">' . l_t('Spectated games') . '</div>';
    print libHome::gameWatchBlock();
    print '</td>
	</tr></table>';
    print '</div>';
    print '</div>';
}
libHTML::$footerIncludes[] = l_j('home.js');
libHTML::$footerScript[] = l_jf('homeGameHighlighter') . '();';
$_SESSION['lastSeenHome'] = time();
libHTML::footer();