Lively Kernel canvas
// this script is evaluated on world load
CodeSnippets40
JournalMigration//1.add'apps.Journal'tolocalrequirements//2.RemoveoldPageSpecificCode//3.CreateNewJournaljournal=newJournalWidget();pane=journal.buildView();pane.name='journal'pane.openInWorld()//4.MoveoldJournalEntriesintothenewJournalthis.world().submorphs.select(function(ea){returneainstanceofJournalEntryMorph}).each(function(ea){$morph('journal').ownerWidget.container.addMorph(ea)})//5.Fixsomelayouting$morph('journal').ownerWidget.container.name='JournalContainer'$morph('JournalContainer').submorphs.invoke('adjustToSubmorphBounds')1419
CodeSnippettoremoveJournalEntriesofaspecificMonths$morph('JournalContainer').submorphs.select(function(ea){returnea.dateText.textString.startsWith('2010-07')}).invoke('remove')144
Wikicontroltruetrue
//replaceapatterninalotoftextMorphs....oftheworld//rectangleistheresothatIdon'treplacemyselfreplaceInTextMorphs=function(pattern,replace){vartextMorphs=WorldMorph.current().submorphs.select(function(ea){returnea.textString&&ea.textString.match(pattern)})textMorphs.each(function(textMorph){textMorph.setTextString(textMorph.textString.replace(pattern,replace))})}replaceInTextMorphs(/(•!\t)|(•\!)/g,"\n-")replaceInTextMorphs(/–\!/g,"\n\t-")17
null34