define("welcome_res/lib/Login",["client"],function(d){function a(b){c(b||"Unexpected error. Trying again.");setTimeout(function(){e()},1E3)}function f(a){b=a;3==b?c("Room is full, you can't play, but you can watch"):2==b?document.getElementById("messageDiv").style.display="none":4==b?c("Entering room"):c("Connection Lost")}function e(){f(4);var b="Guest"+Math.ceil(1E3*Math.random());d.sendMessage("n|"+b,"Nick",3E3,{onAbort:function(b,c){a()},onDeny:function(b,c,e){-2720==c?(f(2),g(e,!1)):-2700==c?
(f(3),g(e,!0)):a(e)},onDiscarded:function(b){a()},onError:function(b){a()},onProcessed:function(c){f(2);g(b,!1)}})}function c(b){document.getElementById("messageDiv").innerHTML=b}var b=1;d.addListener({onListenStart:function(){this.onStatusChange(d.getStatus())},onStatusChange:function(c){console.log("\x3e\x3e\x3e\x3e\x3e change: "+c);0==c.indexOf("CONNECTED:")?1==b&&e():0==c.indexOf("DISCONNECTED:WILL-RETRY")&&(f(1),h())}});var g=function(){},h=function(){};return{init:function(b,c){g=b||g;h=c||
h}}});
define("welcome_res/lib/Player",["Subscription","client"],function(d,a){var f=function(a,c){this.nick=a.getValue("key");this.message=a.getValue("msg");this.isBall=0==this.nick.indexOf("Ball-");this.appended=!1;this.divMsg=this.messageEl=this.posX=this.posY=this.avatar=this.sub=this.div=null;c?(this.randomNum=2,this.color="#003D06"):(this.randomNum=4,this.color="#809E83")};f.prototype={getColor:function(){return this.color},makeAvatar:function(a,c,b){this.avatar||this.div&&!b||(this.avatar=document.createElement("div"),this.isBall?
(this.avatar.className="divBall",this.avatar.style.width="31px",this.avatar.style.height="31px",b=document.createElement("div"),c=document.createElement("img"),c.src="welcome_res/img/ball.png",c.style.border="0",c.style.width="31px",c.style.height="31px"):(this.avatar.className="divPerson",this.avatar.style.width="20px",this.avatar.style.height="46px",b=document.createElement("div"),c=document.createElement("img"),c.src="welcome_res/img/person-"+(9>=this.randomNum?"0"+this.randomNum:this.randomNum)+
".png",c.style.border="0",c.style.width="20px",c.style.height="46px"),b.appendChild(c),this.avatar.appendChild(b),this.room=a,this.goTo(this.posX,this.posY))},goTo:function(a,c){this.posX=null===a?this.posX:a;this.posY=null===c?this.posY:c;if(null!==this.posX||null!==this.posY){var b=this.avatar;if(b){var f=0!==b.offsetHeight?b.offsetHeight:this.isBall?31:46,d=0!==b.offsetWidth?b.offsetWidth:this.isBall?31:20;this.isBall?(b.style.left=this.posX-d/2+"px",b.style.top=this.posY-f/2+"px"):(b.style.left=
this.posX-d+"px",b.style.top=this.posY-f+"px");!this.appended&&this.room&&(this.room.appendChild(b),this.appended=!0)}}},removeAvatar:function(){this.avatar&&(this.avatar.parentNode&&this.avatar.parentNode.removeChild(this.avatar),this.room=this.avatar=null)},subscribe:function(f){this.sub||(this.sub=new d("MERGE",this.nick,["posX","posY"]),this.sub.setRequestedSnapshot("yes"),f&&this.sub.setRequestedMaxFrequency("unfiltered"),this.sub.addListener(this),a.subscribe(this.sub))},unsubscribe:function(){this.sub&&
(a.unsubscribe(this.sub),this.sub=null)},updatePlayer:function(a){this.goTo(a.getValue("posX"),a.getValue("posY"))}};return f});
define("welcome_res/lib/Buddies",["./Player"],function(d){var a=function(a,d,c){(this.unfilteredPlayers=a)&&alert("WARNING: unfiltered players!");this.msnry=this.container=this.me=this.status=null;this.room=d;this.singleSub=c;this.players={}};a.prototype={setOwnerNick:function(a){this.me=a;null!=a&&this.players[a]&&this.setOwnerColor()},positionBuddies:function(){2!=this.status&&(this.status=2);this.makeAvatars()},noBuddies:function(){3==this.status&&(this.status=3);this.clearAvatars()},clearAvatars:function(){for(var a in this.players)this.players[a].removeAvatar(this.msnry);
this.players={}},makeAvatars:function(){for(var a in this.players)this.players[a].makeAvatar(this.room,this.msnry)},subscribeAll:function(){if(!this.singleSub)for(var a in this.players)this.players[a].subscribe(this.unfilteredPlayers)},onUnsubscription:function(){this.clearTiles();this.clearAvatars();this.unsubscribeAll();this.players={}},onItemUpdate:function(a){if("ADD"==a.getValue("command")){var e=a.getValue("key"),c=new d(a,e==this.me);this.players[e]=c;this.singleSub||c.subscribe(this.unfilteredPlayers);
c.makeAvatar(this.room,this.msnry)}else if("DELETE"==a.getValue("command")){e=this.players[a.getValue("key")];this.singleSub||e.unsubscribe();delete this.players[a.getValue("key")];e.removeAvatar(this.msnry);return}this.players[a.getValue("key")].updatePlayer(a)}};return a});
define("welcome_res/lib/AxisControl",["client"],function(d){function a(a){var c=d.getStatus();"STALLED"!=c&&0!=c.indexOf("CONNECTED:")||d.sendMessage(a,"InputKey",1E3)}var f=function(a,c){this.key1=a;this.key2=c;this.going2=this.going1=!1};f.prototype={goOne:function(){this.going2&&(this.going2=!1,a(10*this.key2));this.going1||(this.going1=!0,a(this.key1))},stopOne:function(){this.going1&&(this.going1=!1,a(10*this.key1))},goTwo:function(){this.going1&&(this.going1=!1,a(10*this.key1));this.going2||
(this.going2=!0,a(this.key2))},stopTwo:function(){this.going2&&(this.going2=!1,a(10*this.key2))},stop:function(){this.going1?(this.going1=!1,a(10*this.key1)):this.going2&&(this.going2=!1,a(10*this.key2))}};return f});
define("welcome_res/lib/KeyPad",["./AxisControl"],function(d){function a(a,b,c){c=c||document.body;"undefined"!=typeof c.addEventListener?c.addEventListener(a,b,!1):c.attachEvent("on"+a,b);return!0}function f(a){if(!m&&!l){var c=window.event?event.keyCode:a.keyCode,c=c||a.which;switch(c){case 87:g.goOne();break;case 68:b.goOne();break;case 83:g.goTwo();break;case 65:b.goTwo()}}}function e(a){var c=window.event?event.keyCode:a.keyCode,c=c||a.which;switch(c){case 87:g.stopOne();break;case 68:b.stopOne();
break;case 83:g.stopTwo();break;case 65:b.stopTwo()}}function c(a){if(!p&&!l){var c=window.event?event.keyCode:a.keyCode,c=c||a.which;switch(c){case 84:h();break;case 82:h(!0)}}}var b=new d(39,37),g=new d(38,40),h=function(){},k=!1,n=!1,l=!1,m=!0,p=!1;return{disableIfFocusOn:function(c){a("focus",function(){l=!0},c);a("blur",function(){l=!1},c)},startListening:function(){k||(a("keyup",e),a("keydown",f),k=!0);m=!1},stopListening:function(){g.stop();b.stop();m=!0},listenMasterCommands:function(b){n||
(n=!0,a("keydown",c));h=b||h;p=!1},stopMasterCommands:function(){p=!0}}});
define("welcome_res/lib/Buttons",["./AxisControl"],function(d){function a(a,c,b){for(var d=0;d<a.length;d++)evnt=a[d],c.addEventListener?c.addEventListener(evnt,b,!1):c.attachEvent("on"+evnt,b)}function f(a,c,b,d){return function(){a.idle||(d?b?c.stopOne():c.stopTwo():b?c.goOne():c.goTwo())}}var e=["mousedown","touchstart","touchenter"],c=["mouseup","touchend","touchcancel","touchleave","mouseout"],b=function(b,h,k,n){var l=new d(39,37),m=new d(38,40);this.buttons={up:document.getElementById(b),down:document.getElementById(h),
left:document.getElementById(k),right:document.getElementById(n)};a(e,this.buttons[b],f(this,m,!0,!1));a(e,this.buttons[h],f(this,m,!1,!1));a(e,this.buttons[n],f(this,l,!0,!1));a(e,this.buttons[k],f(this,l,!1,!1));a(c,this.buttons[b],f(this,m,!0,!0));a(c,this.buttons[h],f(this,m,!1,!0));a(c,this.buttons[n],f(this,l,!0,!0));a(c,this.buttons[k],f(this,l,!1,!0));this.stopListening()};b.prototype={startListening:function(){this.idle=!1},stopListening:function(){this.idle=!0}};return b});
var hostToUse="file:"==document.location.protocol?"http://localhost:8080":document.location.protocol+"//"+document.location.hostname+(document.location.port?":"+document.location.port:"");
define("client",["LightstreamerClient","StatusWidget"],function(d,a){var f=new d(hostToUse,"WELCOME");f.addListener(new a("left","20px",!1));f.addListener({onStatusChange:function(a){0==a.indexOf("CONNECTED")?document.getElementById("welcomeMsg").innerHTML="\x3cspan class\x3d'ok'\x3eCongratulations! Your Lightstreamer Server is up and running.\x3c/span\x3e":0==a.indexOf("DISCONNECTED")&&(document.getElementById("welcomeMsg").innerHTML="\x3cspan class\x3d'ko'\x3eOops! Can't connect to Lightstreamer Server. Please check your configuration.\x3c/span\x3e")}});
f.connect();return f});
require(["client","Subscription","DynaGrid"],function(d,a,f){var e=new f("stocks",!0);f=e.extractFieldList();e.setSort("stock_name");e.setNodeTypes(["div","span","img"]);e.setAutoCleanBehavior(!0,!1);e.addListener({onVisualUpdate:function(a,b,d){null!=b&&(b.setHotTime(300),b.setHotToColdTime(200),d=b.getChangedFieldValue("last_price"),null!==d?(a=e.getValue(a,"last_price"),!a||d>a?b.setAttribute("#BFF2C8","#FFFFFF","backgroundColor"):b.setAttribute("#FFF7D5","#FFFFFF","backgroundColor"),b.setCellValue("last_price",
formatDecimal(d,2,!0))):b.setAttribute("#BFF2C8","#FFFFFF","backgroundColor"),b.setCellAttribute("arrow","","","backgroundColor"),a=b.getChangedFieldValue("pct_change"),null!==a&&(a=formatDecimal(a,2,!0)+"%",-1<a.indexOf("-")?(b.setCellValue("arrow","./welcome_res/img/quotes_down.gif"),b.setCellAttribute("pct_change","#003D06","#FF2E2E","color"),b.setCellValue("pct_change",a)):(b.setCellValue("arrow","./welcome_res/img/quotes_up.gif"),b.setCellAttribute("pct_change","#003D06","#00CC22","color"),b.setCellValue("pct_change",
"+"+a))),a=b.getChangedFieldValue("time"),null!==a&&b.setCellValue("time",formatTime(a)),a=b.getChangedFieldValue("min"),null!==a&&b.setCellValue("min",formatDecimal(a,2,!0)),a=b.getChangedFieldValue("max"),null!==a&&b.setCellValue("max",formatDecimal(a,2,!0)))}});a=new a("MERGE","item1 item2 item3 item4 item5 item6".split(" "),f);a.addListener(e);a.setDataAdapter("STOCKS");a.setRequestedSnapshot("yes");d.subscribe(a)});
require(["client","Subscription","Chart","StaticGrid","SimpleChartListener"],function(d,a,f,e,c){e=new e("data",!0);e.setAutoCleanBehavior(!0,!1);e.addListener({onVisualUpdate:function(a,b){if(null!=b){var c=b.getChangedFieldValue("TIME");null!=c&&b.setCellValue("TIME",c/1E3);c=b.getChangedFieldValue("Speed");null!=c&&(c=Math.round(.621371*c),b.setCellValue("Speed",c));c=b.getChangedFieldValue("Distance");null!=c&&(c=formatDecimal(.621371*c,2,!0),b.setCellValue("Distance",c))}}});var b=new f("speedChart",
!0);b.setAutoCleanBehavior(!0,!1);b.setXAxis("Distance");b.addYAxis("Speed");b.addListener(new c(2,20));b.addListener({onNewLine:function(a,b,c,d){b.setStyle("#00CC22","#00CC22",1,1)},onRemovedLine:function(){b.positionXAxis(0,0)}});var g=new f("rpmChart",!0);g.setAutoCleanBehavior(!0,!1);g.setXAxis("Distance");g.addYAxis("Rpm");g.addListener(new c(2,3));g.addListener({onNewLine:function(a,b,c,d){b.setStyle("#003D06","#003D06",1,1)},onRemovedLine:function(){g.positionXAxis(0,0)}});a=new a("MERGE",
"P_driver_1",["TIME","Speed","Rpm","Gear_output","Distance"]);a.setDataAdapter("TELEMETRY");a.setRequestedSnapshot("yes");a.addListener(e);a.addListener(g);a.addListener(b);d.subscribe(a)});
require(["client","Subscription","DynaGrid"],function(d,a,f){var e=new f("messages",!0);e.setMaxDynaRows("unlimited");e.setAutoScroll("ELEMENT","chatInnerContainer");e.setAutoCleanBehavior(!0,!1);e.addListener({associated:{},next:0,colors:"#FFFFE0 #FFEBCD #F0F8FF #CCFFCC #FFF5EE #E0FFFF #F0FFF0 #F0E68C #87CEEB #E6E6FA #FFB6C1 #F5FFFA #FFFAFA #F5F5DC #F8F8FF #FFE4E1 #D8BFD8 #FFF0F5 #EEE8AA".split(" "),onVisualUpdate:function(a,b,d){null!=b&&(a=b.getCellValue("nick"),b=b.getCellValue("IP")+"_"+a,a=
this.associated[b],a||(this.associated[b]=this.colors[this.next],this.next=this.next>=this.colors.length?0:this.next+1,a=this.associated[b]),d.style.backgroundColor=a)}});a=new a("DISTINCT","chat_room",e.extractFieldList());a.setDataAdapter("CHAT");a.setRequestedSnapshot(30);a.addListener(e);a.addListener({onClearSnapshot:function(a,b){var d=new Date,d=[pad2(d.getHours()),pad2(d.getMinutes()),pad2(d.getSeconds())].join(":");e.updateRow(1,{timestamp:d,message:"Chat history flushed... Let's keep it clean"})}});
d.subscribe(a)});var lsclient=null;require(["client"],function(d){lsclient=d;d.addListener({onStatusChange:function(a){0==a.indexOf("CONNECTED")?document.getElementById("chatButton").disabled=!1:document.getElementById("chatButton").disabled=!0}})});function chatSubmitForm(){var d=document.getElementById("chatInput");if(window.lsclient&&d){var a=d.value;a&&a!=document.getElementById("chatInput").placeholder&&(lsclient.sendMessage("CHAT|"+a),d.value="",d.focus())}}
document.getElementById("roomContainer")&&require("client Subscription welcome_res/lib/Login welcome_res/lib/Buddies welcome_res/lib/KeyPad welcome_res/lib/Buttons".split(" "),function(d,a,f,e,c,b){var g=new e(!1,document.getElementById("roomContainer"),!0),h=new a("COMMAND","Players_list","command key nick msg usrAgnt posX posY 1Plot.SymbolName".split(" "));h.setDataAdapter("ROOMBALL");h.setRequestedSnapshot("yes");h.addListener(g);var k=new b("up","down","left","right");c.disableIfFocusOn(document.getElementById("chatInput"));
f.init(function(a,b){b||(g.setOwnerNick(a),c.startListening(),k.startListening());d.subscribe(h);g.positionBuddies()},function(){g.noBuddies();g.setOwnerNick(null);c.stopListening();k.stopListening()})});function formatTime(d){var a=new Number(d.substring(0,d.indexOf(":")));12<a&&(a-=12);d=d.substring(d.indexOf(":"),d.length);return a+d}
function formatDecimal(d,a,f){for(var e=new String("1"),c=new String("0"),b=a;0<b;b--)e+=c;d=Math.round(d*e);d=new String(d/e);if(!f)return d;f=0;b=d.indexOf(".");-1==b?d+=".":f=d.length-b-1;for(b=f;b<a;b++)d+=c;return d}
function moreBrowsers(){var d=Math.floor(70*Math.random());window.open("index.html","LSDemoWindow"+Math.floor(1E4*Math.random()),"location\x3dyes,scrollbars\x3dyes,resizable\x3dyes,width\x3d"+Math.round(window.screen.availWidth/2)+",height\x3d"+(window.innerHeight-d)+",left\x3d"+Math.round(window.screen.availWidth/2+(70*Math.random()-35))+",top\x3d"+d)}
function checkURL(){return"file:"==location.protocol?(alert("To open the Monitoring Dashboard, get this page from your Lightstreamer Server via http, not from file. See GETTING_STARTED.TXT for full instructions."),!1):!0}function pad2(d){return(10>d?"0":"")+d}define("welcome_res/lib/index",function(){});
