Advertisement
Guest User

fyrevm-web-manager

a guest
May 21st, 2016
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.57 KB | None | 0 0
  1. <html>
  2. <!--
  3. // Written in 2016 by Thilo Planz
  4. // To the extent possible under law, I have dedicated all copyright and related and neighboring rights
  5. // to this software to the public domain worldwide. This software is distributed without any warranty.
  6. // http://creativecommons.org/publicdomain/zero/1.0/   
  7. -->
  8. <head>
  9.     <script src="stop-the-ifpress.js" ></script>
  10.     <style>
  11.         .header { display: inline-block; width: 30%; }
  12.         body { padding-top: 40px; padding-left: 200px; padding-right: 200px;}
  13.         #status {
  14.             background-color: black;
  15.             color: yellow;
  16.             width: 500px;
  17.             height: 20pt;
  18.             font-size: 16pt;
  19.             text-align: center;
  20.             position: fixed;
  21.             top: 0;
  22.             }
  23.         #MAIN { height: 75%; overflow: scroll; margin: 20px 0; white-space: pre-wrap}
  24.     </style>
  25. </head>
  26.    
  27. <body>
  28.     <div id='status'>Loading ...</div>
  29.     <h1 id='LOCN'></h1>
  30.     <div>
  31.         <b id='SCOR' class='header'></b>
  32.         <b id='TURN' class='header'></b>
  33.         <b id='TIME' class='header'></b>   
  34.     </div>
  35.     <div id='MAIN'></div>
  36.     <div id='PRPT'></div>  
  37. </body>
  38.  
  39. <script>
  40.    
  41. function OutputReady() {
  42.  
  43.     var channelData = manager.ChannelData;
  44.  
  45.     if (channelData) {
  46.         if (channelData.MAIN){
  47.             setText('MAIN',channelData.MAIN);
  48.         }
  49.         if (channelData.LOCN){
  50.             setText('LOCN', channelData.LOCN);
  51.         }
  52.         if (channelData.SCOR || +c.SCOR === 0){
  53.             setText('SCOR', "Score: "+channelData.SCOR);
  54.         }
  55.         if (channelData.TURN){
  56.             setText('TURN', "Turn: "+channelData.TURN);
  57.         }
  58.         if (channelData.TIME){
  59.             setText('TIME', Math.floor(+channelData.TIME / 100) +":"+ (+channelData.TIME % 100));
  60.         }
  61.         if (channelData.PRPT){
  62.             promptLine = channelData.PRPT;
  63.         }  
  64.     }
  65.     // waiting for key or line input ?
  66.     var wait = manager.WaitingFor
  67.     if (wait === 0 || wait === 1){
  68.         getInput()
  69.     }
  70. }
  71.  
  72. var promptLine = "";
  73.  
  74. function getInput(){
  75.     var div = document.getElementById('PRPT');
  76.     div.innerHTML = '<form onsubmit="sendCommand(); return false;">'+promptLine+' <input size="80"/><form>';
  77.     var input = div.getElementsByTagName('INPUT')[0];
  78.     input.focus();
  79.     input.scrollIntoView();
  80. }
  81.    
  82. function sendCommand(){
  83.     var div = document.getElementById('PRPT');
  84.     var input = div.getElementsByTagName('INPUT')[0];
  85.     var command = input.value;
  86.     div.innerHTML = '';
  87.     setText('status', 'processing ...');
  88.     setText('MAIN', '\n\n\n... '+command);
  89.     manager.SendCommand(command)
  90.  }
  91.  
  92.    
  93. function setText(id, text){
  94.     document.getElementById(id).textContent = text
  95. }
  96.  
  97.  
  98. var manager = new FyreVMWeb.Manager();
  99. manager.OutputReady = OutputReady;
  100. manager.LoadStory("stop-the-ifpress.ulx")
  101. </script>  
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement