Lively Kernel canvas * MIT license * * Includes enhancements by Scott Trenda * and Kris Kowal * * Accepts a date, a mask, or a date and a mask. * Returns a formatted version of the given date. * The date defaults to the current date/time. * The mask defaults to dateFormat.masks.default. */ // http://blog.stevenlevithan.com/archives/date-time-format var dateFormat = function () { var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = /[^-+\dA-Z]/g, pad = function (val, len) { val = String(val); len = len || 2; while (val.length < len) val = "0" + val; return val; }; // Regexes and supporting functions are cached through closure return function (date, mask, utc) { var dF = dateFormat; // You can't provide utc if you skip other args (use the "UTC:" mask prefix) if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { mask = date; date = undefined; } // Passing date through Date applies Date.parse, if necessary date = date ? new Date(date) : new Date; if (isNaN(date)) throw SyntaxError("invalid date"); mask = String(dF.masks[mask] || mask || dF.masks["default"]); // Allow setting the utc argument via the mask if (mask.slice(0, 4) == "UTC:") { mask = mask.slice(4); utc = true; } var _ = utc ? "getUTC" : "get", d = date[_ + "Date"](), D = date[_ + "Day"](), m = date[_ + "Month"](), y = date[_ + "FullYear"](), H = date[_ + "Hours"](), M = date[_ + "Minutes"](), s = date[_ + "Seconds"](), L = date[_ + "Milliseconds"](), o = utc ? 0 : date.getTimezoneOffset(), flags = { d: d, dd: pad(d), ddd: dF.i18n.dayNames[D], dddd: dF.i18n.dayNames[D + 7], m: m + 1, mm: pad(m + 1), mmm: dF.i18n.monthNames[m], mmmm: dF.i18n.monthNames[m + 12], yy: String(y).slice(2), yyyy: y, h: H % 12 || 12, hh: pad(H % 12 || 12), H: H, HH: pad(H), M: M, MM: pad(M), s: s, ss: pad(s), l: pad(L, 3), L: pad(L > 99 ? Math.round(L / 10) : L), t: H < 12 ? "a" : "p", tt: H < 12 ? "am" : "pm", T: H < 12 ? "A" : "P", TT: H < 12 ? "AM" : "PM", Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] }; return mask.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); }); }; }(); // Some common format strings dateFormat.masks = { "default": "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" }; // Internationalization strings dateFormat.i18n = { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] }; // For convenience... Date.prototype.format = function (mask, utc) { return dateFormat(this, mask, utc); };]]>Draft-PresentationManager save-don'tfixexternalimageURLs-parsetheslidenamesfromwhatever(JSON,PageNavigationclass,...)-usedraganddroptoreorder-savetheneworderTODOspm=newPresentationManager();varurl=newURL('http://www.lively-kernel.org/repository/webwerkstatt/projects/CodeDB/lively-presentation/');varslideNames=["title.xhtml","contents.xhtml","motivation.xhtml","goals.xhtml","terminology.xhtml","model.xhtml","interaction.xhtml","couchdb.xhtml","representations.xhtml","demonstration.xhtml","related-work.xhtml","summary.xhtml","issues-outlook.xhtml",];pm.openIn(WorldMorph.current());pm.loadPresentation(url,slideNames);/*listMorph=pm.panel['slidePane'].innerMorph();listMorph.itemListlist=listMorph.itemList;item1=list[0];item2=list[1];list[0]=item2;list[1]=item1;listMorph.updateList(list);*/WorkspacerelayingdroponDropWorkspacemw=newlively.ide.startSourceControl().addModule('ProjectSeminar2010/CustomStyles.js');//mw.retrieveSourceAndParse()potPresent=mw.ast().subElements().findAll(function(ea){returnea.type=='klassDef'&&ea.subElements().detect(function(ea){returnea.type=='propertyDef'&&ea.name=='url'})&&ea.subElements().detect(function(ea){returnea.type=='propertyDef'&&ea.name=='slideNames'})});presentations=potPresent.collect(function(ea){returneval('({'+//'foo:"bar",'+'})');ea.subElements().detect(function(ea2){returnea2.name=='url'}).getSourceCode()+ea.subElements().detect(function(ea2){returnea2.name=='slideNames'}).getSourceCode()+'})');});presentations.each(function(ea){console.log(''+ea.url);});Workspacecop.create('DebugLayer').refineClass(DragnDropListMorph,{acceptsDropOf:function(proceed,item){console.log('acceptsDropOf:'+this+''+item)returnproceed(item)},acceptDrop:function(proceed,item,evt){console.log('acceptDrop'+this+''+item+''+evt)returnproceed(item,evt)}})TestRunnerTabCompletionLayerTestTabCompletionTestRunTestCaseRunAllTestCasesRefresh-----varmorphName='dragAndDropListTestMorph1';varm=$morph(morphName);if(m)m.remove();varitems=[{isListItem:true,string:'a',value:1},{isListItem:true,string:'b',value:2},{isListItem:true,string:'c',value:3}];varlist=newDragnDropListPane(newRectangle(0,0,100,300));list.innerMorph().setList=function(items){this.updateList(items)};list.innerMorph().updateList(items)list.innerMorph().setWithLayers([DebugLayer])list.name=morphNamelist.setPosition(pt(50,1100))list.openInWorld()varmorphName='dragAndDropListTestMorph2';varm=$morph(morphName);if(m)m.remove();varitems=[{isListItem:true,string:'d',value:4},{isListItem:true,string:'e',value:5},{isListItem:true,string:'f',value:6}];varlist=newDragnDropListPane(newRectangle(0,0,100,300));list.innerMorph().updateList(items)list.innerMorph().setList=function(items){this.updateList(items)};list.innerMorph().setWithLayers([DebugLayer])list.name=morphNamelist.setPosition(pt(200,1100))list.openInWorld()lively/Widgets.js:2950:propertyDef:Global>>Global.newDragnDropListPane=functio...lively/Helper.js:453:propertyDef:DragAndDropListTester>>buildView:lively/LKWiki.js:70:propertyDef:WikiNavigator>>buildView:lively/TestFramework.js:704:propertyDef:TestRunner>>buildView:lively/ide.js:49:propertyDef:lively.ide.BasicBrowser>>panelSpec:lively/ide.js:1009:propertyDef:lively.ide.LocalCodeBrowser>>panelSpec:lively/ide.js:1051:propertyDef:lively.ide.WikiCodeBrowser>>panelSpec:lively/ide.js:3591:propertyDef:lively.ide.FileVersionViewer>>buildView:apps/Presentation.js:16:propertyDef:PresentationManager>>buildView:browseloaddefaultmodulessearchagainpanelSpec:[['locationPane',newTextPane,newRectangle(0,0,0.8,0.05)],['codeBaseDirBtn',function(bnds){returnnewButtonMorph(bnds)},newRectangle(0.8,0,0.12,0.05)],['localDirBtn',function(bnds){returnnewButtonMorph(bnds)},newRectangle(0.92,0,0.08,0.05)],['Pane1',newDragnDropListPane,newRectangle(0,0.05,0.25,0.32)],['Pane2',newDragnDropListPane,newRectangle(0.25,0.05,0.25,0.35)],['Pane3',newDragnDropListPane,newRectangle(0.5,0.05,0.25,0.35)],['Pane4',newDragnDropListPane,newRectangle(0.75,0.05,0.25,0.35)],['midResizer',function(bnds){returnnewHorizontalDivider(bnds)},newRectangle(0,0.44,1,0.01)],['sourcePane',newTextPane,newRectangle(0,0.45,1,0.49)],['bottomResizer',function(bnds){returnnewHorizontalDivider(bnds)},newRectangle(0,0.94,1,0.01)],['commentPane',newTextPane,newRectangle(0,0.95,1,0.05)]],ChangelistforReferencestonewDragnDropListPane fontHelvetica12:spacewidth3from17xWidth7enableProgresssuccesspublishingworldathttp://www.lively-kernel.org/repository/webwerkstatt/marko/draft-presentation.xhtml,status204finishedsavingstatusmsg:worldsavedtoundefinedin2972ms(1790msserialization)-------------------------------------------invoke658726:Morph([[0.000005932433850830421,0.0016894531436264515,334.13726806640625,447.0968322753906]])fitWidthfailureonTextMorph.getCharBoundsfitWidthfailureonTextMorph.getCharBoundsTextMorphfindsnoline???statusmsg:serializing....problemstoparsehttp://www.lively-kernel.org/repository/webwerkstatt/marko/draft-presentation.xhtmlextendForSerialization[objectSVGDefsElement]Warn:unexpected:#<Relay{{"List":"-TestClasses","Selection":"+SelectedTestClass"}}>sdelegateis#<Record{{"TestClasses":{},"SelectedTestClass":{},"ResultText":{},"FailureList":{},"Failure":{}}}>Warn:unexpected:#<Relay{{"Text":"-ResultText"}}>sdelegateis#<Record{{"TestClasses":{},"SelectedTestClass":{},"ResultText":{},"FailureList":{},"Failure":{}}}>Warn:unexpected:#<Relay{{"List":"-FailureList","Selection":"+Failure"}}>sdelegateis#<Record{{"TestClasses":{},"SelectedTestClass":{},"ResultText":{},"FailureList":{},"Failure":{}}}>Warn:CannotcorrectlyserializeconnectionshavingundefinedsourceortargetobjectsWarn:CannotcorrectlyserializeconnectionshavingundefinedsourceortargetobjectsWarn:Cannotcorrectlyserializeconnectionshavingundefinedsourceortargetobjects050ConsoleMorphTest.js:FilterableListMorphTest:--all--https://lively-kernel.org/repository/webwerkstatt2011/codebaselocal-----BWINF/Dan/LivelyHPImgzn/OldPartsBin/PartsBin/ProjectSeminar2010/Tests/alex/apps/benchmarks/bin/constantin/contextjs/cop/davide/demos/documentation/draft/fabian/fabrik/fred/games/issues/lauritz/lib/lively/marko/martin/media/meineerde/migration/odata/ometa/papers/philipp/projects/roadmap/robert/sandbox/schlichting/server/serverTest/sofia/swa/testCreatePartsSpace/tim/tmohr/users/webcollab-integration/widgets/../Foo.js(notparsed)Pen.lkmlLocalcode--------------------AddmoduleLoadallLineNoDbgerrorsisoffEvalonSortViewas...lively/Widgets.js:1813:propertyDef:DragWrapper>>dropMeOnMorph:lively/Widgets.js:1925:propertyDef:DragnDropListMorph>>acceptDrop:lively/Widgets.js:1944:propertyDef:Morph>>acceptDrop:browseloaddefaultmodulessearchagainacceptDrop:function(item,evt){vartarget=this.morphToReceiveEvent(evt);varindex=this.submorphs.indexOf(target);console.log(index);varotherItem=this.itemList[index];this.setList(this.listWith(item,index),true);if(item.onDrop)item.onDrop(otherItem);console.log('Dropaccepted!')},ChangelistforReferencestoacceptDropabe----------dfcitem4item3item2item1$morph('listMorph').layoutManager=newVerticalLayout()$morph('listMorph').relayout()Wikicontrol