TextMorph.subclass('ServerSandBoxWorkspace',{style:{borderWidth:0},initialize:function($super,rect,textString,useChangeClue,optId){$super(rect,textString,useChangeClue);this.sandboxServer=newNodeJSSandboxServer(null,optId);this.isSync=true;},//initializeTransientState:function($super){//$super()//this.sandboxServer=newNodeJSSandboxServer();//},boundEval:function(str){this.sandboxServer.evalOnServer(str,false&&this.isSync);},tryBoundEval:function(str,offset,printIt){//FIXMEvarresult;this.waitMorph=newBoxMorph(this.bounds());this.waitMorph.applyStyle({fill:Color.black,fillOpacity:0.3});this.addMorph(this.waitMorph);try{connect(this.sandboxServer,'result',this,printIt?'gotServerResultAndPrintIt':'gotServerResult',{removeAfterUpdate:true})this.boundEval(str);}catch(e){this.showError(e,offset)}return'';},gotServerResult:function(result){console.log('Gotresult')this.waitMorph.remove();},gotServerResultAndPrintIt:function(result){this.gotServerResult(result)this.setNullSelectionAt(this.selectionRange[1]+1);varprevSelection=this.selectionRange[0];varreplacement=""+resultthis.replaceSelectionWith(replacement);this.setSelectionRange(prevSelection,prevSelection+replacement.length);},replaceTextMorph:function(textmorph){//FIXMEif(textmorph.constructor!=TextMorph)thrownewError('replaceTextMorphneedsatextmorph')this.setExtent(textmorph.getExtent());this.setPosition(textmorph.getPosition());varclip=textmorph.owner;textmorph.remove()clip.addMorph(this);},open:function(id){//newServerSandBoxWorkspace().open('workspace1')if(id)this.sandboxServer.id=id;varpanel=WorldMorph.current().addTextWindow({title:'ServerSandBoxid:'+this.sandboxServer.id,content:''});this.replaceTextMorph(panel.innerMorph());},morphMenu:function($super,evt){varmenu=$super(evt),self=this;if(!menu)returnnullmenu.addItem([this.isSync?"beasync":"besync",function(){self.isSync=!self.isSync}])returnmenu},});
nulltruetrue2000000
0.5