| 1 import "dart:html" as l;import "dart:indexed_db" as m;import "dart:async" as n;c
lass t{static const u="Chrome";static const v="Firefox";static const AB="Inte
rnet Explorer";static const BB="Safari";final q;final minimumVersion;const t(
this.q,[this.minimumVersion]);}class CB{const CB();}class DB{final name;const D
B(this.name);}class EB{const EB();}class FB{const FB();}class GB{static final o
="todo";static final i="todos";var HB;var IB=2;var JB;var KB;GB(){KB=l.query('#
todo-items');JB=l.query('#todo');l.query('input#submit').onClick.listen((g)=>LB(
));} open(){return l.window.indexedDB.open(o,version:IB,onUpgradeNeeded:MB).then
(NB).catchError(OB);} OB(g){l.window.alert('Oh no! Something went wrong. See the
console for details.');l.window.console.log('An error occurred: {${g}}');} NB(
g){HB=g;PB();} MB( h){var g=(h.target as m.OpenDBRequest).result;if(!g.objectSto
reNames.contains(i)){g.createObjectStore(i,keyPath:'timeStamp');}} LB(){var g=JB
.value.trim();if(g.length>0){QB(g);}JB.value='';} QB( j){var g=HB.transaction(i,
'readwrite');var h=g.objectStore(i);return h.put({'text':j,'timeStamp':new DateT
ime.now().millisecondsSinceEpoch.toString()}).then((RB)=>PB()).catchError((k)=>O
B);} SB( k){var g=HB.transaction(i,'readwrite');var j=g.objectStore(i);var h=j.d
elete(k);h.then((s)=>PB(),onError:OB);} PB(){KB.nodes.clear();var g=HB.transacti
on(i,'readwrite');var h=g.objectStore(i);var k=h.openCursor(autoAdvance:true).li
sten((j){TB(j.value);},onError:OB);} TB( k){var j=new l.Element.tag('span');j.te
xt=k['text'];var h=new l.Element.tag('a');h.text='[Delete]';h.onClick.listen((s)
=>SB(k['timeStamp']));var g=new l.Element.tag('li');g.nodes.add(j);g.nodes.add(h
);KB.nodes.add(g);}} main(){new GB().open();} |