for(var t=0,u=K.HDR_SIZE;u",DEFAULT_PROCESSING_TEXT="Processing ... ",DEFAULT_PROCESSING_TIMER=5,MIN_RETRY_INTERVAL=15;var rn=function(l,n){this.ws_proto=null,this.oem_app=null,this.keep_alive_timer=null,this.powerStatusTimer=null,this.oem_app=new Mn,delete this.nwBuffer,this.nwBuffer=null,this.nwBuffer=new DataStream,this.server=l,this.pos=0,this.video=n,delete this.newBuffer,this.newBuffer=null,this.firstPacket=!0,this.isVideoPaused=!1,this.isHostDisplayOn=!0,this.Host_OS_shutdown=!1,this.fps_timer=null,this.ws_proto=-1!=l.indexOf("https://")?"wss://":"ws://",this.bmc_ip=l,-1!=l.indexOf("://")&&(this.bmc_ip=l.substr(l.indexOf("://")+3,l.length)),this.createWebSocket(),this.video.blank_count=0,window.master=!1,this.video.stopped=!1,window.mousemode=-1,this.video.blank_count=0,this.other_session_name="",this.other_session_ip="",this.video.host_led_status=0,this.video.kbdLEDBtns=new Array("#host_lock_btn","#l_win_hold_btn","#r_win_hold_btn","#num_lock","#caps_lock","#scr_lock","#l_alt_btn","#r_alt_btn","#l_ctrl_btn","#r_ctrl_btn"),this.retry_count=1,this.is_reconnecting=!1,this.is_waiting_permission=!1};rn.prototype={createHeader:function(l,n,e,t){var u=new DataStream(8+n,0,DataStream.LITTLE_ENDIAN);return u.writeUint16(l,DataStream.LITTLE_ENDIAN),u.writeUint32(n,DataStream.LITTLE_ENDIAN),u.writeUint16(e,DataStream.LITTLE_ENDIAN),t instanceof Uint8Array?u.writeUint8Array(t):t&&u.writeString(t),"binary"==this.wsmode?u:{buffer:base64ArrayBuffer(u.buffer)}},send:function(l){0==this.is_reconnecting&&this.ws.send(l)},sendIPMIData:function(l){var n=null,e=null;try{null!=l&&(n=new Uint8Array(l),e=window._video.sock.createHeader(K.CMD_IPMI_REQ_COMMAND,n.length,0,n),window._video.sock.send(e.buffer))}catch(t){console.log("Error while sending ipmi data "+t)}finally{null!=e&&(delete e,e=null),null!=n&&(delete n,n=null)}},enablePowerControls:function(l){1==l&&(0==this.video.power_status&&this.updateKbdLEDStatus(0),this.updateKbdLEDBtns(),this.updatePowerCtrlBtn())},onGetPowerControlStatus:function(l){if(1==l)clearInterval(this.powerStatusTimer),this.powerStatusTimer=null;else if(0==l&&(this.video.blank_count++,this.video.paintBlankScreen(),null==this.powerStatusTimer)){var n=this;this.powerStatusTimer=setInterval(function(){var l=n.createHeader(K.CMD_POWER_STATUS,0,0);n.send(l.buffer),delete l},3e4)}this.enablePowerControls(!0)},onPowerControlResponse:function(l){this.enablePowerControls(!0)},updateActiveUserMenu:function(){var l=$("#active-user");for(l.html(""),i=0;i"+String.fromCharCode.apply(null,n)+" ("+IPMI_PRIV[u][1]+") "+String.fromCharCode.apply(null,e)+"":"
  • "+String.fromCharCode.apply(null,n)+" ("+IPMI_PRIV[u][1]+") "+String.fromCharCode.apply(null,e)+''),window.mousemode=MEDIA_CONFIGS.mouse_mode=n),$("#kvm").css(3==window.mousemode?{cursor:"none"}:{cursor:"auto"})},showMenu:function(l,n){for(var e=0;e0&&(n=SERVER_CONF[1].currentState),1==l&&MEDIA_CONFIGS.num_cd>0&&MEDIA_CONFIGS.kvm_cd>0&&1==n&&1==window.mediaLicenseStatus&&1==window.master?($("#media").removeAttr("disabled"),$("#media_redirection").show()):this.disableMediaOption()}},checkMediaLicenseStatus:function(l){1==l?(window.mediaLicenseStatus=!0,this.enableMediaOption()):(window.mediaLicenseStatus=!1,this.disableMediaOption())},OnEncryptionStatus:function(){1!=window.encryption&&(window.encryption=!0,1==window.DISABLE_ENCRYPT_FLAG?(sessionStorage.setItem("status","disable_encryption_error_message"),$("#status_dialog").trigger("showStatus"),0==$("#kbd_mouse_encryption").children("i").length&&$("#kbd_mouse_encryption").append(''),window.DISABLE_ENCRYPT_FLAG=!1):(sessionStorage.setItem("status","encryption_enable"),$("#status_dialog").trigger("showStatus")))},OnInitialEncryptionStatus:function(){window.encryption=!0,sessionStorage.setItem("status","encryption_enable"),$("#status_dialog").trigger("showStatus"),0==$("#kbd_mouse_encryption").children("i").length&&$("#kbd_mouse_encryption").append('')},updateMediaMenuState:function(){SERVER_CONF.length<=0||((0==MEDIA_CONFIGS.num_cd||0==MEDIA_CONFIGS.kvm_cd||0==SERVER_CONF[1].currentState)&&this.disableMediaOption(),MEDIA_CONFIGS.num_cd>0&&1==SERVER_CONF[1].currentState&&this.enableMediaOption())},compareConfData:function(l,n){l.currentState!=SERVER_CONF[n].currentState&&(SERVER_CONF[n].currentState=l.currentState),l.interfaceName!=SERVER_CONF[n].interfaceName&&(l.interfaceName=SERVER_CONF[n].interfaceName),l.nonSecureAccessPort!=SERVER_CONF[n].nonSecureAccessPort&&(SERVER_CONF[n].nonSecureAccessPort=l.nonSecureAccessPort),l.secureAccessPort!=SERVER_CONF[n].secureAccessPort&&(SERVER_CONF[n].secureAccessPort=l.secureAccessPort),l.sessionInactivityTimeout!=SERVER_CONF[n].sessionInactivityTimeout&&(SERVER_CONF[n].sessionInactivityTimeout=l.sessionInactivityTimeout),l.maxAllowedSessions!=SERVER_CONF[n].maxAllowedSessions&&(SERVER_CONF[n].maxAllowedSessions=l.maxAllowedSessions),l.currentActiveSession!=SERVER_CONF[n].currentActiveSession&&(SERVER_CONF[n].currentActiveSession=l.currentActiveSession),l.maxSessionInactivityTimeout!=SERVER_CONF[n].maxSessionInactivityTimeout&&(SERVER_CONF[n].maxSessionInactivityTimeout=l.maxSessionInactivityTimeout),l.minSessionInactivityTimeout!=SERVER_CONF[n].minSessionInactivityTimeout&&(SERVER_CONF[n].minSessionInactivityTimeout=l.minSessionInactivityTimeout)},updateMediaConfigChange:function(){console.log("updateMediaConfigChange "),this.updateMediaMenuState()},updateKVMMenuList:function(l,n){if(!window._video.isVideoPaused){for(var e=kvmMenuItems,t=0;t-1&&e.splice(u,1),this.enableMenuOrButton(l[t],n)}for(var i=0;i-1?1==n?$(l).removeAttr("disabled"):$(l).attr("disabled","disabled"):1==n?this.updateMenuItemState(l,!0):this.updateMenuItemState(l,!1)},createMenuItem:function(l,n,e,t,u,i,r){var o=0;if(null!=l&&null!=n&&null!=e&&0/0!=parseInt(t))for(var s=0;s0));s++){0==s&&0!=t&&1==i&&this.createSeparator(e,t,r),menuId=l[s].replace("#","");var a=document.getElementById(e),c=document.createElement("li"),d=document.createElement("a"),_=document.createTextNode(n[s]);d.setAttribute("id",menuId),null!=r&&d.setAttribute("class",r),d.appendChild(_),d.href="#",c.appendChild(d),a.insertBefore(c,a.children[t]),document.getElementById(menuId).addEventListener("click",u,!1)}},createSeparator:function(l,n,e){var t=document.createElement("li");t.setAttribute("role","separator"),null!=e?t.setAttribute("class","divider "+e):t.setAttribute("class","divider");var u=document.getElementById(l);u.insertBefore(t,u.children[n])},syncMediaConf:function(){MEDIA_CONFIGS.num_cd=window.mediaconf.num_cd,MEDIA_CONFIGS.num_fd=window.mediaconf.num_fd,MEDIA_CONFIGS.num_hd=window.mediaconf.num_hd,MEDIA_CONFIGS.powerSaveMode=window.mediaconf.power_save_mode,MEDIA_CONFIGS.kvm_cd=window.mediaconf.kvm_num_cd,MEDIA_CONFIGS.kvm_fd=window.mediaconf.kvm_num_fd,MEDIA_CONFIGS.kvm_hd=window.mediaconf.kvm_num_hd},updateHostLockStateMenu:function(l){if(1==window._video.isVideoPaused)return this.updateMenuItemState("#hd_turn_off",!1),this.updateMenuItemState("#hd_turn_on",!1),void this.updateMenuItemState("#host_lock_btn",!1);if((l==HOST_LOCK_STATUS.HOST_DISPLAY_UNLOCK||l==HOST_LOCK_STATUS.HOST_DISPLAY_UNLOCKED_AND_DISABLED)&&($("#hd_turn_off").children("i").length>0&&$("#hd_turn_off").children("i").remove(),0==$("#hd_turn_on").children("i").length&&($("#hd_turn_on").append(''),o("#host_lock_btn",BTN_ON),S("#host_lock_btn",window.CommonStrings.tooltip_hostDisplayOn))),(l==HOST_LOCK_STATUS.HOST_DISPLAY_LOCK||l==HOST_LOCK_STATUS.HOST_DISPLAY_LOCKED_AND_DISABLED)&&($("#hd_turn_on").children("i").length>0&&$("#hd_turn_on").children("i").remove(),0==$("#hd_turn_off").children("i").length&&($("#hd_turn_off").append(''),o("#host_lock_btn",BTN_OFF),S("#host_lock_btn",window.CommonStrings.tooltip_hostDisplayOff))),0==window.master)this.updateMenuItemState("#hd_turn_off",!1),this.updateMenuItemState("#hd_turn_on",!1),this.updateMenuItemState("#host_lock_btn",!1);else switch(this.updateMenuItemState("#host_lock_btn",!0),l){case HOST_LOCK_STATUS.HOST_DISPLAY_UNLOCK:this.updateMenuItemState("#hd_turn_on",!1),this.updateMenuItemState("#hd_turn_off",!0);break;case HOST_LOCK_STATUS.HOST_DISPLAY_LOCK:this.updateMenuItemState("#hd_turn_on",!0),this.updateMenuItemState("#hd_turn_off",!1);break;case HOST_LOCK_STATUS.HOST_DISPLAY_UNLOCKED_AND_DISABLED:case HOST_LOCK_STATUS.HOST_DISPLAY_LOCKED_AND_DISABLED:this.updateMenuItemState("#hd_turn_off",!1),this.updateMenuItemState("#hd_turn_on",!1),this.updateMenuItemState("#host_lock_btn",!1)}},updateMenuItemState:function(l,n){l="#"==l[0]?l.replace("#",""):l,null!=document.getElementById(l)&&(1==n?(document.getElementById(l).disabled=!1,$("#"+l).removeClass("disable_a_href")):(document.getElementById(l).disabled=!0,$("#"+l).addClass("disable_a_href")))},updateWindowOnFocus:function(l,n){if(void 0!==typeof l&&void 0!==typeof n&&null!=l&&null!=n&&0!=l.length&&0!=n.length&&(modalDialogID=l,focusID=n),"block"==$("#"+modalDialogID).css("display"))$("#"+focusID).focus(),$("#menu").find("button").attr("disabled","disabled");else{if($("#kvm_textbox").focus(),"disabled"==$("#menu").find("button").attr("disabled")&&$("#menu").find("button").attr("disabled",!1),1==B){usbkbdmsg.set(18,usbkbd.KEY_LOCATION_LEFT,!1);var e=usbkbdmsg.report();window._video.sock.send(e.buffer),delete e,e=null}modalDialog_ID=null,focus_ID=null}},updateKbdLEDStatus:function(l){this.video.host_led_status!=l&&(0!=(l&KBD_LED.NUM_LOCK)?o("#num_lock",BTN_ON):o("#num_lock",BTN_DISABLED),0!=(l&KBD_LED.CAPS_LOCK)?o("#caps_lock",BTN_ON):o("#caps_lock",BTN_DISABLED),0!=(l&KBD_LED.SCR_LOCK)?o("#scr_lock",BTN_ON):o("#scr_lock",BTN_DISABLED),this.video.host_led_status=l)},showKbdLEDBtns:function(l){for(var n=0;nthis.nwBuffer.buffer.byteLength){delete this.newBuffer,delete e;break}if(this.pos+=K.HDR_SIZE,this.updateLastRecvTime(),e.type!=K.CMD_VIDEO_PACKETS){delete this.newBuffer,this.newBuffer=null,this.prev_complete=!0;var u=this.nwBuffer.buffer.slice(this.pos,this.pos+e.pkt_size);this.pos+=e.pkt_size,this.newBuffer=new DataStream(u),delete u}if(1==this.oem_app.isOEMCommand(e.type));else switch(e.type){case K.CMD_CONNECTION_ALLOWED:-1==$(this.video.soc_menu_list[0]).index()&&(kvmMenuItems=kvmMenuItems.concat(this.video.soc_menu_list)),this.video.updateSocMenu(),this.sendValidateVideoSessionPkt();break;case K.CMD_STOP_SESSION_IMMEDIATE:switch(sessionStorage.setItem("status","stop_session"),e.status){case 2:sessionStorage.setItem("stop_reason","kvm_server_restart");break;case 5:sessionStorage.setItem("stop_reason","kvm_conf_change");break;case 7:sessionStorage.setItem("stop_reason","kvm_web_logout");break;case 8:sessionStorage.setItem("stop_reason","kvm_license_exp");break;case 9:sessionStorage.setItem("stop_reason","kvm_timed_out");break;case 10:sessionStorage.setItem("stop_reason","kvm_terminated");break;case 11:sessionStorage.setItem("stop_reason","kvm_web_restart");break;case 12:sessionStorage.setItem("stop_reason","bmc_warm_reset");break;case 13:sessionStorage.setItem("stop_reason","bmc_restore_defaults");break;default:sessionStorage.setItem("stop_reason","")}$("#status_dialog").trigger("showStatus"),this.video.stopped=!0;break;case K.CMD_SET_FPS:break;case K.CMD_USB_MOUSE_MODE:var r=1*this.newBuffer.readUint8();window.mousemode!=r&&this.UpdateMouseModeMenu(window.mousemode,r);break;case K.CMD_GET_FULL_SCREEN:break;case K.CMD_GET_KBD_LED_STATUS:var o=this.newBuffer.readUint8();this.updateKbdLEDStatus(o);break;case K.CMD_MAX_SESSION_CLOSE:switch(sessionStorage.setItem("status","stop_session"),e.status){case 0:sessionStorage.setItem("stop_reason","kvm_max_session_reached");break;case 1:sessionStorage.setItem("stop_reason","same_kvm_client_user");break;default:sessionStorage.setItem("stop_reason","")}$("#status_dialog").trigger("showStatus"),this.video.stopped=!0;break;case K.CMD_VALIDATED_VIDEO_SESSION:var s=this.newBuffer.readUint8();if((0==s||2==s||3==s)&&(sessionStorage.setItem("status","invalid_session"),0==s?sessionStorage.setItem("invalid_sess_reason","kvm_inv_sess"):2==s?sessionStorage.setItem("invalid_sess_reason","kvm_disabled"):3==s&&sessionStorage.setItem("invalid_sess_reason","kvm_inv_sess_info"),$("#status_dialog").trigger("showStatus"),this.validated=0,this.video.stopped=!0),this.validated=1,e.pkt_size>1){var a=this.newBuffer.readUint8();this.current_session_id=a,console.log("session index: "+this.current_session_id)}if(1==this.video.lm_option&&$("#hd_turn_on").click(),null==this.keep_alive_timer){var c=this;this.keep_alive_timer=setInterval(function(){if(0==c.is_reconnecting){var l=c.createHeader(K.CMD_KEEP_ALIVE_PKT,0,0);c.send(l.buffer),delete l}},3e3)}break;case K.CMD_KVM_SHARING:case K.CMD_SET_NEXT_MASTER:var d=255&e.status,_=e.status>>8;if(e.type==K.CMD_KVM_SHARING);else{var h=this.createHeader(K.CMD_POWER_STATUS,0,0);this.send(h.buffer)}var s=this.newBuffer.readString();if(s.length>0&&(sessionStorage.setItem("other_session_info",window.btoa(s)),this.other_session_name=s.substring(0,64),this.other_session_ip=s.substring(64,129)),d==un.STATUS_KVM_PRIV_REQ_MASTER)if(1==un.KVM_BLOCK_USER_REQUEST){console.log("KVM master permission request blocked");var p=window.atob(sessionStorage.getItem("other_session_info"));if("undefined"!=typeof p){var m=this.createHeader(K.CMD_KVM_SHARING,p.length,un.STATUS_KVM_PRIV_REQ_MASTER+(un.KVM_REQ_BLOCKED<<8),p);this.send(m.buffer)}}else e.type==K.CMD_KVM_SHARING?(this.dialogType="KVM_SHARING",$("#master_dialog").trigger("requestKvmPermission")):(this.dialogType="FULL_PERMISSION_REQUEST",$("#master_dialog").trigger("requestMasterPermission"));else if(d==un.STATUS_KVM_PRIV_WAIT_SLAVE)$("#slave_dialog").trigger("waitForPermission"),this.is_waiting_permission=!0;else if(d==un.STATUS_KVM_PRIV_RESPONSE_TO_SLAVE)_==un.KVM_REQ_ALLOWED?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","slave_permission_full"),$("#status_dialog").trigger("showStatus")):_==un.KVM_REQ_PARTIAL?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","slave_permission_part"),$("#status_dialog").trigger("showStatus")):_==un.KVM_REQ_TIMEOUT?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","slave_permission_timeout"),$("#status_dialog").trigger("showStatus")):_==un.KVM_REQ_BLOCKED?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","master_blocked_request"),$("#status_dialog").trigger("showStatus")):_==un.KVM_NOT_MASTER?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","master_changed"),$("#status_dialog").trigger("showStatus")):e.type==K.CMD_KVM_SHARING&&(_==un.KVM_REQ_DENIED?($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","slave_permission_none"),$("#status_dialog").trigger("showStatus")):_==un.KVM_REQ_MASTER_RECONN&&($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","master_reconn"),$("#status_dialog").trigger("showStatus"))),1==this.is_waiting_permission&&(this.is_waiting_permission=!1);else if(d==un.STATUS_KVM_PRIV_SWITCH_MASTER){if(e.type==K.CMD_KVM_SHARING){var g=sessionStorage.getItem("status");"reconnect"!==g?(sessionStorage.setItem("status","switch_master"),$("#status_dialog").trigger("showStatus")):"reconnect"===g&&(_==un.KVM_REQ_ALLOWED?($("#request_full").hide(),0==window.master&&(sessionStorage.setItem("status","slave_permission_full"),$("#status_dialog").trigger("showStatus"))):_==un.KVM_REQ_PARTIAL&&1==this.is_waiting_permission&&(sessionStorage.setItem("status","slave_permission_part"),$("#status_dialog").trigger("showStatus"))),sessionStorage.setItem("status","connected")}else $("#status").html(""),$("#request_full").hide(),0==window.master&&(sessionStorage.setItem("status","slave_permission_full"),$("#status_dialog").trigger("showStatus")),1==window.reconnect_enabled&&MEDIA_REDIR.status==MEDIA_REDIR.CONNECTED&&(console.log("RECONNECT MEDIA!!!"),$("#media").click());1==this.is_waiting_permission&&(this.is_waiting_permission=!1)}else d==un.STATUS_KVM_PRIV_REQ_TIMEOUT_TO_MASTER?_==un.KVM_REQ_TIMEOUT&&(sessionStorage.setItem("status","master_timeout"),$("#status_dialog").trigger("showStatus")):d==un.STATUS_KVM_PRIV_REQ_CANCEL&&($("#slave_dialog").trigger("resetDialog"),sessionStorage.setItem("status","slave_quit"),$("#status_dialog").trigger("showStatus"));this.updateActiveUserMenu();break;case K.CMD_PAINT_BLANK_SCREEN:this.video.blank_count++,this.video.paintBlankScreen();break;case K.CMD_VIDEO_PACKETS:if(this.video.cmdOnVideoPackets(e),null==this.fps_timer){var c=this;this.fps_timer=setInterval(function(){if("undefined"!=typeof window.frames_received&&"undefined"!=typeof window.frames_processed){var l=window.frames_received-window.frames_processed;0>l&&(l=-l);var n=c.createHeader(K.CMD_FPS_DIFF,0,l);c.send(n.buffer),window.frames_received=window.frames_processed=0,delete n,n=null}},500)}break;case K.CMD_GET_USER_MACRO:var v=this.newBuffer.readUint8Array();f(v);break;case K.CMD_ACTIVE_CLIENTS:var w=this.newBuffer.readUint8Array();this.client_info=[],this.num_clients=Math.round(w.byteLength/134);var b=0;for(i=0;iz;z++)L=w.subarray(b,b+N),R=1*w[b+N],x=w[b+35],P=1*w[b+39],U=1*w[b+43],F=1*w[b+47],B=1*w[b+47],V=1*w[b+48],H=1*w[b+52],j=1*w[b+56],1==O?SERVER_CONF.push({serviceName:L,currentState:R,interfaceName:x,nonSecureAccessPort:P,secureAccessPort:U,sessionInactivityTimeout:F,maxAllowedSessions:B,currentActiveSession:V,maxSessionInactivityTimeout:H,minSessionInactivityTimeout:j}):(this.server_conf.push({serviceName:L,currentState:R,interfaceName:x,nonSecureAccessPort:P,secureAccessPort:U,sessionInactivityTimeout:F,maxAllowedSessions:B,currentActiveSession:V,maxSessionInactivityTimeout:H,minSessionInactivityTimeout:j}),this.compareConfData(this.server_conf[z],z)),b+=61;this.updateMediaConfigChange();break;case K.CMD_KVM_MEDIA_INFO:console.log("CMD_KVM_MEDIA_INFO",e.status);var Y=!1,q=1*this.newBuffer.readUint32(),G=1*this.newBuffer.readUint32(),W=this.newBuffer.readUint8(),Q=(this.newBuffer.readUint8(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32()),X=1*this.newBuffer.readUint32(),J=1*this.newBuffer.readUint32(),Z=(1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32(),1*this.newBuffer.readUint32()),ln=1*this.newBuffer.readUint32(),nn=1*this.newBuffer.readUint32(),en=1*this.newBuffer.readUint32();MEDIA_CONFIGS.powerSaveMode=Z,MEDIA_CONFIGS.reconn_retry_count=q,MEDIA_CONFIGS.reconn_retry_interval=G,(MEDIA_CONFIGS.num_cd!=Q||MEDIA_CONFIGS.num_fd!=X||MEDIA_CONFIGS.num_hd!=J)&&(MEDIA_CONFIGS.num_cd!=Q&&(Y=!0,MEDIA_CONFIGS.num_cd=Q),MEDIA_CONFIGS.num_fd=X,MEDIA_CONFIGS.num_hd=J),MEDIA_CONFIGS.kvm_cd!=ln&&(Y=!0,MEDIA_CONFIGS.kvm_cd=ln),MEDIA_CONFIGS.kvm_fd=nn,MEDIA_CONFIGS.kvm_hd=en,MEDIA_CONFIGS.mouse_mode!=W&&this.UpdateMouseModeMenu(MEDIA_CONFIGS.mouse_mode,W),1==Y&&this.updateMediaMenuState();break;case K.CMD_MEDIA_FREE_INSTANCE_STATUS:break;default:this.video.onSocControlMessage(e,this.newBuffer)}delete this.newBuffer,delete e,this.newBuffer=null,e=null,l.pos==l.nwBuffer.byteLength&&(delete l.nwBuffer,l.nwBuffer=null,l.nwBuffer=new DataStream,l.pos=0)}if(1==this.video.stopped)return void this.close();if(1!=this.video.running)return}1==this.video.running&&setTimeout(function(){l.startRead.call(l)},0)},close:function(){clearInterval(this.keep_alive_timer),this.keep_alive_timer=null;var l=this.createHeader(8,0,0);this.send(l.buffer),this.validated=0,this.video.running=!1,this.video.stopped=!0;var n=this;setTimeout(function(){n.ws.close()},500)},setHelpContent:function(l,n,e){$("#help_title").html(e),$("#help_body").addClass("row"),$("#help_body").html('
    '),$("#copyright").html(n),$("#logo").attr("src",l)},getDefaultHelpText:function(){return window.CommonStrings.kvm_version+APP_VERSION+NEW_LINE_TAG+window.CommonStrings.plugin_version+SOC_VERSION+window.CommonStrings.for+SOC_NAME+NEW_LINE_TAG+window.CommonStrings.copyright},createWebSocket:function(){var l=this;if(-1!=this.bmc_ip.indexOf("[")&&/Trident\/|MSIE /.test(window.navigator.userAgent)){var n=location.hostname;n=n.split(":").join("-"),n=n.replace(/[\[\]]+/g,""),n+=".ipv6-literal.net",n+=location.port?":"+location.port:"",this.ws=new WebSocket(this.ws_proto+n+"/kvm",["binary","base64"])}else this.ws=new WebSocket(this.ws_proto+this.bmc_ip+"/kvm",["binary","base64"]);this.ws.binaryType="arraybuffer",this.ws.onopen=function(n){l.wsmode=this.protocol?this.protocol:"base64",l.onopen&&l.onopen(n),1==l.is_reconnecting&&(l.pos=l.nwBuffer.byteLength,l.retry_count=1,l.showProcessingPopup(window.CommonStrings.reconnect_success,1))},this.ws.onmessage=function(n){var e=5e3;l.pauseRead=!0,l.pos==l.nwBuffer.byteLength&&(delete l.nwBuffer,l.nwBuffer=null,l.nwBuffer=new DataStream,l.pos=0);var t=null;if(t="binary"==l.wsmode?new Uint8Array(n.data):P.decode(n.data),l.pos>e){var u=new Uint8Array(l.nwBuffer.buffer.slice(l.pos,l.nwBuffer.byteLength));delete l.nwBuffer,l.nwBuffer=null,l.nwBuffer=new DataStream,l.pos=0,l.nwBuffer.writeUint8Array(u,DataStream.LITTLE_ENDIAN),delete u,u=null}l.nwBuffer.writeUint8Array(t,DataStream.LITTLE_ENDIAN),l.pauseRead=!1,delete t,l.startReading||(l.startReading=!0,setTimeout(function(){l.startRead.call(l)},2)),l.onmessage&&l.onmessage(n)},this.ws.onclose=function(n){if(1==window.reconnect_enabled&&0==l.video.stopped&&(l.is_reconnecting=!0,sessionStorage.setItem("status","reconnect"),l.showProcessingPopup(window.CommonStrings.reconnect,null)),1==l.is_reconnecting&&l.retry_count<=MEDIA_CONFIGS.reconn_retry_count){var e=0,t=new Date,u=t.getTime(),i=1e3*MIN_RETRY_INTERVAL-(u-l.lastRecvTime);0>i&&(i=0),MEDIA_CONFIGS.reconn_retry_interval>MIN_RETRY_INTERVAL&&(e=MEDIA_CONFIGS.reconn_retry_interval-MIN_RETRY_INTERVAL),e=1e3*e+i,0>e&&(e=0),this.retryTimer=setTimeout(function(){l.ws=null,l.retry_count++,l.createWebSocket(),l.updateLastRecvTime()},e),n.preventDefault()}else 1==window.reconnect_enabled&&1==l.is_reconnecting?(sessionStorage.setItem("status","connection_failure"),$("#status_dialog").trigger("showStatus")):l.onclose&&l.onclose(n)},this.ws.onerror=function(n){1==window.reconnect_enabled&&(l.is_reconnecting=!0),1==l.is_reconnecting&&l.retry_count