extentions.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <!DOCTYPE html>
  2. <!-- saved from url=(0033)http://www.taffydb.com/extensions -->
  3. <html lang="en" class="gr__taffydb_com"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>TaffyDB - Extensions</title>
  5. <meta name="description" content="">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="">
  8. <meta name="author" content="">
  9. <script id="twitter-wjs" src="./index_files/widgets.js.download"></script><script type="text/javascript" async="" src="./index_files/ga.js.download"></script><script type="text/javascript" src="./index_files/XRegExp.js.download"></script> <!-- XRegExp is bundled with the final shCore.js during build -->
  10. <script type="text/javascript" src="./index_files/shCore.js.download"></script>
  11. <script type="text/javascript" src="./index_files/shBrushJScript.js.download"></script>
  12. <link type="text/css" rel="stylesheet" href="./index_files/shCore.css">
  13. <link type="text/css" rel="Stylesheet" href="./index_files/shThemeDefault.css">
  14. <script type="text/javascript">SyntaxHighlighter.all();</script>
  15. <!-- Le styles -->
  16. <link href="./index_files/bootstrap.css" rel="stylesheet">
  17. <style type="text/css">
  18. body {
  19. padding-top: 60px;
  20. padding-bottom: 40px;
  21. }
  22. .sidebar-nav {
  23. padding: 9px 0;
  24. }
  25. .toolbar {
  26. opacity:0;
  27. }
  28. .method {
  29. }
  30. .method td {
  31. border-bottom:thin solid silver;
  32. border-top:thin solid silver;
  33. vertical-align:text-top;
  34. }
  35. .method td:first-child {
  36. color:gray;
  37. background-color:#F2EDEF;
  38. font-size:160%;
  39. text-align:center;
  40. vertical-align:middle;
  41. }
  42. b {
  43. background-color:#F2EDEF;
  44. }
  45. </style>
  46. <link href="./index_files/bootstrap-responsive.css" rel="stylesheet">
  47. <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
  48. <!--[if lt IE 9]>
  49. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  50. <![endif]-->
  51. <!-- Le fav and touch icons -->
  52. <link rel="shortcut icon" href="http://www.taffydb.com/ico/favicon.ico">
  53. <link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://www.taffydb.com/ico/apple-touch-icon-144-precomposed.png">
  54. <link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://www.taffydb.com/ico/apple-touch-icon-114-precomposed.png">
  55. <link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://www.taffydb.com/ico/apple-touch-icon-72-precomposed.png">
  56. <link rel="apple-touch-icon-precomposed" href="http://www.taffydb.com/ico/apple-touch-icon-57-precomposed.png">
  57. <script type="text/javascript">
  58. var _gaq = _gaq || [];
  59. _gaq.push(['_setAccount', 'UA-130587-11']);
  60. _gaq.push(['_trackPageview']);
  61. (function() {
  62. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  63. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  64. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  65. })();
  66. </script>
  67. <script type="text/javascript" charset="utf-8" async="" src="./index_files/timeline.619317855a58aa2366562a395f9e40ef.js.download"></script></head>
  68. <body data-gr-c-s-loaded="true">
  69. <div class="navbar navbar-fixed-top">
  70. <div class="navbar-inner">
  71. <div class="container-fluid">
  72. <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  73. <span class="icon-bar"></span>
  74. <span class="icon-bar"></span>
  75. <span class="icon-bar"></span>
  76. </a>
  77. <a class="brand" href="/">TaffyDB</a>
  78. <div class="pull-right">
  79. <a class="btn" href="https://github.com/typicaljoe/taffydb">
  80. taffy.js
  81. </a>
  82. </div>
  83. <div class="nav-collapse">
  84. <ul class="nav">
  85. <li><a href="/">Home</a></li>
  86. <li><a href="https://github.com/typicaljoe/taffydb/archive/master.zip">Download</a></li>
  87. <li><a href="/beginner.html">Beginner's Guide</a></li>
  88. <li><a href="/writing_queries.html">Writing Queries</a></li>
  89. <li><a href="/working_with_data.html">Working With Data</a></li>
  90. <li class="active"><a href="extentions.html">Extensions</a></li>
  91. </ul>
  92. </div><!--/.nav-collapse -->
  93. </div>
  94. </div>
  95. </div>
  96. <div class="container-fluid">
  97. <div class="row-fluid">
  98. <div class="span3">
  99. <div class="well sidebar-nav">
  100. <ul class="nav nav-list">
  101. <li class="nav-header">On Github</li>
  102. <li><a href="https://github.com/typicaljoe/taffydb">GitHub Home</a></li>
  103. <li><a href="https://github.com/typicaljoe/taffydb/archive/master.zip">Download</a></li>
  104. <li><a href="https://github.com/typicaljoe/taffydb/blob/master/taffy.js">Source Code</a></li>
  105. <form id="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
  106. <input type="hidden" name="cmd" value="_s-xclick">
  107. <input type="hidden" name="hosted_button_id" value="ENS2E6Z99PDZN">
  108. </form>
  109. <li class="nav-header">Community and Support</li>
  110. <li><a href="https://github.com/typicaljoe/taffydb/issues?state=open">Open Issues</a></li>
  111. <li><a href="#" onclick="document.getElementById('paypal').submit()">Donate</a>
  112. </li>
  113. <li class="nav-header">Created by</li>
  114. <iframe id="twitter-widget-0" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="twitter-timeline twitter-timeline-rendered" style="position: static; visibility: visible; display: inline-block; width: 520px; height: 600px; padding: 0px; border: none; max-width: 100%; min-width: 180px; margin-top: 0px; margin-bottom: 0px; min-height: 200px;" data-widget-id="249607754170368000" title="Twitter Timeline" src="./index_files/saved_resource.html"></iframe>
  115. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  116. </ul>
  117. </div><!--/.well -->
  118. </div><!--/span-->
  119. <div class="span9">
  120. <div class="hero-unit">
  121. <h1>Extending TaffyDB</h1>
  122. <p>TaffyDB is easy to extend. Simply use the extend method to add a new method to all TaffyDB collections on your page.</p>
  123. <p>Here is an example that creates an "avg" method that takes a column and returns the avg value.</p>
  124. <pre class="brush: js">// Create a new empty database
  125. TAFFY.extend("avg",function (c) {
  126. // This runs the query or returns the results if it has already run
  127. this.context({
  128. results: this.getDBI().query(this.context())
  129. });
  130. // setup the sum
  131. var total = 0;
  132. // loop over every record in the results and sum up the column.
  133. TAFFY.each(this.context().results,function (r) {
  134. total = total + r[c];
  135. })
  136. // divide the total by the number of records and return
  137. return total/this.context().results.length;
  138. });
  139. </pre>
  140. <p>What can you build?</p>
  141. </div>
  142. <footer>
  143. </footer>
  144. </div><!--/span-->
  145. </div><!--/row-->
  146. <hr>
  147. <footer>
  148. <div align="center"><img src="./index_files/taffydbboxV3.jpg"></div>
  149. </footer>
  150. </div><!--/.fluid-container-->
  151. <!-- Le javascript
  152. ================================================== -->
  153. <!-- Placed at the end of the document so the pages load faster -->
  154. <script src="./index_files/jquery.js.download"></script>
  155. <script src="./index_files/bootstrap-transition.js.download"></script>
  156. <script src="./index_files/bootstrap-alert.js.download"></script>
  157. <script src="./index_files/bootstrap-modal.js.download"></script>
  158. <script src="./index_files/bootstrap-dropdown.js.download"></script>
  159. <script src="./index_files/bootstrap-scrollspy.js.download"></script>
  160. <script src="./index_files/bootstrap-tab.js.download"></script>
  161. <script src="./index_files/bootstrap-tooltip.js.download"></script>
  162. <script src="./index_files/bootstrap-popover.js.download"></script>
  163. <script src="./index_files/bootstrap-button.js.download"></script>
  164. <script src="./index_files/bootstrap-collapse.js.download"></script>
  165. <script src="./index_files/bootstrap-carousel.js.download"></script>
  166. <script src="./index_files/bootstrap-typeahead.js.download"></script>
  167. <iframe id="rufous-sandbox" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" style="position: absolute; visibility: hidden; display: none; width: 0px; height: 0px; padding: 0px; border: none;" title="Twitter analytics iframe" src="./index_files/saved_resource(1).html"></iframe></body></html>