Advertisement
Guest User

Untitled

a guest
Sep 10th, 2011
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var arrCommandHistory = new Array();
  2. var iCommandHistoryIndex = 0;
  3. var isContactMode = false;
  4. var contactPrompt = '';
  5.  
  6. function handleKeyPress(keyCode, obj) {
  7.     switch (keyCode) {
  8.     case 13:
  9.         handleReturn(obj);
  10.         break;
  11.     case 38:
  12.         if (iCommandHistoryIndex > 0) {
  13.             iCommandHistoryIndex--;
  14.             document.getElementById('commandContainer').innerHTML = arrCommandHistory[iCommandHistoryIndex];
  15.             document.getElementById('entryBox').value = arrCommandHistory[iCommandHistoryIndex];
  16.         }
  17.         break;
  18.     case 40:
  19.         if (iCommandHistoryIndex < arrCommandHistory.length) {
  20.             if (iCommandHistoryIndex < arrCommandHistory.length - 1) {
  21.                 iCommandHistoryIndex++;
  22.             }
  23.             document.getElementById('commandContainer').innerHTML = arrCommandHistory[iCommandHistoryIndex];
  24.             document.getElementById('entryBox').value = arrCommandHistory[iCommandHistoryIndex];
  25.         }
  26.         break;
  27.     default:
  28.         document.getElementById('commandContainer').innerHTML = obj.value.replace(/ /g, '&nbsp;');
  29.     }
  30. }
  31. function handleReturn(obj) {
  32.     arrCommandHistory[arrCommandHistory.length] = obj.value;
  33.     iCommandHistoryIndex = arrCommandHistory.length;
  34.     var head = document.getElementsByTagName('head').item(0);
  35.     var old = document.getElementById('lastScript');
  36.     if (old) head.removeChild(old);
  37.     script = document.createElement('script');
  38.     script.src = 'RPC-Executer.aspx?command=' + obj.value + '&random=' + (Math.round((Math.random() * 1000) + 1));
  39.     script.type = 'text/javascript';
  40.     script.defer = true;
  41.     script.id = 'lastScript';
  42.     void(head.appendChild(script));
  43. }
  44. function RPCCallback(sHTML) {
  45.     sHTML = sHTML.replace(/&lt;/g, '<');
  46.     var obj = document.getElementById('entryBox');
  47.     var sOutput = '';
  48.     if (!isContactMode) {
  49.         sOutput += '<div style="padding-bottom:15px;">C:\\> ' + obj.value + '<br />';
  50.         setPromptToNormal();
  51.     } else {
  52.         sOutput += '<div style="padding-bottom:15px;">' + document.getElementById('commandPrompt').innerHTML + '&nbsp;' + obj.value + '<br />';
  53.         document.getElementById('commandPrompt').innerHTML = contactPrompt + ': ';
  54.     }
  55.     sOutput += sHTML;
  56.     sOutput += '</div>';
  57.     document.getElementById('outputContainer').innerHTML += sOutput;
  58.     obj.value = '';
  59.     document.getElementById('commandContainer').innerHTML = '';
  60.     window.scrollBy(0, 10000);
  61. }
  62. function RPCCallbackClearScreen() {
  63.     document.getElementById('entryBox').value = '';
  64.     document.getElementById('outputContainer').innerHTML = '<br>';
  65.     document.getElementById('commandContainer').innerHTML = '';
  66.     window.scrollBy(0, -10000);
  67. }
  68. function setPromptToNormal() {
  69.     document.getElementById('commandPrompt').innerHTML = 'C:\\>';
  70. }
  71. function popUp(sURL) {
  72.     var oWin = window.open(sURL, '', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1');
  73.     if (oWin == null || typeof (oWin) == "undefined") {
  74.         alert("It seems that you have a popup blocker enabled.  Please disable it and try again.");
  75.     }
  76. }
  77. function setFocusToEntryBox() {
  78.     var o = document.getElementById('entryBox');
  79.     o.focus();
  80.     o.value = o.value;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement