Lively Kernel canvas
// this script is evaluated on world load
400)
this.error('Error in login/receive from stream. Message: ' + newText);
// newText can be a list of cr lf separated json messages
// call onLogin/onReceive just with one json obj at a time
var messages = newText.split('\r\n');
messages.pop(); // remove last empty string
messages.forEach(function(message) {
var json = lively.webcollab.parseJson(message);
if (reqTextPos === 0 || json.isLoginMessage /*FIXME under heavy load reqTextPos not 0 when login response arrives*/) {
this._isLoggedIn = json && json.isSuccess;
this.onLogin(req);
} else {
this.onReceive(json);
}
}, this);
}]]> 400) {
var json = JSON.unserialize(req.responseText);
this.error('Logout not successful ' + json.status);
}
this._isLoggedIn = false;
}]]> 400)
this.error('Error requesting active users');
var json = JSON.unserialize(req.responseText);
this.onGetActiveUsers(json.activeUsers);
}]]>= 400)
this.error('Failure issuing request. Status: ' + req.status + ' ' + req.responseText);
};
req.open(method, url, !sync);
req.send(content);
return req;
}]]>
ProgrammierenimWebmitLivelyKernelsave-HilfefürinteraktiveEntwicklung-alt+dführteineZeile/Bereichausalt+pführteineZeile/BereichausundfügtdasErgebnisindenTexteinEinenCodeBrowseröffnen:WorldMenu->Tools...->LocalcodeBrowserEinTextFensterzumprogrammieren:WorldMenu->ComplexMorphs...->TextWindowEinenMorphbenennen:RechtsklickaufMorph->Properties...->editname...EinenButtonbauen:ComplexMorphs...->ButtonMorph.DannRechtsklickaufButton->Editscript/EditlabelBenanntenMorphimTextreferenzieren:$morph('dieserTextMorph')EineneueKlasseoderbeimStartauszuführendenCodeanlegen:KontextmenüimLocalcodeBrowseröffnenundaddclassoderadddoitanklickensaveas...-KleinerJavaScriptÜberblick-Dynamischgetyptvarx='EinString';vary=10;x+y;Arraysarray=[1,'String']SyntaxähnlichzuCfor(vari=0;i<10;i++){varmorph=Morph.makeCircle(pt(100+(i*40),100),20)morph.openInWorld();}Objektorientiertobjekt={x:1,y:'HalloWelt',toString:function(){returnthis.y+this.x}}objekt.toString()KlassenObject.subclass('MyNewClass',{einAttribut:5,eineMethode:function(){return'HalloWelt'+this.einAttribut}})instanz=newMyNewClass()instanz.eineMethode()KleinesBeispielprogrammgraph=Morph.makeLine([pt(0,0)],2,Color.black)graph.openInWorld()for(varx=0;x<2*Math.PI;x+=0.1){vary=Math.sin(x)*100+200;varpoint=pt(x*100,y);graph.shape.addPoint(point);}graph.remove()Wikicontrol