Exemplo n.º 1
0
function loadScripts()
{
    $skin = getSkinName();
    //Generate a list of all the current skins.
    $skins = array();
    if (($dir = opendir("assets/skins/")) !== false) {
        while (($file = readdir($dir)) !== false) {
            //Ignore directories and index.html
            if ($file == "." || $file == ".." || $file == "index.html") {
                continue;
            }
            //Gets "white" from "path/to/white.css"
            $skins[] = pathinfo($file, PATHINFO_FILENAME);
        }
        closedir($dir);
    }
    if (!empty($_SERVER["HTTPS"])) {
        //Since you're using SSL, we need the SSL server's address
        echo "\n<script type=\"text/javascript\">\n\twebchat.servers[0].port = 9192;\n\twebchat.servers[0].address = \"wss://marbleblast.com\";\n</script>";
    }
    if (array_key_exists("port", $_GET)) {
        $port = (int) $_GET["port"];
        echo "\n<script type=\"text/javascript\">\n\twebchat.servers[0].port = {$port};\n\tif (webchat.servers.length > 1)\n\t\twebchat.servers.pop(1);\n</script>";
    }
    if (array_key_exists("address", $_GET)) {
        $address = addslashes($_GET["address"]);
        echo "\n<script type=\"text/javascript\">\n\twebchat.servers[0].address = '{$address}';\n\tif (webchat.servers.length > 1)\n\t\twebchat.servers.pop(1);\n</script>";
    }
    //JSONP, should either load our user info or redirect us.
    if (array_key_exists("username", $_COOKIE) && array_key_exists("key", $_COOKIE)) {
        //If we're here, then we're on marbleblast.com/webchat/ and we _do_ have their info. Spit it out for them.
        echo "<script type=\"text/javascript\">" . getLoginJSONP("JS") . "</script>";
    } else {
        //If we're here, we're on webchat.marbleblast.com and we don't have their username. Send a JSONP request to
        // the main marbleblast.com domain (with cookies, which cannot be sent with XHR) which will return a script
        // for filling in their information (see above, user.php).
        echo "<script type=\"text/javascript\" src=\"//marbleblast.com/webchat/?getkey=JS\"></script>";
    }
    //The black skin has inverted colors by default
    if ($skin === "black") {
        echo "<script type=\"text/javascript\">webchat.setInvertColors(true);</script>";
    } else {
        echo "<script type=\"text/javascript\">webchat.setInvertColors(false);</script>";
    }
    //Dynamically generated skin list
    echo "<script type=\"text/javascript\">webchat.skins = " . json_encode($skins) . "; webchat.skin = \"{$skin}\";</script>";
}
Exemplo n.º 2
0
	<!-- UTF-8 so we can use strange chars -->
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">

	<!-- JQuery ... Inb4 Javascript snobs -->
	<script src="//code.jquery.com/jquery-2.2.0.min.js"></script>

	<!-- Super cool icons by Font Awesome -->
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

	<!-- Support older browsers with crappy web sockets -->
	<script src="assets/jquery.gracefulWebSocket.js"></script>

	<!-- Styles in the head, so they load first -->
	<link rel="stylesheet" type="text/css" href="assets/webchat.css">
	<link id="styleskin" rel="stylesheet" type="text/css" href="assets/skins/<?php 
echo getSkinName();
?>
.css">

	<!-- Mobile phones like to zoom. We don't like that. -->
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<!-- Google analytics because I love stats -->
	<script>
		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
		})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

		ga('create', 'UA-48516589-1', 'auto', {
			'allowLinker' : true