Advertisement
RyanDolan123

Untitled

Jan 14th, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.51 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4.     <title>Roblox</title>
  5.  
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
  7.  
  8.     <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"
  9.        type="text/javascript"></script>
  10.  
  11. </head>
  12. <body id="BODY1" style="padding: 0; margin: 0">
  13.     <!-- Main -->
  14.     <div id="Main" style="position: absolute; top: 0; left: 0; bottom: 0; right: 0; margin-bottom: 40px;
  15.        margin-right: 200px; padding: 0 1px 1px 0">
  16.     </div>
  17.     <!-- TODO: nuke the Panel div when we don't need it for debugging -->
  18.     <div id="Panel" style="position: absolute; top: 0; right: 0; bottom: 0; width: 200px;
  19.        margin-bottom: 40px; overflow: auto; border-left-style: solid; border-width: 1px">
  20.         <div id="outputPanel" style="width: 100%">
  21.         </div>
  22.  
  23.         <script type="text/javascript">
  24.             var traces = new Array();
  25.             var traceIndex = 19;
  26.             function trace(message) {
  27.                 var div = $('<div></div>')
  28.                 div.text(message);
  29.                 div.appendTo(outputPanel);
  30.  
  31.                 if (traces.length < 20)
  32.                    traces.push(div);
  33.                else {
  34.                    traceIndex = traceIndex + 1;
  35.                    if (traceIndex == 20)
  36.                        traceIndex = 0;
  37.                    traces[traceIndex].remove();
  38.                    traces[traceIndex] = div;
  39.                }
  40.            }
  41.        </script>
  42.  
  43.     </div>
  44.     <!-- Taskbar -->
  45.     <div id="Taskbar" style="background-color: Window; padding: 5px; height: 30px; position: absolute;
  46.        left: 0; right: 0; bottom: 0; position: absolute; bottom: 0; left: 0; border-width: 1px;
  47.        border-top-style: solid">
  48.         <div id="CommonButtons" style="float: right; margin: 5px">
  49.             <button onclick="window.external.IsFullscreen = !window.external.IsFullscreen; return false">
  50.                 Fullscreen</button>
  51.             <button onclick="focusContent(); window.external.Quit(); return false">
  52.                 Quit</button>
  53.         </div>
  54.         <div id="block" style="float: right; background-color: #abc; width: 20px; height: 20px;
  55.            margin: 5px">
  56.         </div>
  57.  
  58.         <script type="text/javascript">
  59.             function animateGrow() {
  60.                 $(block).animate({ width: "+=20px" }, { duration: "slow", complete: animateShrink });
  61.             }
  62.             function animateShrink() {
  63.                 $(block).animate({ width: "-=20px" }, { duration: "slow", complete: animateGrow });
  64.             }
  65.             $(animateGrow);
  66.         </script>
  67.  
  68.         <div id="GameButtons" style="display: inline">
  69.             <button onclick="roblox3D.DoVerb('ReportAbuse'); return false" style="display: inline">
  70.                 Report Abuse</button>
  71.             <button onclick="showWeb(); return false">
  72.                 Leave Game</button>
  73.             <div id="FPS" style="display: inline">
  74.             </div>
  75.         </div>
  76.         <div id="WebButtons" style="display: none">
  77.             <button id="playButton" onclick="play(); return false" style="display: inline">
  78.                 Play</button>
  79.             <button id="Button2" onclick="createView(100); return false" style="display: inline">
  80.                 CreateView 100</button>
  81.         </div>
  82.     </div>
  83.     <!-- Scripts -->
  84.  
  85.     <script type="text/javascript">
  86.         var content;
  87.  
  88.         function focusContent() {
  89.             // TODO: This code is ugly
  90.             if (document.getElementById('roblox3D'))
  91.                 document.getElementById('roblox3D').focus();
  92.             else if (document.getElementById('robloxFrame'))
  93.                 document.getElementById('robloxFrame').focus();
  94.         }
  95.  
  96.         var windowed = true;
  97.         function create3D(callback) {
  98.             if (content)
  99.                 $(content).remove();
  100.             $(WebButtons).hide('slow', function() {
  101.                 Main.innerHTML = '<object id="roblox3D" classid="CLSID:D7EB14E2-66D2-4A6E-A50A-666CBE7A7621" width="100%" height="100%"><param name="windowed" value="' + (windowed ? 'true' : 'false') + '"></object>';
  102.                 windowed = !windowed;
  103.                 content = $(roblox3D);
  104.  
  105.                 roblox3D.WhenReady({
  106.                     success: function(result) {
  107.                         focusContent();
  108.                         callback();
  109.                         $(GameButtons).show();
  110.                     },
  111.                     error: showWeb
  112.                 });
  113.             });
  114.         }
  115.  
  116.         function createView(count) {
  117.             if (count == 0)
  118.                 return;
  119.             create3D(function() {
  120.                 window.setTimeout(function() {
  121.                     trace("CreateView " + count);
  122.                     showWeb(function() {
  123.                         window.setTimeout(function() {
  124.                             createView(count - 1);
  125.                         }, 1000);
  126.                     });
  127.                 }, 1000);
  128.             });
  129.         }
  130.  
  131.         function getRobloxBrowserUrl() {
  132.             var iframe = document.getElementById("robloxFrame");
  133.             return iframe.contentWindow.location.href;
  134.         }
  135.  
  136.         // Displays the web browser in an ifram
  137.         function showWeb(callback) {
  138.             if (document.getElementById('roblox3D'))
  139.                 roblox3D.ShutDown();
  140.             if (content)
  141.                 $(content).remove();
  142.             $(GameButtons).hide('slow', function() {
  143.                 content = $('<iframe id="robloxFrame" width="100%" frameborder="0" />');
  144.  
  145.                 var loaded = false;
  146.                 // Define a callback to handle iframe loads and to update the Play button
  147.                 $(content).load(function() {
  148.                     if (loaded)
  149.                         return;
  150.                     loaded = true;
  151.  
  152.                     $(WebButtons).show('slow');
  153.  
  154.                     if (callback)
  155.                         callback();
  156.                 });
  157.  
  158.                 // TODO: Replace "http://www.roblox.com/" with proper domain
  159.                 $(content).attr('src', "http://www.roblox.com/Games.aspx");
  160.                 $(content).appendTo(Main);
  161.  
  162.                 // Handle resize events:
  163.                 $(content).height($(Main).height());
  164.                 // TODO: This only works if the window resizes. If other elements in the layout changes
  165.                 //       then it won't get notified
  166.                 $(window).resize(function() {
  167.                     $(content).height($(Main).height());
  168.                 });
  169.             });
  170.         }
  171.  
  172.         function errorAlert(message, stack) {
  173.             var s = message + '\n' + stack;
  174.             alert(s);
  175.         }
  176.  
  177.         function bindFPS() {
  178.             roblox3D.Lua("f = ... while true do local render = stats():FindFirstChild('Render') if render then f(render['3D CPU Total']:GetValueString()) end wait(1) end", {
  179.                 args: [function(value) {
  180.                     if (value != '?' && roblox3D.IsWindowless)
  181.                        value = value + " windowless";
  182.                     FPS.innerText = value;
  183.                 } ],
  184.                 error: errorAlert
  185.             });
  186.         }
  187.  
  188.         // Loads a the 3D view and then loads a game based on what was displayed in the iframe
  189.         function play() {
  190.             // TODO: getRobloxBrowserUrl().match() to find the place ID
  191.             // TODO: Replace "http://www.roblox.com/" with proper domain
  192.             var gameUrl = 'http://www.roblox.com/Asset/?id=1437';
  193.  
  194.             create3D(function() {
  195.                 bindFPS();
  196.                 return;
  197.                 // TODO: Replace "http://www.roblox.com/" with proper domain
  198.                 // TODO: Replace visit script with multiplayer join (should be done with jquery or json or something)
  199.                 roblox3D.Lua("gameUrl = ... game:Load(gameUrl)", {
  200.                     args: [gameUrl],
  201.                     success: function() {
  202.                         roblox3D.Lua("http://www.roblox.com/game/visit.ashx");
  203.                     },
  204.                     error: function(message, stack) { alert(stack); }
  205.                 });
  206.             });
  207.         }
  208.  
  209.         // TODO: Nuke this when the Panel div goes away
  210.         window.external.onStandardOut = function(type, message) { trace(message); };
  211.  
  212.         // Startup:
  213.         $(play);    
  214.     </script>
  215.  
  216. </body>
  217. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement