/* * This file is part of Deliantra clientV. * * Copyright (©) 2012 Marek Olszewski * * Deliantra clientV is free software: you can redistribute it and/or * modify it under the terms of the Affero GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the Affero GNU General Public Licens * and the GNU General Public License along with this program. If not, see * . * * The authors can be reached via e-mail to */ String.prototype.each = function (f,p){ for (var i=0;i= 0 && this.indexOf(e) "+(item.nr_of>1?item.namepl:item.name)+(item.nr_of>1?item.nr_of:"")+"" }else{ div.innerHTML="
"+(item.nr_of>1?item.namepl:item.name)+"
" } div.addEventListener("click",myInventoryItemClick); div.addEventListener("mouseover",inventoryItemMouseOver); div.addEventListener("mouseout",inventoryItemMouseOut); div.addEventListener("mousemove",inventoryItemMouseMove); },{}) content = xPlayerWindow.getElementsByClassName("floor_widnow_content")[0]; content.innerHTML = ""; var container = secondaryContainer != 0 ? containers["container_" + secondaryContainer] : floorItems; container.each(function (item,i,p){ if (isNaN(item.nr_of)) return; content.appendChild(div = $_("div")); var img = tilesInfo.getImgByFaceNum(item.face); if (img){ div.innerHTML="
"+(item.nr_of>1?item.namepl:item.name)+(item.nr_of>1?item.nr_of:"")+"
" }else{ div.innerHTML="
"+(item.nr_of>1?item.namepl:item.name)+"
" } div.addEventListener("mouseover",inventoryItemMouseOver); div.addEventListener("mouseout",inventoryItemMouseOut); div.addEventListener("mousemove",inventoryItemMouseMove); div.addEventListener("click",floorInventoryItemClick); },{}) } function floorInventoryItemClick(e){ var itemId = parseInt(this.getElementsByTagName("input")[0].value); if (!keys.shift){ return; } for (var i = 0;i1 ? floorItems[i].namepl:floorItems[i].name)); }else{ } } } function myInventoryItemClick(e){ var itemId = parseInt(this.getElementsByTagName("input")[0].value); if (!keys.shift){ return; } for (var i = 0;i1 ? myItems[i].namepl:myItems[i].name)); }else{ } } } function inventoryItemMouseOver(e){ this.style.background = "solid"; this.style.backgroundColor="white"; var itemId = this.getElementsByTagName("input")[0].value; doSend("ex " + itemId); xInfoWindow.show(true); xInfoWindow.style.left = (e.clientX+5)+"px"; xInfoWindow.style.top = (e.clientY+5)+"px"; } function inventoryItemMouseMove(e){ xInfoWindow.style.left = (e.clientX+5)+"px"; xInfoWindow.style.top = (e.clientY+5)+"px"; } function inventoryItemMouseOut(e){ this.style.background = "transparent"; xInfoWindow.show(false); } function createWindow(title,width,height,x,y){ var windowTemplate = document.getElementById("window_template_container").innerHTML; var div = $_("div"); div.innerHTML = windowTemplate; var xwindow = div.getElementsByClassName("window")[0]; xwindow.style.left = x+"px"; xwindow.style.top = y+"px"; xwindow.style.width = width + "px"; xwindow.width = function (){ return parseInt(xwindow.style.width); }; xwindow.height = function (){ return parseInt(xwindow.style.height); }; xwindow.show = function (b){ xwindow.style.display = b?"block":"none"; return true; }; xwindow.visible = function (b){ return xwindow.style.display =="block"; }; xwindow.style.height = height + "px"; xwindow.getElementsByClassName("window_top_title")[0].innerHTML = title; xwindow.getElementsByClassName("window_close")[0].onclick = function (){(xwindow.close());}; xwindow.onmousedown = function (e) { if (e.clientY-parseInt(xwindow.style.top)<25){ currentWindow = xwindow; currentWindowOffset={x:e.clientX-parseInt(xwindow.style.left),y:e.clientY-parseInt(xwindow.style.top)} }else if (e.clientY-parseInt(xwindow.style.top)>parseInt(xwindow.style.height)-5){ if (e.clientX-parseInt(xwindow.style.left)>parseInt(xwindow.style.width)-5){ currentWindowResize = true; currentWindow = xwindow; } } }; xwindow.contents = xwindow.getElementsByClassName("content")[0]; xwindow.contents.parent = xwindow; xwindow.close = function (){document.getElementsByTagName("body")[0].removeChild(xwindow);}; appendToBody(xwindow); return xwindow; } function onMouseUp (e){ if (currentWindow!=null){ currentWindow = null; currentWindowResize = false; } } function onMouseMove (e){ stage.mouseX = e.clientX; stage.mouseY = e.clientY; if (currentWindow!=null){ if (currentWindowResize == false){ currentWindow.style.left = (stage.mouseX-currentWindowOffset.x)+"px"; currentWindow.style.top = (stage.mouseY-currentWindowOffset.y)+"px"; }else{ currentWindow.style.width = (stage.mouseX-parseInt(currentWindow.style.left))+"px"; currentWindow.style.height = (stage.mouseY-parseInt(currentWindow.style.top))+"px"; } } } function ptInRect(pt,rect){ if (pt.xrect.x+rect.width) return false; if (pt.y>rect.y+rect.height) return false; return true; } function onClick (e){ x = e.clientX; y = e.clientY; try{ e.preventDefault(); }catch (ex){ } return false; } function channels_setActive(channel_info){ for (var i=0;i{weight} = unpack "l", pack "L", unpack "N", substr $data, 0, 4, "" ; if (flags & UPD_FACE) itm.face = buff.readUint32(); if((itm.flags&F_OPEN)){ secondaryContainer = tag; updateItemsList(); } //TODO: finish it! /* if ($flags & UPD_NAME) { my $len = unpack "C", substr $data, 0, 1, ""; my $names = substr $data, 0, $len, ""; utf8::decode $names; @$item{qw(name name_pl)} = split /\x00/, $names; } $item->{anim} = unpack "n", substr $data, 0, 2, "" if $flags & UPD_ANIM; $item->{animspeed} = TICK * unpack "C", substr $data, 0, 1, "" if $flags & UPD_ANIMSPEED; $item->{nrof} = unpack "N", substr $data, 0, 4, "" if $flags & UPD_NROF; $item->{mtime} = time; if ($item->{tag} == $self->{player}{tag}) { $self->player_update ($self->{player} = $item); } else { $self->item_update ($item); } */ } function removeItemEx(itmid){ removeItem(myItems,itmid); removeItem(floorItems,itmid); for (var s in containers){ if (typeof(containers[s]) == typeof({}) ){ removeItem(containers[s],itmid); } } } function feed_delitem (data,dataAsArray){ var buff=new Buffer(dataAsArray); buff.position = 8; while (buff.position=0;--i){ if (items[i].itemId == itmid){ return items[i]; } } return null; } function removeItem (items,itmid){ for (var i=items.length-1;i>=0;--i){ if (items[i].itemId == itmid){ items.splice(i,1); } } updateItemsList(); } function feed_ex (data,dataAsArray){ var buff=new Buffer(dataAsArray); buff.position = 3; var len = buff.unpack_w(); var str = buff.readString(len); xInfoWindow.contents.innerHTML = str.split("\n").join("
")+"shift+click - drop,move or pickup item"; } function feed_query (data,dataAsArray){ switch (String.fromCharCode(dataAsArray[6])){ case "0": //var login = prompt("What is your name? (login names are case-sensitive):"); doSend("reply " + getLogin()) return true; break; case "4": //var password = prompt("What is your password?"); doSend("reply " + getPassword()); return true break; } return false; } function feed_version (data,dataAsArray){ var smapsize = Math.floor(xMapWindow.width()/64); mapsize.width = mapsize.height = parseInt(smapsize); smapsize = smapsize +"x" + smapsize; map_clear(); doSend('setup tileset 1 excmd 1 smoothing 1 mapinfocmd 1 facecache 1 newmapcmd 1 extmap 1 fxix 3 darkness 1 extcmd 2 msg 2 frag 0 map1acmd 1 spellmon 1 itemcmd 2 exp64 1 widget 1 lzf 0 mapsize ' + smapsize); window.addEventListener("keydown",function (e){ if (skipKeyTest){ return; } if (keys.states [e.keyCode]==0){ onKeyDown(e.keyCode); } keys.states [e.keyCode] = 1; try { e.preventDefault(); }catch (e){ } return false; }); window.addEventListener("keyup",function (e){ if (skipKeyTest){ return; } if (keys.states [e.keyCode]==1){ onKeyUp(e.keyCode); } keys.states [e.keyCode] = 0; try { e.preventDefault(); }catch (e){ } //isRunning = false; return false; }); channels_add({id:"log"}); channels_add({id:"map"}); return false; } function feed_setup (data,dataAsArray){ doSend('exti ["http_faceurl", ' + exti.getNextId() +']'); } function clear_cell (cell){ cell.darkness = 256; cell.flags = 0; cell.player =0; cell.tiles = []; return cell; } function MapCell(){ this.previousCell = null; this.nextCell = null; this.data = {}; clear_cell(this.data); } function MapRow(){ this.previousRow = null; this.nextRow = null; this.firstCell = null; this.lastCell = null; this.length = 0; while (this.length> 10) & 63); y = ((flags >> 4) & 63); cell = map_get_cell (x, y); if (!(flags&15)){ clear_cell(cell); //ctx.clearRect(x<<6,(y<<6),64,64); continue; } if (cell.darkness==0){ cell.darkness = 256; } if ((flags & 8)){ do { var cmd = 0; var ext = 0; ext = data[index++]; cmd = ext & 0x7f; if (cmd<4){ cell.darkness = 255 - ext * 64 + 1; }else if (cmd == 5){ cell.stat_width = 1; cell.stat_hp = data[index++]; }else if (cmd == 6) {// monster width{ cell.stat_width = data[index++] + 1; }else if (cmd == 0x47){ if (data[index] == 1) cell.player = data [index + 1]; else if (data[index] == 2) cell.player = data [index + 2] + (data [index + 1] << 8); else if (data[index] == 3) cell.player = data [index + 3] + (data [index + 2] << 8) + (data [index + 1] << 16); else if (data[index] == 4) cell.player = data [index + 4] + (data [index + 3] << 8) + (data [index + 2] << 16) + (data [index + 1] << 24); index += data[index] +1; } else if (cmd == 8) // cell flags cell.flags = data[index++]; else if (ext & 0x40) // unknown, multibyte => skip index+= data[index]+1; else index++; }while (ext&0x80); } for (var z = 0; z <= 2; ++z) if ((flags & (4 >> z))) { var face = (data [index++] << 8) + data [index++]; //need_facenum (face); cell.tiles [z] = face; } //Map[y][x]=cell; } drawMap(); return true; } function drawMap(){ ctx.clearRect(0,0,stage.stageWidth,stage.stageHeight); ctx.fillStyle = "#000"; ctx.fillRect(0,0,canvas.width,canvas.height); for (var i = 0;i0){ ctx.fillStyle = "#f00"; ctx.fillRect(x,y,((255-cellx.stat_hp)/255)*64,8); //ctx.fillText(cellx.stat_hp,x,y); } cell = cell.nextCell; } } } function feed_ext (data,dataAsArray){ if (data.indexOf ("channel_info")>0){ var channel_info = JSON.parse(data.substr(4))[1]; channels_add(channel_info); return true; }else{ var o = JSON.parse(data.substr(4)); var replyID = parseInt(o[0].split("-")[1]); if (replyID == 100){ baseURL = o[1]; baseURL = "http://testserver.deliantra.net:13327" + baseURL + ""; doSend('exti ["resource",'+exti.getNextId()+',"exp_table"]'); }else if (replyID==101){ expTableFacenum = parseInt(o[1]); Faces.request(expTableFacenum,"json",function (tileInfo){expTable=(tileInfo.resource);}); doSend ('exti ["resource",'+exti.getNextId() + ', "skill_info", "spell_paths","command_help"]'); }else if (replyID==102){ Faces.request(parseInt(o[1]),"json",function (faceInfo){skillNames=(faceInfo.resource);}); Faces.request(parseInt(o[2]),"json",function (faceInfo){spellPaths=(faceInfo.resource);}); Faces.request(parseInt(o[3]),"json",function (faceInfo){commandsAll=(faceInfo.resource);}); doSend("addme"); } else{ } writeToScreen(data); } return false; } var Constants = { a_none : 0, a_readied : 1, a_wielded : 2, a_worn : 3, a_active : 4, a_applied : 5, F_APPLIED : 0x000F, F_LOCATION : 0x00F0, F_UNPAID : 0x0200, F_MAGIC : 0x0400, F_CURSED : 0x0800, F_DAMNED : 0x1000, F_OPEN : 0x2000, F_NOPICK : 0x4000, F_LOCKED : 0x8000 }; function Buffer (dataArray){ this.buffer = dataArray; this.position = 0; this.length = dataArray.length; return this; } Buffer.prototype.unpack_w = function (){ var num = 0; var byte = 0; do { num*=128; byte = parseInt(this.buffer[this.position++]); num+=byte&0x7f; }while (byte&0x80); return num; }; Buffer.prototype.readUint32 = function (){ var ret = 0; for (var i=0;i<4;++i){ ret*=256; ret+=this.buffer[this.position++]; } return ret; }; Buffer.prototype.readUint8 = function (){ var ret = 0; for (var i=0;i<1;++i){ ret*=256; ret+=parseInt(this.buffer[this.position++]); } return ret; }; Buffer.prototype.readUint16 = function (){ var ret = 0; for (var i=0;i<2;++i){ ret*=256; ret+=this.buffer[this.position++]; } return ret; }; Buffer.prototype.readString = function (len){ var ret = ""; if ( typeof (len) != "undefined"){ for (var i=0;i1) item.namepl = names[1]; item.animation_id = buff.readUint16(); item.anim_speed = buff.readUint8(); item.nr_of = buff.readUint32(); item.clientType = buff.readUint16(); item.container = container; if (container==player.tag){ myItems.push (item); }else if (container==0){ floorItems.push(item); }else { if ( typeof(containers['container_' + container]) != typeof([])){ containers['container_' + container] = []; } containers['container_' + container].push(item); } } if (container==0){ xFloorWindow.contents.innerHTML=""; for (var i=0;i"+(item.nr_of>1?item.namepl:item.name)+(item.nr_of>1?item.nr_of:"")+"" }else{ div.innerHTML+="
"+(item.nr_of>1?item.namepl:item.name)+"
" } div.addEventListener("click",floorInventoryItemClick); div.addEventListener("mouseover",inventoryItemMouseOver); div.addEventListener("mouseout",inventoryItemMouseOut); div.addEventListener("mousemove",inventoryItemMouseMove); } } updateItemsList(); return false; } function Spell (){ } function updateSpellList (){ var content = xPlayerWindow.getElementsByClassName("spellbook_widnow_content")[0]; content.style.display = "block"; content.innerHTML = ""; var table; var tr; var td; content.appendChild(table = $_("table")); table.style.width="100%"; if (mySpells.length<=0){ return; } table.appendChild(tr = $_("tr")); item = mySpells[0]; for (s in item){ if ((typeof(item[s])==typeof(1))||(typeof(item[s])==typeof(""))){ if (s=="tag"){ }else if (s=="message"){ }else if (s=="face"){ tr.appendChild(td=$_("td")); td.innerHTML = s; }else{ tr.appendChild(td=$_("td")); td.innerHTML = s; } } } mySpells.each(function (item,i,p){ table.appendChild(tr = $_("tr")); tr.index = i; var img = tilesInfo.getImgByFaceNum(item.face); var s; for (s in item){ if (isNaN(item['face'])){ continue; } if ((typeof(item[s])==typeof(1))||(typeof(item[s])==typeof(""))){ if (s=="tag"){ tr.tag = item[s]; }else if (s=="message"){ tr.message = item[s]; }else if (s=="face"){ tr.appendChild(td=$_("td")); td.innerHTML = ""; }else{ tr.appendChild(td=$_("td")); td.innerHTML = item[s]; } } } tr.addEventListener("click",mySpellItemClick); tr.addEventListener("mouseover",SpellItemMouseOver); tr.addEventListener("mouseout",SpellItemMouseOut); tr.addEventListener("mousemove",SpellItemMouseMove); /*if (img){ div.innerHTML="
"+(item.nr_of>1?item.namepl:item.name)+(item.nr_of>1?item.nr_of:"")+"
" }else{ div.innerHTML="
"+(item.nr_of>1?item.namepl:item.name)+"
" }*/ },{}) } function updateSkillList (){ var content = xPlayerWindow.getElementsByClassName("skills_widnow_content")[0]; content.innerHTML = ""; var tableLeft; var tableRight; var tr; var td; content.appendChild(tableLeft = $_("table")); tableLeft.style.width="45%"; tableLeft.style.float = "left"; content.appendChild(tableRight = $_("table")); tableRight.style.width="45%"; tableRight.style.float = "right"; var j=0; for (i=CS_STAT_SKILLINFO;i
shift-click to cast
ctrl-click to invoke"; xInfoWindow.show(true); xInfoWindow.style.left = (e.clientX+5)+"px"; xInfoWindow.style.top = (e.clientY+5)+"px"; } function SpellItemMouseMove(e){ xInfoWindow.style.left = (e.clientX+5)+"px"; xInfoWindow.style.top = (e.clientY+5)+"px"; } function SpellItemMouseOut(e){ this.style.background = "transparent"; xInfoWindow.show(false); } function feed_addspell (data,dataAsArray){ var buff = new Buffer(dataAsArray); buff.position = data.indexOf(" ")+1; while (buff.position0)){ var faceInfo = this.pending.pop(); faceInfo.load(); } }, FT_FACE : 0 * 2 + 0, // faces (images) FT_MUSIC : 1 * 2 + 1, // background music FT_SOUND : 2 * 2 + 1, // effects FT_RSRC : 3 * 2 + 0, // generic data files MAXDOWNLOADS : 5 } function feed_fx (data,dataAsArray){ var buff = new Buffer(dataAsArray); buff.position = 3; var out=""; var type = 0; var nameX = ""; var len; while (buff.position>4]+out; nameX+=out; } var faceInfo = Faces.getByNum(id,true); faceInfo.setType (type).setName (nameX); if (faceInfo.isRequested){ faceInfo.load(); } } return false; } function feed_newmap (data,dataAsArray){ //messageBox("newmap"); map_clear(); } function feed_mapinfo (data,dataAsArray){ var parts = data.split(/ /); //map_clear(); return false; } function feed_msg (data,dataAsArray){ var o = null; if (data.indexOf("[")>0){ o = JSON.parse(data.substr(4)); channels_addMessage(o[1],o) return true; } return false; } function feed_anim (data,dataAsArray){ return false; } function feed_stats (data,dataAsArray){ var buff = new Buffer(dataAsArray); buff.position = "stats".length + 1; while (buff.position < buff.length){ var stat = buff.readUint8(); var value; if (stat_32bit.contains(stat)){ value = buff.readUint32(); }else if (stat == CS_STAT_SPEED||stat==CS_STAT_WEAP_SP){ value = (1/FLOAT_MULTF) * buff.readUint32(); }else if (stat==CS_STAT_RANGE||stat==CS_STAT_TITLE){ var len = buff.readUint8(); value = buff.readString(len); }else if (stat == CS_STAT_EXP64){ var hi = buff.readUint32(); var lo = buff.readUint32(); value = hi * Math.pow(2,32) + lo; }else if (stat>=CS_STAT_SKILLINFO && stat < CS_STAT_SKILLINFO + CS_NUM_SKILLS){ var lvl = buff.readUint8(); var hi = buff.readUint32(); var lo = buff.readUint32(); value = [lvl,hi * Math.pow(2,32) + lo]; }else{ value = buff.readUint16(); if (value > 60000){ value -= 65536; } } myStats [stat] = value; //stats_update (stat); } return true; } function feed_player (data,dataAsArray){ var buff = new Buffer(dataAsArray); buff.position ="player ".length; //my ($tag, $weight, $face, $name) = unpack "NNN C/a", $data; player.tag = buff.readUint32(); player.weight = buff.readUint32(); player.face = buff.readUint32(); var len = buff.readUint8(); player.name = buff.readString(len); return false; } function feed_drawinfo (data,dataAsArray){ return false; } var tilesInfo = { getImgByFaceNum:function (id){ var fi = Faces.getByNum(id,true); return fi.resource; } } function need_facenum (num){ } function feed_map_scroll (data,dataAsArray,base64data){ data = data.split(/ /); data.shift(); dx += parseInt(data.shift()); dy += parseInt(data.shift()); } function $_(p,o){ if (document.getElementById(p)!=null){ return document.getElementById(p); }else{ var ret = document.createElement(p); unselectable(ret); if (o&&o.css){ var s=""; for (var s in o.css){ if (typeof(o.css[s])==typeof("")||typeof(o.css[s])==typeof(1)){ ret.style[s] = o.css[s]; } } } return ret; } } var tiles = []; function processExtObj (o){ switch (o[0]){ case "channel_info": channels[o[1].id] = o[1]; channels.list.push (channels[o[1].id]); channels[o[1].id].index =channels.length; channels.length+=1; return true; default: return false; break; } } function doSend(message) { writeToScreen("SENT: " + message); websocket.send(message); } /** * Command console */ var xCommandContainer = null; var xCommandLine = null; var xCommandLines = null; var command = ""; var lastCommand = ""; var firstOption = null; var commandsAll = []; function commandLineOnKeyDown (e){ if (e.keyCode==13){ skipKeyTest = false; doSend("command " + this.value); command = ""; lastCommand = this.value; document.getElementsByTagName("body")[0].removeChild(xCommandContainer); } else if (e.keyCode==27){ command = ""; skipKeyTest = false; document.getElementsByTagName("body")[0].removeChild(xCommandContainer); } else { //messageBox(JSON.stringify(commandsAll)); } } function autoComplete (keyCode){ if (xCommandContainer==null){ xCommandContainer =$_("div",{css:{position:"absolute",left:(stage.stageWidth/2)+"px",top:(stage.stageHeight/2)+"px"}}); xCommandLine = $_("input"); xCommandLine.addEventListener("keydown",commandLineOnKeyDown); xCommandContainer.appendChild(xCommandLine); xCommandContainer.appendChild($_("br")); xCommandLines = $_("select"); xCommandLines.height = 5; xCommandContainer.appendChild(xCommandLines); } if (command == ""){ skipKeyTest = true; appendToBody(xCommandContainer); try { xCommandLine.focus(); }catch (e){ } } command+=String.fromCharCode(keyCode).toLowerCase(); xCommandLine.value = command; } /** * Key up/down handlers */ function onKeyDown (keyCode){ switch(keyCode){ case 38: if (keys.ctrl&&!isRunning){ isRunning = true; doSend("command run 1"); //doSend("command north") } else if (!isFiring&&keys.shift){ doSend("command fire 1"); isFiring = true; }else doSend("command north"); break; case 40: if (keys.ctrl&&!isRunning){ isRunning = true; doSend("command run 5" ); //doSend("command souh") } else if (!isFiring&&keys.shift){ doSend("command fire 5" ); isFiring = true; }else doSend("command south"); break; case 37: if (keys.ctrl&&!isRunning){ isRunning = true; doSend("command run 7" ); // doSend("command west") } else if (!isFiring&&keys.shift){ doSend("command fire 7"); isFiring = true; }else doSend("command west"); break; case 39: if (keys.ctrl&&!isRunning){ isRunning = true; doSend("command run 3" ); //doSend("command west") }else if (!isFiring&&keys.shift){ doSend("command fire 3"); isFiring = true; }else doSend("command east"); break; case 49: case 9: xPlayerWindow.show(!xPlayerWindow.visible() ); break; case 67: skipKeyTest = true; xCommmandWindow.show(true); break; case 32: doSend("command apply"); break; case 188: doSend("command get"); break; case 16: keys.shift = 1; break; case 18: keys.alt = 1; break; case 17: keys.ctrl = 1; break; case 113: showPlayerTab({},"statistics"); break; case 114: showPlayerTab({},"skills"); break; case 115: showPlayerTab({},"spellbook"); break; case 116: showPlayerTab({},"inventory"); break; default: //messageBox(keyCode); break; } } function onKeyUp(keyCode){ switch(keyCode){ case 38: if (isRunning&&!keys.ctrl){ doSend("command run_stop"); isRunning = false; } if (isFiring&&!keys.shift){ doSend("command fire_stop"); isFiring = false; } break; case 40: if (isFiring&&!keys.shift){ doSend("command fire_stop"); isFiring = false; } if (isRunning&&!keys.ctrl){ doSend("command run_stop"); isRunning = false; } break; case 37: if (isFiring&&!keys.shift){ doSend("command fire_stop"); isFiring = false; } if (isRunning&&!keys.ctrl){ doSend("command run_stop"); isRunning = false; } break; case 39: if (isFiring&&!keys.shift){ doSend("command fire_stop"); isFiring = false; } if (isRunning&&!keys.ctrl){ doSend("command run_stop"); isRunning = false; } break; case 49: break; case 16: keys.shift = 0; if (isFiring&&!keys.shift){ doSend("command fire_stop"); isFiring= false; } break; case 18: keys.alt = 0; break; case 17: keys.ctrl = 0; if (isRunning&&!keys.ctrl){ doSend("command run_stop"); isRunning = false; } break; default: //messageBox(e.keyCode); break; } if ((keyCode>="A".charCodeAt(0))&&(keyCode<="Z".charCodeAt(0))){ autoComplete(keyCode); //launch command console } } /* * UTILS */ function decode_base64toArray(s) { var e={},i,k,v=[],r=[],w=String.fromCharCode; var n=[[65,91],[97,123],[48,58],[43,44],[47,48]]; for(z in n){for(i=n[z][0];i=8){r.push((b>>>(l-=8))%256);} } } return r; } function writeToScreen(message) { var d = new Date(); //Messages.push(new Message(200,(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() ) + ":" + message)); output.value = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ":" + message + "\n" + output.value; } function arr2bytes(arr){ var s = ""; for (var i=0;i