Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / data.html
diff --git a/docs/source/data.html b/docs/source/data.html
new file mode 100644 (file)
index 0000000..2981fed
--- /dev/null
@@ -0,0 +1,67 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">// Unique task ids, if the time isn't unique enough, the addition \r
+// of random chars should be\r
+Ext.uniqueId = function(){\r
+       var t = String(new Date().getTime()).substr(4);\r
+       var s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r
+       for(var i = 0; i < 4; i++){\r
+               t += s.charAt(Math.floor(Math.random()*26));\r
+       }\r
+       return t;\r
+}\r
+\r
+// Define the Task data type\r
+tx.data.Task = Ext.data.Record.create([\r
+    {name: 'taskId', type:'string'},\r
+    {name: 'listId', type:'string'},\r
+    {name: 'title', type:'string'},\r
+    {name: 'description', type:'string'},\r
+    {name: 'dueDate', type:'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''},\r
+    {name: 'completed', type:'boolean'},\r
+    {name: 'completedDate', type:'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''},\r
+    {name: 'reminder', type:'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT, defaultValue: ''}\r
+]);\r
+\r
+// Define the List data type\r
+tx.data.List = Ext.data.Record.create([\r
+    {name: 'listId', type:'string'},\r
+    {name: 'parentId', type:'string'},\r
+    {name: 'listName', type:'string'},\r
+    {name: 'isFolder', type:'boolean'}\r
+]);\r
+\r
+tx.data.conn = Ext.sql.Connection.getInstance();\r
+\r
+tx.data.tasks = new tx.data.TaskStore();\r
+tx.data.lists = new tx.data.ListStore();\r
+\r
+\r
+tx.data.getDefaultReminder = function(task){\r
+       var s = task.data.dueDate ? task.data.dueDate.clearTime(true) : new Date().clearTime();\r
+       s = s.add('mi', Ext.state.Manager.get('defaultReminder'));\r
+       return s;\r
+};\r
+\r
+\r
+tx.data.getActiveListId = function(){\r
+    var id = tx.data.tasks.activeList;\r
+    if(!id){\r
+        var first = tx.data.lists.getAt(0);\r
+        if(first){\r
+            id = first.id;\r
+        }else{\r
+            id = tx.data.lists.newList().id;\r
+        }\r
+    }\r
+    return id;\r
+};\r
+\r
+</pre>    \r
+</body>\r
+</html>
\ No newline at end of file